|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Prove the cross-reset crash-log + reset-loop guard (T2-03, #191). More...
#include <stddef.h>#include <stdint.h>#include "ra8_board_ek_ra8d2.h"#include "ra8_boot_entry.h"#include "ra8_cgc.h"#include "ra8_crashlog.h"#include "ra8_err.h"#include "ra8_exception.h"#include "ra8_isr.h"#include "ra8_log.h"#include "ra8_mstp.h"Go to the source code of this file.
Enumerations | |
| enum | fc_consts_t : uint32_t { k_fc_uart_baud = 115200U , k_fc_hex_nib_mask = 0xFU } |
| Console + hex-printer knobs (no magic numbers). More... | |
| enum | fc_hex_t : uint8_t { k_fc_hex_nib_bits = 4U , k_fc_hex_digits = 8U } |
| Hex-printer iteration constants. More... | |
| enum | fc_synth_t : uint32_t { k_fc_synth_exc = 6U , k_fc_synth_pc = 0x02001234U , k_fc_synth_lr = 0x02001200U , k_fc_synth_cfsr = 0x02000000U } |
| Synthetic decoded-fault values for the write proof. More... | |
Functions | |
| static void | fc_print (const uint8_t *msg, uint32_t len) |
| Emit a byte run on the SCI8 console. | |
| static void | fc_print_uint (uint32_t value) |
| Print a uint32 in decimal (0 prints as "0"). | |
| static void | fc_print_hex32 (uint32_t value) |
| Print a uint32 as "0x" + 8 fixed hex digits (MSB-first). | |
| 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). | |
| static void | fc_setup_or_halt (void) |
| Bring up clocks / MSTP + the SCI8 console; halt on failure. | |
| static void | fc_print_record (const ra8_crashlog_record_t *rec) |
| Print a decoded record's exception class, PC, and loop count. | |
| static void | fc_make_synth (ra8_exception_last_t *out) |
| Fill a decoded snapshot with representative synthetic fault values. | |
| void | main (void) |
| The application entry point Reset_Handler hands control to. | |
Variables | |
| static const uint8_t | k_msg_boot [] = "crashlog: boot\r\n" |
| static const uint8_t | k_msg_fail [] = "crashlog: FAIL init\r\n" |
| static const uint8_t | k_msg_none [] = "crashlog: no prior record (cold/first boot)\r\n" |
| static const uint8_t | k_msg_prior [] = "crashlog: prior record exc=" |
| static const uint8_t | k_msg_pc [] = " pc=" |
| static const uint8_t | k_msg_loops [] = " boot_loops=" |
| static const uint8_t | k_msg_safemode [] = "crashlog: SAFE-MODE requested -- reset loop, idling\r\n" |
| static const uint8_t | k_msg_recorded [] = "crashlog: recorded+readback exc=" |
| static const uint8_t | k_msg_crlf [] = "\r\n" |
Prove the cross-reset crash-log + reset-loop guard (T2-03, #191).
ra8_crashlog (libs/ra8_core) persists the decoded fault snapshot into a .noinit record the reset handler does not zero, counts crash-reboot cycles, and latches a safe-mode request once the count crosses a threshold. This app drives that state machine end to end so it is provable BOTH headlessly (ra8_emulator) and on the bench:
Definition in file main.c.
| enum fc_consts_t : uint32_t |
| enum fc_hex_t : uint8_t |
| enum fc_synth_t : uint32_t |
|
static |
ra8_log byte sink: forward every log byte to the SCI8 console.
The fault path logs through ra8_log, whose default ITM backend drops every byte in fault context; a registered polled sink does not, making a real dump visible on the bench UART.
| [in] | ctx | Unused opaque cookie (sink ABI). |
| [in] | byte | Log byte to emit. |
Definition at line 181 of file main.c.
References ra8_board_uart_console_write().
Referenced by main().
|
static |
Fill a decoded snapshot with representative synthetic fault values.
| [out] | out | Snapshot to populate. Must not be nullptr. |
out points at writable storage. Definition at line 268 of file main.c.
References ra8_exception_diagnostics_t::cfsr, ra8_exception_last_t::diag, ra8_exception_last_t::exc_number, ra8_exception_last_t::frame, k_fc_synth_cfsr, k_fc_synth_exc, k_fc_synth_lr, k_fc_synth_pc, k_ra8_exc_magic_valid, ra8_exception_frame_t::lr, ra8_exception_last_t::magic, and ra8_exception_frame_t::pc.
Referenced by main().
|
static |
Print the fail banner and trap (ra8_emulator halts on the BKPT).
| [in] | msg | Banner bytes. |
| [in] | len | Banner length. |
Definition at line 199 of file main.c.
References fc_print().
Referenced by fc_setup_or_halt(), and main().
|
static |
Emit a byte run on the SCI8 console.
Thin wrapper discarding the write status: console loss is acceptable for a print helper; the HIL gate re-checks output.
| [in] | msg | Bytes to send (not NUL-inspected). |
| [in] | len | Number of bytes. |
Definition at line 102 of file main.c.
References ra8_board_uart_console_write().
Referenced by fc_panic_halt(), fc_print_hex32(), fc_print_record(), fc_print_uint(), and main().
|
static |
Print a uint32 as "0x" + 8 fixed hex digits (MSB-first).
Fixed-width so a faulting PC always reads as a full address.
| [in] | value | Value to print in hexadecimal. |
Definition at line 154 of file main.c.
References fc_print(), k_fc_hex_digits, k_fc_hex_nib_bits, and k_fc_hex_nib_mask.
Referenced by fc_print_record(), and main().
|
static |
Print a decoded record's exception class, PC, and loop count.
| [in] | rec | Validated record to print. Must not be nullptr. |
rec came from a successful ra8_crashlog_peek(). Definition at line 243 of file main.c.
References ra8_crashlog_record_t::boot_loops, ra8_exception_last_t::exc_number, ra8_crashlog_record_t::fault, fc_print(), fc_print_hex32(), fc_print_uint(), ra8_exception_last_t::frame, k_msg_crlf, k_msg_loops, k_msg_pc, k_msg_prior, and ra8_exception_frame_t::pc.
Referenced by main().
|
static |
Print a uint32 in decimal (0 prints as "0").
Digits are pushed LSB-first into a local buffer then emitted MSB-first; at most 10 digits (uint32 max is 4294967295).
| [in] | value | Value to print. |
< Decimal base.
< Max digits in a uint32 (4G).
Definition at line 120 of file main.c.
References fc_print().
Referenced by fc_print_record(), and main().
|
static |
Bring up clocks / MSTP + the SCI8 console; halt on failure.
Minimal bring-up: CGC, MSTP, console. No timers needed.
Definition at line 219 of file main.c.
References fc_panic_halt(), k_fc_uart_baud, k_msg_fail, k_ra8_ok, ra8_board_uart_console_init(), ra8_cgc_init(), and ra8_mstp_init().
Referenced by main().
| void main | ( | void | ) |
The application entry point Reset_Handler hands control to.
Returns void, not int. This is a freestanding image: there is no hosted C environment, no process and nothing to report an exit status to. ISO C fixes main at int only for a hosted implementation; for a freestanding one (C23 5.1.2.1) the startup function's name and type are implementation-defined, and this is that definition. Reset_Handler discards no value because there is none to discard, and if main ever does return, startup halts the CPU rather than resuming anything.
The firmware lane is compiled -ffreestanding (see cmake/ra8_add_app.cmake) and the flag and this signature travel together: without it both GCC and clang reject a non-int main (-Wmain / -Wmain-return-type). Do not remove one without the other.
That coupling is why the declaration sits behind __STDC_HOSTED__ == 0, which -ffreestanding sets and a hosted build does not. The guard is not defensive dressing: this header is reachable from host builds (the unit tests compile ra8_core natively), and an unguarded void main(void); makes every hosted translation unit that includes it fail with conflicting types for 'main' against its own ISO int main. The declaration therefore exists exactly where its contract does.
Hosted first-party code – everything under tests/ and tools/ – uses the ISO int main(...) contract instead, because it genuinely does run under an OS that reads the exit status. scripts/checks/check_entry_points.py holds each domain to its own contract (#707).
Declared here, once, for the same reason SystemInit is: every vector_table.c used to restate it as a local extern int32_t main(void);, sixteen copies that no compiler ever compared against the definition – and roughly thirty of them had silently drifted out of agreement with the main they called.
The application entry point Reset_Handler hands control to.
Brings up CGC + BSP audio then plays blocks.
The application entry point Reset_Handler hands control to.
Brings up CGC + GPT triple, runs sweep.
The application entry point Reset_Handler hands control to.
Brings up clocks + UART + RMII pins, then ThreadX.
The application entry point Reset_Handler hands control to.
Brings up clocks + UART, then enters ThreadX.
The application entry point Reset_Handler hands control to.
Brings up LED, console, SDHI pins, then ThreadX.
The application entry point Reset_Handler hands control to.
Brings up CGC + USB-FS + UAC1, then enters the iso-IN feed loop forever.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
See file header.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Profiles power modes once a second.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Brings up the clocks, console, SPI, and SD card, then runs the shared ra8_io VFS round-trip over the SD-over-SPI block device. On success it prints the exact PASS banner the HIL runner and ra8_emulator smoke gate scrape for; on any failure it prints FAIL and parks the core.
The application entry point Reset_Handler hands control to.
Initialises logging and the console, brings up the OSPI NOR volume, runs the erase-before-write round-trip, and prints a single PASS/FAIL verdict line over SCI8 before parking in an infinite loop.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Both USB controllers' clocks and pins come up before the kernel so the workers only deal with stack bring-up.
The application entry point Reset_Handler hands control to.
Brings up logging and the clock tree, releases the Cortex-M33 (which then blinks LED1 via ra8_pcntr_set_output()), and idles. See the file header.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Brings up logging, the clock tree, and the VCOM console, runs the cacheable-SRAM round-trip with the D-cache that SystemInit() enabled through ra8_cache_dcache_enable(), emits the matching PASS / FAIL banner over the console and ra8_log, then parks in WFI. Every byte the self-test touches runs with the L1 caches + MPU enabled by the shared boot (RA8_BOOT_ENABLE_CACHE_MPU + RA8_BOOT_CACHE_VIA_HAL).
The application entry point Reset_Handler hands control to.
Publishes the mailbox, releases the Cortex-M33 into the emitter, yields until it signals done, validates the blob the M33 built, then logs the PASS/FAIL verdict and the chapter count read back from the blob. See the file header for the offload narrative.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Publishes the mailbox, arms the IPC0 wake and configures the LPM block, releases the Cortex-M33 into the reader, waits for the first held page, logs the page-0 verdict, then runs the #150 mode-switch cycle – parking in low-power WFI and waking on the M33's page-turn pokes – before logging the handoff verdict and parking for good. See the file header for the narrative.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Brings up the timebase then measures forever.
The application entry point Reset_Handler hands control to.
Arms the RIIC1 target and polls the dispatcher.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Brings up the LIN commander then drives frames.
The application entry point Reset_Handler hands control to.
Brings up logging, "renders" page 0 into the shared mailbox, releases the Cortex-M33 into its hold loop, and parks the M85 in low-power WFI sleep. See the file header for the power-saving narrative.
The application entry point Reset_Handler hands control to.
The USB clock, pins, console, and the SD card all come up before the kernel so the worker only deals with USB stack bring-up.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Brings up logging, the clock tree, and the VCOM console, runs the three-step self-test (MPU enabled, canonical boot map, Device MMIO), emits the matching PASS / FAIL banner over the console and ra8_log, then parks in WFI.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Initialises logging + console, brings up the MRAM volume, runs the wear-levelling + power-cycle-survival flow, and prints a single PASS/FAIL verdict.
The application entry point Reset_Handler hands control to.
Initialises logging + console, brings up the MRAM volume, runs the program/erase round-trip, and prints a single PASS/FAIL verdict.
The application entry point Reset_Handler hands control to.
Brings up the clocks, console, and SDHI bus pins, runs the native SD card identification, fills the payload, then runs the full ra8_io VFS round-trip over the native-SDHI block device. On success it prints the exact PASS banner the HIL runner and ra8_emulator smoke gate scrape for; on any failure it prints FAIL and parks the core.
The application entry point Reset_Handler hands control to.
Brings up the console and both stdio sinks, retargets the engine's stdio to the in-RAM capture sink, runs the two-backend swap, replays the RAM capture out of the UART, and prints a single PASS/FAIL verdict per abstraction before parking in an infinite loop.
The application entry point Reset_Handler hands control to.
Brings up the clocks, console, and SDHI bus pins, runs the native SD card identification, fills the payload, then writes + reads + compares one raw 512-byte block straight against ra8_sdcard. On success it prints the exact PASS banner; on any failure it prints FAIL and parks the core.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Brings up clocks + UART + RMII + RSIP, then ThreadX.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Initializes and arms ADC_B, formats each successful channel sample without variadic I/O, emits the verdict, toggles LED1, and delays.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Brings up logging, releases the Cortex-M33 (which then blinks LED1), and idles. See the file header for the teaching narrative.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
See the file header for the full behaviour summary.
The application entry point Reset_Handler hands control to.
Brings up logging, the clock tree, and the VCOM console, runs the three-step self-test (cacheable SRAM, RO MRAM const, Device MMIO), emits the matching PASS / FAIL banner over the console and ra8_log, then parks in WFI. Every byte the self-test touches runs with the L1 caches and MPU enabled by the shared boot (RA8_BOOT_ENABLE_CACHE_MPU).
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Lights HOCO + PLL, then runs a 1 Hz blink.
The application entry point Reset_Handler hands control to.
See file header for behaviour summary.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Initializes the demo, executes one comparison per period, increments the exported match or mismatch counter, and toggles the matching LED.
The application entry point Reset_Handler hands control to.
Brings up the clock tree, MSTP, ISR/ELC, and the VCOM console, programs a software-triggered DTC block copy, runs it with the L1 caches + MPU enabled by the shared boot (RA8_BOOT_ENABLE_CACHE_MPU), emits the matching PASS / FAIL banner over the console and ra8_log, then parks in WFI.
The application entry point Reset_Handler hands control to.
Brings up logging, zeros the shared control block, releases the Cortex-M33, waits for its boot signature, then yields while the M33 counts autonomously to k_bg_target_count. After the M33 sets done, the M85 reads the counter and logs the PASS/FAIL verdict.
The application entry point Reset_Handler hands control to.
Brings up logging, releases the Cortex-M33, confirms it booted, runs k_m85_demo_rounds narrated mailbox rounds, then drops into the idle heartbeat. See the file header for the teaching narrative.
The application entry point Reset_Handler hands control to.
Fires ELC software events once a second.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Definition at line 281 of file main.c.
References ra8_crashlog_record_t::boot_loops, ra8_exception_last_t::exc_number, ra8_crashlog_record_t::fault, fc_log_sink(), fc_make_synth(), fc_panic_halt(), fc_print(), fc_print_hex32(), fc_print_record(), fc_print_uint(), fc_setup_or_halt(), ra8_exception_last_t::frame, k_msg_boot, k_msg_crlf, k_msg_fail, k_msg_loops, k_msg_none, k_msg_pc, k_msg_recorded, k_msg_safemode, ra8_exception_frame_t::pc, ra8_crashlog_claim(), ra8_crashlog_install(), ra8_crashlog_peek(), ra8_crashlog_record_fault(), ra8_crashlog_safe_mode_requested(), ra8_isr_globals_enable(), and ra8_log_set_byte_sink().
|
static |
Definition at line 86 of file main.c.
Referenced by fc_print_record(), and main().
|
static |
Definition at line 83 of file main.c.
Referenced by fc_print_record(), and main().
|
static |
|
static |
Definition at line 82 of file main.c.
Referenced by fc_print_record(), and main().
|
static |
Definition at line 81 of file main.c.
Referenced by fc_print_record().
|
static |