diff --git a/embed/boardloader/main.c b/embed/boardloader/main.c index 6addf590c..783067490 100644 --- a/embed/boardloader/main.c +++ b/embed/boardloader/main.c @@ -104,7 +104,7 @@ static secbool copy_sdcard(void) display_printf("\n\nerasing flash:\n\n"); // erase all flash (except boardloader) - const uint8_t sectors[] = { + static const uint8_t sectors[] = { 3, FLASH_SECTOR_STORAGE_1, FLASH_SECTOR_STORAGE_2, @@ -168,7 +168,7 @@ int main(void) periph_init(); if (sectrue != flash_configure_option_bytes()) { - const uint8_t sectors[] = { + static const uint8_t sectors[] = { FLASH_SECTOR_STORAGE_1, FLASH_SECTOR_STORAGE_2, }; diff --git a/embed/bootloader/main.c b/embed/bootloader/main.c index d9c337f31..c7df11b87 100644 --- a/embed/bootloader/main.c +++ b/embed/bootloader/main.c @@ -283,6 +283,13 @@ main_start: ui_screen_third(); ui_fadein(); + // erase storage + static const uint8_t sectors_storage[] = { + FLASH_SECTOR_STORAGE_1, + FLASH_SECTOR_STORAGE_2, + }; + ensure(flash_erase_sectors(sectors_storage, sizeof(sectors_storage), NULL), NULL); + // and start the usb loop if (bootloader_usb_loop(NULL, NULL) != sectrue) { return 1; diff --git a/embed/bootloader/messages.c b/embed/bootloader/messages.c index 4a3a1f83d..7d0e29e06 100644 --- a/embed/bootloader/messages.c +++ b/embed/bootloader/messages.c @@ -475,7 +475,7 @@ int process_msg_FirmwareUpload(uint8_t iface_num, uint32_t msg_size, uint8_t *bu // if firmware is not upgrade, erase storage if (sectrue != is_upgrade) { - const uint8_t sectors_storage[] = { + static const uint8_t sectors_storage[] = { FLASH_SECTOR_STORAGE_1, FLASH_SECTOR_STORAGE_2, }; @@ -530,7 +530,7 @@ int process_msg_FirmwareUpload(uint8_t iface_num, uint32_t msg_size, uint8_t *bu int process_msg_WipeDevice(uint8_t iface_num, uint32_t msg_size, uint8_t *buf) { - const uint8_t sectors[] = { + static const uint8_t sectors[] = { 3, FLASH_SECTOR_STORAGE_1, FLASH_SECTOR_STORAGE_2, diff --git a/embed/reflash/main.c b/embed/reflash/main.c index 7ff2870bb..3013f4b4a 100644 --- a/embed/reflash/main.c +++ b/embed/reflash/main.c @@ -77,7 +77,7 @@ int main(void) display_printf("updating boardloader + bootloader\n"); - const uint8_t sectors[] = { + static const uint8_t sectors[] = { FLASH_SECTOR_BOARDLOADER_START, 1, FLASH_SECTOR_BOARDLOADER_END,