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

On-silicon HIL: large-structure EPUB opens on the static arena (#144). More...

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

Go to the source code of this file.

Enumerations

enum  est_consts_t : uint32_t {
  k_est_uart_baud = 115200U ,
  k_est_expect_chap = 60U ,
  k_est_expect_toc = 60U ,
  k_est_expect_files = 125U ,
  k_est_dec_ten = 10U
}
 Console / assertion knobs (no magic numbers). More...

Functions

static void est_print (const uint8_t *msg, uint32_t len)
 Emit a byte run on the SCI8 console.
static void est_panic_halt (const uint8_t *msg, uint32_t len)
 Print the fail banner and trap (ra8_emulator halts on the BKPT).
static void est_print_uint (uint32_t value)
 Print a small unsigned integer in decimal.
static void est_setup_or_halt (void)
 Bring up clocks/MSTP/time + the SCI8 console; halt on failure.
static void est_open_or_halt (uint16_t *out_chap, uint16_t *out_toc)
 Open the stress EPUB through bounded ZIP/XML paths; assert the structure.
void main (void)
 App entry: open the large-structure EPUB on silicon, print the banner.

Variables

static epub_book_t s_book
 Opened book (large – file-scope, not on the stack).
static const uint8_t k_msg_boot [] = "epub-stress-hil: boot\r\n"
static const uint8_t k_msg_fail [] = "epub-stress-hil: FAIL init\r\n"
static const uint8_t k_msg_open [] = "epub-stress-hil: FAIL open (arena no_mem?)\r\n"
static const uint8_t k_msg_chap [] = "epub-stress-hil: FAIL chapters\r\n"
static const uint8_t k_msg_toc [] = "epub-stress-hil: FAIL toc\r\n"
static const uint8_t k_msg_cov [] = "epub-stress-hil: FAIL cover\r\n"
static const uint8_t k_msg_pre [] = "epub-stress-hil: files=125 chapters="
static const uint8_t k_msg_tocp [] = " toc="
static const uint8_t k_msg_covp [] = " cover=ok"
static const uint8_t k_msg_ok [] = " PASS\r\n"

Detailed Description

On-silicon HIL: large-structure EPUB opens on the static arena (#144).

Regression gate for #144 bug 1 ("large EPUBs fail to open with no_mem"). On the firmware target, miniz's ZIP central directory uses a 96 KiB static arena while OPF and NCX parsing use fixed caller-owned XML workspaces. A big real book (many image files + a large OPF manifest) stresses both bounds. The original no_mem turned out to be the 16 KiB OPF/NCX scratch buffer (fixed in the NCX commit, now 48 KiB), not the arena – this gate proves the arena itself holds a large-structure book.

It opens a baked synthetic large-structure EPUB in memory – 60 chapters

  • 60 manifest resources + an NCX with 60 navPoints + a cover, 125 archive entries / a ~10 KB OPF (more files than the 108-file, 41-chapter real Boox book that triggered the report) – and asserts:
    • epub_open returns k_ra8_ok (all bounded resources were sufficient),
    • chapter count == 60 (full spine parsed),
    • NCX TOC count == 60 (every navPoint extracted, #144 bug 2),
    • the cover-image manifest item resolved (cover_path non-empty).

The fixture is synthetic (not the copyrighted novel), tens of KB, so it bakes into MRAM and opens in memory like epub_parse. Deterministic, so the ra8_emulator CRC-free banner is the regression net:

epub-stress-hil: files=125 chapters=60 toc=60 cover=ok PASS

Any failure prints a FAIL banner and halts on a BKPT before PASS.

[Ring 7 / App] {World: NS}

Since
0.1.0

Definition in file main.c.

Enumeration Type Documentation

◆ est_consts_t

enum est_consts_t : uint32_t

Console / assertion knobs (no magic numbers).

Enumerator
k_est_uart_baud 

Console baud.

k_est_expect_chap 

Spine length of the synthetic book.

k_est_expect_toc 

navPoint count in the synthetic NCX.

k_est_expect_files 

Archive entries (reported, not gated).

k_est_dec_ten 

Decimal base for the small printer.

Definition at line 54 of file main.c.

Function Documentation

◆ est_open_or_halt()

void est_open_or_halt ( uint16_t * out_chap,
uint16_t * out_toc )
static

Open the stress EPUB through bounded ZIP/XML paths; assert the structure.

Halts on any failure stage before returning. Proves the miniz arena and caller-owned XML workspaces handle a 125-entry / 60-chapter book and that the NCX + cover both parse.

Parameters
[out]out_chapReceives the parsed chapter count (== 60 on success).
[out]out_tocReceives the parsed NCX TOC count (== 60 on success).
Precondition
est_setup_or_halt ran.
Postcondition
On return the assertions held; out_chap / out_toc are set.
Since
0.1.0

Definition at line 143 of file main.c.

References epub_get_chapter_count(), epub_get_toc_count(), epub_open(), est_panic_halt(), k_epub_stress_fixture, k_epub_stress_fixture_len, k_est_expect_chap, k_est_expect_toc, k_msg_chap, k_msg_cov, k_msg_open, k_msg_toc, k_ra8_ok, and s_book.

Referenced by main().

◆ est_panic_halt()

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

Print the fail banner and trap (ra8_emulator halts on the BKPT).

Definition at line 83 of file main.c.

References est_print().

Referenced by est_open_or_halt(), and est_setup_or_halt().

◆ est_print()

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

Emit a byte run on the SCI8 console.

Definition at line 77 of file main.c.

References ra8_board_uart_console_write().

Referenced by est_panic_halt(), est_print_uint(), and main().

◆ est_print_uint()

void est_print_uint ( uint32_t value)
static

Print a small unsigned integer in decimal.

Definition at line 93 of file main.c.

References est_print(), and k_est_dec_ten.

Referenced by main().

◆ est_setup_or_halt()

void est_setup_or_halt ( void )
static

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

Definition at line 112 of file main.c.

References est_panic_halt(), k_est_uart_baud, k_msg_fail, 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: open the large-structure EPUB on silicon, print the banner.

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 chapters/toc/cover banner is emitted; CPU loops in WFI.
Since
0.1.0

Definition at line 174 of file main.c.

References est_open_or_halt(), est_print(), est_print_uint(), est_setup_or_halt(), k_msg_boot, k_msg_covp, k_msg_ok, k_msg_pre, k_msg_tocp, and ra8_isr_globals_enable().

Variable Documentation

◆ k_msg_boot

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

Definition at line 65 of file main.c.

◆ k_msg_chap

const uint8_t k_msg_chap[] = "epub-stress-hil: FAIL chapters\r\n"
static

Definition at line 68 of file main.c.

◆ k_msg_cov

const uint8_t k_msg_cov[] = "epub-stress-hil: FAIL cover\r\n"
static

Definition at line 70 of file main.c.

Referenced by ec_render_cover_or_halt(), and est_open_or_halt().

◆ k_msg_covp

const uint8_t k_msg_covp[] = " cover=ok"
static

Definition at line 73 of file main.c.

Referenced by main().

◆ k_msg_fail

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

Definition at line 66 of file main.c.

◆ k_msg_ok

const uint8_t k_msg_ok[] = " PASS\r\n"
static

Definition at line 74 of file main.c.

◆ k_msg_open

const uint8_t k_msg_open[] = "epub-stress-hil: FAIL open (arena no_mem?)\r\n"
static

Definition at line 67 of file main.c.

◆ k_msg_pre

const uint8_t k_msg_pre[] = "epub-stress-hil: files=125 chapters="
static

Definition at line 71 of file main.c.

◆ k_msg_toc

const uint8_t k_msg_toc[] = "epub-stress-hil: FAIL toc\r\n"
static

Definition at line 69 of file main.c.

Referenced by est_open_or_halt().

◆ k_msg_tocp

const uint8_t k_msg_tocp[] = " toc="
static

Definition at line 72 of file main.c.

Referenced by main().

◆ s_book

epub_book_t s_book
static

Opened book (large – file-scope, not on the stack).

Definition at line 63 of file main.c.