Skip to content

Commit 0249d14

Browse files
committed
loader: Support relocating sections to different memory regions.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
1 parent 7bc5dc6 commit 0249d14

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

loader/CMakeLists.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,20 @@ project(app LANGUAGES C CXX)
1616

1717
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/blobs)
1818

19+
# Memory region relocation based on Kconfig
20+
# Relocate LLEXT heap if region specified
21+
if(NOT "${CONFIG_LLEXT_HEAP_REGION}" STREQUAL "")
22+
zephyr_code_relocate(FILES ${ZEPHYR_BASE}/subsys/llext/llext_mem.c
23+
LOCATION ${CONFIG_LLEXT_HEAP_REGION}_BSS_NOINIT)
24+
endif()
25+
26+
# Relocate main stack if region specified
27+
if(NOT "${CONFIG_MAIN_STACK_REGION}" STREQUAL "")
28+
zephyr_code_relocate(FILES ${ZEPHYR_BASE}/kernel/init.c
29+
LOCATION ${CONFIG_MAIN_STACK_REGION}_BSS_NOINIT)
30+
endif()
31+
32+
1933
# for USB device stack NEXT
2034
target_sources_ifdef(CONFIG_USB_DEVICE_STACK_NEXT app PRIVATE
2135
${CMAKE_CURRENT_LIST_DIR}/../cores/arduino/usb_device_descriptor.c

loader/Kconfig

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#
2+
# Copyright (c) 2025 Arduino
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
7+
source "Kconfig.zephyr"
8+
9+
config LLEXT_HEAP_REGION
10+
string "LLEXT heap memory region"
11+
depends on CODE_DATA_RELOCATION
12+
help
13+
Specify the memory region for LLEXT heap.
14+
15+
config MAIN_STACK_REGION
16+
string "Main stack memory region"
17+
depends on CODE_DATA_RELOCATION
18+
help
19+
Specify the memory region for main stack.

0 commit comments

Comments
 (0)