|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
DRW 2D-engine blit + per-pixel alpha-blend headless CRC demo (EK-RA8D2). More...
#include <stddef.h>#include <stdint.h>#include "ra8_board_ek_ra8d2.h"#include "ra8_boot_entry.h"#include "ra8_cgc.h"#include "ra8_check.h"#include "ra8_drw.h"#include "ra8_err.h"#include "ra8_isr.h"#include "ra8_mstp.h"#include "ra8_time.h"Go to the source code of this file.
Enumerations | |
| enum | drw_blend_config_t : uint32_t { k_drw_blend_baud = 115200U , k_drw_blend_period_ms = 1000U , k_drw_blend_idle_budget = 200000U , k_drw_blend_alpha = 0x80U , k_drw_blend_fnv_offset = 2166136261U , k_drw_blend_fnv_prime = 16777619U } |
| Compile-time scalar settings for the demo. More... | |
| enum | drw_blend_hash_t : uint32_t { k_drw_blend_byte_bits = 8U , k_drw_blend_byte_mask = 0xFFU , k_drw_blend_hex_digit = 8U , k_drw_blend_hi_nibble = 7U , k_drw_blend_nib_bits = 4U , k_drw_blend_nib_mask = 0xFU } |
| Byte / nibble constants for the FNV hash and hex banner formatting. More... | |
| enum | drw_blend_color_t : uint32_t { k_drw_blend_bg_argb = 0xFF202060U , k_drw_blend_sp_argb = 0xFF40C040U , k_drw_blend_fg_argb = 0xFFE04040U , k_drw_blend_fg_a80 = 0x80E04040U } |
| ARGB8888 colours used by the three render layers. More... | |
| enum | drw_blend_geom_t : uint16_t { k_drw_blend_fb_dim = 32U , k_drw_blend_sp_xy = 8U , k_drw_blend_sp_wh = 16U , k_drw_blend_fg_xy = 4U , k_drw_blend_fg_wh = 16U , k_drw_blend_full_org = 0U } |
| Framebuffer + layer rectangle geometry, in pixels. More... | |
Functions | |
| static void | drw_blend_panic_halt (void) |
| Park forever after a fatal init failure. | |
| static void | drw_blend_setup_or_halt (void) |
| Bring CGC + SysTick + SCI8 + LEDs + MSTP up. | |
| static ra8_err_t | drw_blend_configure (void) |
| Bring up the DRW engine pointed at g_drw_blend_fb. | |
| static ra8_err_t | drw_blend_fill (int16_t x, int16_t y, uint16_t w, uint16_t h, uint32_t argb) |
| Issue one opaque ra8_drw_fill_rect and wait for the engine. | |
| static ra8_err_t | drw_blend_arm (void) |
| Arm the blend unit for opaque-over (source-over) global-alpha mixing. | |
| static uint32_t | drw_blend_framebuffer_hash (void) |
| FNV-1a-32 over the rendered framebuffer bytes. | |
| static ra8_err_t | drw_blend_render (uint32_t *out_crc) |
| Render the three layers (background, sprite, blended foreground). | |
| static void | drw_blend_print_hex (uint32_t value) |
| Print one hex nibble's worth of the 32-bit CRC over the console. | |
| static void | drw_blend_print_pass (uint32_t crc) |
| Emit the success banner: prefix + 8 hex CRC + " PASS\r\n". | |
| void | main (void) |
| The application entry point Reset_Handler hands control to. | |
Variables | |
| static const char * | s_tag = "drw_blend" |
| Diagnostic / log tag. | |
| static const uint8_t | k_drw_blend_pass_pfx [] = "drw: blit+blend crc=" |
| Success / failure banner text. | |
| static const uint8_t | k_drw_blend_pass_sfx [] = " PASS\r\n" |
| static const uint8_t | k_drw_blend_fail_msg [] = "drw: blit+blend FAIL\r\n" |
| volatile uint32_t | g_drw_blend_fb [(uint32_t) k_drw_blend_fb_dim *(uint32_t) k_drw_blend_fb_dim] |
| 32 x 32 ARGB8888 framebuffer the DRW composites into. | |
| volatile uint32_t | g_drw_blend_crc = 0U |
| FNV-1a-32 hash of the last rendered framebuffer. | |
| volatile uint32_t | g_drw_blend_err = 0U |
| Non-zero if a DRW call returned an error during the last render. | |
| volatile uint32_t | g_drw_blend_heartbeat = 0U |
| Bumps once per main-loop pass – liveness for headless probes. | |
DRW 2D-engine blit + per-pixel alpha-blend headless CRC demo (EK-RA8D2).
Issue #120 asks for a demo that exercises the DRW ("D/AVE 2D") engine's blit AND alpha-blend path (ra8_drw_blend_t), not just the solid fill the sibling drw_fill_demo covers. This app renders three layers into a small 32x32 ARGB8888 framebuffer in SRAM and then folds an FNV-1a-32 hash over the whole framebuffer, exactly like ereader_chrome does for its chrome:
The rendered framebuffer is byte-deterministic, so its hash is constant on every boot. The app prints "drw: blit+blend crc=<8hex> PASS" over the J-Link OB CDC channel once a second; the headless gate (ra8_emulator_smoke.sh / hil.conf uart_scrape) asserts that banner. No display panel is touched – this is a pure compute + memory test.
Definition in file main.c.
| enum drw_blend_color_t : uint32_t |
ARGB8888 colours used by the three render layers.
Background, sprite, and foreground source colours. The foreground is the COLOR1 source fed through the blend unit at k_drw_blend_alpha.
| enum drw_blend_config_t : uint32_t |
Compile-time scalar settings for the demo.
Baud, loop period, the bounded ra8_drw_wait_idle poll budget, the global-alpha value driven into the blend unit, and the FNV-1a-32 constants used to hash the framebuffer.
| enum drw_blend_geom_t : uint16_t |
Framebuffer + layer rectangle geometry, in pixels.
A 32x32 ARGB8888 framebuffer. The sprite is a centred 16x16 box; the blended foreground is a 16x16 box offset up-left so it overlaps both the background and the sprite, giving a deterministic three-region composite.
| enum drw_blend_hash_t : uint32_t |
Byte / nibble constants for the FNV hash and hex banner formatting.
The FNV pass extracts one byte per shift; the hex printer emits eight nibbles, most-significant first. Naming these clears the magic-number gate.
|
staticnodiscard |
Arm the blend unit for opaque-over (source-over) global-alpha mixing.
Sets COLOR1 to the foreground source via ra8_drw_set_gradient (COLOR2 is unused here but written for determinism), then programs ra8_drw_blend_t for the standard source-over combination at the demo's global alpha. The subsequent ra8_drw_fill_rect composites COLOR1 over each destination pixel instead of overwriting it.
| k_ra8_ok | Blend unit armed. |
| k_ra8_err_null_ptr | Internal descriptor pointer was NULL (cannot happen; both descriptors are stack locals). |
Definition at line 302 of file main.c.
References k_drw_blend_alpha, k_drw_blend_bg_argb, k_drw_blend_fg_argb, k_ra8_ok, ra8_drw_set_blend(), and ra8_drw_set_gradient().
Referenced by drw_blend_render().
|
staticnodiscard |
Bring up the DRW engine pointed at g_drw_blend_fb.
| k_ra8_ok | DRW configured for ARGB8888 over the demo framebuffer. |
| k_ra8_err_null_ptr | Internal config pointer was NULL (cannot happen). |
| k_ra8_err_hw_init_failed | MSTP enable failed. |
Definition at line 227 of file main.c.
References g_drw_blend_fb, k_drw_blend_fb_dim, k_ra8_drw_writefmt_argb8888, and ra8_drw_init().
Referenced by main().
|
staticnodiscard |
Issue one opaque ra8_drw_fill_rect and wait for the engine.
| [in] | x | Top-left X in pixels. |
| [in] | y | Top-left Y in pixels. |
| [in] | w | Width in pixels. |
| [in] | h | Height in pixels. |
| [in] | argb | 0xAARRGGBB fill colour. |
| k_ra8_ok | Fill rasterized. |
| k_ra8_err_invalid_arg | Geometry rejected by ra8_drw_fill_rect. |
| k_ra8_err_hw_timeout | Engine stayed busy past the poll budget. |
Definition at line 263 of file main.c.
References k_drw_blend_idle_budget, k_ra8_ok, ra8_drw_fill_rect(), and ra8_drw_wait_idle().
Referenced by drw_blend_render().
|
static |
FNV-1a-32 over the rendered framebuffer bytes.
Definition at line 334 of file main.c.
References g_drw_blend_fb, k_drw_blend_byte_bits, k_drw_blend_byte_mask, k_drw_blend_fb_dim, k_drw_blend_fnv_offset, and k_drw_blend_fnv_prime.
Referenced by drw_blend_render().
|
static |
Park forever after a fatal init failure.
Definition at line 176 of file main.c.
Referenced by drw_blend_setup_or_halt(), and main().
|
static |
Print one hex nibble's worth of the 32-bit CRC over the console.
Definition at line 419 of file main.c.
References k_drw_blend_hex_digit, k_drw_blend_hi_nibble, k_drw_blend_nib_bits, k_drw_blend_nib_mask, and ra8_board_uart_console_write().
Referenced by drw_blend_print_pass().
|
static |
Emit the success banner: prefix + 8 hex CRC + " PASS\r\n".
Definition at line 431 of file main.c.
References drw_blend_print_hex(), k_drw_blend_pass_pfx, k_drw_blend_pass_sfx, and ra8_board_uart_console_write().
Referenced by main().
|
staticnodiscard |
Render the three layers (background, sprite, blended foreground).
| [out] | out_crc | Receives the FNV-1a-32 hash of the rendered framebuffer. |
| k_ra8_ok | Framebuffer rendered and hashed. |
| k_ra8_err_null_ptr | out_crc was NULL. |
| k_ra8_err_invalid_arg | A layer rectangle was rejected. |
| k_ra8_err_hw_timeout | The engine stayed busy past the budget. |
Definition at line 370 of file main.c.
References drw_blend_arm(), drw_blend_fill(), drw_blend_framebuffer_hash(), g_drw_blend_err, k_drw_blend_bg_argb, k_drw_blend_fb_dim, k_drw_blend_fg_a80, k_drw_blend_fg_wh, k_drw_blend_fg_xy, k_drw_blend_full_org, k_drw_blend_sp_argb, k_drw_blend_sp_wh, k_drw_blend_sp_xy, k_ra8_ok, RA8_CHECK_NULL_PTR, and s_tag.
Referenced by main().
|
static |
Bring CGC + SysTick + SCI8 + LEDs + MSTP up.
Definition at line 184 of file main.c.
References drw_blend_panic_halt(), k_drw_blend_baud, k_ra8_board_led1, k_ra8_board_led2, k_ra8_clock_id_cpuclk0, k_ra8_ok, ra8_board_led_init(), ra8_board_uart_console_init(), ra8_cgc_get_clock_hz(), ra8_cgc_init(), ra8_mstp_init(), and ra8_time_init().
Referenced by main().
| void main | ( | void | ) |
The application entry point Reset_Handler hands control to.
Returns void, not int. This is a freestanding image: there is no hosted C environment, no process and nothing to report an exit status to. ISO C fixes main at int only for a hosted implementation; for a freestanding one (C23 5.1.2.1) the startup function's name and type are implementation-defined, and this is that definition. Reset_Handler discards no value because there is none to discard, and if main ever does return, startup halts the CPU rather than resuming anything.
The firmware lane is compiled -ffreestanding (see cmake/ra8_add_app.cmake) and the flag and this signature travel together: without it both GCC and clang reject a non-int main (-Wmain / -Wmain-return-type). Do not remove one without the other.
That coupling is why the declaration sits behind __STDC_HOSTED__ == 0, which -ffreestanding sets and a hosted build does not. The guard is not defensive dressing: this header is reachable from host builds (the unit tests compile ra8_core natively), and an unguarded void main(void); makes every hosted translation unit that includes it fail with conflicting types for 'main' against its own ISO int main. The declaration therefore exists exactly where its contract does.
Hosted first-party code – everything under tests/ and tools/ – uses the ISO int main(...) contract instead, because it genuinely does run under an OS that reads the exit status. scripts/checks/check_entry_points.py holds each domain to its own contract (#707).
Declared here, once, for the same reason SystemInit is: every vector_table.c used to restate it as a local extern int32_t main(void);, sixteen copies that no compiler ever compared against the definition – and roughly thirty of them had silently drifted out of agreement with the main they called.
The application entry point Reset_Handler hands control to.
Brings up CGC + BSP audio then plays blocks.
The application entry point Reset_Handler hands control to.
Brings up CGC + GPT triple, runs sweep.
The application entry point Reset_Handler hands control to.
Brings up clocks + UART + RMII pins, then ThreadX.
The application entry point Reset_Handler hands control to.
Brings up clocks + UART, then enters ThreadX.
The application entry point Reset_Handler hands control to.
Brings up LED, console, SDHI pins, then ThreadX.
The application entry point Reset_Handler hands control to.
Brings up CGC + USB-FS + UAC1, then enters the iso-IN feed loop forever.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
See file header.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Profiles power modes once a second.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Brings up the clocks, console, SPI, and SD card, then runs the shared ra8_io VFS round-trip over the SD-over-SPI block device. On success it prints the exact PASS banner the HIL runner and ra8_emulator smoke gate scrape for; on any failure it prints FAIL and parks the core.
The application entry point Reset_Handler hands control to.
Initialises logging and the console, brings up the OSPI NOR volume, runs the erase-before-write round-trip, and prints a single PASS/FAIL verdict line over SCI8 before parking in an infinite loop.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Both USB controllers' clocks and pins come up before the kernel so the workers only deal with stack bring-up.
The application entry point Reset_Handler hands control to.
Brings up logging and the clock tree, releases the Cortex-M33 (which then blinks LED1 via ra8_pcntr_set_output()), and idles. See the file header.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Brings up logging, the clock tree, and the VCOM console, runs the cacheable-SRAM round-trip with the D-cache that SystemInit() enabled through ra8_cache_dcache_enable(), emits the matching PASS / FAIL banner over the console and ra8_log, then parks in WFI. Every byte the self-test touches runs with the L1 caches + MPU enabled by the shared boot (RA8_BOOT_ENABLE_CACHE_MPU + RA8_BOOT_CACHE_VIA_HAL).
The application entry point Reset_Handler hands control to.
Publishes the mailbox, releases the Cortex-M33 into the emitter, yields until it signals done, validates the blob the M33 built, then logs the PASS/FAIL verdict and the chapter count read back from the blob. See the file header for the offload narrative.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Publishes the mailbox, arms the IPC0 wake and configures the LPM block, releases the Cortex-M33 into the reader, waits for the first held page, logs the page-0 verdict, then runs the #150 mode-switch cycle – parking in low-power WFI and waking on the M33's page-turn pokes – before logging the handoff verdict and parking for good. See the file header for the narrative.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Brings up the timebase then measures forever.
The application entry point Reset_Handler hands control to.
Arms the RIIC1 target and polls the dispatcher.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Brings up the LIN commander then drives frames.
The application entry point Reset_Handler hands control to.
Brings up logging, "renders" page 0 into the shared mailbox, releases the Cortex-M33 into its hold loop, and parks the M85 in low-power WFI sleep. See the file header for the power-saving narrative.
The application entry point Reset_Handler hands control to.
The USB clock, pins, console, and the SD card all come up before the kernel so the worker only deals with USB stack bring-up.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Brings up logging, the clock tree, and the VCOM console, runs the three-step self-test (MPU enabled, canonical boot map, Device MMIO), emits the matching PASS / FAIL banner over the console and ra8_log, then parks in WFI.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Initialises logging + console, brings up the MRAM volume, runs the wear-levelling + power-cycle-survival flow, and prints a single PASS/FAIL verdict.
The application entry point Reset_Handler hands control to.
Initialises logging + console, brings up the MRAM volume, runs the program/erase round-trip, and prints a single PASS/FAIL verdict.
The application entry point Reset_Handler hands control to.
Brings up the clocks, console, and SDHI bus pins, runs the native SD card identification, fills the payload, then runs the full ra8_io VFS round-trip over the native-SDHI block device. On success it prints the exact PASS banner the HIL runner and ra8_emulator smoke gate scrape for; on any failure it prints FAIL and parks the core.
The application entry point Reset_Handler hands control to.
Brings up the console and both stdio sinks, retargets the engine's stdio to the in-RAM capture sink, runs the two-backend swap, replays the RAM capture out of the UART, and prints a single PASS/FAIL verdict per abstraction before parking in an infinite loop.
The application entry point Reset_Handler hands control to.
Brings up the clocks, console, and SDHI bus pins, runs the native SD card identification, fills the payload, then writes + reads + compares one raw 512-byte block straight against ra8_sdcard. On success it prints the exact PASS banner; on any failure it prints FAIL and parks the core.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Brings up clocks + UART + RMII + RSIP, then ThreadX.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Initializes and arms ADC_B, formats each successful channel sample without variadic I/O, emits the verdict, toggles LED1, and delays.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Brings up logging, releases the Cortex-M33 (which then blinks LED1), and idles. See the file header for the teaching narrative.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
See the file header for the full behaviour summary.
The application entry point Reset_Handler hands control to.
Brings up logging, the clock tree, and the VCOM console, runs the three-step self-test (cacheable SRAM, RO MRAM const, Device MMIO), emits the matching PASS / FAIL banner over the console and ra8_log, then parks in WFI. Every byte the self-test touches runs with the L1 caches and MPU enabled by the shared boot (RA8_BOOT_ENABLE_CACHE_MPU).
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Lights HOCO + PLL, then runs a 1 Hz blink.
The application entry point Reset_Handler hands control to.
See file header for behaviour summary.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
The application entry point Reset_Handler hands control to.
Initializes the demo, executes one comparison per period, increments the exported match or mismatch counter, and toggles the matching LED.
Definition at line 440 of file main.c.
References drw_blend_configure(), drw_blend_panic_halt(), drw_blend_print_pass(), drw_blend_render(), drw_blend_setup_or_halt(), g_drw_blend_crc, g_drw_blend_heartbeat, k_drw_blend_fail_msg, k_drw_blend_period_ms, k_ra8_board_led1, k_ra8_board_led2, k_ra8_ok, ra8_board_led_toggle(), ra8_board_uart_console_write(), ra8_delay_ms(), and ra8_isr_globals_enable().
| volatile uint32_t g_drw_blend_crc = 0U |
| volatile uint32_t g_drw_blend_err = 0U |
Non-zero if a DRW call returned an error during the last render.
Definition at line 165 of file main.c.
Referenced by drw_blend_render().
| volatile uint32_t g_drw_blend_fb[(uint32_t) k_drw_blend_fb_dim *(uint32_t) k_drw_blend_fb_dim] |
32 x 32 ARGB8888 framebuffer the DRW composites into.
Definition at line 149 of file main.c.
Referenced by drw_blend_configure(), and drw_blend_framebuffer_hash().
| volatile uint32_t g_drw_blend_heartbeat = 0U |
|
static |
|
static |
Success / failure banner text.
Definition at line 138 of file main.c.
Referenced by drw_blend_print_pass().
|
static |
Definition at line 139 of file main.c.
Referenced by drw_blend_print_pass().