SBSFU , More than one Download SLOTS with stm32g474re example not working
I know this matter is dense and niche, so ill try to articulate my process in a digestible manner and add some memes.
I Recently downloaded sbsfu-v2-7-0 (legacy) package.
After some YMODEM bug fixes, i have a working example SBSFU for only one ACTIVE SLOT and single Download SLOT.
STM32CubeExpansion_SBSFU_V2.7.0\Projects\NUCLEO-G474RE\Applications\2_Images

The codebase readme says it supports more Download SLOTS, Great!, this way we could have two different UserApp downloaded, in order to activate more SLOTs : (app_sfu.h)
/* Multi-images configuration :
- Max : 3 Active images and 3 Download area
- Not necessary same configuration between SFU_NB_MAX_ACTIVE_IMAGE and SFU_NB_MAX_DWL_AREA
- Active slot identified with SFU magic (1,2,3) information from header
- Do not forget to add keys for each image in SE_Corebin/Binary folder
- Master slot : image started in priority if valid
- FW image valid all feature authorized from master slot
*/
#define SFU_NB_MAX_ACTIVE_IMAGE 1U /*!< 1 active image managed */
#define SFU_NB_MAX_DWL_AREA 1U /*!< 1 dwl area managed */
#define MASTER_SLOT SLOT_ACTIVE_1 /*!< SLOT_ACTIVE_1 identified as master slot */
- So i increase by one that define
#define SFU_NB_MAX_DWL_AREA 2U
- Duplicate both symetric and asymetric keys to support the second UserApp (i would preffer just the same set of keys for both) i just duplicated the files and change the names.
- The linker complains the new keys are not going to fit in the designated flash area so it needs to be bigger (mapping_sbsfu.ld)
/* SE key region protected by MPU isolation */
__ICFEDIT_SE_Key_region_ROM_start__ = __ICFEDIT_SE_CallGate_region_ROM_end__ + 1; /* PCROP protection : Alignment on 512 bytes */
__ICFEDIT_SE_Key_region_ROM_end__ = __ICFEDIT_SE_Key_region_ROM_start__ + 0xFF +0x100; /* PCROP protection : Minimum size is 1024 bytes , javi added extra space for KEY2*/
- The new Download Slot2 needs to be alocated in the (mapping_fwimg.ld)
/* Slots must be aligned on 4096 bytes (0x1000) */
/* Active slot #1 (144 kbytes) */
__ICFEDIT_SLOT_Active_1_start__ = 0x08010000;
__ICFEDIT_SLOT_Active_1_end__ = 0x08033FFF;
__ICFEDIT_SLOT_Active_1_header__ = __ICFEDIT_SLOT_Active_1_start__;
/* SWAP (8 kbytes) */
__ICFEDIT_SWAP_start__ = 0x08034000;
__ICFEDIT_SWAP_end__ = 0x08035FFF;
/* Dwl slot #1 (144 kbytes) */
__ICFEDIT_SLOT_Dwl_1_start__ = 0x08036000;
__ICFEDIT_SLOT_Dwl_1_end__ = 0x08059FFF;
/* Dwl slot #2 (144 kbytes) */
__ICFEDIT_SLOT_Dwl_2_start__ = 0x0805A000;
__ICFEDIT_SLOT_Dwl_2_end__ = 0x0807DFFF;
- After all this if i want to create an UserApp.sfb to be downloaded in the SLOT2 it needs to have a SFU2 header, i accomplished that by modifying the postbuild command argument indicating SFUx from "1" to "2"
arm-none-eabi-objcopy -O binary "${BuildArtifactFileBaseName}.elf" "../${BuildArtifactFileBaseName}.bin" && arm-none-eabi-size "${BuildArtifactFileName}" && "../../../2_Images_SECoreBin/STM32CubeIDE/postbuild.sh" "../" "${BuildArtifactFileBaseName}.elf" "../${BuildArtifactFileBaseName}.bin" "2" "1"
- Now SFU1 UserApp download and installation still work, but SFU2 YMODEM transfer stops right at the beginning returning a header authentication failure.

