Skip to content

Commit ad855fa

Browse files
tejlmandjukkar
authored andcommitted
[nrf fromtree] 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 <[email protected]> (cherry picked from commit 2e8868c) (cherry picked from commit d62198c)
1 parent 0108dd5 commit ad855fa

File tree

2 files changed

+32
-8
lines changed

2 files changed

+32
-8
lines changed

CMakeLists.txt

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1617,10 +1617,9 @@ list(APPEND
16171617
)
16181618
list(APPEND post_build_byproducts ${KERNEL_MAP_NAME})
16191619

1620-
if(NOT CONFIG_BUILD_NO_GAP_FILL)
1621-
# Use ';' as separator to get proper space in resulting command.
1622-
set(GAP_FILL "$<TARGET_PROPERTY:bintools,elfconvert_flag_gapfill>0xff")
1623-
endif()
1620+
# Use ';' as separator to get proper space in resulting command.
1621+
set(gap_fill_prop "$<TARGET_PROPERTY:bintools,elfconvert_flag_gapfill>")
1622+
set(gap_fill "$<$<BOOL:${gap_fill_prop}>:${gap_fill_prop}${CONFIG_BUILD_GAP_FILL_PATTERN}>")
16241623

16251624
if(CONFIG_OUTPUT_PRINT_MEMORY_USAGE)
16261625
target_link_libraries(${logical_target_for_zephyr_elf} $<TARGET_PROPERTY:linker,memusage>)
@@ -1681,7 +1680,7 @@ if(CONFIG_BUILD_OUTPUT_HEX OR BOARD_FLASH_RUNNER STREQUAL openocd)
16811680
post_build_commands
16821681
COMMAND $<TARGET_PROPERTY:bintools,elfconvert_command>
16831682
$<TARGET_PROPERTY:bintools,elfconvert_flag>
1684-
${GAP_FILL}
1683+
$<$<BOOL:${CONFIG_BUILD_OUTPUT_HEX_GAP_FILL}>:${gap_fill}>
16851684
$<TARGET_PROPERTY:bintools,elfconvert_flag_outtarget>ihex
16861685
${remove_sections_argument_list}
16871686
$<TARGET_PROPERTY:bintools,elfconvert_flag_infile>${KERNEL_ELF_NAME}
@@ -1703,7 +1702,7 @@ if(CONFIG_BUILD_OUTPUT_BIN)
17031702
post_build_commands
17041703
COMMAND $<TARGET_PROPERTY:bintools,elfconvert_command>
17051704
$<TARGET_PROPERTY:bintools,elfconvert_flag>
1706-
${GAP_FILL}
1705+
${gap_fill}
17071706
$<TARGET_PROPERTY:bintools,elfconvert_flag_outtarget>binary
17081707
${remove_sections_argument_list}
17091708
$<TARGET_PROPERTY:bintools,elfconvert_flag_infile>${KERNEL_ELF_NAME}
@@ -1790,7 +1789,7 @@ if(CONFIG_BUILD_OUTPUT_S19)
17901789
post_build_commands
17911790
COMMAND $<TARGET_PROPERTY:bintools,elfconvert_command>
17921791
$<TARGET_PROPERTY:bintools,elfconvert_flag>
1793-
${GAP_FILL}
1792+
$<$<BOOL:${CONFIG_BUILD_OUTPUT_S19_GAP_FILL}>:${gap_fill}>
17941793
$<TARGET_PROPERTY:bintools,elfconvert_flag_outtarget>srec
17951794
$<TARGET_PROPERTY:bintools,elfconvert_flag_srec_len>1
17961795
$<TARGET_PROPERTY:bintools,elfconvert_flag_infile>${KERNEL_ELF_NAME}

Kconfig.zephyr

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,15 +706,34 @@ config CLEANUP_INTERMEDIATE_FILES
706706
from the build process. Note this breaks incremental builds, west spdx
707707
(Software Bill of Material generation), and maybe others.
708708

709+
config BUILD_GAP_FILL_PATTERN
710+
hex "Gap fill pattern"
711+
default 0xFF
712+
help
713+
Pattern used for gap filling of output files.
714+
This value should be set to the value of a clean flash as this can
715+
significantly reduce flash write times.
716+
This setting only defines the gap fill pattern and doesn't enable gap
717+
filling.
718+
Note: binary files are always gap filled as they contain no address
719+
information.
720+
709721
config BUILD_NO_GAP_FILL
710-
bool "Don't fill gaps in generated hex/bin/s19 files."
722+
bool "Don't fill gaps in generated hex/s19 files [DEPRECATED]."
723+
select DEPRECATED
711724

712725
config BUILD_OUTPUT_HEX
713726
bool "Build a binary in HEX format"
714727
help
715728
Build an Intel HEX binary zephyr/zephyr.hex in the build directory.
716729
The name of this file can be customized with CONFIG_KERNEL_BIN_NAME.
717730

731+
config BUILD_OUTPUT_HEX_GAP_FILL
732+
bool "Fill gaps in hex files"
733+
depends on !BUILD_NO_GAP_FILL
734+
help
735+
Fill gaps in hex based files.
736+
718737
config BUILD_OUTPUT_BIN
719738
bool "Build a binary in BIN format"
720739
default y
@@ -749,6 +768,12 @@ config BUILD_OUTPUT_S19
749768
Build an S19 binary zephyr/zephyr.s19 in the build directory.
750769
The name of this file can be customized with CONFIG_KERNEL_BIN_NAME.
751770

771+
config BUILD_OUTPUT_S19_GAP_FILL
772+
bool "Fill gaps in s19 files"
773+
depends on !BUILD_NO_GAP_FILL
774+
help
775+
Fill gaps in s19 based files.
776+
752777
config BUILD_OUTPUT_UF2
753778
bool "Build a binary in UF2 format"
754779
depends on BUILD_OUTPUT_BIN

0 commit comments

Comments
 (0)