NUCLEO-L476RG invalidated firmware update behavior
- May 31, 2021
- 2 replies
- 4087 views
Hi all,
We have been testing our 2 images configuration SBSFU firmware update with our NUCLEO-L476RG. We have encountered 2 scenario's during which the different steps taken by the bootloader was not entirely clear to us. We could use your help to clarify this.
So in both scenario's we started by normally flashing our firmware to the STM32. Nothing special.
Subsequently, in the first scenario, we do a hardware reset to do a YMODEM transfer to transfer new firmware to the STM. When this update is completed, we again do a hardware reset and transfer new firmware again over YMODEM, before the previous firmware was validated (this was intentional for testing this scenario). You can find the output log of this scenario in the attached file output-log-scenario-1.txt.
We have 2 questions about this scenario and its output:
- Are we correct to assume that the following happens?
- So in the first update, the new FW is downloaded in the DWL slot and successfully swapped with the ACTIVE slot. After the installation is complete, the FW in the ACTIVE slot is not validated yet.
- Then, the hardware reset triggers the second update. After that second YMODEM transfer, the STM resets, and the bootloader realizes that the ACTIVE slot was not validated yet, so a rollback should happen.
- It wants to rollback to the normally backed up FW in the DWL slot, but this slot now contains the just downloaded FW (and not any backed-up FW) and therefore it fails and says "backed up FW not identified", so the rollback fails.
- It resets, and after the reset it has a new downloaded FW in the DWL slot, so it just installs that one. Is this a correct interpretation?
- What does it mean that "backed-up FW is not identified"? Does it mean that it is not validated or has it another meaning?
In the second scenario, of which you can find the logs in output-log-scenario-2.txt, a similar process happens. The first FW update installs successfully, and starts running. However, the second FW update is executed before the first FW update was validated (again, this was intentional for this scenario) and fails during the YMODEM tranfer.
Here we have 3 questions:
- Is this the correct interpretation?
- In the first update, the new FW is downloaded in the DWL slot and successfully swapped with the ACTIVE slot.
- After the installation is complete, the FW in the ACTIVE slot is not validated yet. Then, the hardware reset triggers the second update.
- The second update then fails during the YMODEM transfer (the reason for the YMODEM failure is not important for our question) and the STM resets. After resetting, the STM realizes that its FW in ACTIVE1 is not validated yet and wants to rollback. For some reason, the backed-up FW is now identified correctly (why? shouldn't this be the same as in scenario 1, something as "backed-up FW" not identified"?) and the rollback procedure seems to complete without errors. However, the rollback did not happen yet.
- Then it resets, and it first erases ACTIVE1 (why?), and then it actually says it has no "No valid FW found in the active slots nor new FW to be installed" because the YMODEM transfer into the DWL slot failed (so we think that now nothing is in the DWL slot?). So it's only option is to wait for now FW.
- Why don't we get the "backed up FW not identified" message. This part of this scenario should be similar to scenario 1? Is it because the YMODEM transfer failed and maybe the DWL slot does not contain anyhing useful?
- Is it correct that when the YMODEM transfer fails, there is nothing in the DWL slot and therefore it says "No valid FW found in the active slots nor new FW to be installed"?
- Why is the FW in ACTIVE1 erased? We think it happens at the following lines in sfu_boot.c:
/* 3- No active firmware candidate for execution ==> Local download */
if (m_ActiveSlotToExecute == 0U)
{
/* Control if all active slot are empty */
for (i = 0U; i < SFU_NB_MAX_ACTIVE_IMAGE; i++)
{
if (SlotStartAdd[SLOT_ACTIVE_1 + i] != 0U) /* Slot configured ? */
{
if (SFU_IMG_VerifyEmptyActiveSlot(SLOT_ACTIVE_1 + i) != SFU_SUCCESS)
{
/*
* We should never reach this code.
* Could come from an attack ==> as an example we invalidate current firmware.
*/
TRACE("\r\n\t Slot SLOT_ACTIVE_%d not empty : erasing ...", SLOT_ACTIVE_1 + i);
(void)SFU_IMG_InvalidateCurrentFirmware(SLOT_ACTIVE_1 + i); /* If this fails we continue anyhow */
}
}
}It would be great if you could give us some insight in the process behind this. Of course, we also checked the code, but some of these details we could not figure out.
Thanks in advance!
ac_gd
