-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
st-util should exit on LIBUSB_ERROR_NO_DEVICE #780
Comments
I think |
Yeah I think you are right, an call to libusb should be checked appropriate. If you want you can patch and send a PR. It should also be done for the other calls to libusb in the usb.c file. Thanks for reporting! |
I would love to. However, I'm not sure that I understand the project structure so a plain
I might not understand this very well. Do you mean " |
I have placed a comment in the PR, there are more places where it can go wrong when calls are made to libusb. The project is organised in the following way:
|
@chenguokai: Do you have an idea on how to proceed here? |
After checked the error handling process with When I come up with two possible deal strategies: Common part: Check the return value of
Analysis: Option 1 is acceptable since we cannot predict what will happen after a communication error. The draw back is that st-util may fail more frequently on some unstable usb ports or something alike. |
Thx for the detailed analysis. I'd favour option 1 here. If people run into problems related to specific local hardware instabilities, there is nothing we can do to it anyway and this is also nothing what the stlink tools should considerate. It seems more important that we do any compromise on debugging. Are you able to fix this straight away? |
I will check the documentation of gdb to send packet(s) properly. Not too difficult I guess. |
I didn't say it, but I was going for option 2. But after your explanation: You're right. You've got me convinced: Unless there is a valid reason to believe an error is temporary an error should be considered fatal immediately. Retrying without informing the user will lead to sudden surprises. Suppose 1/100th or 1/1000th of the transferred bits gets corrupted (at whatever level). If that results in a command being "invalid" in 99% of the time, the user in that situation would on average get plenty warnings (i.e. stlink suddenly quitting) that his hardware is unstable before he gets the silent data corruption that causes problems.... The "easy way out" is to just "exit ()". That will suddenly close the connection to gdb and it will handle that sufficiently gracefully. |
Basic functions run well under the PR with a stm32f401 board. |
When I first unplug the USB debugger and then try to issue a command via GDB, st-util gives the following errors very rapidly:
thus occupying the CPU nearly 100%. This results in serious waste of time (restarting the virtual machine, etc.).
The kind of error message is quite normal. However,
stutil
should exit immediately on this error so that I could handle the rest of the issue by restartingstutil
or taking some other measure.The text was updated successfully, but these errors were encountered: