cmake: deprecate BUILD_NO_GAP_FILL and introduce type specific gap fill

Deprecate BUILD_NO_GAP_FILL as it gives a false impression that gap
filling can be disabled in binary files.
Binary files are always gap filled due to the fact they contain no
address information. Only option for binary files is to control the gap
fill pattern. When no gap fill is enabled in binary files, then a
default pattern is used by the tool, which usually is 0x00.

Generally the pattern 0x00 leads to unnecessary flash writes, as a
flash generally contains 0xFF after an erase.
Therefore provide a gap fill pattern Kconfig setting instead, with
default value of 0xFF.

For hex-files, intel hex and s19, then gap filling is generally not
needed but in order to still support cases where gap filling is required
then this commit introduces BUILD_OUTPUT_HEX_GAP_FILL and
BUILD_OUTPUT_S19_GAP_FILL. Both settings are disabled per default.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This commit is contained in:
Torsten Rasmussen 2024-11-28 09:07:00 +01:00 committed by Benjamin Cabé
commit 2e8868c16e
2 changed files with 32 additions and 8 deletions

View file

@ -1647,10 +1647,9 @@ list(APPEND
) )
list(APPEND post_build_byproducts ${KERNEL_MAP_NAME}) list(APPEND post_build_byproducts ${KERNEL_MAP_NAME})
if(NOT CONFIG_BUILD_NO_GAP_FILL)
# Use ';' as separator to get proper space in resulting command. # Use ';' as separator to get proper space in resulting command.
set(GAP_FILL "$<TARGET_PROPERTY:bintools,elfconvert_flag_gapfill>0xff") set(gap_fill_prop "$<TARGET_PROPERTY:bintools,elfconvert_flag_gapfill>")
endif() set(gap_fill "$<$<BOOL:${gap_fill_prop}>:${gap_fill_prop}${CONFIG_BUILD_GAP_FILL_PATTERN}>")
if(CONFIG_OUTPUT_PRINT_MEMORY_USAGE) if(CONFIG_OUTPUT_PRINT_MEMORY_USAGE)
target_link_libraries(${logical_target_for_zephyr_elf} $<TARGET_PROPERTY:linker,memusage>) target_link_libraries(${logical_target_for_zephyr_elf} $<TARGET_PROPERTY:linker,memusage>)
@ -1711,7 +1710,7 @@ if(CONFIG_BUILD_OUTPUT_HEX OR BOARD_FLASH_RUNNER STREQUAL openocd)
post_build_commands post_build_commands
COMMAND $<TARGET_PROPERTY:bintools,elfconvert_command> COMMAND $<TARGET_PROPERTY:bintools,elfconvert_command>
$<TARGET_PROPERTY:bintools,elfconvert_flag> $<TARGET_PROPERTY:bintools,elfconvert_flag>
${GAP_FILL} $<$<BOOL:${CONFIG_BUILD_OUTPUT_HEX_GAP_FILL}>:${gap_fill}>
$<TARGET_PROPERTY:bintools,elfconvert_flag_outtarget>ihex $<TARGET_PROPERTY:bintools,elfconvert_flag_outtarget>ihex
${remove_sections_argument_list} ${remove_sections_argument_list}
$<TARGET_PROPERTY:bintools,elfconvert_flag_infile>${KERNEL_ELF_NAME} $<TARGET_PROPERTY:bintools,elfconvert_flag_infile>${KERNEL_ELF_NAME}
@ -1733,7 +1732,7 @@ if(CONFIG_BUILD_OUTPUT_BIN)
post_build_commands post_build_commands
COMMAND $<TARGET_PROPERTY:bintools,elfconvert_command> COMMAND $<TARGET_PROPERTY:bintools,elfconvert_command>
$<TARGET_PROPERTY:bintools,elfconvert_flag> $<TARGET_PROPERTY:bintools,elfconvert_flag>
${GAP_FILL} ${gap_fill}
$<TARGET_PROPERTY:bintools,elfconvert_flag_outtarget>binary $<TARGET_PROPERTY:bintools,elfconvert_flag_outtarget>binary
${remove_sections_argument_list} ${remove_sections_argument_list}
$<TARGET_PROPERTY:bintools,elfconvert_flag_infile>${KERNEL_ELF_NAME} $<TARGET_PROPERTY:bintools,elfconvert_flag_infile>${KERNEL_ELF_NAME}
@ -1820,7 +1819,7 @@ if(CONFIG_BUILD_OUTPUT_S19)
post_build_commands post_build_commands
COMMAND $<TARGET_PROPERTY:bintools,elfconvert_command> COMMAND $<TARGET_PROPERTY:bintools,elfconvert_command>
$<TARGET_PROPERTY:bintools,elfconvert_flag> $<TARGET_PROPERTY:bintools,elfconvert_flag>
${GAP_FILL} $<$<BOOL:${CONFIG_BUILD_OUTPUT_S19_GAP_FILL}>:${gap_fill}>
$<TARGET_PROPERTY:bintools,elfconvert_flag_outtarget>srec $<TARGET_PROPERTY:bintools,elfconvert_flag_outtarget>srec
$<TARGET_PROPERTY:bintools,elfconvert_flag_srec_len>1 $<TARGET_PROPERTY:bintools,elfconvert_flag_srec_len>1
$<TARGET_PROPERTY:bintools,elfconvert_flag_infile>${KERNEL_ELF_NAME} $<TARGET_PROPERTY:bintools,elfconvert_flag_infile>${KERNEL_ELF_NAME}

