1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-15 19:08:07 +00:00

boardloader: don't erase sectors in flash_set_option_bytes for now

This commit is contained in:
Pavol Rusnak 2017-10-20 14:42:51 +02:00
parent d6ae912703
commit 21fac2e2c3
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D

View File

@ -1,6 +1,5 @@
#include STM32_HAL_H
#include "flash.h"
#include "lowlevel.h"
#define WANTED_WRP (OB_WRP_SECTOR_0 | OB_WRP_SECTOR_1 | OB_WRP_SECTOR_2)
@ -11,7 +10,7 @@ void flash_set_option_bytes(void)
{
FLASH_OBProgramInitTypeDef opts;
while (1) {
for(;;) {
HAL_FLASHEx_OBGetConfig(&opts);
opts.OptionType = 0;
@ -37,20 +36,7 @@ void flash_set_option_bytes(void)
break; // protections are configured
}
uint32_t sector_error = 0;
FLASH_EraseInitTypeDef erase;
erase.TypeErase = FLASH_TYPEERASE_SECTORS;
erase.Banks = FLASH_BANK_1 | FLASH_BANK_2;
erase.Sector = FLASH_SECTOR_3;
erase.NbSectors = 21;
erase.VoltageRange = FLASH_VOLTAGE_RANGE_3;
// attempt to erase all sectors except the boardloader sectors
flash_unlock();
HAL_FLASHEx_Erase(&erase, &sector_error);
flash_lock();
// now attempt to lock down the boardloader sectors
// attempt to lock down the boardloader sectors
HAL_FLASHEx_OBProgram(&opts);
}
}