|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
WDT supervisor abstraction HIL demo for EK-RA8D2. More...
#include <stdint.h>#include "ra8_board_ek_ra8d2.h"#include "ra8_boot_entry.h"#include "ra8_cgc.h"#include "ra8_err.h"#include "ra8_wdt.h"#include "ra8_wdt_supervisor.h"#include "tx_api.h"Go to the source code of this file.
Enumerations | |
| enum | wdt_sup_demo_const_t : uint32_t { k_wdt_sup_demo_stack_bytes = 1024U , k_wdt_sup_demo_priority = 5U , k_wdt_sup_demo_worker_a_period_ms = 100U , k_wdt_sup_demo_worker_b_period_ms = 250U , k_wdt_sup_demo_worker_a_deadline_ms = 500U , k_wdt_sup_demo_worker_b_deadline_ms = 750U , k_wdt_sup_demo_sup_period_ms = 50U } |
| Demo tunables. More... | |
| enum | wdt_sup_step_t : uint32_t { k_wdt_sup_step_start = 0U , k_wdt_sup_step_wdt_init = 1U , k_wdt_sup_step_supervisor_init = 2U , k_wdt_sup_step_worker_a_registered = 3U , k_wdt_sup_step_worker_b_registered = 4U , k_wdt_sup_step_supervisor_started = 5U } |
| Bring-up step codes for g_wdt_supervisor_demo_step (memprobe). More... | |
| enum | wdt_sup_err_sentinel_t : uint32_t { k_wdt_sup_err_none = 0xFFFFFFFFU } |
| Sentinel for g_wdt_supervisor_demo_last_err ("none yet"). More... | |
Functions | |
| static void | wdt_sup_demo_bring_up (void) |
| Bring up WWDT, supervisor, and two registered worker threads. | |
| static void | worker_a_entry (ULONG arg) |
| Worker A entry. | |
| static void | worker_b_entry (ULONG arg) |
| Worker B entry. | |
| static void | wdt_sup_demo_halt (void) |
| static void | wdt_sup_demo_spawn_workers (void) |
| Spawn the two worker threads after the supervisor is up. | |
| void | tx_application_define (void *first_unused) |
| void | main (void) |
| The application entry point Reset_Handler hands control to. | |
Variables | |
| static uint8_t | s_thread_a_stack [k_wdt_sup_demo_stack_bytes] |
| static uint8_t | s_thread_b_stack [k_wdt_sup_demo_stack_bytes] |
| static uint8_t | s_sup_stack [k_wdt_sup_demo_stack_bytes] |
| static TX_THREAD | s_thread_a |
| static TX_THREAD | s_thread_b |
| static uint8_t | s_handle_a = 0U |
| static uint8_t | s_handle_b = 0U |
| volatile uint32_t | g_wdt_supervisor_demo_tick = 0U |
| Worker-A check-in counter, read via J-Link memprobe. | |
| volatile uint32_t | g_wdt_supervisor_demo_step = k_wdt_sup_step_start |
| Bring-up step tracker, read via J-Link memprobe. | |
| volatile uint32_t | g_wdt_supervisor_demo_last_err = k_wdt_sup_err_none |
| Captures the most recent ra8_err_t / TX_SUCCESS value. | |
WDT supervisor abstraction HIL demo for EK-RA8D2.
Second of three apps under #18. Exercises libs/ra8_wdt_supervisor end-to-end on real hardware: the supervisor refreshes the WWDT only when every registered worker thread has called ra8_wdt_supervisor_checkin inside its deadline. Two synthetic worker threads (a fast 100 ms one and a slow 250 ms one) check in on disjoint cadences; the supervisor thread (auto-spawned by ra8_wdt_supervisor_start) ticks every 50 ms and decides whether to refresh the underlying WWDT.
Liveness counter g_wdt_supervisor_demo_tick is incremented by worker A each time it checks in; hil_jlink_memprobe.sh asserts the counter advances over the bench sample window.
Definition in file main.c.
| enum wdt_sup_demo_const_t : uint32_t |
Demo tunables.
| enum wdt_sup_err_sentinel_t : uint32_t |
Sentinel for g_wdt_supervisor_demo_last_err ("none yet").
| Enumerator | |
|---|---|
| k_wdt_sup_err_none | Wdt sup error none. |
| enum wdt_sup_step_t : uint32_t |
Bring-up step codes for g_wdt_supervisor_demo_step (memprobe).
| 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.
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, tracks falling SW1 edges as counter deltas, and independently increments the exported liveness counter whenever successive GPT samples advance.
The application entry point Reset_Handler hands control to.
Initializes the demo and GPT0, runs one bounded DMA request per iteration, updates the exported match/mismatch counter, and delays.
The application entry point Reset_Handler hands control to.
Initializes and arms GPT0 once, then starts, polls, records the exported pass/failure counters, toggles LED1 on completion, and delays before the next one-shot.
The application entry point Reset_Handler hands control to.
Brings up both controllers then scans each.
The application entry point Reset_Handler hands control to.
Brings up CGC + IIC_B + console then probes.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Emits the boot banner, initializes the option-controlled IWDT, samples its counter, and on legal samples queues a refresh, clears status, toggles LED1, and emits the refresh banner.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Performs one Deep-Sleep cycle, emits the wake banner, then parks in a normal blink loop.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Initializes channel zero, formats and enqueues each counter line, toggles LED1, and delays before incrementing the next sample.
The application entry point Reset_Handler hands control to.
Bench-tests SDRAM and prints MB/s.
The application entry point Reset_Handler hands control to.
Brings up SPI_B + loops a self-test pattern.
The application entry point Reset_Handler hands control to.
Configures GPIO, then launches ThreadX.
The application entry point Reset_Handler hands control to.
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 CGC + SCI8 then drops into the ThreadX scheduler.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Brings up clocks + UART + RMII pins, then enters ThreadX.
The application entry point Reset_Handler hands control to.
Raises CPUCLK0, configures LED1, launches ThreadX.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Brings up CGC + SCI8 + LED1 then prints.
The application entry point Reset_Handler hands control to.
Brings up SCI8 + ISRs, prints, then echoes via IRQ.
The application entry point Reset_Handler hands control to.
Initializes and arms ULPT0, then polls its underflow bit. Each event emits the fixed wake banner, stops the channel to clear status, and starts the next interval with the same reload.
The application entry point Reset_Handler hands control to.
Both USB controllers' clocks and pins come up before the kernel so the two workers only deal with stack bring-up.
Definition at line 300 of file main.c.
References k_ra8_ok, ra8_cgc_init(), and wdt_sup_demo_halt().
| void tx_application_define | ( | void * | first_unused | ) |
Definition at line 292 of file main.c.
References wdt_sup_demo_spawn_workers().
|
static |
Bring up WWDT, supervisor, and two registered worker threads.
Definition at line 188 of file main.c.
References g_wdt_supervisor_demo_last_err, g_wdt_supervisor_demo_step, k_ra8_ok, k_ra8_wdt_clkdiv_4, k_ra8_wdt_on_expiry_nmi, k_ra8_wdt_sleep_stop_count, k_ra8_wdt_timeout_1024, k_ra8_wdt_window_end_0, k_ra8_wdt_window_start_100, k_wdt_sup_demo_priority, k_wdt_sup_demo_stack_bytes, k_wdt_sup_demo_sup_period_ms, k_wdt_sup_demo_worker_a_deadline_ms, k_wdt_sup_demo_worker_b_deadline_ms, k_wdt_sup_step_supervisor_init, k_wdt_sup_step_supervisor_started, k_wdt_sup_step_wdt_init, k_wdt_sup_step_worker_a_registered, k_wdt_sup_step_worker_b_registered, ra8_wdt_init(), ra8_wdt_supervisor_init(), ra8_wdt_supervisor_register_thread(), ra8_wdt_supervisor_start(), s_handle_a, s_handle_b, s_sup_stack, and wdt_sup_demo_halt().
Referenced by worker_a_entry().
|
static |
Definition at line 170 of file main.c.
Referenced by main(), wdt_sup_demo_bring_up(), and wdt_sup_demo_spawn_workers().
|
static |
Spawn the two worker threads after the supervisor is up.
Definition at line 259 of file main.c.
References k_wdt_sup_demo_priority, k_wdt_sup_demo_stack_bytes, s_thread_a, s_thread_a_stack, s_thread_b, s_thread_b_stack, TX_AUTO_START, TX_NO_TIME_SLICE, TX_SUCCESS, tx_thread_create, wdt_sup_demo_halt(), worker_a_entry(), and worker_b_entry().
Referenced by tx_application_define().
|
static |
Worker A entry.
100 ms loop, checks in each iteration.
| [in] | arg | Unused. |
Definition at line 129 of file main.c.
References g_wdt_supervisor_demo_tick, k_ra8_ok, k_wdt_sup_demo_worker_a_period_ms, ra8_wdt_supervisor_checkin(), s_handle_a, tx_thread_sleep, and wdt_sup_demo_bring_up().
Referenced by wdt_sup_demo_spawn_workers().
|
static |
Worker B entry.
250 ms loop, checks in each iteration.
| [in] | arg | Unused. |
Definition at line 157 of file main.c.
References k_wdt_sup_demo_worker_b_period_ms, ra8_wdt_supervisor_checkin(), s_handle_b, and tx_thread_sleep.
Referenced by wdt_sup_demo_spawn_workers().
| volatile uint32_t g_wdt_supervisor_demo_last_err = k_wdt_sup_err_none |
Captures the most recent ra8_err_t / TX_SUCCESS value.
Stamped right after every bring-up call, so JLink can read the actual error code returned on a halt.
Definition at line 112 of file main.c.
Referenced by wdt_sup_demo_bring_up().
| volatile uint32_t g_wdt_supervisor_demo_step = k_wdt_sup_step_start |
Bring-up step tracker, read via J-Link memprobe.
Stamped at every bring-up checkpoint so a halt in wdt_sup_demo_halt can be traced back to its origin: 1 = wdt_init done, 2 = supervisor_init done, 3 = register_a done, 4 = register_b done, 5 = supervisor_start done, 6 = thread A created, 7 = thread B created. Negative-stamped (with the high bit set) on the failing step.
Definition at line 95 of file main.c.
Referenced by wdt_sup_demo_bring_up().
| volatile uint32_t g_wdt_supervisor_demo_tick = 0U |
Worker-A check-in counter, read via J-Link memprobe.
Worker A bumps this every iteration after a successful ra8_wdt_supervisor_checkin. The probe asserts the counter advances >= 3 over a 4 s window – catches "ThreadX wedged", "supervisor failed to spawn", and "worker thread crashed before first iteration".
Definition at line 69 of file main.c.
Referenced by worker_a_entry().
|
static |
Definition at line 53 of file main.c.
Referenced by wdt_sup_demo_bring_up(), and worker_a_entry().
|
static |
Definition at line 54 of file main.c.
Referenced by wdt_sup_demo_bring_up(), and worker_b_entry().
|
static |
Definition at line 50 of file main.c.
Referenced by internal_wdt_setup(), and wdt_sup_demo_bring_up().
|
static |
|
static |