How to make update binary that does not write in some parts of the flash?
I have a project in which I have a specific flash section dedicated to device calibrations (.factory_variables). This allows me to to create a full_program.elf file and an update.elf file with different linkers.
- full_program.elf file: used in production
- update.elf: used in to update
Having to maintain two linkers is not efficient (compile time, binary management ,etc). I am trying to do a single compilation and then use arm-none-eabi-objcopy.exe to remove the calibration section. However when trying to update with the update.elf and stm32cubeprogrammer the following error appears:

The reason for this error is that stm32cubeprogrammer incorrectly detects the .elf headers with size = 0.
I am currently creating the update with the following command:
cp full_program.elf update.elf
arm-none-eabi-objcopy.exe --remove-section .factory_variables .\update.elfUsing readelf tool I can see that update.elf is correctly created. Section 3 is "emptied" and leaved with 0 space
ORIGINAL FILE:
readelf --segments .\2023-05-30-1.0.1-FULL.elf
Elf file type is EXEC (Executable file)
Entry point 0x8022d75
There are 10 program headers, starting at offset 52
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
LOAD 0x010000 0x08000000 0x08000000 0x001f8 0x001f8 R 0x10000
LOAD 0x018000 0x08008000 0x08008000 0x02d0d 0x02d0d RW 0x10000
LOAD 0x020000 0x08010000 0x08010000 0x02d0c 0x02d0c RW 0x10000
LOAD 0x032000 0x20072000 0x08018000 0x00060 0x00060 RW 0x10000
LOAD 0x040000 0x08020000 0x08020000 0x175420 0x175420 RWE 0x10000
LOAD 0x1c0000 0x20000000 0x08195420 0x004c8 0x2db48 RW 0x10000
LOAD 0x00db48 0x2002db48 0x081958e8 0x00000 0x00600 RW 0x10000
LOAD 0x1ce000 0x2007e000 0x081958e8 0x00390 0x00390 RW 0x10000
LOAD 0x1d4000 0x20074000 0x20074000 0x02d0c 0x02d0c RW 0x10000
LOAD 0x000000 0xc0000000 0xc0000000 0x00000 0x177000 RW 0x10000
Section to Segment mapping:
Segment Sections...
00 .isr_vector
01 .data_calibration
02 .data_calibration_copy
03 .factory_variables
04 .text .rodata FontFlashSection FontSearchFlashSection ExtFlashSection TextFlashSection .ARM .init_array .fini_array
05 .data .bss
06 ._user_heap_stack
07 .rte_variables
08 .config_ram
09 TouchGFX_FramebufferUPDATE.ELF
readelf --segments .\a.elf
Elf file type is EXEC (Executable file)
Entry point 0x8022d75
There are 10 program headers, starting at offset 52
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
LOAD 0x010000 0x08000000 0x08000000 0x001f8 0x001f8 R 0x10000
LOAD 0x018000 0x08008000 0x08008000 0x02d0d 0x02d0d RW 0x10000
LOAD 0x020000 0x08010000 0x08010000 0x02d0c 0x02d0c RW 0x10000
LOAD 0x000174 0x20072000 0x00000000 0x00000 0x00000 RW 0x10000
LOAD 0x030000 0x08020000 0x08020000 0x175420 0x175420 RWE 0x10000
LOAD 0x1b0000 0x20000000 0x08195420 0x2e4d8 0x2e4d8 RW 0x10000
LOAD 0x1edb48 0x2002db48 0x081958e8 0x2e010 0x2e010 RW 0x10000
LOAD 0x24e000 0x2007e000 0x081958e8 0x2e010 0x2e010 RW 0x10000
LOAD 0x284000 0x20074000 0x20074000 0x02d0c 0x02d0c RW 0x10000
LOAD 0x000000 0xc0000000 0xc0000000 0x00000 0x177000 RW 0x10000
Section to Segment mapping:
Segment Sections...
00 .isr_vector
01 .data_calibration
02 .data_calibration_copy
03
04 .text .rodata FontFlashSection FontSearchFlashSection ExtFlashSection TextFlashSection .ARM .preinit_array .init_array .fini_array
05 .data .bss ._user_heap_stack
06 ._user_heap_stack
07 .rte_variables
08 .config_ram
09 TouchGFX_FramebufferHow can I remove this 0 size segment or remove the .factory_variables from the ELF file to allow updating without overwritting the configuration?
