File syn_fwboot.c¶
FileList > src > syntropic > system > syn_fwboot.c
Go to the source code of this file
A/B firmware boot manager implementation.
#include "../port/syn_port_flash.h"#include "../util/syn_assert.h"#include "syn_fwboot.h"#include "syn_fwimage.h"#include <string.h>
Public Functions¶
| Type | Name |
|---|---|
| SYN_Status | syn_fwboot_confirm (SYN_FwBootManager * mgr) Confirm the currently active slot as good. |
| SYN_Status | syn_fwboot_init (SYN_FwBootManager * mgr, uint32_t slot_a, uint32_t slot_b) Initialize the boot manager. |
| SYN_Status | syn_fwboot_refresh (SYN_FwBootManager * mgr) Reload slot headers from flash. |
| uint8_t | syn_fwboot_select (SYN_FwBootManager * mgr, bool rollback) Select the best slot to boot. |
Public Static Functions¶
| Type | Name |
|---|---|
| SYN_Status | read_header (uint32_t addr, SYN_FwImageHeader * hdr) Read a firmware image header from flash. |
| SYN_Status | write_state (uint32_t addr, const SYN_FwImageHeader * hdr, uint8_t new_state) Write a new state to a firmware header (erase + rewrite). |
Public Functions Documentation¶
function syn_fwboot_confirm¶
Confirm the currently active slot as good.
Promotes state from TESTING to CONFIRMED. Call after the application has started successfully (after syn_boot_mark_healthy).
Parameters:
mgrBoot manager.
Returns:
SYN_OK if confirmed, SYN_ERROR if not in TESTING state.
function syn_fwboot_init¶
Initialize the boot manager.
Reads image headers from both slots.
Parameters:
mgrBoot manager instance.slot_aFlash base address of slot A.slot_bFlash base address of slot B.
Returns:
SYN_OK on success.
function syn_fwboot_refresh¶
Reload slot headers from flash.
Call after an OTA update to refresh the cached state.
Parameters:
mgrBoot manager.
Returns:
SYN_OK on success.
function syn_fwboot_select¶
Select the best slot to boot.
Priority: * TESTING slot (continue testing a new image) * NEW slot (first boot of a new image — marks as TESTING) * CONFIRMED slot with highest version * Any CONFIRMED slot
If a TESTING slot failed (called with rollback=true), it's marked INVALID and the other CONFIRMED slot is selected.
Parameters:
mgrBoot manager.rollbacktrue if the previous boot was unhealthy (trigger rollback).
Returns:
Slot index (SYN_FW_SLOT_A or SYN_FW_SLOT_B), or SYN_FW_SLOT_NONE.
Public Static Functions Documentation¶
function read_header¶
Read a firmware image header from flash.
Parameters:
addrFlash address.hdr[out] Header struct.
Returns:
SYN_OK on success.
function write_state¶
Write a new state to a firmware header (erase + rewrite).
Parameters:
addrFlash address of the header.hdrCurrent header.new_stateNew state value.
Returns:
SYN_OK on success.
The documentation for this class was generated from the following file src/syntropic/system/syn_fwboot.c