View file

@ -709,8 +709,21 @@ config CLEANUP_INTERMEDIATE_FILES
from the build process. Note this breaks incremental builds, west spdx from the build process. Note this breaks incremental builds, west spdx
(Software Bill of Material generation), and maybe others. (Software Bill of Material generation), and maybe others.
config BUILD_GAP_FILL_PATTERN
hex "Gap fill pattern"
default 0xFF
help
Pattern used for gap filling of output files.
This value should be set to the value of a clean flash as this can
significantly reduce flash write times.
This setting only defines the gap fill pattern and doesn't enable gap
filling.
Note: binary files are always gap filled as they contain no address
information.
config BUILD_NO_GAP_FILL config BUILD_NO_GAP_FILL
bool "Don't fill gaps in generated hex/bin/s19 files." bool "Don't fill gaps in generated hex/s19 files [DEPRECATED]."
select DEPRECATED
config BUILD_OUTPUT_HEX config BUILD_OUTPUT_HEX
bool "Build a binary in HEX format" bool "Build a binary in HEX format"
@ -718,6 +731,12 @@ config BUILD_OUTPUT_HEX
Build an Intel HEX binary zephyr/zephyr.hex in the build directory. Build an Intel HEX binary zephyr/zephyr.hex in the build directory.
The name of this file can be customized with CONFIG_KERNEL_BIN_NAME. The name of this file can be customized with CONFIG_KERNEL_BIN_NAME.
config BUILD_OUTPUT_HEX_GAP_FILL
bool "Fill gaps in hex files"
depends on !BUILD_NO_GAP_FILL
help
Fill gaps in hex based files.
config BUILD_OUTPUT_BIN config BUILD_OUTPUT_BIN
bool "Build a binary in BIN format" bool "Build a binary in BIN format"
default y default y
@ -752,6 +771,12 @@ config BUILD_OUTPUT_S19
Build an S19 binary zephyr/zephyr.s19 in the build directory. Build an S19 binary zephyr/zephyr.s19 in the build directory.
The name of this file can be customized with CONFIG_KERNEL_BIN_NAME. The name of this file can be customized with CONFIG_KERNEL_BIN_NAME.
config BUILD_OUTPUT_S19_GAP_FILL
bool "Fill gaps in s19 files"
depends on !BUILD_NO_GAP_FILL
help
Fill gaps in s19 based files.
config BUILD_OUTPUT_UF2 config BUILD_OUTPUT_UF2
bool "Build a binary in UF2 format" bool "Build a binary in UF2 format"
depends on BUILD_OUTPUT_BIN depends on BUILD_OUTPUT_BIN