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 e-reader chrome render pipeline. More...

#include <stdint.h>
#include "ra8_board_ek_ra8d2.h"
#include "ra8_boot_entry.h"
#include "ra8_box.h"
#include "ra8_cgc.h"
#include "ra8_err.h"
#include "ra8_gfx.h"
#include "ra8_gfx_font.h"
#include "ra8_isr.h"
#include "ra8_mstp.h"
#include "ra8_time.h"
#include "ra8_ui.h"
Include dependency graph for main.c:

Go to the source code of this file.

Enumerations

enum  chrome_hil_cfg_t : uint32_t {
  k_ch_fb_w = 320U ,
  k_ch_fb_h = 240U ,
  k_ch_uart_baud = 115200U ,
  k_ch_max_nodes = 16U ,
  k_ch_cell_count = 4U ,
  k_ch_status_h = 28U ,
  k_ch_root_pad = 8U ,
  k_ch_grid_pad = 6U ,
  k_ch_grid_gap = 8U ,
  k_ch_cell_pad = 8U ,
  k_ch_border_w = 1U ,
  k_ch_fnv_offset = 2166136261U ,
  k_ch_fnv_prime = 16777619U ,
  k_ch_hex_nibbles = 8U ,
  k_ch_nibble_bits = 4U ,
  k_ch_nibble_mask = 0x0FU ,
  k_ch_dec_ten = 10U
}
 Framebuffer + console + render geometry constants. More...
enum  chrome_hil_color_t : uint32_t {
  k_ch_col_page = 0xF4F0E8U ,
  k_ch_col_bar = 0x303860U ,
  k_ch_col_bar_tx = 0xFFFFFFU ,
  k_ch_col_cell = 0xC8D8F0U ,
  k_ch_col_edge = 0x283048U ,
  k_ch_col_ink = 0x101010U
}
 Chrome palette (0xRRGGBB; ra8_gfx down-converts to RGB565). More...

Functions

static void ch_print (const uint8_t *msg, uint32_t len)
 Emit a byte run on the SCI8 console.
static void ch_panic_halt (void)
 Park forever in WFI after a fatal init error.
static void ch_print_hex (uint32_t value)
 Print value as 8 uppercase hex digits + a trailing EOL.
static void ch_print_uint (uint32_t value)
 Print a small unsigned integer in decimal.
static int16_t ch_build_chrome (ra8_box_tree_t *tree)
 Build the status-bar-over-grid chrome tree; return the root index.
static void ch_fill (const ra8_ui_rect_t *r, uint32_t color)
 Fill a rectangle by drawing h horizontal spans.
static void ch_border (const ra8_ui_rect_t *r, uint32_t color)
 Draw a 1-pixel border around a rectangle.
static void ch_render (const ra8_box_tree_t *tree)
 Render the laid-out tree: per node, fill + border + label.
static uint32_t ch_framebuffer_hash (void)
 FNV-1a-32 over the rendered framebuffer bytes.
static void ch_setup_or_halt (void)
 Bring up clocks/MSTP/time + the SCI8 console; halt on failure.
void main (void)
 App entry: render the chrome to SRAM, hash it, print over UART.

Variables

static uint16_t s_framebuffer [(size_t) k_ch_fb_h *(size_t) k_ch_fb_w]
 RGB565 render target in internal SRAM.
static ra8_box_t s_box_nodes [k_ch_max_nodes]
 Box-tree node storage.
static const char * s_label [k_ch_max_nodes]
 Per-node label (NULL = no text), indexed by box-tree node.
static const char *const k_ch_titles [k_ch_cell_count]
 Demo shelf titles (public-domain).
static const uint8_t k_msg_boot [] = "ereader-hil: boot\r\n"
static const uint8_t k_msg_fail [] = "ereader-hil: FAIL init\r\n"
static const uint8_t k_msg_pre [] = "ereader-hil: chrome boxes="
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 e-reader chrome render pipeline.

Tag
[Ring 6 / APP] {World: S}

