48static const char*
const s_tag =
"ra8_ota";
125 for (uint32_t guard = 0U; guard < cap + 1U; ++guard) {
289 uint32_t content_len = 0U;
396 const uint32_t remaining = total - *in_out_done;
411 addr_base + *in_out_done,
485 uint32_t chunks = 0U;
490 if (chunks >= max_chunks) {
558 uint32_t content_len = 0U;
788#if defined(__GNUC__) || defined(__clang__)
static const char * s_tag
Logging / check tag.
Annotation-attribute framework macros for ra8-firmware.
#define RA8_PRIV
Module-private helper: shared across TUs but only inside one library.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Validation and Error-Checking Macros for ra8-firmware.
#define RA8_CHECK_NULL_PTR(ptr, tag, message)
Reject nullptr pointer, returning k_ra8_err_null_ptr.
Error Code Definitions for ra8-firmware.
@ k_ra8_err_invalid_state
Module in wrong state for requested operation.
@ k_ra8_err_not_initialized
Module not initialized – _init() not yet called successfully.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
@ k_ra8_err_hw_error
Generic hardware fault detected (error flag set, fault interrupt).
@ k_ra8_err_invalid_size
Invalid size parameter (too large, too small, or misaligned).
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
void * memset(void *dst, int value, size_t n)
Fill memory with a constant byte value.
void * memcpy(void *dst, const void *src, size_t n)
Copy memory area between non-overlapping regions.
ra8_err_t ra8_ota_run_step(void)
Drive the OTA state machine one step forward.
ra8_err_t ra8_ota_commit_and_reboot(void)
Latch the inactive bank as the next boot bank and reboot.
void ra8_ota_system_reset_hook(void)
Weak system-reset hook overridden by the target build.
static ra8_err_t internal_prepare_bank(const ra8_ota_manifest_t *manifest)
Erase the inactive bank and prime the SHA accumulator.
static ra8_err_t internal_drain(uint8_t *dst, uint32_t cap, uint32_t *out_n)
Drain the network stream and accumulate up to cap bytes.
static ra8_err_t internal_step_dispatch(void)
Drive one transition based on the current state.
static ra8_err_t internal_fetch_manifest_payload(uint32_t *out_got)
Open the manifest URL and drain its payload into g_ra8_ota_buf.
static ra8_err_t internal_download_chunk(uint32_t addr_base, uint32_t *in_out_done, uint32_t total)
Stream one chunk: drain network -> hash -> flash program.
bool g_ra8_ota_initialized
True once ra8_ota_init succeeded (shared; contract in ra8_ota_internal.h).
static bool s_manifest_valid
Whether s_manifest holds a valid payload.
static ra8_ota_manifest_t s_manifest
Cached decoded manifest from the most recent check.
ra8_err_t ra8_ota_download_to_inactive_bank(const ra8_ota_manifest_t *manifest)
Download an image into the inactive bank, hashing as it goes.
ra8_ota_state_t g_ra8_ota_state
Current state-machine value (shared; contract in ra8_ota_internal.h).
static ra8_err_t s_last_err
Last error observed by the state machine.
uint8_t g_ra8_ota_buf[k_ra8_ota_chunk_bytes]
Streaming buffer (shared; contract in ra8_ota_internal.h).
ra8_err_t ra8_ota_run_full_update(void)
Drive the OTA state machine through an end-to-end update.
void priv_ota_set_state(ra8_ota_state_t new_state, ra8_err_t err)
Implementation of priv_ota_set_state() – latch state + progress fan-out.
ra8_err_t ra8_ota_init(const ra8_ota_cfg_t *cfg)
Initialise the OTA module from a caller-supplied configuration.
ra8_ota_state_t ra8_ota_get_state(void)
Return the current OTA state-machine value.
ra8_err_t ra8_ota_check_for_update(ra8_ota_manifest_t *out_manifest)
Fetch and decode the upstream manifest, leaving it cached.
ra8_ota_cfg_t g_ra8_ota_cfg
Configuration captured at init time (shared; contract in ra8_ota_internal.h).
static ra8_err_t internal_download_loop(const ra8_ota_manifest_t *manifest)
Drain chunks until the entire image is downloaded or an error fires.
static uint32_t s_bytes_done
Bytes already programmed into the inactive bank.
ra8_err_t ra8_ota_deinit(void)
Reset the OTA module to its un-initialized state.
Phase-5 OTA firmware-update orchestration for the RA8D2.
ra8_ota_state_t
Cooperative state-machine states.
@ k_ra8_ota_state_count
Sentinel.
@ k_ra8_ota_state_error
Last operation failed; see last err.
@ k_ra8_ota_state_checking
Manifest fetch in flight.
@ k_ra8_ota_state_verifying
SHA-256 + ECDSA verification.
@ k_ra8_ota_state_done
Update applied (reset is imminent).
@ k_ra8_ota_state_committing
About to swap banks + reset.
@ k_ra8_ota_state_downloading
Streaming firmware to inactive bank.
@ k_ra8_ota_state_idle
No update in progress.
ra8_err_t ra8_ota_verify_signature(const ra8_ota_manifest_t *manifest)
Verify SHA-256 + ECDSA over the freshly programmed bank.
@ k_ra8_ota_chunk_bytes
Download streaming chunk size in bytes.
@ k_ra8_ota_max_image_bytes
512 KiB upper bound per bank.
@ k_ra8_ota_manifest_max_bytes
Largest accepted manifest payload.
Test-access surface for ra8_ota internal helpers (MC/DC).
ra8_err_t priv_ota_manifest_decode(const char *json, ra8_ota_manifest_t *out)
Decode every field of a JSON manifest into an ra8_ota_manifest_t.
ra8_err_t priv_ota_validate_cfg(const ra8_ota_cfg_t *cfg)
Validate the entire OTA configuration descriptor.
bool priv_ota_download_state_invalid(uint32_t state_idle_val, uint32_t state_downloading_val, uint32_t state)
Pure predicate: state is neither IDLE nor DOWNLOADING.
Secure-comparison primitives for the crypto / secure-boot paths.
Initialisation descriptor for ra8_ota_init.
Decoded representation of the server manifest.
char image_url[k_ra8_ota_url_max_bytes]
HTTPS URL of the image blob.
uint32_t image_size_bytes
Image size on the wire.
Snapshot delivered to the caller's progress callback.