Skip to content

Conversation

@stevenportley
Copy link
Collaborator

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.

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);
Copy link
Collaborator

@ckungler ckungler Jan 27, 2026

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) {
Copy link
Collaborator

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);
Copy link
Collaborator

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;
}

Copy link
Collaborator

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)

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.

3 participants