The e-reader chrome (#76 box model + #80 interaction) is golden-validated on the ra8_emulator. This app closes the on-hardware gap: it exercises the real ra8_box layout + ra8_gfx software render on the actual RA8D2, deterministically, with no panel / SDRAM / touch / SD dependency.

It builds a representative chrome screen as an ra8_box tree (a status bar over a 2-column grid of "book" cells), lays it out with ra8_box_layout, renders the boxes (fill + 1-px border) and labels (bundled ra8_gfx_font_8x16) into a static RGB565 framebuffer in internal SRAM, then folds an FNV-1a-32 hash over the whole framebuffer and prints it over the SCI8 J-Link OB console:

ereader-hil: chrome boxes=<N> crc=<8 hex>

The HIL gate (hil.conf, uart_scrape) asserts that hash equals the baseline captured on-bench – so any drift in the box-model math, the software rasteriser, or the toolchain output flags a regression on real silicon. Deterministic: integer layout + a fixed bitmap font + a zeroed static framebuffer give the same hash every boot.

Since
0.1.0

Definition in file main.c.

Enumeration Type Documentation

◆ chrome_hil_cfg_t

enum chrome_hil_cfg_t : uint32_t

Framebuffer + console + render geometry constants.

Enumerator
k_ch_fb_w 

Framebuffer width, pixels.

k_ch_fb_h 

Framebuffer height, pixels.

k_ch_uart_baud 

Console baud.

k_ch_max_nodes 

Box-tree node capacity.

k_ch_cell_count 

Book cells in the grid.

k_ch_status_h 

Status-bar fixed height, px.

k_ch_root_pad 

Root padding, px.

k_ch_grid_pad 

Grid padding, px.

k_ch_grid_gap 

Grid inter-cell gap, px.

k_ch_cell_pad 

Cell text inset, px.

k_ch_border_w 

Cell border width, px.

k_ch_fnv_offset 

FNV-1a-32 offset basis.

k_ch_fnv_prime 

FNV-1a-32 prime.

k_ch_hex_nibbles 

Hex digits in a 32-bit value.

k_ch_nibble_bits 

Bits per hex nibble.

k_ch_nibble_mask 

Low-nibble mask.

k_ch_dec_ten 

Hex digit / decimal split.

Definition at line 52 of file main.c.

◆ chrome_hil_color_t

enum chrome_hil_color_t : uint32_t

Chrome palette (0xRRGGBB; ra8_gfx down-converts to RGB565).

Enumerator
k_ch_col_page 

Page / root background.

k_ch_col_bar 

Status-bar fill (navy).

k_ch_col_bar_tx 

Status-bar text (white).

k_ch_col_cell 

Cell fill (light blue).

k_ch_col_edge 

Cell border (dark navy).

k_ch_col_ink 

Cell label (near-black).

Definition at line 76 of file main.c.

Function Documentation

◆ ch_border()

void ch_border ( const ra8_ui_rect_t * r,
uint32_t color )
static

Draw a 1-pixel border around a rectangle.

Definition at line 212 of file main.c.

References ra8_ui_rect_t::h, ra8_gfx_line(), ra8_ui_rect_t::w, ra8_ui_rect_t::x, and ra8_ui_rect_t::y.

Referenced by ch_render().

◆ ch_build_chrome()

int16_t ch_build_chrome ( ra8_box_tree_t * tree)
static

◆ ch_fill()

void ch_fill ( const ra8_ui_rect_t * r,
uint32_t color )
static

Fill a rectangle by drawing h horizontal spans.

Definition at line 204 of file main.c.

References ra8_ui_rect_t::h, ra8_gfx_line(), ra8_ui_rect_t::w, ra8_ui_rect_t::x, and ra8_ui_rect_t::y.

Referenced by ch_render().

◆ ch_framebuffer_hash()

uint32_t ch_framebuffer_hash ( void )
static

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

Definition at line 250 of file main.c.

References k_ch_fnv_offset, k_ch_fnv_prime, and s_framebuffer.

Referenced by main().

◆ ch_panic_halt()

void ch_panic_halt ( void )
static

Park forever in WFI after a fatal init error.

Definition at line 118 of file main.c.

References ch_print(), and k_msg_fail.

Referenced by ch_setup_or_halt(), and main().

◆ ch_print()

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

Emit a byte run on the SCI8 console.

Definition at line 112 of file main.c.

References ra8_board_uart_console_write().

Referenced by ch_panic_halt(), ch_print_hex(), ch_print_uint(), and main().

◆ ch_print_hex()

void ch_print_hex ( uint32_t value)
static

Print value as 8 uppercase hex digits + a trailing EOL.

Definition at line 127 of file main.c.

References ch_print(), k_ch_dec_ten, k_ch_hex_nibbles, k_ch_nibble_bits, and k_ch_nibble_mask.

Referenced by main().

◆ ch_print_uint()

void ch_print_uint ( uint32_t value)
static

Print a small unsigned integer in decimal.

Definition at line 139 of file main.c.

References ch_print(), and k_ch_dec_ten.

Referenced by main().

◆ ch_render()

void ch_render ( const ra8_box_tree_t * tree)
static

Render the laid-out tree: per node, fill + border + label.

Definition at line 223 of file main.c.

References ch_border(), ch_fill(), ra8_box_tree_t::count, k_ch_cell_pad, k_ch_col_bar, k_ch_col_bar_tx, k_ch_col_ink, k_ch_col_page, k_ra8_box_no_colour, ra8_box_tree_t::nodes, ra8_gfx_clear(), ra8_gfx_font_8x16, ra8_gfx_text_out(), and s_label.

Referenced by main().

◆ ch_setup_or_halt()

void ch_setup_or_halt ( void )
static

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

Definition at line 267 of file main.c.

References ch_panic_halt(), k_ch_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: render the chrome to SRAM, hash it, print over UART.

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 292 of file main.c.

References ch_build_chrome(), ch_framebuffer_hash(), ch_panic_halt(), ch_print(), ch_print_hex(), ch_print_uint(), ch_render(), ch_setup_or_halt(), ra8_box_tree_t::count, k_ch_fb_h, k_ch_fb_w, k_msg_boot, k_msg_crc, k_msg_eol, k_msg_pre, k_ra8_gfx_format_rgb565, k_ra8_ok, ra8_box_layout(), ra8_gfx_init(), ra8_isr_globals_enable(), and s_framebuffer.

Variable Documentation

◆ k_ch_titles

const char* const k_ch_titles[k_ch_cell_count]
static
Initial value:
= {"Frankenstein",
"Moby Dick",
"Walden",
"The Odyssey"}

Demo shelf titles (public-domain).

Definition at line 95 of file main.c.

Referenced by ch_build_chrome().

◆ k_msg_boot

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

Definition at line 100 of file main.c.

◆ k_msg_crc

const uint8_t k_msg_crc[] = " crc="
static

Definition at line 103 of file main.c.

◆ k_msg_eol

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

Definition at line 104 of file main.c.

◆ k_msg_fail

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

Definition at line 101 of file main.c.

◆ k_msg_pre

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

Definition at line 102 of file main.c.

◆ s_box_nodes

ra8_box_t s_box_nodes[k_ch_max_nodes]
static

Box-tree node storage.

Definition at line 89 of file main.c.

Referenced by ch_build_chrome().

◆ s_framebuffer

uint16_t s_framebuffer[(size_t) k_ch_fb_h *(size_t) k_ch_fb_w]
static

RGB565 render target in internal SRAM.

Definition at line 86 of file main.c.

◆ s_label

const char* s_label[k_ch_max_nodes]
static

Per-node label (NULL = no text), indexed by box-tree node.

Definition at line 92 of file main.c.

Referenced by ch_build_chrome(), ch_render(), er_add_book_tile(), er_build_library(), er_build_nav(), er_build_toolbar(), er_render_boxnodes(), and er_reset_side_tables().