|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
DOTF (Decryption On The Fly) bring-up + AES self-test 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_dotf.h"#include "ra8_err.h"#include "ra8_isr.h"#include "ra8_mstp.h"#include "ra8_time.h"Go to the source code of this file.
Enumerations | |
| enum | dotf_demo_config_t : uint32_t { k_dotf_demo_baud = 115200U , k_dotf_demo_period_ms = 1000U } |
| Compile-time settings. More... | |
| enum | dotf_demo_chan_t : uint8_t { k_dotf_demo_ch0 = 0U , k_dotf_demo_ch1 = 1U } |
| DOTF channels exercised by the demo. More... | |
| enum | dotf_demo_sentinel_t : uint32_t { k_dotf_demo_err_unset = 0xFFFFFFFFU } |
| Sentinel for "ra8_dotf_init has not run yet" in g_dotf_init_err. More... | |
Functions | |
| static void | internal_dotf_demo_panic_halt (void) |
| Park the processor after an unrecoverable DOTF demo failure. | |
| static void | internal_dotf_demo_setup_or_halt (void) |
| Bring CGC, SysTick, SCI8, LEDs, and MSTP up. | |
| static uint8_t | internal_dotf_demo_verdict (ra8_err_t st0_err, ra8_err_t st1_err, ra8_err_t status_err) |
| Verdict: both channels' self-test + status calls succeeded. | |
| static ra8_err_t | internal_dotf_demo_sample (uint8_t *out_ok) |
| Self-test both channels and read REG00 back; fold into the verdict. | |
| void | main (void) |
| The application entry point Reset_Handler hands control to. | |
Variables | |
| static const char * | s_tag = "dotf_demo" |
| Diagnostic / log tag. | |
| static const uint8_t | s_dotf_demo_ok_msg [] = "dotf: ch0/1 init=ok selftest=run ok=Y\r\n" |
| Output line tags. | |
| static const uint8_t | s_dotf_demo_bad_msg [] = "dotf: selftest=FAIL ok=N\r\n" |
| volatile uint32_t | g_dotf_ok = 0U |
| 1 when both channels' self-test + status calls returned k_ra8_ok. | |
| volatile uint32_t | g_dotf_init_err = (uint32_t)k_dotf_demo_err_unset |
| ra8_err_t from ra8_dotf_init (0 == k_ra8_ok). | |
| volatile uint32_t | g_dotf_reg00 = 0U |
| Last REG00 snapshot from ra8_dotf_get_status(ch0). | |
| volatile uint32_t | g_dotf_st0_snap = 0U |
| Channel-0 self-test REG00 snapshot (opaque on host / off-target). | |
| volatile uint32_t | g_dotf_st1_snap = 0U |
| Channel-1 self-test REG00 snapshot (opaque on host / off-target). | |
| volatile uint32_t | g_dotf_heartbeat = 0U |
| Bumps once per main-loop pass – liveness for headless probes. | |
DOTF (Decryption On The Fly) bring-up + AES self-test demo (EK-RA8D2).
The RA8D2 DOTF block (HUM Ch 45 p 3048..3050) transparently decrypts read traffic on the AXI side of the OSPI / xSPI controller using an AES core in CTR mode, so encrypted code in external flash can execute in place. The block also exposes a built-in AES self-test (HUM Ch 45.1 p 3048, "Supports self-test function"), triggered by REG00 bit 20.
This demo exercises the safe, key-free half of the driver only:
What this demo deliberately does NOT do: install a key, stage an IV, program a conversion region, or ra8_dotf_enable a channel. Arming the AES core over a live XiP window would fault the next instruction fetch (HUM Ch 45 warning), and key handling needs an ra8_rsip-wrapped key. None of that is touched here – both channels stay in transparent bypass, so the demo writes no keys, IV, region, OTP, option-setting, or flash. It is a read-mostly bring-up probe with no persistent side effects.
Bring-up: CGC + SysTick + SCI8 + LEDs + MSTP. Once a second: "dotf: ch0/1 init=ok selftest=run ok=Y\r\n". The raw REG00 snapshots go to g_dotf_reg00 / g_dotf_st0_snap / g_dotf_st1_snap for on-silicon probing. LED1 toggles while healthy; LED2 toggles on a fault.
Bare EK-RA8D2 only – no shields or external transceivers.
Definition in file main.c.
| enum dotf_demo_chan_t : uint8_t |
| enum dotf_demo_config_t : uint32_t |
| enum dotf_demo_sentinel_t : uint32_t |
|
static |
Park the processor after an unrecoverable DOTF demo failure.
Retains channel status snapshots, LEDs, and console diagnostics in a permanent wait-for-interrupt loop for debugger inspection.
Definition at line 154 of file main.c.
References RA8_INTERNAL.
Referenced by internal_dotf_demo_setup_or_halt(), and main().
|
staticnodiscard |
Self-test both channels and read REG00 back; fold into the verdict.
| [out] | out_ok | 1 when both self-test calls AND the status read returned k_ra8_ok. The opaque REG00 snapshots are reported via globals, not gated (ra8_emulator does not model the AES core). |
| k_ra8_err_null_ptr | out_ok was NULL. |
Definition at line 249 of file main.c.
References g_dotf_reg00, g_dotf_st0_snap, g_dotf_st1_snap, internal_dotf_demo_verdict(), k_dotf_demo_ch0, k_dotf_demo_ch1, k_ra8_ok, RA8_CHECK_NULL_PTR, ra8_dotf_get_status(), ra8_dotf_run_self_test(), RA8_INTERNAL, and s_tag.
Referenced by main().
|
static |
Bring CGC, SysTick, SCI8, LEDs, and MSTP up.
Initializes clock and module-stop services, starts the millisecond time base, opens the UART console, and claims both status LEDs. Any failed dependency enters the permanent panic halt.
Definition at line 178 of file main.c.
References internal_dotf_demo_panic_halt(), k_dotf_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().
Referenced by main().
|
staticnodiscard |
Verdict: both channels' self-test + status calls succeeded.
| [in] | st0_err | ra8_err_t from ra8_dotf_run_self_test(ch0). |
| [in] | st1_err | ra8_err_t from ra8_dotf_run_self_test(ch1). |
| [in] | status_err | ra8_err_t from ra8_dotf_get_status(ch0). |
Definition at line 224 of file main.c.
References k_ra8_ok.
Referenced by internal_dotf_demo_sample().
| 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.
Definition at line 275 of file main.c.
References g_dotf_heartbeat, g_dotf_init_err, g_dotf_ok, internal_dotf_demo_panic_halt(), internal_dotf_demo_sample(), internal_dotf_demo_setup_or_halt(), k_dotf_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_dotf_init(), ra8_isr_globals_enable(), s_dotf_demo_bad_msg, and s_dotf_demo_ok_msg.
| volatile uint32_t g_dotf_heartbeat = 0U |
| volatile uint32_t g_dotf_init_err = (uint32_t)k_dotf_demo_err_unset |
| volatile uint32_t g_dotf_ok = 0U |
| volatile uint32_t g_dotf_reg00 = 0U |
Last REG00 snapshot from ra8_dotf_get_status(ch0).
Definition at line 112 of file main.c.
Referenced by internal_dotf_demo_sample().
| volatile uint32_t g_dotf_st0_snap = 0U |
Channel-0 self-test REG00 snapshot (opaque on host / off-target).
Definition at line 120 of file main.c.
Referenced by internal_dotf_demo_sample().
| volatile uint32_t g_dotf_st1_snap = 0U |
Channel-1 self-test REG00 snapshot (opaque on host / off-target).
Definition at line 128 of file main.c.
Referenced by internal_dotf_demo_sample().
|
static |
|
static |