From e704c33d7d06e8df9c0cfb4f0d013a870b546ad5 Mon Sep 17 00:00:00 2001 From: tychovrahe Date: Wed, 13 Nov 2024 11:18:42 +0100 Subject: [PATCH] fix(core): flash driver - fix support for emulating STM32U5G based models [no changelog] --- core/embed/trezorhal/unix/flash.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/core/embed/trezorhal/unix/flash.c b/core/embed/trezorhal/unix/flash.c index b91fa00f53..399e249135 100644 --- a/core/embed/trezorhal/unix/flash.c +++ b/core/embed/trezorhal/unix/flash.c @@ -36,8 +36,10 @@ #if defined STM32F427xx || defined STM32F429xx #define FLASH_SECTOR_COUNT 24 -#elif defined STM32U585xx || defined STM32U5A9xx +#elif defined STM32U585xx #define FLASH_SECTOR_COUNT 256 +#elif defined STM32U5G9xx +#define FLASH_SECTOR_COUNT 512 #else #error Unknown MCU #endif @@ -69,11 +71,11 @@ static uint32_t FLASH_SECTOR_TABLE[FLASH_SECTOR_COUNT + 1] = { [22] = 0x081C0000, // - 0x081DFFFF | 128 KiB [23] = 0x081E0000, // - 0x081FFFFF | 128 KiB [24] = 0x08200000, // last element - not a valid sector -#elif defined STM32U585xx || defined STM32U5A9xx +#elif defined STM32U585xx || defined STM32U5G9xx [0] = 0x08000000, // - 0x08001FFF | 8 KiB // rest is initialized in flash_init #else -#error Unknown Trezor model +#error Unknown MCU #endif }; @@ -88,7 +90,7 @@ static void flash_exit(void) { void flash_init(void) { 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++) { FLASH_SECTOR_TABLE[i + 1] = FLASH_SECTOR_TABLE[i] + 0x2000; // 8KiB size sectors