Skip to content

Commit 3be4c4c

Browse files
mathieuchopstmaescolar
authored andcommitted
soc: st: stm32f0: SRAM vector table CMake Linker Generator compatibility
Add required CMake directives to enable working CONFIG_SRAM_VECTOR_TABLE=y on STM32F0 series when CONFIG_CMAKE_LINKER_GENERATOR=y. Builds OK with both ZEPHYR_TOOLCHAIN_VARIANT undefined (uses GNU toolchain from Zephyr SDK) and set to "iar" (uses IAR toochain from EWARM v9.70.1). Signed-off-by: Mathieu Choplain <[email protected]>
1 parent 244fe54 commit 3be4c4c

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

soc/st/stm32/stm32f0x/CMakeLists.txt

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,27 @@
11
# SPDX-License-Identifier: Apache-2.0
22

3-
# The vector table must be placed at the start of SRAM
4-
zephyr_linker_sources_ifdef(CONFIG_SRAM_VECTOR_TABLE
5-
RAM_SECTIONS
6-
SORT_KEY 0
7-
sram_vector_table.ld
8-
)
3+
if(CONFIG_SRAM_VECTOR_TABLE)
4+
# The vector table must be placed at the start of SRAM.
5+
# Reserve the first sizeof(<vector table>) bytes for this purpose.
6+
if(CONFIG_CMAKE_LINKER_GENERATOR)
7+
# We use MIN_SIZE to perform the equivalent of GNU ld `. += <XXX>;`
8+
# but we have to compute the size of the vector table manually as
9+
# it must be a bytes count (can't be `_vector_end - _vector_start`).
10+
# Fortunately, the vector table size can be easily computed:
11+
# 16 words for the architectural exceptions plus one word per IRQ
12+
# (each word is 32 bits = 4 bytes).
13+
math(EXPR vect_tbl_size "(16 + ${CONFIG_NUM_IRQS}) * 4")
14+
zephyr_linker_section(NAME .st_stm32f0x_vt TYPE NOLOAD GROUP RAM_REGION ADDRESS 0x20000000 NOINPUT NOINIT)
15+
zephyr_linker_section_configure(SECTION .st_stm32f0x_vt MIN_SIZE ${vect_tbl_size} SYMBOLS _ram_vector_start _ram_vector_end)
16+
else()
17+
zephyr_linker_sources(
18+
RAM_SECTIONS
19+
SORT_KEY 0
20+
sram_vector_table.ld
21+
)
22+
endif()
23+
endif()
24+
925
zephyr_include_directories(${ZEPHYR_BASE}/drivers)
1026
zephyr_sources(soc.c)
1127

0 commit comments

Comments
 (0)