Skip to content

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.

SYN_Status syn_fwboot_confirm (
    SYN_FwBootManager * mgr
) 

Promotes state from TESTING to CONFIRMED. Call after the application has started successfully (after syn_boot_mark_healthy).

Parameters:

  • mgr Boot manager.

Returns:

SYN_OK if confirmed, SYN_ERROR if not in TESTING state.


function syn_fwboot_init

Initialize the boot manager.

SYN_Status syn_fwboot_init (
    SYN_FwBootManager * mgr,
    uint32_t slot_a,
    uint32_t slot_b
) 

Reads image headers from both slots.

Parameters:

  • mgr Boot manager instance.
  • slot_a Flash base address of slot A.
  • slot_b Flash base address of slot B.

Returns:

SYN_OK on success.


function syn_fwboot_refresh

Reload slot headers from flash.

SYN_Status syn_fwboot_refresh (
    SYN_FwBootManager * mgr
) 

Call after an OTA update to refresh the cached state.

Parameters:

  • mgr Boot manager.

Returns:

SYN_OK on success.


function syn_fwboot_select

Select the best slot to boot.

uint8_t syn_fwboot_select (
    SYN_FwBootManager * mgr,
    bool rollback
) 

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:

  • mgr Boot manager.
  • rollback true 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.

static SYN_Status read_header (
    uint32_t addr,
    SYN_FwImageHeader * hdr
) 

Parameters:

  • addr Flash address.
  • hdr [out] Header struct.

Returns:

SYN_OK on success.


function write_state

Write a new state to a firmware header (erase + rewrite).

static SYN_Status write_state (
    uint32_t addr,
    const SYN_FwImageHeader * hdr,
    uint8_t new_state
) 

Parameters:

  • addr Flash address of the header.
  • hdr Current header.
  • new_state New state value.

Returns:

SYN_OK on success.



The documentation for this class was generated from the following file src/syntropic/system/syn_fwboot.c