|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
SRAM ECC bring-up + error-status monitor demo (EK-RA8D2). More...
#include <stdint.h>#include "ra8_attributes.h"#include "ra8_board_ek_ra8d2.h"#include "ra8_boot_entry.h"#include "ra8_cgc.h"#include "ra8_check.h"#include "ra8_err.h"#include "ra8_isr.h"#include "ra8_mstp.h"#include "ra8_sram.h"#include "ra8_time.h"Go to the source code of this file.
Enumerations | |
| enum | ecc_demo_config_t : uint32_t { k_ecc_demo_baud = 115200U , k_ecc_demo_period_ms = 1000U , k_ecc_demo_pat_xor = 0x5A5A5A5AU } |
| Compile-time settings. More... | |
| enum | ecc_demo_geom_t : uint8_t { k_ecc_demo_bank = 2U , k_ecc_demo_test_words = 64U } |
| ECC target geometry. More... | |
Functions | |
| static void | internal_panic_halt (void) |
| Park forever after a fatal ECC demo initialization failure. | |
| static uint32_t | internal_pattern (uint32_t i) |
| Calculate the deterministic read/write test pattern for one word. | |
| static void | internal_setup_or_halt (void) |
| Bring CGC, SysTick, SCI8, LEDs, and MSTP up. | |
| static ra8_err_t | internal_configure (void) |
| Enable full ECC + zero-init on spare bank 2 and resolve its base. | |
| static ra8_err_t | internal_sample (uint8_t *out_ok) |
| Round-trip a pattern through the ECC-protected buffer, then read the ECC status, and fold both into the verdict. | |
| void | main (void) |
| The application entry point Reset_Handler hands control to. | |
Variables | |
| static const char * | s_tag = "ecc_demo" |
| Diagnostic / log tag. | |
| static const uint8_t | s_ecc_demo_ok_msg [] = "ecc: sram2 ecc=on rw=ok ok=Y\r\n" |
| Output line tags. | |
| static const uint8_t | s_ecc_demo_bad_msg [] = "ecc: sram2 rw=BAD ok=N\r\n" |
| volatile uint32_t | g_ecc_ok = 0U |
| 1 when ECC is healthy: rw round-trips and no error is latched. | |
| volatile uint32_t | g_ecc_rw_ok = 0U |
| 1 when the ECC-protected buffer read back exactly. | |
| volatile uint32_t | g_ecc_esr = 0U |
| Last raw SRAMESR snapshot (0 = no ECC error latched). | |
| volatile uint32_t | g_ecc_1bit = 0U |
| Per-bank 1-bit-error bitmap from the last SRAMESR read (bit n = bank n). | |
| volatile uint32_t | g_ecc_2bit = 0U |
| Per-bank 2-bit-error bitmap from the last SRAMESR read (bit n = bank n). | |
| volatile uint32_t | g_ecc_heartbeat = 0U |
| Bumps once per main-loop pass – liveness for headless probes. | |
| static volatile uint32_t * | s_ecc_buf = nullptr |
| Base of the ECC-protected bank, resolved at init. | |
SRAM ECC bring-up + error-status monitor demo (EK-RA8D2).
The RA8D2 SRAM controller can attach SECDED ECC to each 512 KiB bank: 1-bit errors are corrected (and optionally latched), 2-bit errors are uncorrectable and raise an NMI (or reset). This demo enables full ECC ("with-check") on a spare SRAM bank, proves an ECC-protected read/write round-trips, and polls the ECC status register (SRAMESR) – the hardware-error-reporting path – reporting it once a second.
Why bank 2 (0x2210_0000). ECC with-check requires the bank's ECC codes to be initialised first (zero_init), otherwise reading never-written words raises a spurious 2-bit error -> NMI. The zero_init pass rewrites the whole bank, so it must target memory the program does not use. This app's linker places .data / .bss / stack in the first 1 MiB (banks 0-1, 0x2200_0000..0x2210_0000); banks 2-3 are unused, so ECC + zero-init on bank 2 is safe. on_error stays NMI but no error is injected, so the NMI never fires in this demo.
Bring-up: CGC + SysTick + SCI8 + LEDs + MSTP. Once a second: "ecc: sram2 ecc=on rw=ok ok=Y\r\n" (the latched 1-bit / 2-bit error masks go to g_ecc_1bit / g_ecc_2bit for on-silicon probing). LED1 toggles while ECC is healthy; LED2 toggles on a fault.
Bare EK-RA8D2 only – no shields or external transceivers.
Definition in file main.c.
| enum ecc_demo_config_t : uint32_t |
| enum ecc_demo_geom_t : uint8_t |
|
staticnodiscard |
Enable full ECC + zero-init on spare bank 2 and resolve its base.
Banks 0/1/3 stay ECC-disabled (just clock-ungated). Bank 2 gets with-check ECC, 1-bit latch, a 128 KiB ECC region, and the zero-init pass that lays down valid ECC across the bank so no spurious 2-bit error fires. on_error is NMI, but this demo injects no error.
| k_ra8_ok | Bank 2 was initialized and its base was published. |
| (other) | The first SRAM initialization or bank-info error. |
Definition at line 226 of file main.c.
References ra8_sram_config_t::banks, ra8_sram_bank_info_t::data_base, ra8_sram_bank_cfg_t::ecc_mode, ra8_sram_bank_cfg_t::eccrgn, ra8_sram_bank_cfg_t::enable_1bit_latch, k_ecc_demo_bank, k_ra8_ok, k_ra8_sram_ecc_with_chk, k_ra8_sram_on_error_interrupt, k_ra8_sram_region_128kb, ra8_sram_bank_cfg_t::on_error, RA8_INTERNAL, ra8_sram_get_bank_info(), ra8_sram_init(), s_ecc_buf, and ra8_sram_bank_cfg_t::zero_init.
|
static |
Park forever after a fatal ECC demo initialization failure.
Repeatedly executes WFI while preserving SRAM status for debug.
Definition at line 139 of file main.c.
References RA8_INTERNAL.
|
static |
Calculate the deterministic read/write test pattern for one word.
Squares the index with defined unsigned wraparound and XORs the fixed salt so neighboring test words differ.
| [in] | i | Zero-based word index. |
| 0..UINT32_MAX | Deterministic wrapped arithmetic result. |
Definition at line 160 of file main.c.
References k_ecc_demo_pat_xor, and RA8_INTERNAL.
Referenced by internal_sample().
|
staticnodiscard |
Round-trip a pattern through the ECC-protected buffer, then read the ECC status, and fold both into the verdict.
| [out] | out_ok | 1 when the buffer read back exactly AND no 1-bit or 2-bit ECC error is latched. |
| k_ra8_err_null_ptr | out_ok was NULL. |
Definition at line 270 of file main.c.
References g_ecc_1bit, g_ecc_2bit, g_ecc_esr, g_ecc_rw_ok, internal_pattern(), k_ecc_demo_test_words, k_ra8_err_not_initialized, k_ra8_ok, ra8_sram_status_t::one_bit_mask, RA8_CHECK_NULL_PTR, RA8_INTERNAL, ra8_sram_get_status(), ra8_sram_status_t::raw_esr, s_ecc_buf, s_tag, and ra8_sram_status_t::two_bit_mask.
|
static |
Bring CGC, SysTick, SCI8, LEDs, and MSTP up.
Initializes foreground-loop dependencies in order and parks on the first failed HAL operation.
Definition at line 176 of file main.c.
References internal_panic_halt(), k_ecc_demo_baud, k_ra8_board_led1, k_ra8_board_led2, k_ra8_clock_id_cpuclk0, k_ra8_ok, ra8_board_led_init(), ra8_board_uart_console_init(), ra8_cgc_get_clock_hz(), ra8_cgc_init(), RA8_INTERNAL, ra8_mstp_init(), and ra8_time_init().
| 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.
Definition at line 305 of file main.c.
References g_ecc_heartbeat, g_ecc_ok, internal_configure(), internal_panic_halt(), internal_sample(), internal_setup_or_halt(), k_ecc_demo_period_ms, k_ra8_board_led1, k_ra8_board_led2, k_ra8_ok, ra8_board_led_toggle(), ra8_board_uart_console_write(), ra8_delay_ms(), ra8_isr_globals_enable(), s_ecc_demo_bad_msg, and s_ecc_demo_ok_msg.
| volatile uint32_t g_ecc_1bit = 0U |
Per-bank 1-bit-error bitmap from the last SRAMESR read (bit n = bank n).
Definition at line 108 of file main.c.
Referenced by internal_sample().
| volatile uint32_t g_ecc_2bit = 0U |
Per-bank 2-bit-error bitmap from the last SRAMESR read (bit n = bank n).
Definition at line 116 of file main.c.
Referenced by internal_sample().
| volatile uint32_t g_ecc_esr = 0U |
Last raw SRAMESR snapshot (0 = no ECC error latched).
Definition at line 100 of file main.c.
Referenced by internal_sample().
| volatile uint32_t g_ecc_heartbeat = 0U |
| volatile uint32_t g_ecc_ok = 0U |
| volatile uint32_t g_ecc_rw_ok = 0U |
1 when the ECC-protected buffer read back exactly.
Definition at line 92 of file main.c.
Referenced by internal_sample().
|
static |
Base of the ECC-protected bank, resolved at init.
Definition at line 127 of file main.c.
Referenced by internal_configure(), and internal_sample().
|
static |
|
static |