zephyr/scripts
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
..
checkpatch drivers: gpio: Added support for raspberry pi 2022-02-02 16:23:35 +01:00
ci scripts: ci: check_compliance: check for (re)defined Kconfig symbols 2022-02-21 19:35:21 -05:00
coccinelle
coredump debug: coredump: dummy window registers, assign an to arn 2021-12-14 07:40:55 -05:00
dts cmake: dts: Add dt_comp_path() cmake function 2022-02-21 22:02:04 -05:00
footprint footprint: track audio features on xtensa 2022-01-05 14:59:01 -05:00
gitlint
kconfig scripts/Kconfig: add dt_node_str_prop_equals Kconfig function 2021-11-24 12:28:02 +01:00
logging/dictionary cmake: version.h generation performed at build time 2022-02-08 07:50:24 -05:00
net
pylib/twister twister: add option to create shorter build paths 2022-02-21 19:39:32 -05:00
release scripts: add script to extract top-ten bug-bashers 2021-09-01 17:06:50 -04:00
schemas/twister twister: fix the testcase-schema.yaml 2021-11-19 11:46:38 -05:00
support
tests twister: raise error for non-existing platform call 2022-01-11 09:53:40 -05:00
tracing
utils scripts: utils: add pinctrl migration script for nRF boards 2021-11-26 14:20:51 +01:00
west_commands west: spdx: Fix missing field in build results 2022-01-26 18:15:33 +01:00
.gitignore
checkpatch.pl checkpatch: Add UTIL_CAT support to checkpatch 2021-12-04 07:22:56 -05:00
checkstack.pl
coccicheck
dir_is_writeable.py
file2hex.py
gen_app_partitions.py scripts: support compile_commands.json in gen_app_partitions.py 2021-11-25 10:41:28 -05:00
gen_cfb_font_header.py
gen_gcov_files.py
gen_handles.py device: iterable supported devices 2021-11-23 12:17:14 +01:00
gen_image_info.py cmake: support ELF image adjustment 2022-01-22 16:57:31 -05:00
gen_kobject_list.py scripts/arch: remove usage of deprecated LooseVersion 2021-11-19 19:16:11 -05:00
gen_kobject_placeholders.py scripts: gen_kobject_placeholders: iterating the dictionary directly 2021-11-19 19:16:11 -05:00
gen_offset_header.py
gen_relocate_app.py code_relocation: Add NOCOPY feature 2022-02-21 22:09:46 -05:00
gen_syscalls.py Tracing: TRACING_SYSCALL status ignored fix 2021-10-26 15:13:08 -04:00
get_maintainer.py scripts: get_maintainer: add count function 2021-10-18 08:36:21 -04:00
list_boards.py
mergehex.py
parse_syscalls.py
process_gperf.py scripts/arch: remove usage of deprecated LooseVersion 2021-11-19 19:16:11 -05:00
requirements-base.txt
requirements-build-test.txt
requirements-compliance.txt
requirements-doc.txt doc: requirements: stick to breathe < 4.33 2022-02-15 11:26:13 +01:00
requirements-extras.txt scripts: add script to extract top-ten bug-bashers 2021-09-01 17:06:50 -04:00
requirements-run-test.txt
requirements.txt
series-push-hook.sh
spelling.txt
subfolder_list.py
tags.sh
twister twister: add fixtures given by --fixture option to each devices. 2022-02-21 21:59:50 -05:00
uf2conv.py
user_wordsize.py
valgrind.supp
west-commands.yml
zephyr_module.py scripts: support propagating workspace status to zephyr revision 2021-12-14 12:32:10 +01:00