mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-22 23:48:12 +00:00
boardloader/bootloader: use static const for sector arrays; erase storage if firmware is broken
This commit is contained in:
parent
290643782a
commit
a3af8faf23
@ -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,
|
||||
};
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user