1.. _code_relocation_nocopy:
2
3Code relocation nocopy
4######################
5
6Overview
7********
8A simple example that demonstrates how relocation of code, data or bss sections
9using a custom linker script.
10
11Differently from the code relocation sample, this sample is relocating the
12content of the ext_code.c file to a different FLASH section and the code is XIP
13directly from there without the need to copy / relocate the code.
14
15nRF5340 DK platform instructions
16********************************
17
18The nRF5340 DK has a 64 Mb external flash memory supporting Quad SPI. It is
19possible to do XIP from the external flash memory.
20
21The external flash memory is mapped to 0x10000000.
22
23In this sample we relocate some of the code to the external flash memory with
24the remaining Zephyr kernel in the internal flash.
25
26To build and flash the application (including the external memory part):
27
28.. zephyr-app-commands::
29   :zephyr-app: samples/application_development/code_relocation_nocopy
30   :board: nrf5340dk_nrf5340_cpuapp
31   :goals: build flash
32   :compact:
33
34Execution output:
35
36.. code-block:: console
37
38  *** Booting Zephyr OS build v3.0.0-rc3-25-g0df32cec1ff2  ***
39  Address of main function 0x4f9
40  Address of function_in_ext_flash 0x10000001
41  Address of var_ext_sram_data 0x200000a0 (10)
42  Address of function_in_sram 0x20000001
43  Address of var_sram_data 0x200000a4 (10)
44  Hello World! nrf5340dk_nrf5340_cpuapp
45