Skip to content

File syn_fwupdate.c

FileList > src > syntropic > system > syn_fwupdate.c

Go to the source code of this file

Streaming firmware updater implementation.

  • #include "../port/syn_port_flash.h"
  • #include "../util/syn_assert.h"
  • #include "../util/syn_crc.h"
  • #include "syn_fwimage.h"
  • #include "syn_fwupdate.h"
  • #include <string.h>

Public Functions

Type Name
void syn_fwupdate_abort (SYN_FwUpdate * upd)
Abort the update.
SYN_Status syn_fwupdate_begin (SYN_FwUpdate * upd, uint32_t slot_addr, uint32_t max_size, uint8_t * page_buf, uint16_t page_buf_size)
Begin a firmware update.
SYN_Status syn_fwupdate_finish (SYN_FwUpdate * upd, uint32_t expected_crc, uint32_t version_code)
Finalize the update.
SYN_Status syn_fwupdate_write (SYN_FwUpdate * upd, const uint8_t * data, size_t len)
Write a chunk of firmware data.

Public Static Functions

Type Name
SYN_Status flush_page (SYN_FwUpdate * upd)
Flush the page buffer to flash.

Public Functions Documentation

function syn_fwupdate_abort

Abort the update.

void syn_fwupdate_abort (
    SYN_FwUpdate * upd
) 

Marks the slot as INVALID and cleans up.

Parameters:

  • upd Updater instance.

function syn_fwupdate_begin

Begin a firmware update.

SYN_Status syn_fwupdate_begin (
    SYN_FwUpdate * upd,
    uint32_t slot_addr,
    uint32_t max_size,
    uint8_t * page_buf,
    uint16_t page_buf_size
) 

Erases the first sector of the target slot and prepares for writing. The image header is written at slot_addr; image data starts at slot_addr + sizeof(SYN_FwImageHeader).

Parameters:

  • upd Updater instance.
  • slot_addr Flash base address of the target slot.
  • max_size Maximum image size in bytes (excl. header).
  • page_buf Caller-provided page buffer.
  • page_buf_size Buffer size (should match flash write granularity).

Returns:

SYN_OK on success, SYN_ERROR on flash erase failure.


function syn_fwupdate_finish

Finalize the update.

SYN_Status syn_fwupdate_finish (
    SYN_FwUpdate * upd,
    uint32_t expected_crc,
    uint32_t version_code
) 

Flushes any remaining buffered data, verifies the CRC-32 matches the expected value, and writes the image header with state = NEW.

Parameters:

  • upd Updater instance.
  • expected_crc Expected CRC-32 of the full image.
  • version_code Version code for the new image.

Returns:

SYN_OK if verification passes and header written, SYN_ERROR on mismatch or flash failure.


function syn_fwupdate_write

Write a chunk of firmware data.

SYN_Status syn_fwupdate_write (
    SYN_FwUpdate * upd,
    const uint8_t * data,
    size_t len
) 

Data is buffered until a full page is ready, then flushed to flash. Automatically erases sectors as needed.

Parameters:

  • upd Updater instance.
  • data Firmware data chunk.
  • len Chunk length.

Returns:

SYN_OK on success, SYN_ERROR on flash write failure or overflow.


Public Static Functions Documentation

function flush_page

Flush the page buffer to flash.

static SYN_Status flush_page (
    SYN_FwUpdate * upd
) 

Parameters:

  • upd Firmware update context.

Returns:

SYN_OK on success.



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