File syn_fwboot.h¶
FileList > src > syntropic > system > syn_fwboot.h
Go to the source code of this file
A/B firmware boot manager — slot selection, rollback, confirm. More...
#include "../common/syn_defs.h"#include "syn_fwimage.h"#include <stdbool.h>#include <stdint.h>
Classes¶
| Type | Name |
|---|---|
| struct | SYN_FwBootManager A/B firmware boot manager — slot selection and rollback state. |
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 |
|---|---|
| uint8_t | syn_fwboot_active_slot (const SYN_FwBootManager * mgr) Get the currently active slot. |
| uint32_t | syn_fwboot_slot_addr (const SYN_FwBootManager * mgr, uint8_t slot) Get the flash base address of a slot. |
| const SYN_FwImageHeader * | syn_fwboot_slot_header (const SYN_FwBootManager * mgr, uint8_t slot) Get the cached header for a slot. |
Macros¶
| Type | Name |
|---|---|
| define | SYN_FW_SLOT_A 0 |
| define | SYN_FW_SLOT_B 1 |
| define | SYN_FW_SLOT_NONE 0xFF |
Detailed Description¶
Works with syn_fwimage headers to manage dual firmware slots. Integrates with syn_boot for crash-loop detection.
** **
- Bootloader reads both slot headers
- syn_fwboot_select() picks the best slot to boot
- If selected slot is NEW → mark as TESTING before jumping
- Application calls syn_fwboot_confirm() after healthy startup
- If boot fails → next boot sees TESTING + unhealthy → rollback
** **
SYN_FwBootManager mgr;
syn_fwboot_init(&mgr, SLOT_A_ADDR, SLOT_B_ADDR);
// In bootloader: pick which slot to run
uint8_t slot = syn_fwboot_select(&mgr);
uint32_t entry = syn_fwboot_slot_addr(&mgr, slot)
+ sizeof(SYN_FwImageHeader);
// Jump to entry...
// In application: after successful startup
syn_fwboot_confirm(&mgr);
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 syn_fwboot_active_slot¶
Get the currently active slot.
Parameters:
mgrBoot manager.
Returns:
Active slot index.
function syn_fwboot_slot_addr¶
Get the flash base address of a slot.
Parameters:
mgrBoot manager.slotSlot index (SYN_FW_SLOT_A or SYN_FW_SLOT_B).
Returns:
Flash base address, or 0 if invalid slot.
function syn_fwboot_slot_header¶
Get the cached header for a slot.
static inline const SYN_FwImageHeader * syn_fwboot_slot_header (
const SYN_FwBootManager * mgr,
uint8_t slot
)
Parameters:
mgrBoot manager.slotSlot index.
Returns:
Pointer to cached header, or NULL if invalid slot.
Macro Definition Documentation¶
define SYN_FW_SLOT_A¶
Firmware slot A index.
define SYN_FW_SLOT_B¶
Firmware slot B index.
define SYN_FW_SLOT_NONE¶
No valid slot.
The documentation for this class was generated from the following file src/syntropic/system/syn_fwboot.h