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.
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 flush_page¶
Flush the page buffer to flash.
Parameters:
updFirmware update context.
Returns:
SYN_OK on success.
The documentation for this class was generated from the following file src/syntropic/system/syn_fwupdate.c