adafruit / tinyuf2

UF2 bootloader based on TinyUSB for embedded devices such as ESP32S2, STM32F4 and iMX RT10xx
MIT License
302 stars 165 forks source link

Windows flashing produces error 0x800701B1 #375

Open zvecr opened 5 months ago

zvecr commented 5 months ago

Operating System

Windows 10

INFO_UF2.TXT

TinyUF2 Bootloader 0.18.1-55-geec497e-dirty - st/cmsis_device_f3 (v2.3.6) st/stm32f3xx_hal_driver (v1.5.6-9-g75cf4fc) tinyusb (0.15.0-566-gf1e006d09) Model: ST STM32F303 Discovery Board-ID: STM32F303-Discovery-MB1035D Date: Jan 31 2024 Flash Size: 0x00040000 bytes

What happened ?

Flashing on both win10 and win11 can generate the error. In all testing, the flash is successful and the board will reboot into the user application while the error dialog is shown.

However from an end user experience, the "unexpected error" dialog causes unnecessary confusion and worry.

Other uf2 based bootloaders I have tested that do not have this issue:

A quick look into the issue, it could be that the reboot is called within the tud_msc_write10_complete_cb callback. By comparison https://github.com/adafruit/uf2-samdx1/blob/master/src/fat.c#L251-L252 and https://github.com/adafruit/uf2-samdx1/blob/master/src/utils.c#L53 seems to suggest a reboot after a delay and from the main loop.

How to reproduce ?

Reset board to bootloader Drag & drop uf2 user file Error dialog will popup

Debug Log

No response

Screenshots

win_flash_error

brentru commented 1 month ago

@hathach Do you have any idea why this occurs? Is it due to windows ejecting the drive too early?

I saw a user on the WipperSnapper subforum report this as well - https://forums.adafruit.com/viewtopic.php?p=1016725#p1016725