-
Notifications
You must be signed in to change notification settings - Fork 25
Add delays after finalizing dfu update + USB fix #186
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
base: main
Are you sure you want to change the base?
Conversation
The eROT may delay momentarily between when a dfu update is finalized and when the reboot is issued. Adding a 1s delay in the host tooling should be sufficient to always allows time for the EarlGrey to restart. Also, fix the USB reconnect logic to re-initialize the libusb context.
| } | ||
|
|
||
| // TODO: Wait for chip to come back and confirm version | ||
| usleep(LIBHOTH_REBOOT_DELAYS_MS * 1000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
super mega nit, but delay instead of delayS ?
|
|
||
| uint64_t start_time_ms = libhoth_get_monotonic_ms(); | ||
|
|
||
| while (1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of waiting in a loop, could an event handler be installed to check for USB discovery events? Based on a quick look at the documentation, I see that libusb_hotplug_register_callback can be used for registering callbacks when events occur. But I haven't used it as of now, so I can't say how well it would work here.
|
|
||
| while (1) { | ||
| int ret = libhoth_usb_get_device(usb_ctx, &usb_loc, &libusb_dev); | ||
| int ret = libusb_init(&usb_ctx); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason to init libusb again? If there is one, would it be possible to call this in the loop instead of once after libhoth_usb_close outside the loop above?
| // Found the device | ||
| break; | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If libusb_init needs to be called inside the loop, would it be a good idea to call libusb_exit before calling libusb_init again? (see https://stackoverflow.com/a/36946813)
The eROT may delay momentarily between when a dfu update is finalized and when the reboot is issued. Adding a 1s delay in the host tooling should be sufficient to always allows time for the EarlGrey to restart.
Also, fix the USB reconnect logic to re-initialize the libusb context.