Skip to content

Commit c086b93

Browse files
hakonfamnashif
authored andcommitted
kconfig: cmake: Support for images without gaps.
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 <[email protected]>
1 parent 9347b0f commit c086b93

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

CMakeLists.txt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,22 +1242,27 @@ list_append_ifdef(CONFIG_CHECK_LINK_MAP
12421242
COMMAND ${PYTHON_EXECUTABLE} ${ZEPHYR_BASE}/scripts/check_link_map.py ${KERNEL_MAP_NAME}
12431243
)
12441244

1245+
if(NOT CONFIG_BUILD_NO_GAP_FILL)
1246+
# Use ';' as separator to get proper space in resulting command.
1247+
set(GAP_FILL "--gap-fill;0xff")
1248+
endif()
1249+
12451250
list_append_ifdef(
12461251
CONFIG_BUILD_OUTPUT_HEX
12471252
post_build_commands
1248-
COMMAND ${CMAKE_OBJCOPY} -S -Oihex --gap-fill 0xFF -R .comment -R COMMON -R .eh_frame ${KERNEL_ELF_NAME} ${KERNEL_HEX_NAME}
1253+
COMMAND ${CMAKE_OBJCOPY} -S -Oihex ${GAP_FILL} -R .comment -R COMMON -R .eh_frame ${KERNEL_ELF_NAME} ${KERNEL_HEX_NAME}
12491254
)
12501255

12511256
list_append_ifdef(
12521257
CONFIG_BUILD_OUTPUT_BIN
12531258
post_build_commands
1254-
COMMAND ${CMAKE_OBJCOPY} -S -Obinary --gap-fill 0xFF -R .comment -R COMMON -R .eh_frame ${KERNEL_ELF_NAME} ${KERNEL_BIN_NAME}
1259+
COMMAND ${CMAKE_OBJCOPY} -S -Obinary ${GAP_FILL} -R .comment -R COMMON -R .eh_frame ${KERNEL_ELF_NAME} ${KERNEL_BIN_NAME}
12551260
)
12561261

12571262
list_append_ifdef(
12581263
CONFIG_BUILD_OUTPUT_S19
12591264
post_build_commands
1260-
COMMAND ${CMAKE_OBJCOPY} --gap-fill 0xFF --srec-len 1 --output-target=srec ${KERNEL_ELF_NAME} ${KERNEL_S19_NAME}
1265+
COMMAND ${CMAKE_OBJCOPY} ${GAP_FILL} --srec-len 1 --output-target=srec ${KERNEL_ELF_NAME} ${KERNEL_S19_NAME}
12611266
)
12621267

12631268
list_append_ifdef(

Kconfig.zephyr

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,10 @@ config BUILD_OUTPUT_S19
289289
Build a binary in S19 format. This will build a zephyr.s19 file need
290290
by some platforms.
291291

292+
config BUILD_NO_GAP_FILL
293+
bool "Don't fill gaps in generated hex/bin/s19 files."
294+
depends on BUILD_OUTPUT_HEX || BUILD_OUTPUT_BIN || BUILD_OUTPUT_S19
295+
292296
config BUILD_OUTPUT_STRIPPED
293297
bool "Build a stripped binary"
294298
help

0 commit comments

Comments
 (0)