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

Implement stm32f3 bootloader protection #299

Closed zvecr closed 1 year ago

zvecr commented 1 year ago

Description of Change

Slight complication on the implementation compared to F4 as HAL_FLASH_OB_Launch resets the MCU. Without specific logic to handle this case the self-updater gets into a bit of a spin.

  1. self-update calls board_flash_protect_bootloader(false)
  2. MCU resets
  3. bootloader main then runs board_flash_protect_bootloader(true)
  4. MCU resets
  5. goto 1

Catching the reset reason allows the bootloader to re-run the self-updater with the now unlocked write protection.

zvecr commented 1 year ago

Anything I can do to move this PR along?

hathach commented 1 year ago

ah sorry for late response, I will pick this up and do some testing soon enough.