|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
.npub linkable-blob container for a Vela-compiled Ethos-U55 model More...
#include <stdint.h>Go to the source code of this file.
Functions | |
| static uint32_t | ra8_npu_blob_read_word (const uint8_t *buf, uint32_t byte_off) |
| Read one little-endian 32-bit word from a .npub byte buffer. | |
.npub linkable-blob container for a Vela-compiled Ethos-U55 model
Defines the small, first-party, little-endian container the OFFLINE Vela build step (tools/vela/src/vela_gen.py) emits and the ON-TARGET loader (ra8_npu_loader.c) consumes. A bare-metal target does NOT parse a TFLite flatbuffer at run time; instead the host build step distills a Vela _vela.tflite (the ethos-u custom operator's command stream plus the tensor region layout) into this lean .npub blob, and the loader maps that blob straight into an ra8_npu_job_t for ra8_npu_submit().
A region descriptor is either BAKED (its bytes live in the blob at data_offset, e.g. the read-only weight arena) or RUNTIME (allocated by the caller in NPU-visible SRAM, e.g. scratch / output activations). The loader turns BAKED regions into a pointer into the blob and RUNTIME regions into a pointer inside a caller-provided arena; see ra8_npu_loader.h.
This header defines a pure DATA FORMAT (constants + one endianness-safe accessor) and touches no NPU register, so – exactly like ra8_npu_fake_cmd.h – it is deliberately NOT gated behind RA8_HAS_NPU: the host-side generator's companion tests and the ra8_emulator model must be able to include it on a device that is not the RA8P1. The RA8P1-only piece is the loader, which turns a blob into an ra8_npu_job_t.
Definition in file ra8_npu_blob.h.
| enum ra8_npu_blob_accel_t : uint32_t |
Vela accelerator configuration recorded in the header (informational).
The value is the Ethos-U55 MAC-per-cycle SKU Vela targeted. The RA8P1 integrates the 256-MAC/cycle SKU (ethos-u55-256, see ra8_npu_regs.h). The loader does not validate it; it is carried so a consumer can confirm the blob was compiled for the right accelerator.
| Enumerator | |
|---|---|
| k_ra8_npu_blob_accel_ethos_u55_256 | ethos-u55-256 (RA8P1 SKU). |
Definition at line 208 of file ra8_npu_blob.h.
| enum ra8_npu_blob_fnv_t : uint32_t |
FNV-1a 32-bit constants for the payload checksum.
The offline generator and the on-target loader fold every payload byte (offset >= k_ra8_npu_blob_header_bytes) with these constants and compare the result against the header checksum word, so a corrupted blob is rejected rather than executed. FNV-1a is used elsewhere in the NPU stand-in (ra8_emulator, npu_smoke) for the same deterministic-digest reason.
| Enumerator | |
|---|---|
| k_ra8_npu_blob_fnv_offset | FNV-1a 32-bit offset basis. |
| k_ra8_npu_blob_fnv_prime | FNV-1a 32-bit prime. |
Definition at line 226 of file ra8_npu_blob.h.
| enum ra8_npu_blob_ident_t : uint32_t |
Container magic marker and format version.
k_ra8_npu_blob_magic is the first word of every .npub blob; its four little-endian bytes spell the ASCII tag "NPU1" (0x4E 0x50 0x55 0x31). A loader rejects any buffer whose first word differs, so a truncated or foreign buffer is refused rather than mis-parsed. k_ra8_npu_blob_version is bumped on any incompatible layout change.
| Enumerator | |
|---|---|
| k_ra8_npu_blob_magic | First word: "NPU1" little-endian. |
| k_ra8_npu_blob_version | Container format version. |
Definition at line 83 of file ra8_npu_blob.h.
| enum ra8_npu_blob_rdesc_t : uint32_t |
Word indices of one region descriptor in the region table.
Each descriptor is k_ra8_npu_blob_region_words little-endian words: role (ra8_npu_blob_role_t), flags (ra8_npu_blob_rflag_t), size in bytes, and data_offset – the byte offset of the region's baked bytes when k_ra8_npu_blob_rflag_baked is set, else unused.
| Enumerator | |
|---|---|
| k_ra8_npu_blob_rdesc_role | region role (ra8_npu_blob_role_t). |
| k_ra8_npu_blob_rdesc_flags | region flags (ra8_npu_blob_rflag_t). |
| k_ra8_npu_blob_rdesc_size | region size in bytes. |
| k_ra8_npu_blob_rdesc_data_offset | baked-data byte offset (if baked). |
| k_ra8_npu_blob_region_words | Descriptor field / word count. |
Definition at line 128 of file ra8_npu_blob.h.
| enum ra8_npu_blob_rflag_t : uint32_t |
Region descriptor flag bits.
k_ra8_npu_blob_rflag_baked marks a region whose bytes are present IN the blob at the descriptor's data_offset (e.g. the weight arena); the loader points the region base at those bytes. A region without the flag is RUNTIME: the loader carves it out of the caller-provided arena.
| Enumerator | |
|---|---|
| k_ra8_npu_blob_rflag_baked | Region bytes are baked into the blob. |
Definition at line 192 of file ra8_npu_blob.h.
| enum ra8_npu_blob_role_t : uint32_t |
Role a region plays in the model's tensor arena layout.
Vela assigns each BASEPn region a role: the read-only weight/bias arena, the scratch arena, and the input / output activation buffers. The loader does not act on the role beyond reporting it; the command stream references regions by their BASEPn index (their order in the descriptor table), not by this label.
Definition at line 171 of file ra8_npu_blob.h.
| enum ra8_npu_blob_size_t : uint32_t |
Fixed byte sizes derived from the word counts.
k_ra8_npu_blob_header_bytes is the header length; the payload the checksum covers begins here. k_ra8_npu_blob_region_desc_bytes is one descriptor's length. k_ra8_npu_blob_arena_align is the alignment the loader applies to each runtime region base within the caller arena (Ethos-U55 tensor arenas are 16-byte aligned).
Definition at line 150 of file ra8_npu_blob.h.
| enum ra8_npu_blob_word_t : uint32_t |
Word indices of the fixed .npub header (little-endian 32-bit words).
The header is k_ra8_npu_blob_header_words words long. total_bytes is the whole blob length; region_count counts the region descriptors that follow the header; cmd_offset / cmd_bytes locate the Vela command stream; accel records the Vela accelerator config (informational); checksum is an FNV-1a digest over every payload byte (everything at or beyond k_ra8_npu_blob_header_bytes).
| Enumerator | |
|---|---|
| k_ra8_npu_blob_word_magic | magic == k_ra8_npu_blob_magic. |
| k_ra8_npu_blob_word_version | format version. |
| k_ra8_npu_blob_word_total_bytes | whole blob length in bytes. |
| k_ra8_npu_blob_word_region_count | number of region descriptors. |
| k_ra8_npu_blob_word_cmd_offset | byte offset to the command stream. |
| k_ra8_npu_blob_word_cmd_bytes | command-stream length in bytes. |
| k_ra8_npu_blob_word_accel | accelerator config (informational). |
| k_ra8_npu_blob_word_checksum | FNV-1a digest over the payload. |
| k_ra8_npu_blob_header_words | Header field / word count. |
Definition at line 103 of file ra8_npu_blob.h.
|
inlinestatic |
Read one little-endian 32-bit word from a .npub byte buffer.
Assembles buf[byte_off .. byte_off+3] as a little-endian uint32_t one byte at a time, so the read is both endianness-independent and free of any unaligned-access assumption (the byte buffer may sit at an arbitrary address). This performs a plain memory read of a caller buffer – no hardware register is touched – so it carries no HUM citation.
| [in] | buf | Base of the .npub byte buffer (non-NULL, caller-checked). |
| [in] | byte_off | Byte offset of the word to read; byte_off + 4 must not exceed the buffer length (caller-checked). |
byte_off. | value | The assembled word; always defined for an in-bounds offset. |
buf is non-NULL. Definition at line 257 of file ra8_npu_blob.h.
References k_ra8_npu_blob_word_bytes.
Referenced by internal_npu_vela_cmd_word().