1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-16 19:38:09 +00:00

fix(core): flash driver - fix support for emulating STM32U5G based models

[no changelog]
This commit is contained in:
tychovrahe 2024-11-13 11:18:42 +01:00 committed by TychoVrahe
parent 4b7cbfea0a
commit e704c33d7d

View File

@ -36,8 +36,10 @@
#if defined STM32F427xx || defined STM32F429xx #if defined STM32F427xx || defined STM32F429xx
#define FLASH_SECTOR_COUNT 24 #define FLASH_SECTOR_COUNT 24
#elif defined STM32U585xx || defined STM32U5A9xx #elif defined STM32U585xx
#define FLASH_SECTOR_COUNT 256 #define FLASH_SECTOR_COUNT 256
#elif defined STM32U5G9xx
#define FLASH_SECTOR_COUNT 512
#else #else
#error Unknown MCU #error Unknown MCU
#endif #endif
@ -69,11 +71,11 @@ static uint32_t FLASH_SECTOR_TABLE[FLASH_SECTOR_COUNT + 1] = {
[22] = 0x081C0000, // - 0x081DFFFF | 128 KiB [22] = 0x081C0000, // - 0x081DFFFF | 128 KiB
[23] = 0x081E0000, // - 0x081FFFFF | 128 KiB [23] = 0x081E0000, // - 0x081FFFFF | 128 KiB
[24] = 0x08200000, // last element - not a valid sector [24] = 0x08200000, // last element - not a valid sector
#elif defined STM32U585xx || defined STM32U5A9xx #elif defined STM32U585xx || defined STM32U5G9xx
[0] = 0x08000000, // - 0x08001FFF | 8 KiB [0] = 0x08000000, // - 0x08001FFF | 8 KiB
// rest is initialized in flash_init // rest is initialized in flash_init
#else #else
#error Unknown Trezor model #error Unknown MCU
#endif #endif
}; };
@ -88,7 +90,7 @@ static void flash_exit(void) {
void flash_init(void) { void flash_init(void) {
if (FLASH_BUFFER) return; if (FLASH_BUFFER) return;
#if defined TREZOR_MODEL_T3T1 || defined TREZOR_MODEL_T3B1 #if defined STM32U585xx || defined STM32U5G9xx
for (size_t i = 0; i < FLASH_SECTOR_COUNT; i++) { for (size_t i = 0; i < FLASH_SECTOR_COUNT; i++) {
FLASH_SECTOR_TABLE[i + 1] = FLASH_SECTOR_TABLE[i + 1] =
FLASH_SECTOR_TABLE[i] + 0x2000; // 8KiB size sectors FLASH_SECTOR_TABLE[i] + 0x2000; // 8KiB size sectors