This implements support for relocating code to chosen memory regions via the `zephyr_code_relocate` CMake function for RISC-V SoCs. ARM-specific assumptions that were made by gen_relocate_app.py need to be corrected, in particular not assuming any particular name for the default RAM section (which is 'SRAM' for most ARM pltaforms) and not assuming 32-bit pointers (so the test works on RV64). Signed-off-by: Peter Marheine <pmarheine@chromium.org>
33 lines
833 B
CMake
33 lines
833 B
CMake
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
cmake_minimum_required(VERSION 3.20.0)
|
|
|
|
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
|
|
project(code_relocation)
|
|
|
|
FILE(GLOB app_sources src/*.c)
|
|
target_sources(app PRIVATE ${app_sources})
|
|
|
|
if (CONFIG_ARM)
|
|
set(RAM_SECTION SRAM)
|
|
else()
|
|
set(RAM_SECTION RAM)
|
|
endif()
|
|
|
|
# Code relocation feature
|
|
zephyr_code_relocate(src/test_file1.c SRAM2)
|
|
|
|
zephyr_code_relocate(src/test_file2.c ${RAM_SECTION})
|
|
|
|
zephyr_code_relocate(src/test_file3.c SRAM2_TEXT)
|
|
zephyr_code_relocate(src/test_file3.c ${RAM_SECTION}_DATA)
|
|
zephyr_code_relocate(src/test_file3.c SRAM2_BSS)
|
|
|
|
zephyr_code_relocate(../../../kernel/sem.c ${RAM_SECTION})
|
|
|
|
if (CONFIG_RELOCATE_TO_ITCM)
|
|
zephyr_code_relocate(../../../lib/libc/minimal/source/string/string.c ITCM_TEXT)
|
|
endif()
|
|
|
|
zephyr_linker_sources(SECTIONS custom-sections.ld)
|