72typedef enum : uint32_t {
91typedef enum : uint8_t {
208 uint32_t pubkey_handle,
Error Code Definitions for ra8-firmware.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
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)
Persist the bank swap and reboot.
void ra8_ota_system_reset_hook(void)
Test/host hook for commit_and_reboot.
void(* ra8_ota_progress_cb_t)(const ra8_ota_progress_t *p)
Caller progress callback type.
ra8_err_t ra8_ota_download_to_inactive_bank(const ra8_ota_manifest_t *manifest)
Stream the firmware blob into the inactive MRAM bank.
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_run_full_update(void)
Kick off an end-to-end update from idle.
ra8_err_t ra8_ota_init(const ra8_ota_cfg_t *cfg)
Initialise the OTA module.
ra8_ota_state_t ra8_ota_get_state(void)
Return the current state-machine value.
ra8_err_t ra8_ota_verify_signature(const ra8_ota_manifest_t *manifest)
Verify SHA-256 + ECDSA over the freshly programmed bank.
ra8_err_t ra8_ota_check_for_update(ra8_ota_manifest_t *out_manifest)
Fetch and decode the manifest JSON over HTTPS.
ra8_ota_constants_t
Compile-time bounds for the OTA module.
@ k_ra8_ota_url_max_bytes
NUL-terminated URL upper bound.
@ k_ra8_ota_sha256_bytes
SHA-256 digest length.
@ k_ra8_ota_version_str_bytes
NUL-terminated version string.
@ k_ra8_ota_thread_stack_bytes
Static ThreadX worker stack.
@ 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_signature_max_bytes
ECDSA-P256 ASN.1 sig upper bound.
@ k_ra8_ota_manifest_max_bytes
Largest accepted manifest payload.
ra8_err_t ra8_ota_deinit(void)
Tear the OTA module down (mostly for tests / re-init).
Initialisation descriptor for ra8_ota_init.
ra8_ota_crypto_iface_t crypto
Crypto interface (must be fully populated).
char manifest_url[k_ra8_ota_url_max_bytes]
HTTPS URL of the manifest JSON.
uint32_t pubkey_handle
Opaque handle to the trusted ECDSA public key.
ra8_ota_flash_iface_t flash
Flash backend (must be fully populated).
bool run_as_thread
true => spawn the static ThreadX worker thread.
ra8_ota_net_iface_t net
Network HTTPS interface (must be fully populated).
ra8_ota_progress_cb_t on_progress
Progress callback (NULL == disabled).
Injected hash + ECDSA verification interface.
void * ctx
Opaque context passed back to every callback.
ra8_err_t(* ecdsa_verify)(void *ctx, uint32_t pubkey_handle, const uint8_t digest[k_ra8_ota_sha256_bytes], const uint8_t *sig, uint32_t sig_len)
Verify sig is a valid ECDSA signature over digest using the public key referenced by pubkey_handle.
ra8_err_t(* sha256_final)(void *ctx, uint8_t out[k_ra8_ota_sha256_bytes])
Finalise and write the 32-byte digest to out.
ra8_err_t(* sha256_update)(void *ctx, const uint8_t *data, uint32_t len)
Feed bytes to the running SHA-256 hash.
ra8_err_t(* sha256_init)(void *ctx)
Begin a SHA-256 streaming hash.
Injected flash backend (so tests do not need real MRAM).
uint8_t inactive_bank_index
Bank index set_startup should select on commit.
ra8_err_t(* program)(void *ctx, uint32_t addr, const uint8_t *src, uint32_t len)
Program len bytes at addr (must be 32-byte aligned).
ra8_err_t(* set_startup)(void *ctx, uint8_t which_bank, bool persistent)
Pick the bank to boot from at the next reset.
uint32_t inactive_bank_addr
Base address of the inactive bank in the MRAM window.
uint32_t bank_size_bytes
Size of one bank in bytes.
void * ctx
Opaque context passed back to every callback.
ra8_err_t(* erase)(void *ctx, uint32_t addr, uint32_t len)
Erase len bytes starting at addr in the inactive bank.
ra8_err_t(* readback)(void *ctx, uint32_t addr, uint8_t *dst, uint32_t len)
Read back len bytes (used by verification re-hash).
Decoded representation of the server manifest.
uint8_t image_sha256[k_ra8_ota_sha256_bytes]
Expected digest.
uint16_t signature_len
Bytes used in signature.
char image_url[k_ra8_ota_url_max_bytes]
HTTPS URL of the image blob.
uint8_t signature[k_ra8_ota_signature_max_bytes]
ECDSA signature over digest.
uint32_t image_size_bytes
Image size on the wire.
char version[k_ra8_ota_version_str_bytes]
Firmware version string.
Injected HTTPS-download interface (Dependency Inversion).
ra8_err_t(* close)(void *ctx)
Tear the streaming GET down.
ra8_err_t(* open)(void *ctx, const char *url, uint32_t *out_content_len)
Begin a streaming GET against url.
void * ctx
Opaque context passed back to every callback.
ra8_err_t(* read)(void *ctx, uint8_t *dst, uint32_t cap, uint32_t *out_len)
Read up to cap bytes from the open session.
Snapshot delivered to the caller's progress callback.
ra8_ota_state_t state
Current state machine value.
uint32_t bytes_total
Manifest-declared size.
uint32_t bytes_done
Bytes successfully programmed so far.
ra8_err_t last_err
Last error (k_ra8_ok if healthy).