39static const char*
const s_tag =
"DEVCFG";
51typedef enum : uint32_t {
60typedef enum : uint8_t {
91typedef enum : uint8_t {
142 for (uint32_t i = 0U; i < len; i++) {
143 crc ^= (uint32_t)data[i];
145 const uint32_t mask = (uint32_t)0U - (crc & 1U);
335 (void)
memcpy(b->panel_serial,
338 (void)
memcpy(b->panel_lut_id,
390 const uint32_t calc =
392 return stored == calc;
421[[nodiscard]]
static bool
460[[nodiscard]]
static uint32_t
500 const uint32_t seq0 = valid0 ? cur0.
seq : 0U;
501 const uint32_t seq1 = valid1 ? cur1.
seq : 0U;
502 const uint32_t newest = (seq0 >= seq1) ? seq0 : seq1;
503 *out_seq = newest + 1U;
559 if (valid0 && valid1) {
585 const uint16_t mv =
s_record.body.panel_vcom_mv;
617 uint32_t target = 0U;
618 uint32_t new_seq = 0U;
static const char * s_tag
Logging / check tag.
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Validation and Error-Checking Macros for ra8-firmware.
#define RA8_RETURN_ON_ERROR(err, tag, message)
Early return on error, propagating the code upward.
#define RA8_CHECK_NULL_PTR(ptr, tag, message)
Reject nullptr pointer, returning k_ra8_err_null_ptr.
ra8_devcfg_state_t
Module cache state established by ra8_devcfg_load.
@ k_ra8_devcfg_state_loaded
A valid record is cached.
@ k_ra8_devcfg_state_unloaded
No load attempted this boot.
@ k_ra8_devcfg_state_unprovisioned
Load ran; neither copy was valid.
void ra8_devcfg_reset(void)
Drop the cached record so a later load re-resolves from scratch.
ra8_err_t ra8_devcfg_commit(const ra8_devcfg_store_t *store, const ra8_devcfg_record_t *rec)
Commit a new record to the stale copy slot with header-last ordering.
ra8_err_t ra8_devcfg_load(const ra8_devcfg_store_t *store)
Load and resolve the device configuration record from both copies.
static ra8_err_t internal_devcfg_write_record(const ra8_devcfg_store_t *store, uint32_t target, const uint8_t *buf)
Program a serialised record to a slot with the header page written last.
static void internal_devcfg_plan(const ra8_devcfg_store_t *store, uint32_t *out_target, uint32_t *out_seq)
Probe both copies and choose the commit target slot and next sequence.
static uint32_t internal_devcfg_unpack_le32(const uint8_t *src)
Load a little-endian 32-bit value from a blob.
static void internal_devcfg_serialize(const ra8_devcfg_record_t *rec, uint32_t seq, uint8_t *buf)
Serialise a record into a k_ra8_devcfg_record_len byte buffer.
static uint32_t internal_devcfg_crc32(const uint8_t *data, uint32_t len)
Compute the IEEE 802.3 CRC-32 of a byte span.
ra8_devcfg_bits_t
Byte / word packing constants (no magic numbers).
@ k_ra8_devcfg_bits_per_byte
CRC inner-loop bound.
@ k_ra8_devcfg_byte_mask
Low-byte extraction mask.
@ k_ra8_devcfg_off_b0
Little-endian byte 0.
@ k_ra8_devcfg_off_b2
Little-endian byte 2.
@ k_ra8_devcfg_off_b3
Little-endian byte 3.
@ k_ra8_devcfg_byte_shift
Bits per byte.
@ k_ra8_devcfg_off_b1
Little-endian byte 1.
ra8_devcfg_crc_t
IEEE 802.3 CRC-32 parameters.
@ k_ra8_devcfg_crc_poly
Reversed IEEE 802.3 poly.
@ k_ra8_devcfg_crc_init
CRC seed / final XOR.
static uint32_t internal_devcfg_target(bool valid0, uint32_t seq0, bool valid1, uint32_t seq1)
Choose the copy offset a new record overwrites (the stale slot).
static bool internal_devcfg_copy_valid(const uint8_t *buf)
Report whether a serialised copy passes every integrity gate.
static void internal_devcfg_pack_le16(uint8_t *dst, uint16_t val)
Store a little-endian 16-bit value into a blob.
static ra8_devcfg_record_t s_record
The resolved record cached by the last successful ra8_devcfg_load.
static uint16_t internal_devcfg_unpack_le16(const uint8_t *src)
Load a little-endian 16-bit value from a blob.
bool ra8_devcfg_is_blank(void)
Report whether neither record copy is valid (the provisioning gate).
ra8_err_t ra8_devcfg_get_vcom_mv(uint16_t *out_mv)
Fetch the validated panel VCOM magnitude in millivolts.
ra8_err_t ra8_devcfg_get_body(const ra8_devcfg_body_t **out_body)
Expose the decoded body of the loaded record.
static void internal_devcfg_deserialize(const uint8_t *buf, ra8_devcfg_record_t *out)
Decode a validated record buffer into a ra8_devcfg_record_t.
static void internal_devcfg_pack_le32(uint8_t *dst, uint32_t val)
Store a little-endian 32-bit value into a blob.
static bool internal_devcfg_probe(const ra8_devcfg_store_t *store, uint32_t offset, ra8_devcfg_record_t *out)
Read one copy through the store and validate it.
Per-device (per-unit) configuration record – schema, storage seam, two-copy resolution.
@ k_ra8_devcfg_body_bytes
Per-unit payload bytes.
@ k_ra8_devcfg_schema_ver
Current schema version.
@ k_ra8_devcfg_magic
"RA8C" record marker.
@ k_ra8_devcfg_record_len
Active record = header + body.
@ k_ra8_devcfg_copy0_off
Copy 0 offset in extra-MRAM.
@ k_ra8_devcfg_copy1_off
Copy 1 offset in extra-MRAM.
@ k_ra8_devcfg_hdr_bytes
Header page (written LAST).
@ k_ra8_devcfg_panel_serial_len
Panel identity, NUL-padded.
@ k_ra8_devcfg_touch_cal_len
ra8_touch_cal_save blob.
@ k_ra8_devcfg_serial_len
Unit serial, NUL-padded.
@ k_ra8_devcfg_panel_lut_len
Panel LUT id, e.g.
@ k_ra8_devcfg_flag_vcom_valid
panel_vcom_mv is real.
@ k_ra8_devcfg_off_vcom
u16 panel VCOM magnitude (mV).
@ k_ra8_devcfg_off_fixture
u16 provisioning fixture id.
@ k_ra8_devcfg_off_hw_rev
u16 board revision.
@ k_ra8_devcfg_off_magic
u32 magic.
@ k_ra8_devcfg_off_serial
char[16] serial (body start).
@ k_ra8_devcfg_off_crc
u32 CRC-32 of the body.
@ k_ra8_devcfg_off_mfg_date
u32 packed YYYYMMDD.
@ k_ra8_devcfg_off_panel_lut
char[8] panel LUT id.
@ k_ra8_devcfg_off_seq
u32 monotonic sequence.
@ k_ra8_devcfg_off_panel_serial
char[12] panel serial.
@ k_ra8_devcfg_off_schema
u16 schema_version.
@ k_ra8_devcfg_off_flags
u32 ra8_devcfg_flags_t.
@ k_ra8_devcfg_off_key_id
u32 device-key identifier.
@ k_ra8_devcfg_off_reclen
u16 record_len.
@ k_ra8_devcfg_off_touch_cal
uint8[36] touch-cal blob.
@ k_ra8_devcfg_vcom_max_mv
Highest accepted VCOM magnitude, mV.
@ k_ra8_devcfg_vcom_min_mv
Lowest accepted VCOM magnitude, mV.
Error Code Definitions for ra8-firmware.
@ k_ra8_err_validation_failed
Validation rule failed (caller-supplied invariant not satisfied).
@ k_ra8_err_not_initialized
Module not initialized – _init() not yet called successfully.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
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.
Lightweight Logging Interface for ra8-firmware.
#define ra8_log_warn(tag, message)
RA8 log warn.
#define ra8_log_error(tag, message)
RA8 log error.
Decoded per-unit payload (the 96-byte record body).
Decoded record: the body plus the header discriminators.
uint32_t flags
ra8_devcfg_flags_t bit-set.
uint32_t seq
Monotonic sequence of this record.
uint16_t schema_version
Schema the record was written under.
ra8_devcfg_body_t body
Per-unit payload.
Dependency-injection vtable for the record backing store.
ra8_devcfg_read_fn_t read
Backing read; non-NULL.
ra8_devcfg_write_fn_t write
Backing write; non-NULL.