1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-22 14:28:07 +00:00

memory: use 1M for flash storage

This commit is contained in:
Pavol Rusnak 2018-04-16 14:03:36 +02:00
parent 2a22d9140d
commit fabfe0661b
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
3 changed files with 16 additions and 15 deletions

View File

@ -39,10 +39,10 @@
Sector 6 | 0x08040000 - 0x0805FFFF | 128 KiB | application code
Sector 7 | 0x08060000 - 0x0807FFFF | 128 KiB | application code
===========+=========================+============================
Sector 8 | 0x08080000 - 0x0809FFFF | 128 KiB | N/A
Sector 9 | 0x080A0000 - 0x080BFFFF | 128 KiB | N/A
Sector 10 | 0x080C0000 - 0x080DFFFF | 128 KiB | N/A
Sector 11 | 0x080E0000 - 0x080FFFFF | 128 KiB | N/A
Sector 8 | 0x08080000 - 0x0809FFFF | 128 KiB | application code
Sector 9 | 0x080A0000 - 0x080BFFFF | 128 KiB | application code
Sector 10 | 0x080C0000 - 0x080DFFFF | 128 KiB | application code
Sector 11 | 0x080E0000 - 0x080FFFFF | 128 KiB | application code
metadata area:
@ -73,7 +73,7 @@ extern uint8_t *emulator_flash_base;
#define FLASH_PTR(x) (const uint8_t*) (x)
#endif
#define FLASH_TOTAL_SIZE (512 * 1024)
#define FLASH_TOTAL_SIZE (1024 * 1024)
#define FLASH_BOOT_START (FLASH_ORIGIN)
#define FLASH_BOOT_LEN (0x8000)
@ -105,7 +105,7 @@ extern uint8_t *emulator_flash_base;
#define FLASH_META_SECTOR_LAST 3
#define FLASH_CODE_SECTOR_FIRST 4
#define FLASH_CODE_SECTOR_LAST 7
#define FLASH_CODE_SECTOR_LAST 11
void memory_protect(void);
void memory_write_unlock(void);

17
setup.c
View File

@ -142,15 +142,16 @@ void setupApp(void)
}
#define MPU_RASR_SIZE_1KB (0x09UL << MPU_RASR_SIZE_LSB)
#define MPU_RASR_SIZE_4KB (0x0bUL << MPU_RASR_SIZE_LSB)
#define MPU_RASR_SIZE_8KB (0x0cUL << MPU_RASR_SIZE_LSB)
#define MPU_RASR_SIZE_16KB (0x0dUL << MPU_RASR_SIZE_LSB)
#define MPU_RASR_SIZE_32KB (0x0eUL << MPU_RASR_SIZE_LSB)
#define MPU_RASR_SIZE_64KB (0x0fUL << MPU_RASR_SIZE_LSB)
#define MPU_RASR_SIZE_4KB (0x0BUL << MPU_RASR_SIZE_LSB)
#define MPU_RASR_SIZE_8KB (0x0CUL << MPU_RASR_SIZE_LSB)
#define MPU_RASR_SIZE_16KB (0x0DUL << MPU_RASR_SIZE_LSB)
#define MPU_RASR_SIZE_32KB (0x0EUL << MPU_RASR_SIZE_LSB)
#define MPU_RASR_SIZE_64KB (0x0FUL << MPU_RASR_SIZE_LSB)
#define MPU_RASR_SIZE_128KB (0x10UL << MPU_RASR_SIZE_LSB)
#define MPU_RASR_SIZE_256KB (0x11UL << MPU_RASR_SIZE_LSB)
#define MPU_RASR_SIZE_512KB (0x12UL << MPU_RASR_SIZE_LSB)
#define MPU_RASR_SIZE_512MB (0x1cUL << MPU_RASR_SIZE_LSB)
#define MPU_RASR_SIZE_1MB (0x13UL << MPU_RASR_SIZE_LSB)
#define MPU_RASR_SIZE_512MB (0x1CUL << MPU_RASR_SIZE_LSB)
// http://infocenter.arm.com/help/topic/com.arm.doc.dui0552a/BABDJJGF.html
#define MPU_RASR_ATTR_FLASH (MPU_RASR_ATTR_C)
@ -168,9 +169,9 @@ void mpu_config(void)
MPU_CTRL = 0;
// Note: later entries overwrite previous ones
// Flash (0x08000000 - 0x0807FFFF, 512 KiB, read-only, execute never)
// Flash (0x08000000 - 0x0807FFFF, 1 MiB, read-only)
MPU_RBAR = FLASH_BASE | MPU_RBAR_VALID | (0 << MPU_RBAR_REGION_LSB);
MPU_RASR = MPU_RASR_ENABLE | MPU_RASR_ATTR_FLASH | MPU_RASR_SIZE_512KB | MPU_RASR_ATTR_AP_PRO_URO;
MPU_RASR = MPU_RASR_ENABLE | MPU_RASR_ATTR_FLASH | MPU_RASR_SIZE_1MB | MPU_RASR_ATTR_AP_PRO_URO;
// Metadata in Flash is read-write when unlocked
// (0x08008000 - 0x0800FFFF, 32 KiB, read-write, execute never)

View File

@ -44,7 +44,7 @@ static void svhandler_flash_program(uint32_t psize) {
}
static void svhandler_flash_erase_sector(uint16_t sector) {
/* we only allow erasing meta sectors 2 and 3. */
/* we only allow erasing meta sectors 2 and 3. */
if (sector < FLASH_META_SECTOR_FIRST ||
sector > FLASH_META_SECTOR_LAST) {
return;