25typedef enum : uint32_t {
33typedef enum : uint8_t {
41 const uint32_t bound = (data ==
nullptr) ? 0U : len;
42 for (uint32_t i = 0U; i < bound; ++i) {
43 crc ^= (uint32_t)data[i];
48 crc = (uint32_t)(crc >> 1U);
63 const bool crc_ok = (computed_crc == hdr->
img_crc32);
64 return magic_ok && len_ok && crc_ok;
70 const bool len_ok = (img_len != 0U) && (img_len <= (uint32_t)
k_ra8_dfu_img_max) &&
72 return entry_ok && len_ok;
77 if (!a_valid && !b_valid) {
80 if (a_valid && (!b_valid || (a_seq >= b_seq))) {
Controller-agnostic USB-DFU MRAM bootloader core for the RA8D2.
ra8_dfu_slot_t
Application-slot identifier.
@ k_ra8_dfu_slot_b
Slot B (0x02090000).
@ k_ra8_dfu_slot_a
Slot A (0x02020000).
@ k_ra8_dfu_slot_none
No valid slot present.
ra8_dfu_action_t
Outcome of the reset-time boot decision.
@ k_ra8_dfu_action_jump_b
Jump to the Slot B application.
@ k_ra8_dfu_action_dfu
Enter the DFU device; do not jump.
@ k_ra8_dfu_action_jump_a
Jump to the Slot A application.
@ k_ra8_dfu_page_size
MRAM program page (32 bytes).
@ k_ra8_dfu_hdr_magic
Valid-image header magic ("RA8D").
@ k_ra8_dfu_img_max
Max image bytes (slot - header).
@ k_ra8_dfu_run_base
SRAM copy-to-run / payload link base.
ra8_dfu_crc_const_t
IEEE-802.3 reflected-CRC32 parameters (poly / init / final XOR).
@ k_ra8_dfu_crc_xout
Final output XOR.
@ k_ra8_dfu_crc_lsb
Low-bit test mask.
@ k_ra8_dfu_crc_poly
Reflected poly of 0x04C11DB7.
@ k_ra8_dfu_crc_init
Shift-register preset.
ra8_dfu_slot_t ra8_dfu_select_slot(bool a_valid, uint32_t a_seq, bool b_valid, uint32_t b_seq)
Pick the active slot from the two slots' validity + sequence.
ra8_dfu_crc_bits_t
Bits folded per input byte in the CRC32 inner loop.
@ k_ra8_dfu_crc_bits
One byte == eight shift iterations.
uint32_t ra8_dfu_crc32(const uint8_t *data, uint32_t len)
Implementation of ra8_dfu_crc32() – bitwise reflected CRC32.
bool ra8_dfu_hdr_valid(const ra8_dfu_img_hdr_t *hdr, uint32_t computed_crc)
Decide whether a slot header describes a valid bootable image.
bool ra8_dfu_run_target_valid(uint32_t entry, uint32_t img_len)
Decide whether a validated slot's image may be copied-to-run.
ra8_dfu_action_t ra8_dfu_boot_decide(bool dfu_trigger, bool a_valid, uint32_t a_seq, bool b_valid, uint32_t b_seq)
Reset-time boot decision: jump to a slot, or enter DFU.
32-byte application-image header at the base of each slot.
uint32_t img_crc32
CRC32 (IEEE) over the image body.
uint32_t magic
Must equal k_ra8_dfu_hdr_magic.
uint32_t img_len
Image body length in bytes (32-byte multiple).