File syn_fwupdate.h¶
FileList > src > syntropic > system > syn_fwupdate.h
Go to the source code of this file
Streaming firmware updater — transport-agnostic, zero-alloc. More...
#include "../common/syn_defs.h"#include "syn_fwimage.h"#include <stdbool.h>#include <stddef.h>#include <stdint.h>
Classes¶
| Type | Name |
|---|---|
| struct | SYN_FwUpdate Firmware update context - manages streaming writes to flash. |
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 |
|---|---|
| bool | syn_fwupdate_active (const SYN_FwUpdate * upd) Check if an update is in progress. |
| uint32_t | syn_fwupdate_progress (const SYN_FwUpdate * upd) Get bytes written so far. |
Detailed Description¶
Receives firmware data in arbitrary-sized chunks, writes to flash, and computes a running CRC-32. On completion, verifies the CRC and writes the image header. On abort, marks the slot as invalid.
The caller provides a page-aligned write buffer (typically 256 bytes, matching flash write granularity). Data is buffered until a full page is ready, then flushed to flash.
** **
static uint8_t page_buf[256];
SYN_FwUpdate upd;
syn_fwupdate_begin(&upd, SLOT_B_ADDR, SLOT_B_SIZE,
page_buf, sizeof(page_buf));
// Feed chunks from HTTP, UART, BLE, etc.
while (have_data) {
syn_fwupdate_write(&upd, chunk, chunk_len);
}
syn_fwupdate_finish(&upd, expected_crc, new_version);
Public Functions Documentation¶
function syn_fwupdate_abort¶
Abort the update.
Marks the slot as INVALID and cleans up.
Parameters:
updUpdater 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:
updUpdater instance.slot_addrFlash base address of the target slot.max_sizeMaximum image size in bytes (excl. header).page_bufCaller-provided page buffer.page_buf_sizeBuffer size (should match flash write granularity).
Returns:
SYN_OK on success, SYN_ERROR on flash erase failure.
function syn_fwupdate_finish¶
Finalize the update.
Flushes any remaining buffered data, verifies the CRC-32 matches the expected value, and writes the image header with state = NEW.
Parameters:
updUpdater instance.expected_crcExpected CRC-32 of the full image.version_codeVersion 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.
Data is buffered until a full page is ready, then flushed to flash. Automatically erases sectors as needed.
Parameters:
updUpdater instance.dataFirmware data chunk.lenChunk length.
Returns:
SYN_OK on success, SYN_ERROR on flash write failure or overflow.
Public Static Functions Documentation¶
function syn_fwupdate_active¶
Check if an update is in progress.
Parameters:
updUpdater instance.
Returns:
true if active.
function syn_fwupdate_progress¶
Get bytes written so far.
Parameters:
updUpdater instance.
Returns:
Bytes written.
The documentation for this class was generated from the following file src/syntropic/system/syn_fwupdate.h