ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
main.c File Reference

Headless on-silicon HIL gate for the raster image decode pipeline (#106). More...

#include <stddef.h>
#include <stdint.h>
#include "cover_fixture.h"
#include "ra8_board_ek_ra8d2.h"
#include "ra8_boot_entry.h"
#include "ra8_cgc.h"
#include "ra8_err.h"
#include "ra8_gfx.h"
#include "ra8_isr.h"
#include "ra8_mstp.h"
#include "ra8_time.h"
#include "reflow_image.h"
Include dependency graph for main.c:

Go to the source code of this file.

Enumerations

enum  iv_consts_t : uint32_t {
  k_iv_fb_w = 160U ,
  k_iv_fb_h = 120U ,
  k_iv_uart_baud = 115200U ,
  k_iv_arena_bytes = 128U * 1024U ,
  k_iv_fnv_offset = 2166136261U ,
  k_iv_fnv_prime = 16777619U ,
  k_iv_hex_nibbles = 8U ,
  k_iv_nibble_bits = 4U ,
  k_iv_nibble_mask = 0x0FU ,
  k_iv_dec_ten = 10U
}
 Framebuffer / console / hash knobs. More...
enum  iv_colors_t : uint32_t { k_iv_col_bg = 0x202028U }
 0x00RRGGBB palette. More...

Functions

static void iv_print (const uint8_t *msg, uint32_t len)
 Emit a byte run on the SCI8 console.
static void iv_panic_halt (void)
 Print the init-fail banner and spin (ra8_emulator halts on the BKPT).
static void iv_print_hex (uint32_t value)
 Print a 32-bit value as 8 upper-case hex digits.
static void iv_print_uint (uint32_t value)
 Print a small unsigned integer in decimal.
static uint32_t iv_framebuffer_hash (void)
 FNV-1a-32 over the rendered framebuffer bytes.
static void iv_setup_or_halt (void)
 Bring up clocks/MSTP/time + the SCI8 console; halt on failure.
void main (void)
 App entry: decode + scale + blit the cover to SRAM, hash it, print.

Variables

static uint16_t s_framebuffer [(size_t) k_iv_fb_h *(size_t) k_iv_fb_w]
 Fixed RGB565 framebuffer in internal SRAM (no panel attached).
static uint8_t s_img_arena [k_iv_arena_bytes]
 Fixed bump arena backing the heap-free PNG decode.
static const uint8_t k_msg_boot [] = "ereader-img-hil: boot\r\n"
static const uint8_t k_msg_fail [] = "ereader-img-hil: FAIL init\r\n"
static const uint8_t k_msg_derr [] = "ereader-img-hil: FAIL decode\r\n"
static const uint8_t k_msg_pre [] = "ereader-img-hil: img "
static const uint8_t k_msg_x [] = "x"
static const uint8_t k_msg_crc [] = " crc="
static const uint8_t k_msg_eol [] = "\r\n"

Detailed Description

Headless on-silicon HIL gate for the raster image decode pipeline (#106).

Closes the real-hardware gap for the zero-heap <img> / cover-image pipeline (reflow_image): decode -> nearest-neighbour scale-to-fit -> blit, with no panel / SDRAM / touch / SD dependency. The app:

  1. Decodes a baked 120x90 PNG cover (cover_fixture.h) through ra8_img_decode_blit(), allocating only from a fixed SRAM bump arena (so the decode reaches no malloc).
  2. Scales it to fit a fixed 160x120 RGB565 framebuffer in internal SRAM.
  3. Folds an FNV-1a-32 hash over the whole framebuffer and prints it on the SCI8 J-Link OB console:

    ereader-img-hil: img <W>x<H> crc=<8 hex>

The render is deterministic (integer nearest-neighbour + fixed RGB565 pack + a zeroed static framebuffer), so the hash is identical every boot and – by construction – the same value the identical host / ra8_emulator render produces. Any drift in the decoder, the scale math, or the toolchain output changes the hash and trips the uart_scrape gate.

[Ring 7 / App] {World: NS}

Since
0.1.0

Definition in file main.c.

Enumeration Type Documentation

◆ iv_colors_t

enum iv_colors_t : uint32_t

0x00RRGGBB palette.

Enumerator
k_iv_col_bg 

Framebuffer clear colour (dark slate).

Definition at line 67 of file main.c.

◆ iv_consts_t

enum iv_consts_t : uint32_t

Framebuffer / console / hash knobs.

Enumerator
k_iv_fb_w 

Framebuffer width, pixels.

k_iv_fb_h 

Framebuffer height, pixels.

k_iv_uart_baud 

Console baud.

k_iv_arena_bytes 

PNG decode scratch, bytes.

k_iv_fnv_offset 

FNV-1a-32 offset basis.

k_iv_fnv_prime 

FNV-1a-32 prime.

k_iv_hex_nibbles 

Hex digits in a 32-bit value.

k_iv_nibble_bits 

Bits per hex nibble.

k_iv_nibble_mask 

Low-nibble mask.

k_iv_dec_ten 

Hex digit / decimal split.

Definition at line 53 of file main.c.

Function Documentation

◆ iv_framebuffer_hash()

uint32_t iv_framebuffer_hash ( void )
static

FNV-1a-32 over the rendered framebuffer bytes.

Definition at line 143 of file main.c.

References k_iv_fnv_offset, k_iv_fnv_prime, and s_framebuffer.

Referenced by main().

◆ iv_panic_halt()

void iv_panic_halt ( void )
static

Print the init-fail banner and spin (ra8_emulator halts on the BKPT).

Definition at line 97 of file main.c.

References iv_print(), and k_msg_fail.

Referenced by iv_setup_or_halt(), and main().

◆ iv_print()

void iv_print ( const uint8_t * msg,
uint32_t len )
static

Emit a byte run on the SCI8 console.

Definition at line 91 of file main.c.

References ra8_board_uart_console_write().

Referenced by iv_panic_halt(), iv_print_hex(), iv_print_uint(), and main().

◆ iv_print_hex()

void iv_print_hex ( uint32_t value)
static

Print a 32-bit value as 8 upper-case hex digits.

Definition at line 107 of file main.c.

References iv_print(), k_iv_dec_ten, k_iv_hex_nibbles, k_iv_nibble_bits, and k_iv_nibble_mask.

Referenced by main().

◆ iv_print_uint()

void iv_print_uint ( uint32_t value)
static

Print a small unsigned integer in decimal.

Definition at line 119 of file main.c.

References iv_print(), and k_iv_dec_ten.

Referenced by main().

◆ iv_setup_or_halt()

void iv_setup_or_halt ( void )
static

Bring up clocks/MSTP/time + the SCI8 console; halt on failure.

Definition at line 160 of file main.c.

References iv_panic_halt(), k_iv_uart_baud, k_ra8_clock_id_cpuclk0, k_ra8_ok, ra8_board_uart_console_init(), ra8_cgc_get_clock_hz(), ra8_cgc_init(), ra8_mstp_init(), and ra8_time_init().

Referenced by main().

◆ main()

void main ( void )

App entry: decode + scale + blit the cover to SRAM, hash it, print.

The application entry point Reset_Handler hands control to.

Precondition
Reset_Handler copied .data and zeroed .bss.
SystemInit set VTOR / FPU / priority grouping.
Postcondition
The framebuffer hash banner is emitted; the CPU then loops in WFI.
Since
0.1.0

Definition at line 185 of file main.c.

References iv_framebuffer_hash(), iv_panic_halt(), iv_print(), iv_print_hex(), iv_print_uint(), iv_setup_or_halt(), k_cover_png, k_cover_png_len, k_iv_arena_bytes, k_iv_col_bg, k_iv_fb_h, k_iv_fb_w, k_msg_boot, k_msg_crc, k_msg_derr, k_msg_eol, k_msg_pre, k_msg_x, k_ra8_gfx_format_rgb565, k_ra8_ok, ra8_gfx_clear(), ra8_gfx_init(), ra8_img_decode_blit(), ra8_isr_globals_enable(), s_framebuffer, and s_img_arena.

Variable Documentation

◆ k_msg_boot

const uint8_t k_msg_boot[] = "ereader-img-hil: boot\r\n"
static

Definition at line 77 of file main.c.

◆ k_msg_crc

const uint8_t k_msg_crc[] = " crc="
static

Definition at line 82 of file main.c.

◆ k_msg_derr

const uint8_t k_msg_derr[] = "ereader-img-hil: FAIL decode\r\n"
static

Definition at line 79 of file main.c.

◆ k_msg_eol

const uint8_t k_msg_eol[] = "\r\n"
static

Definition at line 83 of file main.c.

◆ k_msg_fail

const uint8_t k_msg_fail[] = "ereader-img-hil: FAIL init\r\n"
static

Definition at line 78 of file main.c.

◆ k_msg_pre

const uint8_t k_msg_pre[] = "ereader-img-hil: img "
static

Definition at line 80 of file main.c.

◆ k_msg_x

const uint8_t k_msg_x[] = "x"
static

Definition at line 81 of file main.c.

◆ s_framebuffer

uint16_t s_framebuffer[(size_t) k_iv_fb_h *(size_t) k_iv_fb_w]
static

Fixed RGB565 framebuffer in internal SRAM (no panel attached).

Definition at line 72 of file main.c.

◆ s_img_arena

uint8_t s_img_arena[k_iv_arena_bytes]
static

Fixed bump arena backing the heap-free PNG decode.

Definition at line 75 of file main.c.