Skip to content

File syn_fwimage.h

FileList > src > syntropic > system > syn_fwimage.h

Go to the source code of this file

Firmware image header — standardized format for OTA slots. More...

  • #include "../common/syn_defs.h"
  • #include "../util/syn_crc.h"
  • #include <stdbool.h>
  • #include <stdint.h>

Classes

Type Name
struct SYN_FwImageHeader
Firmware image header — stored at the start of each flash slot.

Public Types

Type Name
enum SYN_FwState
Firmware image lifecycle state.

Public Static Functions

Type Name
bool syn_fwimage_header_valid (const SYN_FwImageHeader * hdr)
Validate a firmware image header.
bool syn_fwimage_is_bootable (const SYN_FwImageHeader * hdr)
Check if a slot contains a bootable image.
void syn_fwimage_seal_header (SYN_FwImageHeader * hdr)
Compute the header CRC and write it into the header.

Macros

Type Name
define SYN_FW_MAGIC 0x53594E46u /\* "SYNF" in little-endian \*/
Magic number identifying a SyntropicOS firmware image header ("SYNF").

Detailed Description

Each firmware slot (A or B) has this header at a known flash offset. The bootloader and OTA updater use it to decide which image to boot, whether an update succeeded, and when to rollback.

Layout in flash:

[SYN_FwImageHeader (24 bytes)] [firmware binary (image_size bytes)]

** **

  • OTA begins: header.state = WRITING
  • OTA complete: header.state = NEW (CRC verified)
  • First boot: bootloader sets state = TESTING
  • App healthy: app calls confirm → state = CONFIRMED
  • App crashes: bootloader sees TESTING + unhealthy → state = INVALID, rollback

Public Types Documentation

enum SYN_FwState

Firmware image lifecycle state.

enum SYN_FwState {
    SYN_FW_STATE_EMPTY = 0xFF,
    SYN_FW_STATE_WRITING = 0x01,
    SYN_FW_STATE_NEW = 0x02,
    SYN_FW_STATE_TESTING = 0x03,
    SYN_FW_STATE_CONFIRMED = 0x04,
    SYN_FW_STATE_INVALID = 0x00
};


Public Static Functions Documentation

function syn_fwimage_header_valid

Validate a firmware image header.

static inline bool syn_fwimage_header_valid (
    const SYN_FwImageHeader * hdr
) 

Checks magic number and header CRC. Does NOT verify the image data CRC (use syn_fwimage_verify_data for that).

Parameters:

  • hdr Header to validate.

Returns:

true if header is valid.


function syn_fwimage_is_bootable

Check if a slot contains a bootable image.

static inline bool syn_fwimage_is_bootable (
    const SYN_FwImageHeader * hdr
) 

An image is bootable if the header is valid and state is NEW, TESTING, or CONFIRMED.

Parameters:

  • hdr Header to check.

Returns:

true if bootable.


function syn_fwimage_seal_header

Compute the header CRC and write it into the header.

static inline void syn_fwimage_seal_header (
    SYN_FwImageHeader * hdr
) 

Call after setting all other fields.

Parameters:

  • hdr Header to seal.

Macro Definition Documentation

define SYN_FW_MAGIC

Magic number identifying a SyntropicOS firmware image header ("SYNF").

#define SYN_FW_MAGIC `0x53594E46u /* "SYNF" in little-endian */`



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