mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-18 04:18:10 +00:00
fix(core): fix firmware hashing on U5
[no changelog]
This commit is contained in:
parent
1c7e8d5391
commit
0d3af6a96a
@ -34,7 +34,6 @@ FIRMWARE_SECTOR_START = 0x28;
|
|||||||
FIRMWARE_SECTOR_END = 0x1f7;
|
FIRMWARE_SECTOR_END = 0x1f7;
|
||||||
KERNEL_START = 0xc050000;
|
KERNEL_START = 0xc050000;
|
||||||
KERNEL_MAXSIZE = 0x80000;
|
KERNEL_MAXSIZE = 0x80000;
|
||||||
KERNEL_U_FLASH_SIZE = 0x200;
|
|
||||||
ASSETS_START = 0xc3f0000;
|
ASSETS_START = 0xc3f0000;
|
||||||
ASSETS_MAXSIZE = 0x10000;
|
ASSETS_MAXSIZE = 0x10000;
|
||||||
ASSETS_SECTOR_START = 0x1f8;
|
ASSETS_SECTOR_START = 0x1f8;
|
||||||
|
@ -77,7 +77,6 @@
|
|||||||
#define FIRMWARE_SECTOR_END 0x1F7
|
#define FIRMWARE_SECTOR_END 0x1F7
|
||||||
#define KERNEL_START 0x0C050000
|
#define KERNEL_START 0x0C050000
|
||||||
#define KERNEL_MAXSIZE (512 * 1024) // 512 kB
|
#define KERNEL_MAXSIZE (512 * 1024) // 512 kB
|
||||||
#define KERNEL_U_FLASH_SIZE 512
|
|
||||||
|
|
||||||
#define ASSETS_START 0x0C3F0000
|
#define ASSETS_START 0x0C3F0000
|
||||||
#define ASSETS_MAXSIZE (8 * 8 * 1024) // 64 kB
|
#define ASSETS_MAXSIZE (8 * 8 * 1024) // 64 kB
|
||||||
|
@ -34,7 +34,6 @@ FIRMWARE_SECTOR_START = 0x28;
|
|||||||
FIRMWARE_SECTOR_END = 0xf7;
|
FIRMWARE_SECTOR_END = 0xf7;
|
||||||
KERNEL_START = 0xc050000;
|
KERNEL_START = 0xc050000;
|
||||||
KERNEL_MAXSIZE = 0x80000;
|
KERNEL_MAXSIZE = 0x80000;
|
||||||
KERNEL_U_FLASH_SIZE = 0x200;
|
|
||||||
ASSETS_START = 0xc1f0000;
|
ASSETS_START = 0xc1f0000;
|
||||||
ASSETS_MAXSIZE = 0x10000;
|
ASSETS_MAXSIZE = 0x10000;
|
||||||
ASSETS_SECTOR_START = 0xf8;
|
ASSETS_SECTOR_START = 0xf8;
|
||||||
|
@ -76,7 +76,6 @@
|
|||||||
#define FIRMWARE_SECTOR_END 0xF7
|
#define FIRMWARE_SECTOR_END 0xF7
|
||||||
#define KERNEL_START 0x0C050000
|
#define KERNEL_START 0x0C050000
|
||||||
#define KERNEL_MAXSIZE (512 * 1024) // 512 kB
|
#define KERNEL_MAXSIZE (512 * 1024) // 512 kB
|
||||||
#define KERNEL_U_FLASH_SIZE 512
|
|
||||||
|
|
||||||
#define ASSETS_START 0x0C1F0000
|
#define ASSETS_START 0x0C1F0000
|
||||||
#define ASSETS_MAXSIZE (8 * 8 * 1024) // 64 kB
|
#define ASSETS_MAXSIZE (8 * 8 * 1024) // 64 kB
|
||||||
|
@ -34,7 +34,6 @@ FIRMWARE_SECTOR_START = 0x28;
|
|||||||
FIRMWARE_SECTOR_END = 0xf7;
|
FIRMWARE_SECTOR_END = 0xf7;
|
||||||
KERNEL_START = 0xc050000;
|
KERNEL_START = 0xc050000;
|
||||||
KERNEL_MAXSIZE = 0x80000;
|
KERNEL_MAXSIZE = 0x80000;
|
||||||
KERNEL_U_FLASH_SIZE = 0x200;
|
|
||||||
ASSETS_START = 0xc1f0000;
|
ASSETS_START = 0xc1f0000;
|
||||||
ASSETS_MAXSIZE = 0x10000;
|
ASSETS_MAXSIZE = 0x10000;
|
||||||
ASSETS_SECTOR_START = 0xf8;
|
ASSETS_SECTOR_START = 0xf8;
|
||||||
|
@ -76,7 +76,6 @@
|
|||||||
#define FIRMWARE_SECTOR_END 0xF7
|
#define FIRMWARE_SECTOR_END 0xF7
|
||||||
#define KERNEL_START 0x0C050000
|
#define KERNEL_START 0x0C050000
|
||||||
#define KERNEL_MAXSIZE (512 * 1024) // 512 kB
|
#define KERNEL_MAXSIZE (512 * 1024) // 512 kB
|
||||||
#define KERNEL_U_FLASH_SIZE 512
|
|
||||||
|
|
||||||
#define ASSETS_START 0x0C1F0000
|
#define ASSETS_START 0x0C1F0000
|
||||||
#define ASSETS_MAXSIZE (8 * 8 * 1024) // 64 kB
|
#define ASSETS_MAXSIZE (8 * 8 * 1024) // 64 kB
|
||||||
|
@ -136,7 +136,7 @@ SECTIONS {
|
|||||||
|
|
||||||
.uflash : ALIGN(512) {
|
.uflash : ALIGN(512) {
|
||||||
*(.uflash*);
|
*(.uflash*);
|
||||||
. = ALIGN(512);
|
. = ALIGN(COREAPP_ALIGNMENT);
|
||||||
} >FLASH AT>FLASH
|
} >FLASH AT>FLASH
|
||||||
|
|
||||||
.fb : ALIGN(4) {
|
.fb : ALIGN(4) {
|
||||||
|
@ -136,7 +136,7 @@ SECTIONS {
|
|||||||
|
|
||||||
.uflash : ALIGN(512) {
|
.uflash : ALIGN(512) {
|
||||||
*(.uflash*);
|
*(.uflash*);
|
||||||
. = ALIGN(512);
|
. = ALIGN(COREAPP_ALIGNMENT);
|
||||||
} >FLASH AT>FLASH
|
} >FLASH AT>FLASH
|
||||||
|
|
||||||
.fb1 : ALIGN(4) {
|
.fb1 : ALIGN(4) {
|
||||||
|
@ -126,11 +126,12 @@ static void mpu_set_attributes(void) {
|
|||||||
#define STORAGE_SIZE NORCOW_SECTOR_SIZE* STORAGE_AREAS_COUNT
|
#define STORAGE_SIZE NORCOW_SECTOR_SIZE* STORAGE_AREAS_COUNT
|
||||||
|
|
||||||
#if defined STM32U5A9xx
|
#if defined STM32U5A9xx
|
||||||
#define SRAM_SIZE SRAM1_SIZE + SRAM2_SIZE + SRAM3_SIZE + SRAM5_SIZE
|
#define SRAM_SIZE (SRAM1_SIZE + SRAM2_SIZE + SRAM3_SIZE + SRAM5_SIZE)
|
||||||
#elif defined STM32U5G9xx
|
#elif defined STM32U5G9xx
|
||||||
#define SRAM_SIZE SRAM1_SIZE + SRAM2_SIZE + SRAM3_SIZE + SRAM5_SIZE + SRAM6_SIZE
|
#define SRAM_SIZE \
|
||||||
|
(SRAM1_SIZE + SRAM2_SIZE + SRAM3_SIZE + SRAM5_SIZE + SRAM6_SIZE)
|
||||||
#elif defined STM32U585xx
|
#elif defined STM32U585xx
|
||||||
#define SRAM_SIZE SRAM1_SIZE + SRAM2_SIZE + SRAM3_SIZE
|
#define SRAM_SIZE (SRAM1_SIZE + SRAM2_SIZE + SRAM3_SIZE)
|
||||||
#else
|
#else
|
||||||
#error "Unknown MCU"
|
#error "Unknown MCU"
|
||||||
#endif
|
#endif
|
||||||
@ -152,6 +153,7 @@ static void mpu_set_attributes(void) {
|
|||||||
|
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
|
#ifdef KERNEL
|
||||||
#ifdef STM32U585xx
|
#ifdef STM32U585xx
|
||||||
#define KERNEL_RAM_START (SRAM2_BASE - KERNEL_SRAM1_SIZE)
|
#define KERNEL_RAM_START (SRAM2_BASE - KERNEL_SRAM1_SIZE)
|
||||||
#define KERNEL_RAM_SIZE \
|
#define KERNEL_RAM_SIZE \
|
||||||
@ -180,9 +182,10 @@ extern uint32_t _codelen;
|
|||||||
#define KERNEL_SIZE (uint32_t) & _codelen
|
#define KERNEL_SIZE (uint32_t) & _codelen
|
||||||
|
|
||||||
#define KERNEL_FLASH_START KERNEL_START
|
#define KERNEL_FLASH_START KERNEL_START
|
||||||
#define KERNEL_FLASH_SIZE (KERNEL_SIZE - KERNEL_U_FLASH_SIZE)
|
#define KERNEL_FLASH_SIZE (KERNEL_SIZE - KERNEL_FLASH_U_SIZE)
|
||||||
|
|
||||||
#define COREAPP_FLASH_START COREAPP_CODE_ALIGN(KERNEL_FLASH_START + KERNEL_SIZE)
|
#define COREAPP_FLASH_START \
|
||||||
|
(COREAPP_CODE_ALIGN(KERNEL_FLASH_START + KERNEL_SIZE) - KERNEL_FLASH_U_SIZE)
|
||||||
#define COREAPP_FLASH_SIZE \
|
#define COREAPP_FLASH_SIZE \
|
||||||
(FIRMWARE_MAXSIZE - (COREAPP_FLASH_START - KERNEL_FLASH_START))
|
(FIRMWARE_MAXSIZE - (COREAPP_FLASH_START - KERNEL_FLASH_START))
|
||||||
|
|
||||||
@ -198,6 +201,8 @@ extern uint32_t _codelen;
|
|||||||
#define COREAPP_RAM1_SIZE SRAM5_SIZE
|
#define COREAPP_RAM1_SIZE SRAM5_SIZE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
// Set if the driver is initialized
|
// Set if the driver is initialized
|
||||||
bool initialized;
|
bool initialized;
|
||||||
@ -376,9 +381,6 @@ mpu_mode_t mpu_reconfig(mpu_mode_t mode) {
|
|||||||
case MPU_MODE_ASSETS:
|
case MPU_MODE_ASSETS:
|
||||||
SET_REGION( 6, ASSETS_START, ASSETS_MAXSIZE, FLASH_DATA, YES, NO );
|
SET_REGION( 6, ASSETS_START, ASSETS_MAXSIZE, FLASH_DATA, YES, NO );
|
||||||
break;
|
break;
|
||||||
case MPU_MODE_SAES:
|
|
||||||
SET_REGRUN( 6, KERNEL_FLASH_U_START, KERNEL_FLASH_U_SIZE,FLASH_CODE, NO, YES ); // Unprivileged kernel flash
|
|
||||||
break;
|
|
||||||
case MPU_MODE_APP:
|
case MPU_MODE_APP:
|
||||||
SET_REGION( 6, ASSETS_START, ASSETS_MAXSIZE, FLASH_DATA, NO, YES );
|
SET_REGION( 6, ASSETS_START, ASSETS_MAXSIZE, FLASH_DATA, NO, YES );
|
||||||
break;
|
break;
|
||||||
@ -393,9 +395,11 @@ mpu_mode_t mpu_reconfig(mpu_mode_t mode) {
|
|||||||
// clang-format off
|
// clang-format off
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
// REGION ADDRESS SIZE TYPE WRITE UNPRIV
|
// REGION ADDRESS SIZE TYPE WRITE UNPRIV
|
||||||
|
#ifdef KERNEL
|
||||||
case MPU_MODE_SAES:
|
case MPU_MODE_SAES:
|
||||||
SET_REGION( 7, KERNEL_RAM_U_START, KERNEL_RAM_U_SIZE, SRAM, YES, YES ); // Unprivileged kernel SRAM
|
SET_REGION( 7, KERNEL_RAM_U_START, KERNEL_RAM_U_SIZE, SRAM, YES, YES ); // Unprivileged kernel SRAM
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
case MPU_MODE_APP:
|
case MPU_MODE_APP:
|
||||||
// DMA2D peripherals (Unprivileged, Read-Write, Non-Executable)
|
// DMA2D peripherals (Unprivileged, Read-Write, Non-Executable)
|
||||||
SET_REGION( 7, 0x5002B000, SIZE_3K, PERIPHERAL, YES, YES );
|
SET_REGION( 7, 0x5002B000, SIZE_3K, PERIPHERAL, YES, YES );
|
||||||
|
Loading…
Reference in New Issue
Block a user