Skip to content

Commit 2e8868c

Browse files
tejlmandkartben
authored andcommitted
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]>
1 parent d9f45a9 commit 2e8868c

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
@@ -1647,10 +1647,9 @@ list(APPEND
16471647
)
16481648
list(APPEND post_build_byproducts ${KERNEL_MAP_NAME})
16491649

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

16551654
if(CONFIG_OUTPUT_PRINT_MEMORY_USAGE)
16561655
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)
17111710
post_build_commands
17121711
COMMAND $<TARGET_PROPERTY:bintools,elfconvert_command>
17131712
$<TARGET_PROPERTY:bintools,elfconvert_flag>
1714-
${GAP_FILL}
1713+
$<$<BOOL:${CONFIG_BUILD_OUTPUT_HEX_GAP_FILL}>:${gap_fill}>
17151714
$<TARGET_PROPERTY:bintools,elfconvert_flag_outtarget>ihex
17161715
${remove_sections_argument_list}
17171716
$<TARGET_PROPERTY:bintools,elfconvert_flag_infile>${KERNEL_ELF_NAME}
@@ -1733,7 +1732,7 @@ if(CONFIG_BUILD_OUTPUT_BIN)
17331732
post_build_commands
17341733
COMMAND $<TARGET_PROPERTY:bintools,elfconvert_command>
17351734
$<TARGET_PROPERTY:bintools,elfconvert_flag>
1736-
${GAP_FILL}
1735+
${gap_fill}
17371736
$<TARGET_PROPERTY:bintools,elfconvert_flag_outtarget>binary
17381737
${remove_sections_argument_list}
17391738
$<TARGET_PROPERTY:bintools,elfconvert_flag_infile>${KERNEL_ELF_NAME}
@@ -1820,7 +1819,7 @@ if(CONFIG_BUILD_OUTPUT_S19)
18201819
post_build_commands
18211820
COMMAND $<TARGET_PROPERTY:bintools,elfconvert_command>
18221821
$<TARGET_PROPERTY:bintools,elfconvert_flag>
1823-
${GAP_FILL}
1822+
$<$<BOOL:${CONFIG_BUILD_OUTPUT_S19_GAP_FILL}>:${gap_fill}>
18241823
$<TARGET_PROPERTY:bintools,elfconvert_flag_outtarget>srec
18251824
$<TARGET_PROPERTY:bintools,elfconvert_flag_srec_len>1
18261825
$<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
@@ -709,15 +709,34 @@ config CLEANUP_INTERMEDIATE_FILES
709709
from the build process. Note this breaks incremental builds, west spdx
710710
(Software Bill of Material generation), and maybe others.
711711

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

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

734+
config BUILD_OUTPUT_HEX_GAP_FILL
735+
bool "Fill gaps in hex files"
736+
depends on !BUILD_NO_GAP_FILL
737+
help
738+
Fill gaps in hex based files.
739+
721740
config BUILD_OUTPUT_BIN
722741
bool "Build a binary in BIN format"
723742
default y
@@ -752,6 +771,12 @@ config BUILD_OUTPUT_S19
752771
Build an S19 binary zephyr/zephyr.s19 in the build directory.
753772
The name of this file can be customized with CONFIG_KERNEL_BIN_NAME.
754773

774+
config BUILD_OUTPUT_S19_GAP_FILL
775+
bool "Fill gaps in s19 files"
776+
depends on !BUILD_NO_GAP_FILL
777+
help
778+
Fill gaps in s19 based files.
779+
755780
config BUILD_OUTPUT_UF2
756781
bool "Build a binary in UF2 format"
757782
depends on BUILD_OUTPUT_BIN

0 commit comments

Comments
 (0)