diff --git a/Kconfig.zephyr b/Kconfig.zephyr index 79ca4249792..ce1a01ea09d 100644 --- a/Kconfig.zephyr +++ b/Kconfig.zephyr @@ -167,6 +167,12 @@ config LINKER_SORT_BY_ALIGNMENT in decreasing size of symbols. This helps to minimize padding between symbols. +config SRAM_VECTOR_TABLE + bool "Place the vector table in SRAM instead of flash" + help + The option specifies that the vector table should be placed at the + start of SRAM instead of the start of flash. + config HAS_SRAM_OFFSET bool help diff --git a/boards/arm/nucleo_f030r8/nucleo_f030r8_defconfig b/boards/arm/nucleo_f030r8/nucleo_f030r8_defconfig index 38de49cdf40..a388bc25bd6 100644 --- a/boards/arm/nucleo_f030r8/nucleo_f030r8_defconfig +++ b/boards/arm/nucleo_f030r8/nucleo_f030r8_defconfig @@ -14,8 +14,7 @@ CONFIG_MAIN_STACK_SIZE=640 CONFIG_IDLE_STACK_SIZE=200 CONFIG_ISR_STACK_SIZE=512 # Prevent Interrupt Vector Table in RAM -CONFIG_IS_BOOTLOADER=y -CONFIG_BOOTLOADER_SRAM_SIZE=8 +CONFIG_SRAM_VECTOR_TABLE=n # Serial Drivers CONFIG_SERIAL=y diff --git a/boards/arm/nucleo_f031k6/nucleo_f031k6_defconfig b/boards/arm/nucleo_f031k6/nucleo_f031k6_defconfig index 9360e4dbbc5..fcfdfe5362b 100644 --- a/boards/arm/nucleo_f031k6/nucleo_f031k6_defconfig +++ b/boards/arm/nucleo_f031k6/nucleo_f031k6_defconfig @@ -13,8 +13,7 @@ CONFIG_IDLE_STACK_SIZE=150 CONFIG_ISR_STACK_SIZE=256 CONFIG_LOG_BUFFER_SIZE=256 # Prevent Interrupt Vector Table in RAM -CONFIG_IS_BOOTLOADER=y -CONFIG_BOOTLOADER_SRAM_SIZE=4 +CONFIG_SRAM_VECTOR_TABLE=n # Serial Drivers CONFIG_SERIAL=y diff --git a/boards/arm/stm32f030_demo/stm32f030_demo_defconfig b/boards/arm/stm32f030_demo/stm32f030_demo_defconfig index 5f9de51593b..4c57ed254fb 100644 --- a/boards/arm/stm32f030_demo/stm32f030_demo_defconfig +++ b/boards/arm/stm32f030_demo/stm32f030_demo_defconfig @@ -14,8 +14,7 @@ CONFIG_MAIN_STACK_SIZE=640 CONFIG_IDLE_STACK_SIZE=200 CONFIG_ISR_STACK_SIZE=512 # Prevent Interrupt Vector Table in RAM -CONFIG_IS_BOOTLOADER=y -CONFIG_BOOTLOADER_SRAM_SIZE=4 +CONFIG_SRAM_VECTOR_TABLE=n # Serial Drivers CONFIG_SERIAL=y diff --git a/boards/arm/stm32f0_disco/stm32f0_disco_defconfig b/boards/arm/stm32f0_disco/stm32f0_disco_defconfig index 66b7a9b0119..1203f38fec1 100644 --- a/boards/arm/stm32f0_disco/stm32f0_disco_defconfig +++ b/boards/arm/stm32f0_disco/stm32f0_disco_defconfig @@ -14,8 +14,7 @@ CONFIG_MAIN_STACK_SIZE=640 CONFIG_IDLE_STACK_SIZE=200 CONFIG_ISR_STACK_SIZE=512 # Prevent Interrupt Vector Table in RAM -CONFIG_IS_BOOTLOADER=y -CONFIG_BOOTLOADER_SRAM_SIZE=8 +CONFIG_SRAM_VECTOR_TABLE=n # Serial Drivers CONFIG_SERIAL=y diff --git a/include/arch/arm/aarch32/cortex_m/scripts/linker.ld b/include/arch/arm/aarch32/cortex_m/scripts/linker.ld index adf43203116..7f4bff0c75e 100644 --- a/include/arch/arm/aarch32/cortex_m/scripts/linker.ld +++ b/include/arch/arm/aarch32/cortex_m/scripts/linker.ld @@ -254,7 +254,7 @@ SECTIONS . = ALIGN(_region_min_align); _image_ram_start = .; -#if defined(CONFIG_SOC_SERIES_STM32F0X) && !defined(CONFIG_IS_BOOTLOADER) +#if defined(CONFIG_SOC_SERIES_STM32F0X) && defined(CONFIG_SRAM_VECTOR_TABLE) /* Must be first in ramable region */ SECTION_PROLOGUE(.st_stm32f0x_vt,(NOLOAD),) { diff --git a/soc/arm/st_stm32/stm32f0/Kconfig.defconfig.series b/soc/arm/st_stm32/stm32f0/Kconfig.defconfig.series index b2b4e3b3d90..de04a02f4d2 100644 --- a/soc/arm/st_stm32/stm32f0/Kconfig.defconfig.series +++ b/soc/arm/st_stm32/stm32f0/Kconfig.defconfig.series @@ -12,4 +12,7 @@ source "soc/arm/st_stm32/stm32f0/Kconfig.defconfig.stm32f0*" config SOC_SERIES default "stm32f0" +config SRAM_VECTOR_TABLE + default y + endif # SOC_SERIES_STM32F0X diff --git a/soc/arm/st_stm32/stm32f0/soc.c b/soc/arm/st_stm32/stm32f0/soc.c index 1fddd1908a2..f5f05086dca 100644 --- a/soc/arm/st_stm32/stm32f0/soc.c +++ b/soc/arm/st_stm32/stm32f0/soc.c @@ -47,7 +47,7 @@ void relocate_vector_table(void) { #if defined(CONFIG_SW_VECTOR_RELAY) || defined(CONFIG_SW_VECTOR_RELAY_CLIENT) _vector_table_pointer = _vector_start; -#elif !defined(CONFIG_IS_BOOTLOADER) +#elif defined(CONFIG_SRAM_VECTOR_TABLE) extern char _ram_vector_start[]; size_t vector_size = (size_t)_vector_end - (size_t)_vector_start;