Skip to content

Commit

Permalink
tools/bootloader: add force-erase option
Browse files Browse the repository at this point in the history
If the STM32H7 fails to program or erase a full chunk of 256 bytes, the
ECC check will trigger a busfault when trying to read from it.

To speed up erasing and optimize wear, we read before erasing to check
if it actually needs erasing. That's when a busfault happens and the
erase time outs.

The workaround is to add an option to do a full erase without check.

Credit goes to:
ArduPilot/ardupilot#22090

And the protocol option added to the bootloader is the same as for
ArduPilot, so compatible.

Signed-off-by: Julian Oes <[email protected]>
  • Loading branch information
julianoes authored and chiara-septentrio committed Jul 4, 2024
1 parent e4ea1f8 commit 6319e71
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions platforms/nuttx/src/bootloader/nxp/imxrt_common/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -432,13 +432,19 @@ flash_func_erase_sector(unsigned sector, bool force)
return;
}

<<<<<<< HEAD
if (force || up_progmem_ispageerased(sector) != 0) {

struct flexspi_nor_config_s *pConfig = &g_bootConfig;

const uint32_t bytes_per_sector = flash_func_sector_size(sector);
uint32_t *address = (uint32_t *)(IMXRT_FLEXSPI1_CIPHER_BASE + (sector * bytes_per_sector));

=======
if (force || flash_func_is_sector_blank(sector) != 0) {
struct flexspi_nor_config_s *pConfig = &g_bootConfig;

>>>>>>> 21e550fdba (tools/bootloader: add force-erase option)
uintptr_t offset = ((uintptr_t) address) - IMXRT_FLEXSPI1_CIPHER_BASE;
irqstate_t flags;
flags = enter_critical_section();
Expand Down

0 comments on commit 6319e71

Please sign in to comment.