SBSFU 2.6.2 firmware swapping issue
Hi Guys,
Ported SBSFU 2.6.2 to STM32G0B1CEU6 (512K FLASH and 64K RAM) based on Nucleo-G071RB example.
Modified mapping_fwimg.ld as below:
/* Slots must be aligned on 2048 bytes (0x800) */
/* swap (4 kbytes) */
__ICFEDIT_SWAP_start__ = 0x08042000;
__ICFEDIT_SWAP_end__ = 0x08042FFF;
/* Active slot #1 (200 kbytes) */
__ICFEDIT_SLOT_Active_1_start__ = 0x08010000;
__ICFEDIT_SLOT_Active_1_end__ = 0x08041FFF;
__ICFEDIT_SLOT_Active_1_header__ = __ICFEDIT_SLOT_Active_1_start__;
/* Dwl slot #1 (200 kbytes) */
__ICFEDIT_SLOT_Dwl_1_start__ = 0x08043000;
__ICFEDIT_SLOT_Dwl_1_end__ = 0x08074FFF;
/* Slots not configured */
__ICFEDIT_SLOT_Active_2_header__ = 0x00000000;
__ICFEDIT_SLOT_Active_2_start__ = 0x00000000;
__ICFEDIT_SLOT_Active_2_end__ = 0x00000000;
__ICFEDIT_SLOT_Active_3_header__ = 0x00000000;
__ICFEDIT_SLOT_Active_3_start__ = 0x00000000;
__ICFEDIT_SLOT_Active_3_end__ = 0x00000000;
__ICFEDIT_SLOT_Dwl_2_start__ = 0x00000000;
__ICFEDIT_SLOT_Dwl_2_end__ = 0x00000000;
__ICFEDIT_SLOT_Dwl_3_start__ = 0x00000000;
__ICFEDIT_SLOT_Dwl_3_end__ = 0x00000000;
Following the step-by-step guide in UM2262.
All security features are turned off. Secure bootloader boots up fine, the first firmware uploads ok and ran. See log below:
= [SBOOT] RuntimeProtections: 0
= [SBOOT] System Security Check successfully passed. Starting...
======================================================================
= (C) COPYRIGHT 2017 STMicroelectronics =
= =
= Secure Boot and Secure Firmware Update =
======================================================================
= [SBOOT] SECURE ENGINE INITIALIZATION SUCCESSFUL
= [SBOOT] STATE: CHECK STATUS ON RESET
INFO: A Reboot has been triggered by a Hardware reset!
= [SBOOT] STATE: CHECK NEW FIRMWARE TO DOWNLOAD
= [SBOOT] STATE: CHECK USER FW STATUS
No valid FW found in the active slots nor new FW to be installed
Waiting for the local download to start...
= [SBOOT] STATE: DOWNLOAD NEW USER FIRMWARE
File> Transfer> YMODEM> Send ...
FwSize=-16843010 | PartialFwSize=-16843010 | PartialFwOffset=-16843010 | 23088 bytes received
= [SBOOT] STATE: REBOOT STATE MACHINE
========= End of Execution ==========
= [SBOOT] RuntimeProtections: 0
= [SBOOT] System Security Check successfully passed. Starting...
======================================================================
= (C) COPYRIGHT 2017 STMicroelectronics =
= =
= Secure Boot and Secure Firmware Update =
======================================================================
= [SBOOT] SECURE ENGINE INITIALIZATION SUCCESSFUL
= [SBOOT] STATE: CHECK STATUS ON RESET
INFO: A Reboot has been triggered by a Software reset!
= [SBOOT] STATE: CHECK NEW FIRMWARE TO DOWNLOAD
= [SBOOT] STATE: CHECK USER FW STATUS
New Fw to be installed from slot SLOT_DWL_1
= [SBOOT] STATE: INSTALL NEW USER FIRMWARE
= [SBOOT] RuntimeProtections: 0
21040 bytes of ciphertext decrypted.
Image preparation done.
Swapping the firmware images..................................................
Installation procedure completed.
FW installation succeeded.
========= End of Execution ==========
= [SBOOT] RuntimeProtections: 0
= [SBOOT] System Security Check successfully passed. Starting...
======================================================================
= (C) COPYRIGHT 2017 STMicroelectronics =
= =
= Secure Boot and Secure Firmware Update =
======================================================================
= [SBOOT] SECURE ENGINE INITIALIZATION SUCCESSFUL
= [SBOOT] STATE: CHECK STATUS ON RESET
INFO: A Reboot has been triggered by a Software reset!
= [SBOOT] STATE: CHECK NEW FIRMWARE TO DOWNLOAD
= [SBOOT] STATE: CHECK USER FW STATUS
A FW is detected in the slot SLOT_ACTIVE_1
= [SBOOT] STATE: VERIFY USER FW SIGNATURE
= [SBOOT] RuntimeProtections: 0
= [SBOOT] STATE: EXECUTE USER FIRMWARE
======================================================================
= (C) COPYRIGHT 2017 STMicroelectronics =
= =
= User App #A =
======================================================================
=================== Main Menu ============================
Download a new Fw Image ------------------------------- 1
Test Protections -------------------------------------- 2
Test SE User Code ------------------------------------- 3
Multiple download ------------------------------------- 4
Validate a FW Image------------------------------------ 5
Selection :
However, got an error when I try to upload a different version from the userApp:
================ New Fw Download =========================
-- Send Firmware
-- -- Erasing download area ...
-- -- File> Transfer> YMODEM> Send ..........................................C
-- -- Programming Completed Successfully!
-- -- Bytes: 23088
-- Image correctly downloaded - reboot
= [SBOOT] RuntimeProtections: 0
= [SBOOT] System Security Check successfully passed. Starting...
======================================================================
= (C) COPYRIGHT 2017 STMicroelectronics =
= =
= Secure Boot and Secure Firmware Update =
======================================================================
= [SBOOT] SECURE ENGINE INITIALIZATION SUCCESSFUL
= [SBOOT] STATE: CHECK STATUS ON RESET
INFO: A Reboot has been triggered by a Software reset!
= [SBOOT] STATE: CHECK NEW FIRMWARE TO DOWNLOAD
= [SBOOT] STATE: CHECK USER FW STATUS
New Fw to be installed from slot SLOT_DWL_1
= [SBOOT] STATE: INSTALL NEW USER FIRMWARE
= [SBOOT] RuntimeProtections: 0
21040 bytes of ciphertext decrypted.
Image preparation done.
Swapping the firmware images.............................................
Abnormal error 2 at line 958 in ../../../Projects/NUCLEO-G071RB/Applications/2_Images/2_Images_SBSFU/SBSFU/App/sfu_fwimg_swap.c - BLOCK
It failed in line:
/* don't copy header in active slot
this will be done at the end during validation step */
if ((index_active_slot == 0) && (chunk == 0))
{
write_len = write_len - SFU_IMG_IMAGE_OFFSET;
}
e_ret_status = SFU_LL_FLASH_Write(&flash_if_status, CHUNK_0_ADDR_MODIFIED(ActiveSlot, index_active_slot, chunk),
buffer, write_len);
STATUS_FWIMG(e_ret_status == SFU_ERROR, SFU_IMG_FLASH_WRITE_FAILED);
if (e_ret_status != SFU_SUCCESS)
{
return SFU_ERROR;
}
}
Any idea why this issue is happening? Thanks.
