From d3ec688d6f45d25a825c73b061c344745309fddc Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Thu, 30 Mar 2017 16:47:02 +0200 Subject: [PATCH] trezorhal: don't set SCB->VTOR in SystemInit --- Makefile | 10 +++++----- micropython/bootloader/crypto.c | 2 -- micropython/bootloader/main.c | 3 +-- micropython/firmware/main.c | 1 + micropython/loader/main.c | 3 +-- micropython/trezorhal/common.h | 4 ++++ micropython/trezorhal/stm32_system.c | 14 -------------- 7 files changed, 12 insertions(+), 25 deletions(-) diff --git a/Makefile b/Makefile index 5307824535..08d426ee5a 100644 --- a/Makefile +++ b/Makefile @@ -44,19 +44,19 @@ testpy: ## run selected unit tests from python-trezor build: build_bootloader build_loader build_firmware build_unix build_cross ## build all -build_bootloader: vendor ## build bootloader +build_bootloader: ## build bootloader $(MAKE) -f Makefile.bootloader $(TREZORHAL_PORT_OPTS) -build_loader: vendor ## build loader +build_loader: ## build loader $(MAKE) -f Makefile.loader $(TREZORHAL_PORT_OPTS) -build_firmware: vendor res build_cross ## build firmware with frozen modules +build_firmware: res build_cross ## build firmware with frozen modules $(MAKE) -f Makefile.firmware $(TREZORHAL_PORT_OPTS) -build_unix: vendor ## build unix port +build_unix: ## build unix port $(MAKE) -f ../../../micropython/unix/Makefile -C vendor/micropython/unix $(UNIX_PORT_OPTS) -build_cross: vendor ## build mpy-cross port +build_cross: ## build mpy-cross port $(MAKE) -C vendor/micropython/mpy-cross $(CROSS_PORT_OPTS) ## clean commands: diff --git a/micropython/bootloader/crypto.c b/micropython/bootloader/crypto.c index 76c09d15d2..58358b95bb 100644 --- a/micropython/bootloader/crypto.c +++ b/micropython/bootloader/crypto.c @@ -5,8 +5,6 @@ #include "crypto.h" -#define FLASH_BASE 0x08000000 - bool parse_header(const uint8_t *data, uint32_t *codelen, uint8_t *sigidx, uint8_t *sig) { uint32_t magic; diff --git a/micropython/bootloader/main.c b/micropython/bootloader/main.c index c82813ff5b..eb5662ca4a 100644 --- a/micropython/bootloader/main.c +++ b/micropython/bootloader/main.c @@ -8,8 +8,6 @@ #include "display.h" #include "sdcard.h" -#define LOADER_START 0x08010000 - #define BOOTLOADER_FGCOLOR 0xFFFF #define BOOTLOADER_BGCOLOR 0x0000 @@ -116,6 +114,7 @@ bool copy_sdcard(void) int main(void) { + SCB->VTOR = BOOTLOADER_START; periph_init(); sdcard_init(); diff --git a/micropython/firmware/main.c b/micropython/firmware/main.c index 46309aab45..dd15322ded 100644 --- a/micropython/firmware/main.c +++ b/micropython/firmware/main.c @@ -24,6 +24,7 @@ int main(void) { + SCB->VTOR = FIRMWARE_START; periph_init(); pendsv_init(); diff --git a/micropython/loader/main.c b/micropython/loader/main.c index 7bf6073799..c69b6c93fe 100644 --- a/micropython/loader/main.c +++ b/micropython/loader/main.c @@ -3,8 +3,6 @@ #include "common.h" #include "display.h" -#define FIRMWARE_START 0x08020000 - #define LOADER_FGCOLOR 0xFFFF #define LOADER_BGCOLOR 0x0000 @@ -17,6 +15,7 @@ void pendsv_isr_handler(void) { int main(void) { + SCB->VTOR = LOADER_START; periph_init(); display_init(); diff --git a/micropython/trezorhal/common.h b/micropython/trezorhal/common.h index f8de1fafc8..a88005d14a 100644 --- a/micropython/trezorhal/common.h +++ b/micropython/trezorhal/common.h @@ -3,6 +3,10 @@ #include +#define BOOTLOADER_START 0x08000000 +#define LOADER_START 0x08010000 +#define FIRMWARE_START 0x08020000 + void periph_init(void); void __attribute__((noreturn)) nlr_jump_fail(void *val); diff --git a/micropython/trezorhal/stm32_system.c b/micropython/trezorhal/stm32_system.c index cb925d71fc..7408146cfc 100644 --- a/micropython/trezorhal/stm32_system.c +++ b/micropython/trezorhal/stm32_system.c @@ -144,13 +144,6 @@ const uint32_t MSIRangeTable[12] = {100000, 200000, 400000, 800000, 1000000, 200 /************************* Miscellaneous Configuration ************************/ -/*!< Uncomment the following line if you need to relocate your vector Table in - Internal SRAM. */ -/* #define VECT_TAB_SRAM */ -#define VECT_TAB_OFFSET 0x00 /*!< Vector Table base offset field. - This value must be a multiple of 0x200. */ -/******************************************************************************/ - /** * @} */ @@ -229,13 +222,6 @@ void SystemInit(void) RCC->CIER = 0x00000000; #endif - /* Configure the Vector Table location add offset address ------------------*/ -#ifdef VECT_TAB_SRAM - SCB->VTOR = SRAM1_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */ -#else - SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */ -#endif - /* dpgeorge: enable 8-byte stack alignment for IRQ handlers, in accord with EABI */ SCB->CCR |= SCB_CCR_STKALIGN_Msk; }