Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1086,11 +1086,13 @@ if(CONFIG_USERSPACE)
-d ${OBJ_FILE_DIR}
-o ${APP_SMEM_UNALIGNED_LD}
${NEWLIB_PART} ${MBEDTLS_PART}
$<TARGET_PROPERTY:${IMAGE}zephyr_property_target,COMPILE_OPTIONS>
$<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:--verbose>
DEPENDS
kernel
${ZEPHYR_LIBS_PROPERTY}
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/
COMMAND_EXPAND_LISTS
COMMENT "Generating app_smem_unaligned linker section"
)

Expand Down Expand Up @@ -1135,12 +1137,14 @@ if(CONFIG_USERSPACE)
-e $<TARGET_FILE:app_smem_unaligned_prebuilt>
-o ${APP_SMEM_ALIGNED_LD}
${NEWLIB_PART} ${MBEDTLS_PART}
$<TARGET_PROPERTY:${IMAGE}zephyr_property_target,COMPILE_OPTIONS>
$<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:--verbose>
DEPENDS
${KERNEL_LIBRARY}
${ZEPHYR_LIBS_PROPERTY}
app_smem_unaligned_prebuilt
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/
COMMAND_EXPAND_LISTS
COMMENT "Generating app_smem_aligned linker section"
)
endif()
Expand Down
7 changes: 7 additions & 0 deletions cmake/app/boilerplate.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,13 @@ if(CONFIG_QEMU_TARGET)
endif()
endif()

# General purpose Zephyr target.
# This target can be used for custom zephyr settings that needs to be used elsewhere in the build system
#
# Currently used properties:
# - COMPILES_OPTIONS: Used by application memory partition feature
add_custom_target(${IMAGE}zephyr_property_target)

# "app" is a CMake library containing all the application code and is
# modified by the entry point ${APPLICATION_SOURCE_DIR}/CMakeLists.txt
# that was specified when cmake was called.
Expand Down
13 changes: 13 additions & 0 deletions cmake/extensions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,19 @@ function(zephyr_library_import library_name library_path)
zephyr_append_cmake_library(${library_name})
endfunction()

# Place the current zephyr library in the application memory partition.
#
# The partition argument is the name of the partition where the library shall
# be placed.
#
# Note: Ensure the given partition has been define using
# K_APPMEM_PARTITION_DEFINE in source code.
function(zephyr_library_app_memory partition)
set_property(TARGET ${IMAGE}zephyr_property_target
APPEND PROPERTY COMPILE_OPTIONS
"-l" $<TARGET_FILE_NAME:${ZEPHYR_CURRENT_LIBRARY}> "${partition}")
endfunction()

# 1.2.1 zephyr_interface_library_*
#
# A Zephyr interface library is a thin wrapper over a CMake INTERFACE
Expand Down
9 changes: 7 additions & 2 deletions doc/reference/usermode/memory_domain.rst
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,13 @@ top-level ``CMakeLists.txt`` adds the following:

gen_app_partitions.py ... --library libc.a z_libc_partition ..

There is no support for expressing this in the project-level configuration
or build files; the toplevel ``CMakeLists.txt`` must be edited.
For pre-compiled libraries there is no support for expressing this in the
project-level configuration or build files; the toplevel ``CMakeLists.txt`` must
be edited.

For Zephyr libraries created using ``zephyr_library`` or ``zephyr_library_named``
the ``zephyr_library_app_memory`` function can be used to specify the memory
partition where all globals in the library should be placed.

Pre-defined Memory Partitions
-----------------------------
Expand Down