|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Minimal chrome stub: register apps + launch + back-stack (#146). More...
#include <stddef.h>#include <stdint.h>#include "ra8_app.h"#include "ra8_board_ek_ra8d2_peripherals.h"#include "ra8_boot_entry.h"#include "ra8_cgc.h"#include "ra8_err.h"#include "ra8_log.h"#include "ra8_widget.h"Go to the source code of this file.
Data Structures | |
| struct | app_launch_ctx_t |
| Per-app stub state: a display name + lifecycle-call counters. More... | |
Macros | |
| #define | APP_LAUNCH_SETTINGS (1) |
| Build-time selector for the optional settings app (#146 exclusion). | |
Enumerations | |
| enum | app_launch_hil_t : uint32_t { k_app_launch_hil_baud = 115200U } |
| VCOM-console line rate for the deterministic HIL success banner. More... | |
| enum | app_launch_id_t : uint16_t { k_app_id_reader = 1U , k_app_id_settings = 2U } |
| Registered app ids (launch keys). More... | |
| enum | app_launch_const_t : uint16_t { k_app_reg_cap = 2U , k_app_nav_cap = 4U , k_app_btn_back = 1U } |
| Capacities + the button id the stub apps understand. More... | |
Functions | |
| static bool | app_launch_hil_console_init (void) |
| Bring up the SCI8 / J-Link OB VCOM console for the HIL success banner. | |
| static void | app_launch_hil_emit_pass (void) |
| Emit the deterministic HIL success banner over the VCOM console. | |
| static void | app_stub_on_enter (ra8_app_t *a) |
| Stub on_enter: count the focus gain and log it. | |
| static void | app_stub_on_leave (ra8_app_t *a) |
| Stub on_leave: count the focus loss and log it. | |
| static void | app_stub_render (const ra8_app_t *a) |
| Stub render: count the frame and log it (stands in for drawing). | |
| static bool | app_stub_on_input (ra8_app_t *a, const ra8_widget_event_t *ev) |
| Stub on_input: count the event, consume only the "back" button. | |
| static bool | app_launch_register (void) |
| Initialise the registry + back-stack and register every app. | |
| static bool | app_launch_enter_reader (void) |
| Launch the reader app from the chrome and verify first focus. | |
| static bool | app_launch_route_back (void) |
| Route a back-button event through the chrome to the active app. | |
| static bool | app_launch_switch_and_back (void) |
| Switch reader -> settings and back, verifying the focus + back-stack. | |
| static bool | app_launch_selfcheck (void) |
| Run the whole deterministic registry + launch + back-stack surface. | |
| static void | app_launch_banner (void) |
| Emit the PASS banner: app count, reader enters, and the PASS line. | |
| void | main (void) |
| App entry: register the apps, run the self-check, emit PASS, park. | |
Variables | |
| static const uint8_t | k_app_launch_pass_banner [] = "app_launch_demo: demo PASS\r\n" |
| Deterministic, run-to-run-stable HIL success banner (uart_scrape gate). | |
| static ra8_app_registry_t | s_reg |
| The app registry (single active app + membership table). | |
| static ra8_app_t * | s_slots [k_app_reg_cap] |
| Caller-owned storage backing the registry's app-pointer table. | |
| static uint16_t | s_nav_stack [k_app_nav_cap] |
| Caller-owned storage backing the navigation back-stack (app ids). | |
| static ra8_app_nav_t | s_nav |
| Navigation back-stack layered over s_reg. | |
| static app_launch_ctx_t | s_reader_ctx = {.name = "reader"} |
| Stub state for the core reader app. | |
| static ra8_app_t | s_reader_app |
| The core reader app instance (registered into s_reg). | |
| static app_launch_ctx_t | s_settings_ctx = {.name = "settings"} |
| Stub state for the optional settings app. | |
| static ra8_app_t | s_settings_app |
| The optional settings app instance (registered into s_reg). | |
| static const ra8_app_vtable_t | k_app_stub_vt |
| Shared lifecycle vtable for every stub app (behaviour keyed off ctx). | |
Minimal chrome stub: register apps + launch + back-stack (#146).
The first runnable increment of the app framework (#146). It proves the ra8_app registry + launcher + the navigation back-stack (ra8_app_nav_t) end-to-end on the real Cortex-M85 image – no display, no widgets, just the lifecycle and routing so the path is observable headlessly on ra8_emulator via the ITM log (each line shows up as [itm] ...).
What it does, acting as a tiny "chrome" / shell:
Each stub app is a function-pointer vtable (init / on_enter / tick / render / on_input / on_leave / deinit) plus the removable flag; the stubs just count their lifecycle calls and log them. A deterministic self-check asserts the exact call counts and back-stack depth at every step, then emits:
[app_launch] INFO: demo PASS (ra8_emulator: [itm] [app_launch] INFO: demo PASS)
so the app doubles as a ra8_emulator regression gate; any failure logs a FAIL ... line and parks in WFI.
[Ring 6 / APP] {World: S}
Definition in file main.c.
| #define APP_LAUNCH_SETTINGS (1) |
Build-time selector for the optional settings app (#146 exclusion).
APP LAUNCH SETTINGS.
Defaults to 1 (settings shipped). Define it to 0 at configure time (-DAPP_LAUNCH_SETTINGS=0) to exclude the removable settings app from the registry, demonstrating the "core uninstallable" build-time-exclusion path: the firmware still builds and runs, with settings simply absent.
| enum app_launch_const_t : uint16_t |
| enum app_launch_hil_t : uint32_t |
VCOM-console line rate for the deterministic HIL success banner.
The EK-RA8D2 J-Link OB VCOM bridge (SCI8, PD02/PD03) runs 8N1 at this rate; the Pi HIL rig's uart_scrape reads /dev/ttyACM0 to gate the app. The banner is additive to the existing ra8_log ITM trace.
| Enumerator | |
|---|---|
| k_app_launch_hil_baud | VCOM console line rate (8N1). |
| enum app_launch_id_t : uint16_t |
|
static |
Emit the PASS banner: app count, reader enters, and the PASS line.
The app count proves the build-time exclusion (2 with settings, 1 without); the reader-enter count proves the back-stack returned focus.
Definition at line 609 of file main.c.
References app_launch_hil_emit_pass(), ra8_app_count(), ra8_log_info, ra8_log_info_val, s_reader_ctx, and s_reg.
Referenced by main().
|
static |
Launch the reader app from the chrome and verify first focus.
The first ra8_app_nav_go has no prior focus, so it pushes nothing: the back-stack stays empty and only reader.on_enter fires. Then the chrome renders the foreground app once.
| true | enters == 1 and depth == 0 after the launch + render. |
| false | Any nav/render call failed or a counter mismatched. |
Definition at line 447 of file main.c.
References k_app_id_reader, k_ra8_ok, ra8_app_nav_depth(), ra8_app_nav_go(), ra8_app_render(), s_nav, s_reader_ctx, and s_reg.
Referenced by app_launch_selfcheck().
|
static |
Bring up the SCI8 / J-Link OB VCOM console for the HIL success banner.
Configures the clock tree (ra8_cgc_init, which publishes the PCLKA the SCI8 BRR divisor is computed from) then the EK-RA8D2 debug console (ra8_board_uart_console_init, SCI8 on PD02/PD03 at k_app_launch_hil_baud). Best-effort: a failure only means the additive HIL banner cannot reach the host; the existing ra8_log ITM trace and the demo logic are unaffected.
| true | Clock + SCI8 console are up. |
| false | A bring-up step failed (the banner is then silently skipped). |
Definition at line 106 of file main.c.
References k_app_launch_hil_baud, k_ra8_ok, ra8_board_uart_console_init(), and ra8_cgc_init().
Referenced by main().
|
static |
Emit the deterministic HIL success banner over the VCOM console.
Writes k_app_launch_pass_banner to the SCI8 / J-Link OB VCOM console and flushes it so the bytes clock out before the CPU parks in WFI. A no-op if the console never came up (the write returns k_ra8_err_not_initialized, ignored).
Definition at line 135 of file main.c.
References k_app_launch_pass_banner, ra8_board_uart_console_flush(), and ra8_board_uart_console_write().
Referenced by app_launch_banner().
|
static |
Initialise the registry + back-stack and register every app.
Binds s_reg and s_nav to their caller-owned storage, builds the core reader app (non-removable) and – when APP_LAUNCH_SETTINGS is on – the optional settings app (removable), and registers each. Any failure short- circuits to a false return so main can log and park.
| true | Every ra8_app_*_init / ra8_app_register returned k_ra8_ok. |
| false | Some init/register step failed. |
Definition at line 400 of file main.c.
References k_app_id_reader, k_app_id_settings, k_app_nav_cap, k_app_reg_cap, k_app_stub_vt, k_ra8_ok, ra8_app_nav_init(), ra8_app_register(), ra8_app_registry_init(), s_nav, s_nav_stack, s_reader_app, s_reader_ctx, s_reg, s_settings_app, s_settings_ctx, and s_slots.
Referenced by main().
|
static |
Route a back-button event through the chrome to the active app.
Proves the "event" leg of the vtable: ra8_app_route_input delivers the event to the foreground app's on_input, which counts it and consumes the back button. Focus is unchanged (the stub just reports it handled the event).
| true | out_handled was true and reader.inputs == 1. |
| false | Routing failed, was not handled, or the counter mismatched. |
Definition at line 485 of file main.c.
References k_app_btn_back, k_ra8_ok, k_ra8_widget_ev_button, ra8_app_route_input(), s_reader_ctx, and s_reg.
Referenced by app_launch_selfcheck().
|
static |
Run the whole deterministic registry + launch + back-stack surface.
Composes app_launch_enter_reader, the optional app_launch_switch_and_back (only when settings ships), and a final check that reader is the active app.
| true | All sub-checks passed and reader is active. |
| false | Some sub-check failed. |
Definition at line 571 of file main.c.
References app_launch_enter_reader(), app_launch_route_back(), app_launch_switch_and_back(), k_app_id_reader, k_ra8_ok, ra8_app_active(), and s_reg.
Referenced by main().
|
static |
Switch reader -> settings and back, verifying the focus + back-stack.
ra8_app_nav_go(settings) fires reader.on_leave then settings.on_enter and pushes reader (depth 1). ra8_app_nav_back pops it: settings.on_leave then reader.on_enter (reader's second enter), depth back to 0.
| true | Lifecycle counts and the popped flag all matched. |
| false | Any nav call failed or a counter / depth mismatched. |
Definition at line 520 of file main.c.
References k_app_id_settings, k_ra8_ok, ra8_app_nav_back(), ra8_app_nav_depth(), ra8_app_nav_go(), s_nav, s_reader_ctx, and s_settings_ctx.
Referenced by app_launch_selfcheck().
|
static |
Stub on_enter: count the focus gain and log it.
| [in,out] | a | The app gaining focus (non-NULL, ctx is an app_launch_ctx_t). |
Definition at line 290 of file main.c.
References app_launch_ctx_t::enters, app_launch_ctx_t::name, and ra8_log_info.
|
static |
Stub on_input: count the event, consume only the "back" button.
| [in,out] | a | The foreground app (non-NULL, ctx is an app_launch_ctx_t). |
| [in] | ev | The input event (non-NULL). |
| true | ev is a k_app_btn_back button press. |
| false | Any other event (the chrome keeps routing it). |
Definition at line 342 of file main.c.
References ra8_widget_event_t::button_id, app_launch_ctx_t::inputs, k_app_btn_back, k_ra8_widget_ev_button, ra8_widget_event_t::kind, app_launch_ctx_t::name, and ra8_log_info.
|
static |
Stub on_leave: count the focus loss and log it.
| [in,out] | a | The app losing focus (non-NULL, ctx is an app_launch_ctx_t). |
Definition at line 306 of file main.c.
References app_launch_ctx_t::leaves, app_launch_ctx_t::name, and ra8_log_info.
|
static |
Stub render: count the frame and log it (stands in for drawing).
| [in] | a | The foreground app (non-NULL, ctx is an app_launch_ctx_t). |
Definition at line 322 of file main.c.
References app_launch_ctx_t::name, ra8_log_info, and app_launch_ctx_t::renders.
| void main | ( | void | ) |
App entry: register the apps, run the self-check, emit PASS, park.
The application entry point Reset_Handler hands control to.
Definition at line 631 of file main.c.
References app_launch_banner(), app_launch_hil_console_init(), app_launch_register(), app_launch_selfcheck(), ra8_log_info, and ra8_log_init().
|
static |
Deterministic, run-to-run-stable HIL success banner (uart_scrape gate).
Emitted over the SCI8 / J-Link OB VCOM console only on the success path, AFTER the registry + launcher self-check passes. The ITM ra8_log verdict is left intact; this is purely additive so the Pi rig (which has no SWO / ITM capture) can gate the app.
Definition at line 82 of file main.c.
Referenced by app_launch_hil_emit_pass().
|
static |
Shared lifecycle vtable for every stub app (behaviour keyed off ctx).
init, tick, and deinit are unused here (NULL = no-op), proving the framework tolerates partial vtables.
Definition at line 364 of file main.c.
Referenced by app_launch_register(), and app_shell_add().
|
static |
Navigation back-stack layered over s_reg.
Definition at line 236 of file main.c.
Referenced by app_launch_enter_reader(), app_launch_register(), app_launch_switch_and_back(), app_shell_back_to_root(), app_shell_launch_library(), app_shell_open_reader(), app_shell_register(), app_shell_settings_round_trip(), er_handle_keyboard_tap(), er_handle_reading_tap(), er_handle_tap(), er_poll_buttons(), er_render_current(), er_render_nag_region(), main(), and wd_build_tree().
|
static |
Caller-owned storage backing the navigation back-stack (app ids).
Definition at line 227 of file main.c.
Referenced by app_launch_register(), and app_shell_register().
|
static |
The core reader app instance (registered into s_reg).
Definition at line 254 of file main.c.
Referenced by app_launch_register(), and app_shell_register().
|
static |
Stub state for the core reader app.
Definition at line 245 of file main.c.
Referenced by app_launch_banner(), app_launch_enter_reader(), app_launch_register(), app_launch_route_back(), app_launch_switch_and_back(), app_shell_open_reader(), app_shell_register(), and app_shell_settings_round_trip().
|
static |
|
static |
The optional settings app instance (registered into s_reg).
Definition at line 273 of file main.c.
Referenced by app_launch_register(), and app_shell_register().
|
static |
Stub state for the optional settings app.
Definition at line 264 of file main.c.
Referenced by app_launch_register(), app_launch_switch_and_back(), app_shell_register(), app_shell_settings_round_trip(), and app_shell_uninstall_demo().
|
static |
Caller-owned storage backing the registry's app-pointer table.