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

usb/class/dfu: void wait_for_usb_dfu() terminates before DFU operation is completed #29611

Closed
nvlsianpu opened this issue Oct 28, 2020 · 0 comments · Fixed by #29612
Closed
Assignees
Labels
area: USB Universal Serial Bus bug The issue is a bug, or the PR is fixing a bug priority: medium Medium impact/importance bug

Comments

@nvlsianpu
Copy link
Collaborator

Describe the bug
After new firmware have been download via USB is completed wait_for_usb_dfu() terminated so fast that dfu_work_handler() was not called by k_work_queue.
If application resets closely after wait_for_usb_dfu() call returned, DFU operation will be not completed.
This is the case while using along with MCUBoot.

To Reproduce
west build -d build/mcuboot -b nrf52840dk_nrf52840 bootloader/mcuboot/boot/zephyr/ -t menuconfi -- -DDTC_OVERLAY_FILE=./boards/nrf52840_single_slot.overlay
ensue BOOT_WAIT_FOR_USB_DFU=y
west build -d build/mcuboot
west build -d build/hellow -b nrf52840dk_nrf52840 zephyr/samples/hello_world/ -- -DDTC_OVERLAY_FILE=/home/anpu/codedev/zephyrproject/bootloader/mcuboot/boot/zephyr/boards/nrf52840_single_slot.overlay
ensure ensue BOOTLOADER_MCUBOOT=y
west build -d build/hellow
west sign -d build/hellow/ -t imgtool -- --key bootloader/mcuboot/root-rsa-2048.pem
west flash -d build/mcuboot
sudo dfu-util --alt 0 --download ./build/hellow/zephyr/zephyr.signed.bin

Mcuboot Log:

*** Booting Zephyr OS build zephyr-v2.4.0-1032-gb73ee57c45f9  ***
[00:00:00.256,622] <inf> mcuboot: Starting bootloader
[00:00:00.262,908] <inf> mcuboot: Waiting for USB DFU
[00:00:18.495,330] <inf> STREAM_FLASH: Erasing page at offset 0x00011000
[00:00:18.740,325] <inf> STREAM_FLASH: Erasing page at offset 0x00012000
[00:00:18.986,633] <inf> STREAM_FLASH: Erasing page at offset 0x00013000
[00:00:19.232,391] <inf> STREAM_FLASH: Erasing page at offset 0x00014000
[00:01:55.318,786] <inf> usb_dfu: USB DFU Completed
[00:01:55.324,310] <inf> mcuboot: USB DFU wait time elapsed
[00:01:55.411,132] <err> mcuboot: Unable to find bootable image

Expected behavior
wait_for_usb_dfu() should terminate after DFU operation was completed

zephyr-rtos 28.10.2020 5374245

@nvlsianpu nvlsianpu added bug The issue is a bug, or the PR is fixing a bug area: USB Universal Serial Bus labels Oct 28, 2020
@eobalski eobalski changed the title usb/class/dfu: void wait_for_usb_dfu() terminates before DFU operation is commplited usb/class/dfu: void wait_for_usb_dfu() terminates before DFU operation is completed Oct 28, 2020
nvlsianpu added a commit to nvlsianpu/zephyr that referenced this issue Oct 28, 2020
End of DFU operation was signaled after the last usb dfu request was
received. Therefeore wait_for_usb_dfu() terminated so fast that
dfu_work_handler() was not called by k_work_queue befor.

wait_for_usb_dfu() should terminate after DFU operation was completed.

For fix that k_poll_signal_raise() was moved after the flash write
operation.

fixes zephyrproject-rtos#29611

Signed-off-by: Andrzej Puzdrowski <[email protected]>
@nvlsianpu nvlsianpu added the priority: medium Medium impact/importance bug label Oct 28, 2020
carlescufi pushed a commit that referenced this issue Oct 30, 2020
End of DFU operation was signaled after the last usb dfu request was
received. Therefeore wait_for_usb_dfu() terminated so fast that
dfu_work_handler() was not called by k_work_queue befor.

wait_for_usb_dfu() should terminate after DFU operation was completed.

For fix that k_poll_signal_raise() was moved after the flash write
operation.

fixes #29611

Signed-off-by: Andrzej Puzdrowski <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: USB Universal Serial Bus bug The issue is a bug, or the PR is fixing a bug priority: medium Medium impact/importance bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants