Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use dd command instead of test command to wait the Serial device #297

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

hanyazou
Copy link
Contributor

@hanyazou hanyazou commented Jun 2, 2017

discussed in the topic "Failed to reconnect serial monitor after uploading on macOS" at http://stm32duino.com/viewtopic.php?f=21&t=2050

@rogerclarkmelbourne
Copy link
Owner

Forum topic has been created to discuss this

http://www.stm32duino.com/viewtopic.php?f=53&t=2275

@rogerclarkmelbourne
Copy link
Owner

Its unclear from that thread if anyone else has confirmed whether this change is OK.

The last comment from danielef seems to suggest it needs the sleep that you commented out in the code posted to the forum.

I'm not in a position to test this as all my mac's are old and not updateable to the current versions of MacOs

@hanyazou
Copy link
Contributor Author

Today I tested this dd modification on latest macOS (10.13) and latest Arduino IDE (1.8.5). I had thought that the dd mod may not be required on the latest OS. But it was still required. Opening the device fails randomly if test -c /dev/cu.XXX returns successfully. The error is "resource busy".

And I had to extend timeout of the generic_boot20_pc13.bin. That was too short. The dfu-util always fails with the default timeout duration.

I'm afraid that no one use this configuration on mac except me.

@hanyazou
Copy link
Contributor Author

I added one more wait loop after upload-reset (0c9aab8) because I found that the new macOS required longer duration to list the target device. I tried various wait argument 750, 1000, 1250... of upload-reset to find 4,000ms seems to be enough. But it was too long to wait for 4 seconds every time before uploading.

@victorpv
Copy link
Contributor

victorpv commented Dec 1, 2017

@hanyazou seems like your PR includes a lot of unrelated commits, quite a good bunch of them.
I suspect you may have been adding more commits to the branch you used for the PR. Has biten me before...

@hanyazou
Copy link
Contributor Author

hanyazou commented Dec 2, 2017

@victorpv thank you for the comment. I've used 'git rebase' on the branch on Oct 22. The rebase took many commits from the master into my branch. I re-created branch in the same name to cleanup.

@victorpv
Copy link
Contributor

victorpv commented Dec 4, 2017

Now looks nice with a single change :)

@@ -55,7 +55,7 @@ ${DFU_UTIL} -d ${usbID} -a ${altID} -D ${binfile} -R ${dfuse_addr} -R
echo -n Waiting for ${dummy_port_fullpath} serial...

COUNTER=0
while [ ! -c ${dummy_port_fullpath} ] && ((COUNTER++ < 40)); do
while ! dd if=${dummy_port_fullpath} of=/dev/null count=0 > /dev/null 2>&1 && ((COUNTER++ < 40)); do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Can you please explain why using dd is better than a built-in check (test -c)? I mean, device existence should be enough, there's no need to try opening it for reading.

  2. The same change is needed for linux (at least).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. I mean, device existence should be enough, there's no need to try opening it for reading.

Because it does not have read permission though the device exist or you can't open the device for read though it have read permission. Please note that some device driver might return EACCESS on open operation even if the device entry on the file system have the permission.

  1. The same change is needed for linux (at least).

I can't test that modification because I don't have Linux PC. If you get device open error on your Linux, please try this patch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants