Skip to content

Commit

Permalink
fixup! feat(core): add support for STM32U585
Browse files Browse the repository at this point in the history
  • Loading branch information
TychoVrahe committed Nov 21, 2023
1 parent 568ae76 commit 2925e18
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 19 deletions.
2 changes: 1 addition & 1 deletion core/embed/models/model_D002_layout.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const flash_area_t BOARDLOADER_AREA = {
.num_subareas = 1,
.subarea[0] =
{
.first_sector = 1,
.first_sector = 2,
.num_sectors = 6,
},
};
Expand Down
35 changes: 17 additions & 18 deletions core/embed/trezorhal/stm32u5/mpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,27 +134,26 @@ static void mpu_set_attributes() {
#define L2_REST_SIZE \
(FLASH_SIZE - (BOOTLOADER_SIZE + BOARDLOADER_SIZE + SECRET_SIZE))

#define L3_PREV_SIZE (STORAGE_SIZE)
#define L3_REST_START (FIRMWARE_START + FIRMWARE_SIZE)
#define L3_REST_SIZE \
#define ASSETS_START (FIRMWARE_START + FIRMWARE_SIZE)
#define ASSETS_SIZE \
(FLASH_SIZE - (FIRMWARE_START + BOOTLOADER_SIZE + BOARDLOADER_SIZE + \
SECRET_SIZE + STORAGE_SIZE))

void mpu_config_boardloader() {
HAL_MPU_Disable();
mpu_set_attributes();
// clang-format off
// REGION ADDRESS SIZE TYPE WRITE UNPRIV
SET_REGION( 0, SECRET_START, SIZE_16K, FLASH_DATA, YES, NO ); // Secret
SET_REGION( 1, BOARDLOADER_START, BOARDLOADER_SIZE, FLASH_CODE, NO, NO ); // Boardloader code
SET_REGION( 2, BOOTLOADER_START, L1_REST_SIZE, FLASH_DATA, YES, NO ); // Bootloader + Storage + Firmware
SET_REGION( 3, SRAM1_BASE_S, SRAM_SIZE, SRAM, YES, NO ); // SRAM1/2/3/5
// REGION ADDRESS SIZE TYPE WRITE UNPRIV
SET_REGION( 0, SECRET_START, SECRET_SIZE, FLASH_DATA, YES, NO ); // Secret
SET_REGION( 1, BOARDLOADER_START, BOARDLOADER_SIZE, FLASH_CODE, NO, NO ); // Boardloader code
SET_REGION( 2, BOOTLOADER_START, L1_REST_SIZE, FLASH_DATA, YES, NO ); // Bootloader + Storage + Firmware
SET_REGION( 3, SRAM1_BASE, SRAM_SIZE, SRAM, YES, NO ); // SRAM1/2/3/5
#if defined STM32U5A9xx || defined STM32U5G9xx
SET_REGION( 4, GFXMMU_BUFFERS_S, SIZE_16M, SRAM, YES, NO ); // Frame buffer
SET_REGION( 4, GFXMMU_BUFFERS, SIZE_16M, SRAM, YES, NO ); // Frame buffer
#else
DIS_REGION( 4 );
#endif
SET_REGION( 5, PERIPH_BASE_S, SIZE_256M, PERIPHERAL, YES, NO ); // Peripherals
SET_REGION( 5, PERIPH_BASE, SIZE_256M, PERIPHERAL, YES, NO ); // Peripherals
DIS_REGION( 6 );
DIS_REGION( 7 );
// clang-format on
Expand All @@ -169,13 +168,13 @@ void mpu_config_bootloader() {
SET_REGION( 0, SECRET_START, L2_PREV_SIZE, FLASH_DATA, YES, NO ); // Secret + Boardloader
SET_REGION( 1, BOOTLOADER_START, BOOTLOADER_SIZE, FLASH_CODE, NO, NO ); // Bootloader code
SET_REGION( 2, STORAGE_START, L2_REST_SIZE, FLASH_DATA, YES, NO ); // Storage + Firmware
SET_REGION( 3, SRAM1_BASE_S, SRAM_SIZE, SRAM, YES, NO ); // SRAM1/2/3/5
SET_REGION( 3, SRAM1_BASE, SRAM_SIZE, SRAM, YES, NO ); // SRAM1/2/3/5
#if defined STM32U5A9xx || defined STM32U5G9xx
SET_REGION( 4, GFXMMU_BUFFERS_S, SIZE_16M, SRAM, YES, NO ); // Frame buffer
SET_REGION( 4, GFXMMU_BUFFERS, SIZE_16M, SRAM, YES, NO ); // Frame buffer
#else
DIS_REGION( 4 );
#endif
SET_REGION( 5, PERIPH_BASE_S, SIZE_256M, PERIPHERAL, YES, NO ); // Peripherals
SET_REGION( 5, PERIPH_BASE, SIZE_256M, PERIPHERAL, YES, NO ); // Peripherals
SET_REGION( 6, FLASH_OTP_BASE, FLASH_OTP_SIZE, FLASH_DATA, YES, NO ); // OTP
DIS_REGION( 7 );
// clang-format on
Expand All @@ -187,16 +186,16 @@ void mpu_config_firmware() {
mpu_set_attributes();
// clang-format off
// REGION ADDRESS SIZE TYPE WRITE UNPRIV
SET_REGION( 0, STORAGE_START, L3_PREV_SIZE, FLASH_DATA, YES, YES ); // Storage
SET_REGION( 0, STORAGE_START, STORAGE_SIZE, FLASH_DATA, YES, YES ); // Storage
SET_REGION( 1, FIRMWARE_START, FIRMWARE_SIZE, FLASH_CODE, NO, YES ); // Firmware
SET_REGION( 2, L3_REST_START, L3_REST_SIZE, FLASH_DATA, YES, YES ); // Reserve
SET_REGION( 3, SRAM1_BASE_S, SRAM_SIZE, SRAM, YES, YES ); // SRAM1/2/3/5
SET_REGION( 2, ASSETS_START, ASSETS_SIZE, FLASH_DATA, YES, YES ); // Assets
SET_REGION( 3, SRAM1_BASE, SRAM_SIZE, SRAM, YES, YES ); // SRAM1/2/3/5
#if defined STM32U5A9xx || defined STM32U5G9xx
SET_REGION( 4, GFXMMU_BUFFERS_S, SIZE_16M, SRAM, YES, YES ); // Frame buffer
SET_REGION( 4, GFXMMU_BUFFERS, SIZE_16M, SRAM, YES, YES ); // Frame buffer
#else
DIS_REGION( 4 );
#endif
SET_REGION( 5, PERIPH_BASE_S, SIZE_256M, PERIPHERAL, YES, YES ); // Peripherals
SET_REGION( 5, PERIPH_BASE, SIZE_256M, PERIPHERAL, YES, YES ); // Peripherals
SET_REGION( 6, FLASH_OTP_BASE, FLASH_OTP_SIZE, FLASH_DATA, YES, YES ); // OTP
DIS_REGION( 7 );
// clang-format on
Expand Down

0 comments on commit 2925e18

Please sign in to comment.