linker: Generate snippets files for dtcm and itcm

This allows to link code and data blocks, e.g. the vector table, into
tightly coupled memory using `zephyr_linker_sources`.

Signed-off-by: Greter Raffael <rgreter@baumer.com>
This commit is contained in:
Greter Raffael 2023-11-14 08:20:53 +00:00 committed by David Leach
commit 33ffe001f8
4 changed files with 43 additions and 2 deletions

View file

@ -1170,6 +1170,8 @@ endfunction(zephyr_check_compiler_flag_hardcoded)
# DATA_SECTIONS Inside the RAMABLE_REGION GROUP, initialized.
# RAMFUNC_SECTION Inside the RAMFUNC RAMABLE_REGION GROUP, not initialized.
# NOCACHE_SECTION Inside the NOCACHE section
# ITCM_SECTION Inside the itcm section.
# DTCM_SECTION Inside the dtcm data section.
# SECTIONS Near the end of the file. Don't use this when linking into
# RAMABLE_REGION, use RAM_SECTIONS instead.
# PINNED_RODATA Similar to RODATA but pinned in memory.
@ -1184,8 +1186,9 @@ endfunction(zephyr_check_compiler_flag_hardcoded)
# Use NOINIT, RWDATA, and RODATA unless they don't work for your use case.
#
# When placing into NOINIT, RWDATA, RODATA, ROM_START, RAMFUNC_SECTION,
# NOCACHE_SECTION the contents of the files will be placed inside
# an output section, so assume the section definition is already present, e.g.:
# NOCACHE_SECTION, DTCM_SECTION or ITCM_SECTION the contents of the files will
# be placed inside an output section, so assume the section definition is
# already present, e.g.:
# _mysection_start = .;
# KEEP(*(.mysection));
# _mysection_end = .;
@ -1220,6 +1223,8 @@ function(zephyr_linker_sources location)
set(rodata_path "${snippet_base}/snippets-rodata.ld")
set(ramfunc_path "${snippet_base}/snippets-ramfunc-section.ld")
set(nocache_path "${snippet_base}/snippets-nocache-section.ld")
set(itcm_path "${snippet_base}/snippets-itcm-section.ld")
set(dtcm_path "${snippet_base}/snippets-dtcm-section.ld")
set(pinned_ram_sections_path "${snippet_base}/snippets-pinned-ram-sections.ld")
set(pinned_data_sections_path "${snippet_base}/snippets-pinned-data-sections.ld")
@ -1237,6 +1242,8 @@ function(zephyr_linker_sources location)
file(WRITE ${rodata_path} "")
file(WRITE ${ramfunc_path} "")
file(WRITE ${nocache_path} "")
file(WRITE ${itcm_path} "")
file(WRITE ${dtcm_path} "")
file(WRITE ${pinned_ram_sections_path} "")
file(WRITE ${pinned_data_sections_path} "")
file(WRITE ${pinned_rodata_path} "")
@ -1262,6 +1269,10 @@ function(zephyr_linker_sources location)
set(snippet_path "${ramfunc_path}")
elseif("${location}" STREQUAL "NOCACHE_SECTION")
set(snippet_path "${nocache_path}")
elseif("${location}" STREQUAL "ITCM_SECTION")
set(snippet_path "${itcm_path}")
elseif("${location}" STREQUAL "DTCM_SECTION")
set(snippet_path "${dtcm_path}")
elseif("${location}" STREQUAL "PINNED_RAM_SECTIONS")
set(snippet_path "${pinned_ram_sections_path}")
elseif("${location}" STREQUAL "PINNED_DATA_SECTIONS")

View file

@ -396,6 +396,11 @@ GROUP_START(ITCM)
__itcm_start = .;
*(.itcm)
*(".itcm.*")
/* Located in generated directory. This file is populated by the
* zephyr_linker_sources() Cmake function. */
#include <snippets-itcm-section.ld>
__itcm_end = .;
} GROUP_LINK_IN(ITCM AT> ROMABLE_REGION)
@ -430,6 +435,11 @@ GROUP_START(DTCM)
__dtcm_data_start = .;
*(.dtcm_data)
*(".dtcm_data.*")
/* Located in generated directory. This file is populated by the
* zephyr_linker_sources() Cmake function. */
#include <snippets-dtcm-section.ld>
__dtcm_data_end = .;
} GROUP_LINK_IN(DTCM AT> ROMABLE_REGION)

View file

@ -327,6 +327,11 @@ GROUP_START(ITCM)
__itcm_start = .;
*(.itcm)
*(".itcm.*")
/* Located in generated directory. This file is populated by the
* zephyr_linker_sources() Cmake function. */
#include <snippets-itcm-section.ld>
__itcm_end = .;
} GROUP_LINK_IN(ITCM AT> ROMABLE_REGION)
@ -361,6 +366,11 @@ GROUP_START(DTCM)
__dtcm_data_start = .;
*(.dtcm_data)
*(".dtcm_data.*")
/* Located in generated directory. This file is populated by the
* zephyr_linker_sources() Cmake function. */
#include <snippets-dtcm-section.ld>
__dtcm_data_end = .;
} GROUP_LINK_IN(DTCM AT> ROMABLE_REGION)

View file

@ -322,6 +322,11 @@ GROUP_START(ITCM)
__itcm_start = .;
*(.itcm)
*(".itcm.*")
/* Located in generated directory. This file is populated by the
* zephyr_linker_sources() Cmake function. */
#include <snippets-itcm-section.ld>
__itcm_end = .;
} GROUP_LINK_IN(ITCM AT> ROMABLE_REGION)
@ -356,6 +361,11 @@ GROUP_START(DTCM)
__dtcm_data_start = .;
*(.dtcm_data)
*(".dtcm_data.*")
/* Located in generated directory. This file is populated by the
* zephyr_linker_sources() Cmake function. */
#include <snippets-dtcm-section.ld>
__dtcm_data_end = .;
} GROUP_LINK_IN(DTCM AT> ROMABLE_REGION)