diff --git a/CMakeLists.txt b/CMakeLists.txt index 4b75d3ac372..787ecbe598f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1055,11 +1055,13 @@ if(CONFIG_USERSPACE) -d ${OBJ_FILE_DIR} -o ${APP_SMEM_UNALIGNED_LD} ${NEWLIB_PART} ${MBEDTLS_PART} + $ $<$:--verbose> DEPENDS kernel ${ZEPHYR_LIBS_PROPERTY} WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/ + COMMAND_EXPAND_LISTS COMMENT "Generating app_smem_unaligned linker section" ) @@ -1104,12 +1106,14 @@ if(CONFIG_USERSPACE) -e $ -o ${APP_SMEM_ALIGNED_LD} ${NEWLIB_PART} ${MBEDTLS_PART} + $ $<$:--verbose> DEPENDS kernel ${ZEPHYR_LIBS_PROPERTY} app_smem_unaligned_prebuilt WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/ + COMMAND_EXPAND_LISTS COMMENT "Generating app_smem_aligned linker section" ) endif() diff --git a/cmake/app/boilerplate.cmake b/cmake/app/boilerplate.cmake index 604fba339f5..fe7d4d95c4a 100644 --- a/cmake/app/boilerplate.cmake +++ b/cmake/app/boilerplate.cmake @@ -525,6 +525,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(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. diff --git a/cmake/extensions.cmake b/cmake/extensions.cmake index 5ca8ad91f9b..f96408f6242 100644 --- a/cmake/extensions.cmake +++ b/cmake/extensions.cmake @@ -484,6 +484,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 zephyr_property_target + APPEND PROPERTY COMPILE_OPTIONS + "-l" $ "${partition}") +endfunction() + # 1.2.1 zephyr_interface_library_* # # A Zephyr interface library is a thin wrapper over a CMake INTERFACE diff --git a/doc/reference/usermode/memory_domain.rst b/doc/reference/usermode/memory_domain.rst index cdcf537a036..65162953021 100644 --- a/doc/reference/usermode/memory_domain.rst +++ b/doc/reference/usermode/memory_domain.rst @@ -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 -----------------------------