From c086b935aa3a79029d962cd34c40a58cbbd68eb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20=C3=98ye=20Amundsen?= Date: Mon, 26 Nov 2018 09:47:16 +0000 Subject: [PATCH] kconfig: cmake: Support for images without gaps. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Defines a Kconfig variable which allows the user to specify that any generated hex/bin/s19 file should not have filled gaps. This is done to support building in a multi image context, where several image files will be merged together. Signed-off-by: Håkon Øye Amundsen --- CMakeLists.txt | 11 ++++++++--- Kconfig.zephyr | 4 ++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b4fc6b22816..bbb1e92c45a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1242,22 +1242,27 @@ list_append_ifdef(CONFIG_CHECK_LINK_MAP COMMAND ${PYTHON_EXECUTABLE} ${ZEPHYR_BASE}/scripts/check_link_map.py ${KERNEL_MAP_NAME} ) +if(NOT CONFIG_BUILD_NO_GAP_FILL) + # Use ';' as separator to get proper space in resulting command. + set(GAP_FILL "--gap-fill;0xff") +endif() + list_append_ifdef( CONFIG_BUILD_OUTPUT_HEX post_build_commands - COMMAND ${CMAKE_OBJCOPY} -S -Oihex --gap-fill 0xFF -R .comment -R COMMON -R .eh_frame ${KERNEL_ELF_NAME} ${KERNEL_HEX_NAME} + COMMAND ${CMAKE_OBJCOPY} -S -Oihex ${GAP_FILL} -R .comment -R COMMON -R .eh_frame ${KERNEL_ELF_NAME} ${KERNEL_HEX_NAME} ) list_append_ifdef( CONFIG_BUILD_OUTPUT_BIN post_build_commands - COMMAND ${CMAKE_OBJCOPY} -S -Obinary --gap-fill 0xFF -R .comment -R COMMON -R .eh_frame ${KERNEL_ELF_NAME} ${KERNEL_BIN_NAME} + COMMAND ${CMAKE_OBJCOPY} -S -Obinary ${GAP_FILL} -R .comment -R COMMON -R .eh_frame ${KERNEL_ELF_NAME} ${KERNEL_BIN_NAME} ) list_append_ifdef( CONFIG_BUILD_OUTPUT_S19 post_build_commands - COMMAND ${CMAKE_OBJCOPY} --gap-fill 0xFF --srec-len 1 --output-target=srec ${KERNEL_ELF_NAME} ${KERNEL_S19_NAME} + COMMAND ${CMAKE_OBJCOPY} ${GAP_FILL} --srec-len 1 --output-target=srec ${KERNEL_ELF_NAME} ${KERNEL_S19_NAME} ) list_append_ifdef( diff --git a/Kconfig.zephyr b/Kconfig.zephyr index e142f6b2848..476cf87c132 100644 --- a/Kconfig.zephyr +++ b/Kconfig.zephyr @@ -289,6 +289,10 @@ config BUILD_OUTPUT_S19 Build a binary in S19 format. This will build a zephyr.s19 file need by some platforms. +config BUILD_NO_GAP_FILL + bool "Don't fill gaps in generated hex/bin/s19 files." + depends on BUILD_OUTPUT_HEX || BUILD_OUTPUT_BIN || BUILD_OUTPUT_S19 + config BUILD_OUTPUT_STRIPPED bool "Build a stripped binary" help