|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
RA8P1 Arm Ethos-U55 NPU foundation smoke – runs a checkable stand-in job. More...
#include <stdint.h>#include "ra8_attributes.h"#include "ra8_board_ra8p1.h"#include "ra8_boot_entry.h"#include "ra8_cgc.h"#include "ra8_device.h"#include "ra8_err.h"#include "ra8_npu.h"#include "ra8_npu_fake_cmd.h"#include "ra8_npu_regs.h"Go to the source code of this file.
Enumerations | |
| enum | npu_smoke_size_t : uint32_t { k_npu_smoke_baud = 115200U , k_npu_smoke_arena_bytes = 64U , k_npu_smoke_cmd_words = k_ra8_npu_fake_word_num , k_npu_smoke_hex_digits = 8U , k_npu_smoke_hex_shift = 4U , k_npu_smoke_hex_mask = 0x0FU } |
| Command-stream / tensor-arena sizes and the console baud. More... | |
| enum | npu_smoke_region_t : uint8_t { k_npu_smoke_region_weights = 0U , k_npu_smoke_region_input = 1U , k_npu_smoke_region_output = 2U , k_npu_smoke_region_count = 3U } |
| Tensor-region indices the smoke job programs into BASEPn. More... | |
| enum | npu_smoke_seed_t : uint8_t { k_npu_smoke_addk = 0x11U , k_npu_smoke_seed_mul = 7U , k_npu_smoke_seed_add = 3U , k_npu_smoke_byte_mask = 0xFFU } |
| Deterministic input pattern + the add-constant the job applies. More... | |
| enum | npu_smoke_fnv_t : uint32_t { k_npu_smoke_fnv_offset = 0x811C9DC5U , k_npu_smoke_fnv_prime = 0x01000193U } |
| FNV-1a 32-bit constants for the displayed output checkword. More... | |
Functions | |
| static void | internal_npu_smoke_panic_halt (void) |
| Park the CPU forever in WFI after a fatal init error (a real panic). | |
| static void | internal_npu_smoke_park (void) |
| Park the CPU forever in WFI after the verdict banner (a clean stop). | |
| static void | internal_npu_smoke_setup_or_halt (void) |
| Bring up CGC + the SCI8 console. | |
| static void | internal_npu_smoke_build_stream (void) |
| Fill the command stream (add-constant op) per the stand-in convention. | |
| static void | internal_npu_smoke_seed_arenas (void) |
| Seed the input arena with a deterministic pattern and zero the output. | |
| static ra8_err_t | internal_npu_smoke_run_job (void) |
| Submit + run + wait for the NPU job. | |
| static bool | internal_npu_smoke_verify (uint32_t *out_check) |
| Verify the output arena equals input+K and fold it into a checkword. | |
| static void | internal_npu_smoke_write (const uint8_t *data, size_t len) |
| static void | internal_npu_smoke_write_hex32 (uint32_t value) |
| static void | internal_npu_smoke_write_status (bool ok) |
| static void | internal_npu_smoke_write_verdict (bool pass) |
| static void | internal_npu_smoke_emit (uint32_t id, bool run_ok, uint32_t check, bool pass) |
| Print the one-line verdict banner over the SCI8 console. | |
| void | main (void) |
| Application entry: bring up the NPU, run a checkable job, print verdict. | |
Variables | |
| static uint32_t | s_npu_cmd_stream [k_npu_smoke_cmd_words] |
| Stand-in command stream in SRAM (ra8_npu_fake_cmd.h layout; add-constant op). | |
| static uint8_t | s_npu_weights [k_npu_smoke_arena_bytes] |
| Region 0 weight arena (present by Vela convention; unused by this op). | |
| static uint8_t | s_npu_input [k_npu_smoke_arena_bytes] |
| Region 1 input tensor: seeded with a deterministic byte pattern. | |
| static uint8_t | s_npu_output [k_npu_smoke_arena_bytes] |
| Region 2 output tensor: zeroed pre-run, holds the NPU result post-run. | |
| volatile uint32_t | g_npu_smoke_id = 0U |
| NPU_ID captured after init, for external (J-Link) inspection. | |
| volatile uint32_t | g_npu_smoke_status = 0U |
| Raw NPU_STATUS captured after the run, for external inspection. | |
| volatile uint32_t | g_npu_smoke_check = 0U |
| Output checkword captured after verify, for external inspection. | |
| volatile uint32_t | g_npu_smoke_pass = 0U |
| Final verdict (1 = PASS, 0 = FAIL), for external inspection. | |
RA8P1 Arm Ethos-U55 NPU foundation smoke – runs a checkable stand-in job.
Companion to examples/ra8p1_foundation/blink_ra8p1 for the NPU. This app drives the FULL ra8_npu command/queue surface end-to-end and CHECKS the result: bring the Ethos-U55 out of module-stop (ra8_npu_init), read the NPU_ID probe, build a command stream + input tensor in SRAM, program them (ra8_npu_submit), kick the job (ra8_npu_run), wait for completion (ra8_npu_wait), then READ the output arena back and assert it holds the deterministic expected result. The verdict is printed over the SCI8 console:
The SCI8 console is provided by the dedicated ra8_board_ra8p1 board layer (issue #226), whose LED/switch/console pins are provisional (mirrored from the pin-compatible EK-RA8D2) until an RA8P1 board is defined – see that layer's header for the TODO(EK-RA8P1 UM / ra8p1_kicad) rationale.
The command stream is NOT a real Vela program: it uses the tiny, documented ra8_emulator / host-test convention in ra8_npu_fake_cmd.h (an "SE55" magic word plus an add-constant opcode). Under tools/ra8_emulator --device ra8p1 the NPU model decodes it and applies the op to the tensor arenas, so this app is a DETERMINISTIC, emulator-runnable check of the driver protocol + BASEPn region programming – run it twice and the banner is identical. It is still a FOUNDATION app: there is no RA8P1 board yet, and real Vela-compiled inference is the follow-up on the RA8P1 NPU epic. On silicon the NPU reaches the arenas over AXI, so a real driver would add cache maintenance around the tensors; the cache-less emulator needs none, so this foundation omits it.
Definition in file main.c.
| enum npu_smoke_fnv_t : uint32_t |
| enum npu_smoke_region_t : uint8_t |
Tensor-region indices the smoke job programs into BASEPn.
| enum npu_smoke_seed_t : uint8_t |
| enum npu_smoke_size_t : uint32_t |
Command-stream / tensor-arena sizes and the console baud.
|
static |
Fill the command stream (add-constant op) per the stand-in convention.
Writes the five header words of ra8_npu_fake_cmd.h: magic|opcode, source region, destination region, byte count, constant addend.
Definition at line 269 of file main.c.
References k_npu_smoke_addk, k_npu_smoke_arena_bytes, k_npu_smoke_region_input, k_npu_smoke_region_output, k_ra8_npu_fake_magic, k_ra8_npu_fake_op_addk, k_ra8_npu_fake_word_const, k_ra8_npu_fake_word_count, k_ra8_npu_fake_word_dst, k_ra8_npu_fake_word_op, k_ra8_npu_fake_word_src, RA8_INTERNAL, and s_npu_cmd_stream.
Referenced by main().
|
static |
Print the one-line verdict banner over the SCI8 console.
Emits fixed text fragments and fixed-width hexadecimal fields directly, avoiding the libc snprintf implementation unavailable to the freestanding target.
| [in] | id | NPU_ID read after init. |
| [in] | run_ok | Whether the submit/run/wait sequence returned k_ra8_ok. |
| [in] | check | Output checkword from internal_npu_smoke_verify(). |
| [in] | pass | Final verdict (id valid AND run_ok AND output matched). |
Definition at line 420 of file main.c.
References internal_npu_smoke_write(), internal_npu_smoke_write_hex32(), internal_npu_smoke_write_status(), internal_npu_smoke_write_verdict(), and ra8_board_uart_console_flush().
Referenced by main().
|
static |
Park the CPU forever in WFI after a fatal init error (a real panic).
Reserved for failures BEFORE a verdict can be emitted (CGC or the SCI8 console did not come up), so a ra8_emulator gate that scans for a *panic_halt terminal PC correctly reads this as a failed run. The normal post-verdict terminal is internal_npu_smoke_park, which is NOT a panic and must not be flagged as one.
Definition at line 202 of file main.c.
References RA8_INTERNAL.
Referenced by internal_npu_smoke_setup_or_halt().
|
static |
Park the CPU forever in WFI after the verdict banner (a clean stop).
Distinct from internal_npu_smoke_panic_halt on purpose: a run that reached the verdict – PASS or FAIL – has done its job and parks here, whose name deliberately does NOT match the *panic_halt / *_halt_loop patterns a ra8_emulator gate treats as a give-up. The authoritative verdict is the emitted verdict=PASS / verdict=FAIL banner (and g_npu_smoke_pass for a memprobe), never the parked PC.
Definition at line 226 of file main.c.
References RA8_INTERNAL.
Referenced by main().
|
static |
Submit + run + wait for the NPU job.
Builds a descriptor over the static regions, submits it, starts the NPU, and synchronously returns the completion wait result.
| k_ra8_ok | Job completed (command stream consumed). |
Definition at line 316 of file main.c.
References ra8_npu_job_t::cmd_stream, ra8_npu_job_t::cmd_stream_bytes, k_npu_smoke_region_count, k_npu_smoke_region_input, k_npu_smoke_region_output, k_npu_smoke_region_weights, k_ra8_ok, RA8_INTERNAL, ra8_npu_run(), ra8_npu_submit(), ra8_npu_wait(), ra8_npu_job_t::region_base, ra8_npu_job_t::region_count, s_npu_cmd_stream, s_npu_input, s_npu_output, and s_npu_weights.
Referenced by main().
|
static |
Seed the input arena with a deterministic pattern and zero the output.
Generates the fixed affine byte sequence used by verification and clears every output byte so stale data cannot produce a false pass.
Definition at line 291 of file main.c.
References k_npu_smoke_arena_bytes, k_npu_smoke_byte_mask, k_npu_smoke_seed_add, k_npu_smoke_seed_mul, RA8_INTERNAL, s_npu_input, and s_npu_output.
Referenced by main().
|
static |
Bring up CGC + the SCI8 console.
Panic-halts on any failure.
The NPU needs no clock beyond the CGC default NPUCLK; only the console (PCLKA/SCICLK) is set up here so the verdict can be printed.
Definition at line 246 of file main.c.
References internal_npu_smoke_panic_halt(), k_npu_smoke_baud, k_ra8_ok, ra8_board_uart_console_init(), ra8_cgc_init(), and RA8_INTERNAL.
Referenced by main().
|
static |
Verify the output arena equals input+K and fold it into a checkword.
Compares every output byte to the wrapped add-constant expectation while accumulating an FNV-1a digest independent of the verdict.
| [out] | out_check | FNV-1a digest of the output bytes (for the banner). |
| true | Every result byte matches its expected value. |
| false | One or more result bytes differ. |
Definition at line 354 of file main.c.
References k_npu_smoke_addk, k_npu_smoke_arena_bytes, k_npu_smoke_byte_mask, k_npu_smoke_fnv_offset, k_npu_smoke_fnv_prime, RA8_INTERNAL, s_npu_input, and s_npu_output.
Referenced by main().
|
static |
Definition at line 370 of file main.c.
References ra8_board_uart_console_write(), and RA8_INTERNAL.
Referenced by internal_npu_smoke_emit(), internal_npu_smoke_write_hex32(), internal_npu_smoke_write_status(), and internal_npu_smoke_write_verdict().
|
static |
Definition at line 375 of file main.c.
References internal_npu_smoke_write(), k_npu_smoke_hex_digits, k_npu_smoke_hex_mask, k_npu_smoke_hex_shift, and RA8_INTERNAL.
Referenced by internal_npu_smoke_emit().
|
static |
Definition at line 387 of file main.c.
References internal_npu_smoke_write(), and RA8_INTERNAL.
Referenced by internal_npu_smoke_emit().
|
static |
Definition at line 394 of file main.c.
References internal_npu_smoke_write(), and RA8_INTERNAL.
Referenced by internal_npu_smoke_emit().
| void main | ( | void | ) |
Application entry: bring up the NPU, run a checkable job, print verdict.
The application entry point Reset_Handler hands control to.
Definition at line 441 of file main.c.
References g_npu_smoke_check, g_npu_smoke_id, g_npu_smoke_pass, g_npu_smoke_status, internal_npu_smoke_build_stream(), internal_npu_smoke_emit(), internal_npu_smoke_park(), internal_npu_smoke_run_job(), internal_npu_smoke_seed_arenas(), internal_npu_smoke_setup_or_halt(), internal_npu_smoke_verify(), k_ra8_ok, ra8_npu_init(), ra8_npu_read_id(), ra8_npu_read_status(), and ra8_npu_status_t::raw.
| volatile uint32_t g_npu_smoke_check = 0U |
| volatile uint32_t g_npu_smoke_id = 0U |
| volatile uint32_t g_npu_smoke_pass = 0U |
| volatile uint32_t g_npu_smoke_status = 0U |
|
static |
Stand-in command stream in SRAM (ra8_npu_fake_cmd.h layout; add-constant op).
QBASE/QSIZE point the NPU at this; the fake model decodes it.
|
static |
Region 1 input tensor: seeded with a deterministic byte pattern.
The NPU (fake) reads this and writes input+K to the output arena.
|
static |
|
static |