zephyr/doc/guides
Carlo Caione d3203dc70d code_relocation: Add NOCOPY feature
* Use case of interest:

Some platforms are shipping in parallel to the internal FLASH some other
storage / external FLASH (usually a QSPI FLASH) that can be used to
execute (XIP) code from.

The content of this external FLASH can usually be written at flash time
using proper tools (see for example the case of the external FLASH on
the nRF5340DK that can be written at flash time using nrfjprog).

The external FLASH is a nice addition that is extremely useful when a
large application code doesn't entirely fit on the internal FLASH so
that we could want to move part of it in the auxiliary FLASH to XIP the
code from there.

* The problem:

Right now Zephyr doesn't have a formal and generic way to move at build
time part of the code to a different memory region.

* The current status:

Zephyr is indeed shipping a code_relocation feature but that doesn't
entirely match our needs.

When XIP is enabled, the code_relocation feature is used in Zephyr to
move the selected code (that is to copy text section, to initialize data
and zero bss) from FLASH to SRAM at run time and execute code from SRAM.

The relocation is done by a generated snippet of code that is
memcpy()-ing the right content to the destination region also using some
build-time generated portions of linker script to retrieve start and
destination addresses and regions.

* This patch:

This patch is leveraging the code_relocation code and adding a NOCOPY
feature. This feature is using the code_relocation feature to
dynamically build the linker script snippets but entirely skipping the
run-time code relocation so that the code can be XIP-ed from the
destination region.

* Example:

Let's say that we have a big file called `huge_file.c` that we want to
XIP from the external FLASH that is mapped in an EXTFLASH region.

In this case we should enable `CONFIG_XIP` and
`CONFIG_CODE_DATA_RELOCATION` and instruct cmake as follows:

  zephyr_code_relocate(src/huge_file.c EXTFLASH_TEXT NOCOPY)
  zephyr_code_relocate(src/huge_file.c SRAM_DATA)

this means that:

- The .text section of the `huge_file.c` must reside in the EXTFLASH
  memory region and we do not need to copy the section there because we
  are going to XIP it (and we assume that the file is going to be placed
  in the external FLASH at flash time).
- The .data section of the `huge_file.c` must still reside in the SRAM
  memory region.

* TODOs:

It's desirable to have the possibility to relocate libraries and
pre-build files instead of source code files.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2022-02-21 22:09:46 -05:00
..
arch DOC: ARC: update arc status page 2021-10-06 09:26:57 -04:00
bluetooth doc: bluetooth: Clarify BLE HW reqs are for Nordic 2021-11-08 10:41:26 +01:00
build doc: update devicetree sections 2021-12-07 13:39:37 -05:00
crypto
debug_tools tracing_user: Add ISR nest level parameter 2022-01-21 14:38:35 -05:00
device_mgmt doc: add OTA section to device management 2022-02-21 20:39:08 -05:00
docs doc: guides: docs: add details on DT_TURBO_MODE 2022-02-21 20:47:10 -05:00
dts doc: drop single quote references 2021-12-10 16:43:34 -05:00
emulator drivers: can: loopback: convert the CAN loopback driver to dts 2022-01-04 15:13:40 -06:00
flash_debug doc/probes: Add debug probe and host tools table and ST-Link tabs 2021-07-22 17:33:43 -04:00
networking doc: use kconfig role and directive 2021-06-29 10:26:28 -04:00
optimizations doc: use kconfig role and directive 2021-06-29 10:26:28 -04:00
pinctrl pinctrl: use groupN instead of pinsN for groups 2022-01-01 07:39:08 -05:00
platformio
pm doc: guides: pm: fix incorrect Kconfig reference 2022-02-08 07:02:47 -05:00
portability doc: guides: Add srand() 2021-07-20 13:32:36 -04:00
porting doc: fix kconfig usage issues 2022-01-17 11:42:53 -05:00
smf doc: guides: smf: use graphviz extension 2021-11-10 13:54:46 -05:00
test doc: twister: add usage for twister --fixture option. 2022-02-21 21:59:50 -05:00
tfm boards: b_u585i_iot02a: Add a non-secure target 2022-01-18 10:42:45 -05:00
tools
west doc: fix PDF build issue due to extlink references 2022-01-17 12:48:43 -05:00
beyond-GSG.rst
coccinelle.rst
code-relocation.rst code_relocation: Add NOCOPY feature 2022-02-21 22:09:46 -05:00
env_vars.rst doc: restore environment variables page 2021-12-14 13:28:20 +01:00
index.rst doc: restore environment variables page 2021-12-14 13:28:20 +01:00
modules.rst doc: document new submanifests folder 2021-10-07 13:45:42 +02:00
zephyr_cmake_package.rst doc: restore environment variables page 2021-12-14 13:28:20 +01:00