|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
App-shell chrome: launch reader / library / settings apps (#146 Ph2). More...
#include <stddef.h>#include <stdint.h>#include "ra8_app.h"#include "ra8_attributes.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_shell_ctx_t |
| Per-app stub state: a display name + lifecycle-call counters. More... | |
Macros | |
| #define | APP_SHELL_SETTINGS (1) |
| Build-time selector for the optional settings app (#146 exclusion). | |
Enumerations | |
| enum | app_shell_hil_t : uint32_t { k_app_shell_hil_baud = 115200U } |
| VCOM-console line rate for the deterministic HIL success banner. More... | |
| enum | app_shell_id_t : uint16_t { k_app_id_library = 1U , k_app_id_reader = 2U , k_app_id_settings = 3U } |
| Registered app ids (launch keys). More... | |
| enum | app_shell_const_t : uint16_t { k_app_reg_cap = 3U , k_app_nav_cap = 4U , k_app_idx_library = 0U , k_app_btn_back = 1U } |
| Capacities, the launcher tile index, and the chrome button id. More... | |
Functions | |
| static bool | app_shell_hil_console_init (void) |
| Bring up the SCI8 / J-Link OB VCOM console for the HIL success banner. | |
| static void | app_shell_hil_emit_pass (void) |
| Emit the deterministic HIL success banner over the VCOM console. | |
| static ra8_err_t | app_stub_init (ra8_app_t *a) |
| Stub init: count the one-time setup and log it (runs at register). | |
| 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 void | app_stub_deinit (ra8_app_t *a) |
| Stub deinit: count the teardown and log it (wired, not yet fired). | |
| static bool | app_shell_add (ra8_app_t *app, app_shell_ctx_t *ctx, uint16_t id, const char *name, bool removable) |
| Build one app instance from the shared vtable and register it. | |
| static bool | app_shell_register (void) |
| Initialise the registry + back-stack and register every app. | |
| static void | app_shell_log_menu (void) |
| Log the launcher "menu": every registered app, its id, and its class. | |
| static bool | app_shell_launch_library (void) |
| Launcher: list the apps then launch library by its registry index. | |
| static bool | app_shell_open_reader (void) |
| Open reader from library, then route a back-button event to it. | |
| static bool | app_shell_settings_round_trip (void) |
| Open settings from reader, then go "back" to reader. | |
| static bool | app_shell_back_to_root (void) |
| Press "back" to the root: pop to library and confirm the empty trail. | |
| static bool | app_shell_uninstall_demo (void) |
| Exercise the run-time "core uninstallable" rule: refuse core, unmount one. | |
| static bool | app_shell_selfcheck (void) |
| Run the whole deterministic launcher + navigate + back-stack surface. | |
| static void | app_shell_banner (void) |
| Emit the PASS banner: app count, library enters, and the PASS line. | |
| void | main (void) |
| App entry: register the apps, run the launcher self-check, emit PASS. | |
Variables | |
| static const uint8_t | k_app_shell_pass_banner [] = "app_shell_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_shell_ctx_t | s_library_ctx = {.name = "library"} |
| Stub state for the core library app. | |
| static ra8_app_t | s_library_app |
| The core library app instance (registered into s_reg). | |
| static app_shell_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_shell_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). | |
App-shell chrome: launch reader / library / settings apps (#146 Ph2).
The chrome / "shell" increment of the app framework (issue #146, Phase 2). It builds on the Phase-1 ra8_app registry + per-app vtable + navigation back-stack (app_launch_demo) and adds the piece a home screen needs: a small launcher that lists the registered apps and launches the one the user picks, with "back" unwinding the navigation trail. No display and no widgets this increment – the path is observable headlessly on ra8_emulator through the ITM log (each line shows up as [itm] ...).
What it does, acting as the device "chrome":
Each stub app's callbacks just count and log their lifecycle (no real UI). A deterministic self-check asserts the exact call counts + back-stack depth at every step, then emits:
[app_shell] INFO: app_shell_demo PASS (ra8_emulator: [itm] [app_shell] INFO: app_shell_demo PASS)
so the app doubles as a ra8_emulator regression gate; any failure logs a FAIL ... line and parks in WFI.
After the navigation legs the shell exercises the run-time "core uninstallable" rule: it asks the framework to uninstall the core library app (refused, k_ra8_err_not_supported) and then the removable settings app (unmounted – its deinit fires and it leaves the registry), proving the removable flag has teeth at run time and not just at build time.
[Ring 6 / APP] {World: S}
Definition in file main.c.
| #define APP_SHELL_SETTINGS (1) |
Build-time selector for the optional settings app (#146 exclusion).
APP SHELL SETTINGS.
Defaults to 1 (settings shipped). Define it to 0 at configure time (-DAPP_SHELL_SETTINGS=0) to exclude the removable settings app from the registry, demonstrating the "core uninstallable" build-time-exclusion path: the shell still builds and runs, with settings simply absent and the settings navigation leg skipped.
| enum app_shell_const_t : uint16_t |
Capacities, the launcher tile index, and the chrome button id.
| enum app_shell_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_shell_hil_baud | VCOM console line rate (8N1). |
| enum app_shell_id_t : uint16_t |
|
static |
Build one app instance from the shared vtable and register it.
Fills app with the shared k_app_stub_vt, the supplied ctx / id / name / removable flag, and registers it into s_reg (which runs its init). Factored out so app_shell_register stays short.
| [out] | app | App instance storage to populate (non-NULL). |
| [in,out] | ctx | Per-app stub state the vtable keys off (non-NULL). |
| [in] | id | Unique launch id. |
| [in] | name | Display name + log tag (non-NULL, static lifetime). |
| [in] | removable | Optional/uninstallable flag (false = core). |
| true | Registered + initialised. |
| false | Registration failed (duplicate id, full, or init error). |
app, ctx, and name are non-NULL. Definition at line 495 of file main.c.
References k_app_stub_vt, k_ra8_ok, app_shell_ctx_t::name, ra8_app_register(), and s_reg.
Referenced by app_shell_register().
|
static |
Press "back" to the root: pop to library and confirm the empty trail.
ra8_app_nav_back pops the last remembered app (library): the foreground app leaves, library.on_enter fires (its second enter), and the back-stack empties (depth 0). Works in both builds: the foreground app is reader (no settings) or reader again after the settings round-trip.
| true | library.enters == 2, the app was popped, and depth == 0. |
| false | The nav call failed, nothing popped, or a counter mismatched. |
Definition at line 755 of file main.c.
References k_ra8_ok, ra8_app_nav_back(), ra8_app_nav_depth(), s_library_ctx, and s_nav.
Referenced by app_shell_selfcheck().
|
static |
Emit the PASS banner: app count, library enters, and the PASS line.
The app count is two in both builds, but for different reasons: without settings only library + reader ever register (build-time exclusion); with settings all three register and the run-time uninstall leg then unmounts settings, leaving the same two. The library-enter count proves the back-stack returned focus to the root.
Definition at line 904 of file main.c.
References app_shell_hil_emit_pass(), ra8_app_count(), ra8_log_info, ra8_log_info_val, s_library_ctx, and s_reg.
Referenced by main().
|
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_shell_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 128 of file main.c.
References k_app_shell_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_shell_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 157 of file main.c.
References k_app_shell_pass_banner, ra8_board_uart_console_flush(), and ra8_board_uart_console_write().
Referenced by app_shell_banner().
|
static |
Launcher: list the apps then launch library by its registry index.
Shows the menu, then launches the app at k_app_idx_library through ra8_app_nav_go_index – the by-position launcher bridge. The first launch has no prior focus, so it pushes nothing: the back-stack stays empty and only library.on_enter fires. The chrome then renders the foreground app once.
| true | enters == 1 and depth == 0 after the launch + render. |
| false | Any launcher/nav/render call failed or a counter mismatched. |
Definition at line 602 of file main.c.
References app_shell_log_menu(), k_app_idx_library, k_ra8_ok, ra8_app_nav_depth(), ra8_app_nav_go_index(), ra8_app_render(), s_library_ctx, s_nav, and s_reg.
Referenced by app_shell_selfcheck().
|
static |
Log the launcher "menu": every registered app, its id, and its class.
Enumerates the registry the way a home screen would (ra8_app_count + ra8_app_at) and logs each app as [name] INFO: core|removable=<id>. This is the launcher's list view (text stand-in for the on-screen tiles). The loop is bounded by the registry capacity (k_app_reg_cap), so it is statically provable (NASA Rule 2).
Definition at line 566 of file main.c.
References k_app_reg_cap, k_ra8_ok, ra8_app_at(), ra8_app_count(), ra8_log_info_val, RA8_LOOP_BOUND, and s_reg.
Referenced by app_shell_launch_library().
|
static |
Open reader from library, then route a back-button event to it.
ra8_app_nav_go(reader) fires library.on_leave then reader.on_enter and pushes library (depth 1); the chrome renders the new foreground app. Then a back-button event is routed through ra8_app_route_input to prove the event leg of the vtable: reader.on_input counts and consumes it (focus unchanged).
| true | library.leaves == 1, reader.enters == 1, reader.inputs == 1, the event was handled, and depth == 1. |
| false | Any nav/render/route call failed or a counter mismatched. |
Definition at line 644 of file main.c.
References k_app_btn_back, k_app_id_reader, k_ra8_ok, k_ra8_widget_ev_button, ra8_app_nav_depth(), ra8_app_nav_go(), ra8_app_render(), ra8_app_route_input(), s_library_ctx, s_nav, s_reader_ctx, and s_reg.
Referenced by app_shell_selfcheck().
|
static |
Initialise the registry + back-stack and register every app.
Binds s_reg and s_nav to their caller-owned storage, then registers the core library and reader apps (non-removable) and – when APP_SHELL_SETTINGS is on – the optional settings app (removable). 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 523 of file main.c.
References app_shell_add(), k_app_id_library, k_app_id_reader, k_app_id_settings, k_app_nav_cap, k_app_reg_cap, k_ra8_ok, ra8_app_nav_init(), ra8_app_registry_init(), s_library_app, s_library_ctx, 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 |
Run the whole deterministic launcher + navigate + back-stack surface.
Composes app_shell_launch_library, app_shell_open_reader, the optional app_shell_settings_round_trip (only when settings ships), app_shell_back_to_root, the optional app_shell_uninstall_demo (the run-time core-uninstallable rule, only when settings ships), and a final check that library is the active app.
| true | All sub-checks passed and library is active. |
| false | Some sub-check failed. |
Definition at line 855 of file main.c.
References app_shell_back_to_root(), app_shell_launch_library(), app_shell_open_reader(), app_shell_settings_round_trip(), app_shell_uninstall_demo(), k_app_id_library, k_ra8_ok, ra8_app_active(), and s_reg.
Referenced by main().
|
static |
Open settings from reader, then go "back" to reader.
ra8_app_nav_go(settings) fires reader.on_leave then settings.on_enter and pushes reader (depth 2); the chrome renders it. ra8_app_nav_back pops it: settings.on_leave then reader.on_enter (reader's second enter), depth back to 1.
| true | Lifecycle counts, the popped flag, and depth all matched. |
| false | Any nav/render call failed or a counter / depth mismatched. |
Definition at line 699 of file main.c.
References k_app_id_settings, k_ra8_ok, ra8_app_nav_back(), ra8_app_nav_depth(), ra8_app_nav_go(), ra8_app_render(), s_nav, s_reader_ctx, s_reg, and s_settings_ctx.
Referenced by app_shell_selfcheck().
|
static |
Exercise the run-time "core uninstallable" rule: refuse core, unmount one.
With library foreground and settings registered-but-background, asks the framework to uninstall the core library app – refused with k_ra8_err_not_supported, nothing torn down – and then the removable settings app, which unmounts: its deinit fires once, it leaves the registry (count drops to two), and ra8_app_state reports it as unmounted. library stays foreground (its slot precedes the removed one, so its active index is untouched).
| true | Core refused, settings deinit fired once, count == 2, settings reports unmounted. |
| false | Any uninstall returned an unexpected code or a count/state mismatched. |
Definition at line 802 of file main.c.
References k_app_id_library, k_app_id_settings, k_ra8_app_state_foreground, k_ra8_app_state_unmounted, k_ra8_err_not_supported, k_ra8_ok, ra8_app_count(), ra8_app_state(), ra8_app_uninstall(), s_library_ctx, s_reg, and s_settings_ctx.
Referenced by app_shell_selfcheck().
|
static |
Stub deinit: count the teardown and log it (wired, not yet fired).
| [in,out] | a | The app being torn down (non-NULL, ctx is app_shell_ctx_t). |
Definition at line 437 of file main.c.
References app_shell_ctx_t::deinits, app_shell_ctx_t::name, and ra8_log_info.
Stub init: count the one-time setup and log it (runs at register).
| [in,out] | a | The app being registered (non-NULL, ctx is app_shell_ctx_t). |
| k_ra8_ok | Setup recorded. |
Definition at line 338 of file main.c.
References app_shell_ctx_t::inits, k_ra8_ok, app_shell_ctx_t::name, and ra8_log_info.
|
static |
Stub on_enter: count the focus gain and log it.
| [in,out] | a | The app gaining focus (non-NULL, ctx is app_shell_ctx_t). |
Definition at line 356 of file main.c.
References app_shell_ctx_t::enters, app_shell_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 app_shell_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 412 of file main.c.
References ra8_widget_event_t::button_id, app_shell_ctx_t::inputs, k_app_btn_back, k_ra8_widget_ev_button, ra8_widget_event_t::kind, app_shell_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 app_shell_ctx_t). |
Definition at line 373 of file main.c.
References app_shell_ctx_t::leaves, app_shell_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 app_shell_ctx_t). |
Definition at line 391 of file main.c.
References app_shell_ctx_t::name, ra8_log_info, and app_shell_ctx_t::renders.
| void main | ( | void | ) |
App entry: register the apps, run the launcher self-check, emit PASS.
The application entry point Reset_Handler hands control to.
Definition at line 925 of file main.c.
References app_shell_banner(), app_shell_hil_console_init(), app_shell_register(), app_shell_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 launcher + navigation 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 104 of file main.c.
Referenced by app_shell_hil_emit_pass().
|
static |
Shared lifecycle vtable for every stub app (behaviour keyed off ctx).
Every callback except tick is wired (init / on_enter / render / on_input / on_leave / deinit); tick stays NULL to prove the framework tolerates a partial vtable.
|
static |
The core library app instance (registered into s_reg).
Definition at line 281 of file main.c.
Referenced by app_shell_register().
|
static |
Stub state for the core library app.
Definition at line 272 of file main.c.
Referenced by app_shell_back_to_root(), app_shell_banner(), app_shell_launch_library(), app_shell_open_reader(), app_shell_register(), and app_shell_uninstall_demo().
|
static |
|
static |
Caller-owned storage backing the navigation back-stack (app ids).
|
static |
The core reader app instance (registered into s_reg).
|
static |
|
static |
|
static |
The optional settings app instance (registered into s_reg).
|
static |
Stub state for the optional settings app.
|
static |
Caller-owned storage backing the registry's app-pointer table.