|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
RA8P1 Ethos-U55 .npub container loader end-to-end – load a .npub, run it. 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_device.h"#include "ra8_err.h"#include "ra8_npu.h"#include "ra8_npu_blob.h"#include "ra8_npu_fake_cmd.h"#include "ra8_npu_loader.h"#include "ra8_npu_model_addk_fake.h"#include "ra8_npu_regs.h"Go to the source code of this file.
Enumerations | |
| enum | npu_vela_size_t : uint32_t { k_npu_vela_baud = 115200U , k_npu_vela_arena = 128U , k_npu_vela_word_bytes = 4U , k_npu_vela_byte_mask = 0xFFU , k_npu_vela_hex_digits = 8U , k_npu_vela_hex_shift = 4U , k_npu_vela_hex_mask = 0x0FU } |
| Console baud, runtime-arena size, banner width, and word geometry. More... | |
| enum | npu_vela_fnv_t : uint32_t { k_npu_vela_fnv_offset = 0x811C9DC5U , k_npu_vela_fnv_prime = 0x01000193U } |
| FNV-1a 32-bit constants for the displayed output checkword. More... | |
Functions | |
| static void | internal_npu_vela_panic_halt (void) |
| Park the CPU forever in WFI after a fatal init error (a real panic). | |
| static void | internal_npu_vela_park (void) |
| Park the CPU forever in WFI after the verdict banner (a clean stop). | |
| static void | internal_npu_vela_setup_or_halt (void) |
| Bring up CGC + the SCI8 console. | |
| static uint32_t | internal_npu_vela_cmd_word (const ra8_npu_job_t *job, ra8_npu_fake_word_idx_t widx) |
| Read a little-endian command-stream word from the loaded job. | |
| static bool | internal_npu_vela_verify (const ra8_npu_job_t *job, uint32_t *out_check) |
| Verify the output arena equals input+K and fold it into a checkword. | |
| static ra8_err_t | internal_npu_vela_run_job (ra8_npu_job_t *out_job) |
| Load the golden blob, submit + run + wait for the NPU job. | |
| static void | internal_npu_vela_write (const uint8_t *data, size_t len) |
| static void | internal_npu_vela_write_hex32 (uint32_t value) |
| static void | internal_npu_vela_write_status (bool ok) |
| static void | internal_npu_vela_write_verdict (bool pass) |
| static void | internal_npu_vela_emit (uint32_t id, bool load_ok, bool run_ok, uint32_t check, bool pass) |
| Print the one-line verdict banner over the SCI8 console. | |
| void | main (void) |
| Application entry: load a .npub model, run it, print the verdict. | |
Variables | |
| static uint8_t | s_npu_vela_arena [k_npu_vela_arena] |
| Runtime arena the loader carves the output activation from. | |
| volatile uint32_t | g_npu_vela_id = 0U |
| NPU_ID captured after init, for external (J-Link) inspection. | |
| volatile uint32_t | g_npu_vela_check = 0U |
| Output checkword captured after verify, for external inspection. | |
| volatile uint32_t | g_npu_vela_pass = 0U |
| Final verdict (1 = PASS, 0 = FAIL), for external inspection. | |
RA8P1 Ethos-U55 .npub container loader end-to-end – load a .npub, run it.
Companion to examples/ra8p1_foundation/npu_smoke on the way to issue #227: instead of hand-building a command stream in SRAM, this app LOADS a committed, generated .npub model container (tools/vela/generated/ra8_npu_model_addk_fake.h, produced offline by tools/vela/src/vela_gen.py) through the on-target loader ra8_npu_load(), which maps it into an ra8_npu_job_t – command stream plus resolved region bases (baked weights/input inside the blob, the output activation carved from a runtime SRAM arena). It then submits + runs the job, reads the output arena back, and asserts it holds the deterministic input + K result. The verdict is printed over the SCI8 console:
The container's command stream is NOT a real Vela program: it is the tiny, documented ra8_emulator / host-test convention in ra8_npu_fake_cmd.h. 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 proof of the FULL offline-build -> on-target-load -> run pipeline. 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_vela_fnv_t : uint32_t |
| enum npu_vela_size_t : uint32_t |
Console baud, runtime-arena size, banner width, and word geometry.
|
static |
Read a little-endian command-stream word from the loaded job.
Computes the byte offset for the requested fake-command word and delegates endian-safe decoding to the blob reader.
| [in] | job | Loaded job whose cmd_stream is byte-addressable. |
| [in] | widx | Word index within the SE55 command stream. |
widx. | 0..UINT32_MAX | The decoded little-endian command word. |
Definition at line 207 of file main.c.
References ra8_npu_job_t::cmd_stream, k_npu_vela_word_bytes, RA8_INTERNAL, and ra8_npu_blob_read_word().
Referenced by internal_npu_vela_verify().
|
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] | load_ok | Whether ra8_npu_load() succeeded. |
| [in] | run_ok | Whether the submit/run/wait sequence returned k_ra8_ok. |
| [in] | check | Output checkword from internal_npu_vela_verify(). |
| [in] | pass | Final verdict (id valid AND load AND run AND output matched). |
Definition at line 341 of file main.c.
References internal_npu_vela_write(), internal_npu_vela_write_hex32(), internal_npu_vela_write_status(), internal_npu_vela_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.
Definition at line 138 of file main.c.
References RA8_INTERNAL.
Referenced by internal_npu_vela_setup_or_halt().
|
static |
Park the CPU forever in WFI after the verdict banner (a clean stop).
Distinct from internal_npu_vela_panic_halt on purpose: a run that reached the verdict has done its job and parks here, whose name deliberately does NOT match the *panic_halt patterns a ra8_emulator gate treats as a give-up. The authoritative verdict is the emitted banner.
Definition at line 160 of file main.c.
References RA8_INTERNAL.
Referenced by main().
|
static |
Load the golden blob, submit + run + wait for the NPU job.
Resolves the generated container into the static arena, submits its descriptor, starts the NPU, and waits synchronously for completion.
| [out] | out_job | Filled with the loaded, run job descriptor on success. |
| k_ra8_ok | The container loaded and the NPU job completed. |
| non-k_ra8_ok | The loader, submission, run, or wait stage failed. |
Definition at line 271 of file main.c.
References k_npu_vela_arena, k_ra8_ok, RA8_INTERNAL, ra8_npu_load(), ra8_npu_model_addk_fake_blob(), ra8_npu_model_addk_fake_bytes(), ra8_npu_run(), ra8_npu_submit(), ra8_npu_wait(), and s_npu_vela_arena.
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 180 of file main.c.
References internal_npu_vela_panic_halt(), k_npu_vela_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.
Reads the resolved input region (baked in the blob) and output region (the runtime arena) straight out of the loaded job, plus the add constant and byte count from the command stream, and checks every output byte against the deterministic input + K result.
| [in] | job | Job returned by ra8_npu_load() (regions resolved). |
| [out] | out_check | FNV-1a digest of the output bytes (for the banner). |
| true | Every byte matches the command stream's add-constant operation. |
| false | One or more bytes differ from the deterministic expectation. |
Definition at line 235 of file main.c.
References internal_npu_vela_cmd_word(), k_npu_vela_byte_mask, k_npu_vela_fnv_offset, k_npu_vela_fnv_prime, k_ra8_npu_fake_word_const, k_ra8_npu_fake_word_count, k_ra8_npu_region_1, k_ra8_npu_region_2, RA8_INTERNAL, and ra8_npu_job_t::region_base.
Referenced by main().
|
static |
Definition at line 290 of file main.c.
References ra8_board_uart_console_write(), and RA8_INTERNAL.
Referenced by internal_npu_vela_emit(), internal_npu_vela_write_hex32(), internal_npu_vela_write_status(), and internal_npu_vela_write_verdict().
|
static |
Definition at line 295 of file main.c.
References internal_npu_vela_write(), k_npu_vela_hex_digits, k_npu_vela_hex_mask, k_npu_vela_hex_shift, and RA8_INTERNAL.
Referenced by internal_npu_vela_emit().
|
static |
Definition at line 307 of file main.c.
References internal_npu_vela_write(), and RA8_INTERNAL.
Referenced by internal_npu_vela_emit().
|
static |
Definition at line 314 of file main.c.
References internal_npu_vela_write(), and RA8_INTERNAL.
Referenced by internal_npu_vela_emit().
| void main | ( | void | ) |
Application entry: load a .npub model, run it, print the verdict.
The application entry point Reset_Handler hands control to.
Definition at line 364 of file main.c.
References ra8_npu_job_t::cmd_stream, g_npu_vela_check, g_npu_vela_id, g_npu_vela_pass, internal_npu_vela_emit(), internal_npu_vela_park(), internal_npu_vela_run_job(), internal_npu_vela_setup_or_halt(), internal_npu_vela_verify(), k_ra8_ok, ra8_npu_init(), and ra8_npu_read_id().
| volatile uint32_t g_npu_vela_check = 0U |
| volatile uint32_t g_npu_vela_id = 0U |
| volatile uint32_t g_npu_vela_pass = 0U |
|
static |
Runtime arena the loader carves the output activation from.
Passed to ra8_npu_load() as the runtime region backing store; the NPU (fake) writes the model output here.
Definition at line 95 of file main.c.
Referenced by internal_npu_vela_run_job().