adafruit / tinyuf2

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

CURRENT.UF2 always blank #322

Closed zvecr closed 8 months ago

zvecr commented 1 year ago

Operating System

Windows 11 Fedora 38 Arch

INFO_UF2.TXT

TinyUF2 Bootloader 0.14.0-10-g86a054f - st/cmsis_device_f3 (v2.3.6) st/stm32f3xx_hal_driver (v1.5.6-9-g75cf4fc) tinyusb (0.15.0-331-ge3b3229d6) Model: ST STM32F303 Discovery Board-ID: STM32F303 discovery Date: Jun 5 2023

What happened ?

Content of CURRENT.UF2 is always just zeros, and does not reflect the current flash contents,

hexdump ~/Desktop/CURRENT.UF2
0000000 0000 0000 0000 0000 0000 0000 0000 0000
*
0080000

(Where hexdump truncates identical lines as *)

This has been reproduced on both a STM32F303 discovery and stm32f401_blackpill, so the issue is not isolated to a single port.

How to reproduce ?

Reboot to bootloader Copy .uf2 to device Reboot to bootloader again Copy CURRENT.UF2 to host Inspect content

Debug Log

No response

Screenshots

No response

MiyukiDark commented 10 months ago

This issue will be on all MCUs where the flash did not start at address 0 It just calculates it totally wrong The issue is in ghostfat.c on lines 486 and on

// CURRENT.UF2: generate data on-the-fly
      uint32_t addr = BOARD_FLASH_APP_START + (fileRelativeSector * UF2_FIRMWARE_BYTES_PER_SECTOR);
      if ( addr < _flash_size ) // TODO abstract this out
      {

addr is always bigger than the size of a flash

hathach commented 8 months ago

should be fixed by #367, pleaes check it out