Skip to content

boot: zephyr: Refactor USB DFU entry logic #2277

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sayooj-aerlync
Copy link

Consolidates USB DFU entry logic by unifying GPIO and timeout-based DFU triggers under a common flag. This avoids code duplication and improves maintainability.
Also improves log clarity for different DFU exit conditions.

@sayooj-aerlync
Copy link
Author

Hi @nordicjm @de-nordic

The tests are failing with the following logs:

+ git clone https://git.trustedfirmware.org/TF-M/trusted-firmware-m.git
~/work/mcuboot ~/work/mcuboot/mcuboot
Cloning into 'trusted-firmware-m'...
fatal: unable to access 'https://git.trustedfirmware.org/TF-M/trusted-firmware-m.git/': The requested URL returned error: 502

What shall I do to make it clone?

@nordicjm
Copy link
Collaborator

Hi @nordicjm @de-nordic

The tests are failing with the following logs:

+ git clone https://git.trustedfirmware.org/TF-M/trusted-firmware-m.git
~/work/mcuboot ~/work/mcuboot/mcuboot
Cloning into 'trusted-firmware-m'...
fatal: unable to access 'https://git.trustedfirmware.org/TF-M/trusted-firmware-m.git/': The requested URL returned error: 502

What shall I do to make it clone?

FIH hardening tests can be ignored, these are failing due to a problem with the TFM git server

Comment on lines 507 to 516
#if defined(CONFIG_BOOT_USB_DFU_WAIT)
mcuboot_status_change(MCUBOOT_STATUS_USB_DFU_WAITING);
wait_for_usb_dfu(K_MSEC(CONFIG_BOOT_USB_DFU_WAIT_DELAY_MS));
BOOT_LOG_INF("USB DFU wait time elapsed");
mcuboot_status_change(MCUBOOT_STATUS_USB_DFU_TIMED_OUT);
#else
wait_for_usb_dfu(K_FOREVER);
BOOT_LOG_INF("USB DFU wait terminated");
#endif
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Something is odd with this block.

Copy link
Author

Choose a reason for hiding this comment

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

Are you talking about alignment? Let me check.

Copy link
Author

Choose a reason for hiding this comment

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

Changed. Please check now.


mcuboot_status_change(MCUBOOT_STATUS_USB_DFU_TIMED_OUT);
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This one is still not ok.

Copy link
Author

Choose a reason for hiding this comment

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

Changed.

#ifdef CONFIG_MCUBOOT_INDICATION_LED
io_led_set(1);
#endif

mcuboot_status_change(MCUBOOT_STATUS_USB_DFU_ENTERED);
}
#elif defined(CONFIG_BOOT_USB_DFU_WAIT)
usb_dfu_requested = true;
Copy link
Collaborator

Choose a reason for hiding this comment

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

This one is also incorrectly indented. Are you using tabs or spaces?

Copy link
Author

Choose a reason for hiding this comment

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

I used tabs initially on vim, that is leading to issues. Spaces are aligning correctly.

Copy link
Author

Choose a reason for hiding this comment

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

Just changed.

Consolidates USB DFU entry logic by unifying GPIO and timeout-based
DFU triggers under a common flag. This avoids code duplication and
improves maintainability.
Also improves log clarity for different DFU exit conditions.

Signed-off-by: Sayooj K Karun <[email protected]>
@sayooj-aerlync
Copy link
Author

Please have a look into this @de-nordic @nordicjm

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