cmake: app mem partion flexibility
This commit allows a more dynamic approach for specifying that a zephyr library must be placed in a dedicated app memomory partition. This is still done by defining the partition in code using K_APPMEM_PARTITION_DEFINE, but now the zephyr library can be added to the generation of partition table using zephyr_library_app_memory instead of modifying the overall zephyr/CMakeLists.txt file. Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This commit is contained in:
parent
5871fc24fb
commit
1f9723af19
4 changed files with 31 additions and 2 deletions
|
@ -1055,11 +1055,13 @@ if(CONFIG_USERSPACE)
|
||||||
-d ${OBJ_FILE_DIR}
|
-d ${OBJ_FILE_DIR}
|
||||||
-o ${APP_SMEM_UNALIGNED_LD}
|
-o ${APP_SMEM_UNALIGNED_LD}
|
||||||
${NEWLIB_PART} ${MBEDTLS_PART}
|
${NEWLIB_PART} ${MBEDTLS_PART}
|
||||||
|
$<TARGET_PROPERTY:zephyr_property_target,COMPILE_OPTIONS>
|
||||||
$<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:--verbose>
|
$<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:--verbose>
|
||||||
DEPENDS
|
DEPENDS
|
||||||
kernel
|
kernel
|
||||||
${ZEPHYR_LIBS_PROPERTY}
|
${ZEPHYR_LIBS_PROPERTY}
|
||||||
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/
|
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/
|
||||||
|
COMMAND_EXPAND_LISTS
|
||||||
COMMENT "Generating app_smem_unaligned linker section"
|
COMMENT "Generating app_smem_unaligned linker section"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1104,12 +1106,14 @@ if(CONFIG_USERSPACE)
|
||||||
-e $<TARGET_FILE:app_smem_unaligned_prebuilt>
|
-e $<TARGET_FILE:app_smem_unaligned_prebuilt>
|
||||||
-o ${APP_SMEM_ALIGNED_LD}
|
-o ${APP_SMEM_ALIGNED_LD}
|
||||||
${NEWLIB_PART} ${MBEDTLS_PART}
|
${NEWLIB_PART} ${MBEDTLS_PART}
|
||||||
|
$<TARGET_PROPERTY:zephyr_property_target,COMPILE_OPTIONS>
|
||||||
$<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:--verbose>
|
$<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:--verbose>
|
||||||
DEPENDS
|
DEPENDS
|
||||||
kernel
|
kernel
|
||||||
${ZEPHYR_LIBS_PROPERTY}
|
${ZEPHYR_LIBS_PROPERTY}
|
||||||
app_smem_unaligned_prebuilt
|
app_smem_unaligned_prebuilt
|
||||||
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/
|
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/
|
||||||
|
COMMAND_EXPAND_LISTS
|
||||||
COMMENT "Generating app_smem_aligned linker section"
|
COMMENT "Generating app_smem_aligned linker section"
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -525,6 +525,13 @@ if(CONFIG_QEMU_TARGET)
|
||||||
endif()
|
endif()
|
||||||
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
|
# "app" is a CMake library containing all the application code and is
|
||||||
# modified by the entry point ${APPLICATION_SOURCE_DIR}/CMakeLists.txt
|
# modified by the entry point ${APPLICATION_SOURCE_DIR}/CMakeLists.txt
|
||||||
# that was specified when cmake was called.
|
# that was specified when cmake was called.
|
||||||
|
|
|
@ -484,6 +484,19 @@ function(zephyr_library_import library_name library_path)
|
||||||
zephyr_append_cmake_library(${library_name})
|
zephyr_append_cmake_library(${library_name})
|
||||||
endfunction()
|
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" $<TARGET_FILE_NAME:${ZEPHYR_CURRENT_LIBRARY}> "${partition}")
|
||||||
|
endfunction()
|
||||||
|
|
||||||
# 1.2.1 zephyr_interface_library_*
|
# 1.2.1 zephyr_interface_library_*
|
||||||
#
|
#
|
||||||
# A Zephyr interface library is a thin wrapper over a CMake INTERFACE
|
# A Zephyr interface library is a thin wrapper over a CMake INTERFACE
|
||||||
|
|
|
@ -284,8 +284,13 @@ top-level ``CMakeLists.txt`` adds the following:
|
||||||
|
|
||||||
gen_app_partitions.py ... --library libc.a z_libc_partition ..
|
gen_app_partitions.py ... --library libc.a z_libc_partition ..
|
||||||
|
|
||||||
There is no support for expressing this in the project-level configuration
|
For pre-compiled libraries there is no support for expressing this in the
|
||||||
or build files; the toplevel ``CMakeLists.txt`` must be edited.
|
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
|
Pre-defined Memory Partitions
|
||||||
-----------------------------
|
-----------------------------
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue