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 coccinelle: check reserved symbols based on a file 2021-04-30 22:09:43 -04:00
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 zephyr_commit_rules.py: Fix pylint warning by simplifying conditional 2019-09-08 22:19:37 -04:00
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 net: scripts: Make test runner script fully generic 2020-11-20 16:07:59 +02:00
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 scripts: Simplify code with sys.exit(<string>) 2019-09-08 12:34:16 +02:00
tests twister: raise error for non-existing platform call 2022-01-11 09:53:40 -05:00
tracing tracing: scripts: add scripts for parsing ctf data 2020-08-24 13:21:12 +02:00
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 cleanup: rename sanitycheck references to twister 2021-01-14 07:50:52 -06:00
checkpatch.pl checkpatch: Add UTIL_CAT support to checkpatch 2021-12-04 07:22:56 -05:00
checkstack.pl First commit 2015-04-10 16:44:37 -07:00
coccicheck scripts: Fix documunt referenc for coccicheck 2020-05-08 17:44:44 +02:00
dir_is_writeable.py global: Remove leading/trailing blank lines in files 2019-12-11 19:17:27 +01:00
file2hex.py scripts: file2hex.py: PEP 8 style fix 2020-06-12 11:09:58 +02:00
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 zephyr: replace zephyr integer types with C99 types 2020-06-08 08:23:57 -05:00
gen_gcov_files.py scripts: gen_gcov_files.py: add argument help text 2020-06-13 16:33:22 -04:00
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 scripts: gen_offset_header: add argument help text 2020-05-21 14:45:24 +02:00
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 scripts: list_boards: handle boards dirs with subset of architectures 2021-06-11 16:26:30 +02:00
mergehex.py scripts: cmake: move print from python to cmake 2020-01-03 08:20:08 -05:00
parse_syscalls.py userspace: net sockets are kernel objects 2020-06-03 22:33:32 +02:00
process_gperf.py scripts/arch: remove usage of deprecated LooseVersion 2021-11-19 19:16:11 -05:00
requirements-base.txt requirements: bump west to >=0.10.1 2021-05-18 09:52:12 -05:00
requirements-build-test.txt scripts: move pip pykwalify from requirements-build-test to -base 2021-01-18 16:56:24 -05:00
requirements-compliance.txt requirements-compliance: restrict junitparser version < 2 2021-01-13 07:58:37 -05:00
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: Update to pyocd 0.29 for LPC55S69 support 2021-01-21 15:53:22 -05:00
requirements.txt python3: add check_compliance package requirements 2020-08-11 14:49:48 -04:00
series-push-hook.sh scripts: series-push-hook: Use main as base comparison branch 2021-05-27 15:55:43 -05:00
spelling.txt scripts: updated spelling.txt file 2017-07-14 12:57:40 +03:00
subfolder_list.py scripts: subfolder_list.py: refactor the code 2020-07-20 17:31:53 -04:00
tags.sh scripts: Update paths on tags.sh 2021-02-19 05:28:09 -06:00
twister twister: add fixtures given by --fixture option to each devices. 2022-02-21 21:59:50 -05:00
uf2conv.py cmake: Add UF2 as an additional build output option. 2021-02-23 21:11:04 +01:00
user_wordsize.py posix arch: build on aarch64 / allow host-specific cmake includes 2020-05-09 12:17:24 +02:00
valgrind.supp lvgl: Suppress memory leak errors detected by valgrind 2019-10-21 12:26:35 -07:00
west-commands.yml west: spdx: Generate SPDX 2.2 tag-value documents 2021-05-05 11:14:06 -04:00
zephyr_module.py scripts: support propagating workspace status to zephyr revision 2021-12-14 12:32:10 +01:00