From 6fae8ef918e08747b02cbb7e055f5a14ba101050 Mon Sep 17 00:00:00 2001 From: Michael Ehrenreich Date: Thu, 28 Apr 2022 03:48:29 +0200 Subject: [PATCH] Resolve location of interrupt vector table at link time --- CMakeLists.txt | 14 +------------- system_stm32f1xx.c | 6 ++---- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e35daf8..f672f8d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -98,8 +98,6 @@ target_compile_options(motortest.elf PRIVATE # -DFEATURE_CAN # -DCAN_LOG_UNKNOWN_ADDR # -DIS_BACK - - -DVECT_TAB_OFFSET=${A_FIRMWARE_APP_BASE} ) add_custom_command(OUTPUT motortest.hex COMMAND arm-none-eabi-objcopy -O ihex motortest.elf motortest.hex DEPENDS motortest.elf) add_custom_command(OUTPUT motortest.bin COMMAND arm-none-eabi-objcopy -O binary -S motortest.elf motortest.bin DEPENDS motortest.elf) @@ -128,8 +126,6 @@ target_compile_options(motortest_peter.elf PRIVATE -DFEATURE_CAN # -DCAN_LOG_UNKNOWN_ADDR -DIS_BACK - - -DVECT_TAB_OFFSET=${A_FIRMWARE_APP_BASE} ) add_custom_command(OUTPUT motortest_peter.hex COMMAND arm-none-eabi-objcopy -O ihex motortest_peter.elf motortest_peter.hex DEPENDS motortest_peter.elf) add_custom_command(OUTPUT motortest_peter.bin COMMAND arm-none-eabi-objcopy -O binary -S motortest_peter.elf motortest_peter.bin DEPENDS motortest_peter.elf) @@ -158,8 +154,6 @@ target_compile_options(feedcode-front.elf PRIVATE -DFEATURE_CAN # -DCAN_LOG_UNKNOWN_ADDR # -DIS_BACK - - -DVECT_TAB_OFFSET=${A_FIRMWARE_APP_BASE} ) add_custom_command(OUTPUT feedcode-front.hex COMMAND arm-none-eabi-objcopy -O ihex feedcode-front.elf feedcode-front.hex DEPENDS feedcode-front.elf) add_custom_command(OUTPUT feedcode-front.bin COMMAND arm-none-eabi-objcopy -O binary -S feedcode-front.elf feedcode-front.bin DEPENDS feedcode-front.elf) @@ -187,8 +181,6 @@ target_compile_options(feedcode-back.elf PRIVATE -DFEATURE_CAN # -DCAN_LOG_UNKNOWN_ADDR -DIS_BACK - - -DVECT_TAB_OFFSET=${A_FIRMWARE_APP_BASE} ) add_custom_command(OUTPUT feedcode-back.hex COMMAND arm-none-eabi-objcopy -O ihex feedcode-back.elf feedcode-back.hex DEPENDS feedcode-back.elf) add_custom_command(OUTPUT feedcode-back.bin COMMAND arm-none-eabi-objcopy -O binary -S feedcode-back.elf feedcode-back.bin DEPENDS feedcode-back.elf) @@ -216,8 +208,6 @@ target_compile_options(greyhash.elf PRIVATE # -DFEATURE_CAN # -DCAN_LOG_UNKNOWN_ADDR # -DIS_BACK - - -DVECT_TAB_OFFSET=${A_FIRMWARE_APP_BASE} ) add_custom_command(OUTPUT greyhash.hex COMMAND arm-none-eabi-objcopy -O ihex greyhash.elf greyhash.hex DEPENDS greyhash.elf) add_custom_command(OUTPUT greyhash.bin COMMAND arm-none-eabi-objcopy -O binary -S greyhash.elf greyhash.bin DEPENDS greyhash.elf) @@ -228,9 +218,7 @@ add_custom_target(flash-greyhash COMMAND st-flash --reset write greyhash.bin ${A add_executable(ab_boot.elf ab_boot/ab_boot.c system_stm32f1xx.c) target_link_options(ab_boot.elf PRIVATE ${COMMON_LINKER_FLAGS} ${AB_BOOT_FIRMWARE_LINKER_FLAGS}) target_link_libraries(ab_boot.elf stm32_hal) -target_compile_options(ab_boot.elf PRIVATE - -DVECT_TAB_OFFSET=0x00000000 -) +target_compile_options(ab_boot.elf PRIVATE ) add_custom_command(OUTPUT ab_boot.hex COMMAND arm-none-eabi-objcopy -O ihex ab_boot.elf ab_boot.hex DEPENDS ab_boot.elf) add_custom_command(OUTPUT ab_boot.bin COMMAND arm-none-eabi-objcopy -O binary -S ab_boot.elf ab_boot.bin DEPENDS ab_boot.elf) add_custom_target(ab_boot ALL SOURCES ab_boot.hex ab_boot.bin) diff --git a/system_stm32f1xx.c b/system_stm32f1xx.c index 7671c97..2034671 100644 --- a/system_stm32f1xx.c +++ b/system_stm32f1xx.c @@ -110,11 +110,9 @@ /*!< Uncomment the following line if you need to relocate your vector Table in Internal SRAM. */ /* #define VECT_TAB_SRAM */ -#if !defined(VECT_TAB_OFFSET) -#warning VECT_TAB_OFFSET is not defined, using default of 0x00000000U -#define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field. \ +extern unsigned int g_pfnVectors[]; +#define VECT_TAB_OFFSET ((unsigned int)g_pfnVectors) /*!< Vector Table base offset field. \ This value must be a multiple of 0x200. */ -#endif /* VECT_TAB_OFFSET */ /** * @}