Skip to content

Commit de8478b

Browse files
danieldegrassecarlescufi
authored andcommitted
doc: code-relocation: Update usage of zephyr_code_relocate
Update usage of zephyr_code_relocate to new API, and add examples of relocating a library target, as well as using multiple files in list or CMake generator expressions. Signed-off-by: Daniel DeGrasse <[email protected]>
1 parent 47271ce commit de8478b

File tree

2 files changed

+33
-8
lines changed

2 files changed

+33
-8
lines changed

doc/kernel/code-relocation.rst

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,13 @@ for data copy operations from ROM to required memory type.
5454
* Inside the ``CMakeLists.txt`` file in the project, mention
5555
all the files that need relocation.
5656

57-
``zephyr_code_relocate(src/*.c SRAM2)``
57+
``zephyr_code_relocate(FILES src/*.c LOCATION SRAM2)``
5858

5959
Where the first argument is the file/files and the second
6060
argument is the memory where it must be placed.
6161

6262
.. note::
6363

64-
The file argument supports limited regular expressions.
6564
function zephyr_code_relocate() can be called as many times as required.
6665
This step has to be performed before calling find_package(Zephyr ...)
6766
in the application's CMakeLists.txt.
@@ -77,21 +76,30 @@ This section shows additional configuration options that can be set in
7776

7877
.. code-block:: none
7978
80-
zephyr_code_relocate(src/file1.c SRAM2)
81-
zephyr_code_relocate(src/file2.c.c SRAM)
79+
zephyr_code_relocate(FILES src/file1.c LOCATION SRAM2)
80+
zephyr_code_relocate(FILES src/file2.c LOCATION SRAM)
8281
8382
* if the memory type is appended with _DATA, _TEXT, _RODATA or _BSS, only the
8483
selected memory is placed in the required memory region.
8584
for example:
8685

8786
.. code-block:: none
8887
89-
zephyr_code_relocate(src/file1.c SRAM2_DATA)
90-
zephyr_code_relocate(src/file2.c.c SRAM2_TEXT)
88+
zephyr_code_relocate(FILES src/file1.c LOCATION SRAM2_DATA)
89+
zephyr_code_relocate(FILES src/file2.c LOCATION SRAM2_TEXT)
9190
9291
* Multiple regions can also be appended together such as: SRAM2_DATA_BSS.
9392
This will place data and bss inside SRAM2.
9493

94+
* Multiple files can be passed to the FILES argument, or CMake generator
95+
expressions can be used to relocate a comma-separated list of files
96+
97+
.. code-block:: none
98+
99+
file(GLOB sources "file*.c")
100+
zephyr_code_relocate(FILES ${sources} LOCATION SRAM)
101+
zephyr_code_relocate(FILES $<TARGET_PROPERTY:my_tgt,SOURCES> LOCATION SRAM)
102+
95103
NOCOPY flag
96104
===========
97105

@@ -106,8 +114,20 @@ to the ``EXTFLASH`` memory region where it will be executed from (XIP). The
106114

107115
.. code-block:: none
108116
109-
zephyr_code_relocate(src/xip_external_flash.c EXTFLASH_TEXT NOCOPY)
110-
zephyr_code_relocate(src/xip_external_flash.c SRAM_DATA)
117+
zephyr_code_relocate(FILES src/xip_external_flash.c LOCATION EXTFLASH_TEXT NOCOPY)
118+
zephyr_code_relocate(FILES src/xip_external_flash.c LOCATION SRAM_DATA)
119+
120+
Relocating libraries
121+
====================
122+
123+
Libraries can be relocated using the LIBRARY argument to
124+
``zephyr_code_relocation()`` with the library name. For example, the following
125+
snippet will relocate kernel code to ITCM and serial drivers to SRAM2:
126+
127+
.. code-block:: none
128+
129+
zephyr_code_relocate(LIBRARY kernel LOCATION ITCM_TEXT)
130+
zephyr_code_relocate(LIBRARY drivers__serial LOCATION SRAM2)
111131
112132
Sample
113133
======

doc/releases/release-notes-3.3.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,11 @@ Boards & SoC Support
311311
Build system and infrastructure
312312
*******************************
313313

314+
* Code relocation
315+
316+
* ``zephyr_code_relocate`` API has changed to accept a list of files to
317+
relocate and a location to place the files.
318+
314319
Drivers and Sensors
315320
*******************
316321

0 commit comments

Comments
 (0)