59typedef enum : uint32_t {
65typedef enum : uint8_t {
71typedef enum : uint32_t {
79static const uint8_t
k_msg_fail[] =
"crashlog: FAIL init\r\n";
80static const uint8_t
k_msg_none[] =
"crashlog: no prior record (cold/first boot)\r\n";
81static const uint8_t
k_msg_prior[] =
"crashlog: prior record exc=";
84static const uint8_t
k_msg_safemode[] =
"crashlog: SAFE-MODE requested -- reset loop, idling\r\n";
102static void fc_print(
const uint8_t* msg, uint32_t len)
124 k_fc_dec_digits = 10U,
126 uint8_t buf[k_fc_dec_digits];
132 while ((value > 0U) && (n < (uint32_t)k_fc_dec_digits)) {
133 buf[n] = (uint8_t)(
'0' + (value % (uint32_t)k_fc_dec_base));
135 value /= (uint32_t)k_fc_dec_base;
137 for (uint32_t i = 0U; i < n; i++) {
156 static const uint8_t k_hex[] =
"0123456789ABCDEF";
157 const uint8_t prefix[] = {
'0',
'x'};
158 fc_print(prefix, (uint32_t)
sizeof(prefix));
202 __asm__
volatile(
"bkpt #0");
204 __asm__
volatile(
"wfi");
245 if (rec ==
nullptr) {
270 if (out ==
nullptr) {
299 __asm__
volatile(
"wfi");
326 __asm__
volatile(
"wfi");
void main(void)
Secure fallback main entry point.
static const uint8_t k_msg_boot[]
static const uint8_t k_msg_fail[]
static void fc_print_record(const ra8_crashlog_record_t *rec)
Print a decoded record's exception class, PC, and loop count.
static const uint8_t k_msg_safemode[]
static void fc_print(const uint8_t *msg, uint32_t len)
Emit a byte run on the SCI8 console.
static const uint8_t k_msg_crlf[]
static const uint8_t k_msg_none[]
static const uint8_t k_msg_loops[]
static void fc_make_synth(ra8_exception_last_t *out)
Fill a decoded snapshot with representative synthetic fault values.
fc_synth_t
Synthetic decoded-fault values for the write proof.
@ k_fc_synth_exc
Pretend UsageFault class.
@ k_fc_synth_cfsr
CFSR.DIVBYZERO, mirrors fault_div0's dump.
@ k_fc_synth_pc
Representative faulting PC (MRAM).
@ k_fc_synth_lr
Representative link register.
static void fc_print_hex32(uint32_t value)
Print a uint32 as "0x" + 8 fixed hex digits (MSB-first).
fc_consts_t
Console + hex-printer knobs (no magic numbers).
@ k_fc_hex_nib_mask
Low-nibble mask for hex printing.
@ k_fc_uart_baud
SCI8 J-Link VCOM console baud.
fc_hex_t
Hex-printer iteration constants.
@ k_fc_hex_digits
Nibbles in a uint32 value.
@ k_fc_hex_nib_bits
Bits per hex nibble.
static const uint8_t k_msg_prior[]
static const uint8_t k_msg_recorded[]
static const uint8_t k_msg_pc[]
static void fc_setup_or_halt(void)
Bring up clocks / MSTP + the SCI8 console; halt on failure.
static void fc_print_uint(uint32_t value)
Print a uint32 in decimal (0 prints as "0").
static void fc_log_sink(void *ctx, uint8_t byte)
ra8_log byte sink: forward every log byte to the SCI8 console.
static void fc_panic_halt(const uint8_t *msg, uint32_t len)
Print the fail banner and trap (ra8_emulator halts on the BKPT).
Board-support layer for the Renesas EK-RA8D2 v1 evaluation kit.
ra8_err_t ra8_board_uart_console_write(const uint8_t *data, size_t len)
Polled blocking write to the J-Link OB VCOM console.
ra8_err_t ra8_board_uart_console_init(uint32_t baud)
Configure SCI8 + PD02/PD03 as the debug-console UART.
Boot entry points shared between a vector table and its startup code.
High-level Clock Generation Circuit driver.
ra8_err_t ra8_cgc_init(void)
Configure the clock tree to a safe default.
Cross-reset crash-log: persist the last fault + a reset-loop guard.
void ra8_crashlog_claim(void)
Consume the record and reset the reset-loop guard (clean claim).
bool ra8_crashlog_peek(ra8_crashlog_record_t *out)
Validate and copy out the last cross-reset record (non-destructive).
bool ra8_crashlog_safe_mode_requested(void)
Whether accumulated crashes crossed the reset-loop threshold.
void ra8_crashlog_record_fault(const volatile ra8_exception_last_t *decoded)
Persist a decoded fault snapshot into the cross-reset record.
void ra8_crashlog_install(void)
Arm the fault-persist hook so decoded faults are logged to .noinit.
Error Code Definitions for ra8-firmware.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
Cortex-M85 CPU exception diagnostic helpers.
@ k_ra8_exc_magic_valid
Snapshot is fully populated.
NVIC + ICU IELSR allocator.
void ra8_isr_globals_enable(void)
Globally enable maskable interrupts (PRIMASK = 0).
Lightweight Logging Interface for ra8-firmware.
void ra8_log_set_byte_sink(ra8_log_byte_sink_fn_t fn, void *ctx)
Install (or clear) an optional byte sink for log output.
Ref-counted Module Stop Control wrapper for the RA8D2.
ra8_err_t ra8_mstp_init(void)
Re-establish the ra8_mstp ref-count table from current hardware state.
The .noinit cross-reset post-mortem record.
ra8_exception_last_t fault
Embedded copy of the decoded fault / NMI snapshot.
uint32_t boot_loops
Monotonic recorded-fault counter; cleared by a claim.
uint32_t cfsr
Configurable Fault Status Register.
uint32_t pc
Program counter at fault.
uint32_t lr
Link register (return addr).
Fixed-SRAM post-mortem snapshot of the most recent fault or NMI.
uint32_t magic
k_ra8_exc_magic_valid when valid.
uint32_t exc_number
Architectural exception number.
ra8_exception_diagnostics_t diag
SCB fault-status snapshot.
ra8_exception_frame_t frame
Stacked GPR frame.