ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
main.c
Go to the documentation of this file.
1
35
36#include <stdint.h>
37
38#include "ra8_board_ek_ra8d2.h"
39#include "ra8_boot_entry.h"
40#include "ra8_cgc.h"
41#include "ra8_err.h"
42#include "ra8_mstp.h"
43#include "ra8_time.h"
44#include "ra8_webp.h"
45#include "ra8_webp_arena.h"
46
61
63static const uint8_t k_webp_lossless[] = {
64 0x52, 0x49, 0x46, 0x46, 0x2C, 0x00, 0x00, 0x00, 0x57, 0x45, 0x42, 0x50, 0x56,
65 0x50, 0x38, 0x4C, 0x1F, 0x00, 0x00, 0x00, 0x2F, 0x07, 0xC0, 0x01, 0x00, 0xCD,
66 0x65, 0x44, 0xFF, 0x63, 0x17, 0x85, 0x28, 0x78, 0xFF, 0x03, 0x42, 0x02, 0xC2,
67 0x14, 0xFF, 0x77, 0x6A, 0x0E, 0x0C, 0x48, 0xC4, 0x04, 0x80, 0xAD, 0x0D, 0x00,
68};
69
71static const uint8_t k_webp_demo_pass[] = "webp: PASS 8x8\r\n";
73static const uint8_t k_webp_demo_fail[] = "webp: FAIL\r\n";
74
76alignas(16) static uint8_t s_webp_demo_scratch[k_webp_demo_scratch];
78alignas(16) static uint8_t s_webp_demo_fb[k_webp_demo_fb_bytes];
79
86static void webp_demo_panic_halt(void)
87{
88 while (1) {
89 __asm__ volatile("wfi");
90 }
91}
92
99static void webp_demo_setup_or_halt(void)
100{
101 uint32_t cpuclk0_hz = 0U;
102 if (ra8_cgc_init() != k_ra8_ok) {
104 }
107 }
108 if (ra8_mstp_init() != k_ra8_ok) {
110 }
111 if (ra8_time_init(cpuclk0_hz) != k_ra8_ok) {
113 }
116 }
117}
118
126static bool webp_demo_decode_ok(void)
127{
128 ra8_webp_arena_t arena = {.base = s_webp_demo_scratch,
129 .cap = sizeof s_webp_demo_scratch,
130 .offset = 0U,
131 .live = 0U};
132 uint32_t w = 0U;
133 uint32_t h = 0U;
135 sizeof k_webp_lossless,
136 &arena,
138 (size_t)k_webp_demo_stride,
139 sizeof s_webp_demo_fb,
140 &w,
141 &h);
142 if ((e != k_ra8_ok) || (w != k_webp_demo_dim) || (h != k_webp_demo_dim)) {
143 return false;
144 }
145 /* Pixel (1,1) of the source pattern is (r,g,b,a) = (32, 32, 32, 255). */
146 const uint8_t* const p = &s_webp_demo_fb[k_webp_demo_stride + k_webp_demo_bpp];
147 return (p[0] == (uint8_t)k_webp_demo_probe_r) && (p[1] == (uint8_t)k_webp_demo_probe_r) &&
148 (p[2] == (uint8_t)k_webp_demo_probe_r) && (p[3] == (uint8_t)k_webp_demo_probe_a);
149}
150
155void main(void)
156{
158
159 const bool ok = webp_demo_decode_ok();
160 const uint8_t* const banner = ok ? k_webp_demo_pass : k_webp_demo_fail;
161 const size_t ban_len = ok ? (sizeof k_webp_demo_pass - 1U) : (sizeof k_webp_demo_fail - 1U);
162 (void)ra8_board_uart_console_write(banner, ban_len);
163
165}
void main(void)
Secure fallback main entry point.
Definition main.c:37
static const uint8_t k_webp_lossless[]
8x8 VP8L (lossless, -exact) fixture – see tests/fixtures/webp/README.md.
Definition main.c:63
webp_demo_consts_t
Fixed geometry + buffer sizes for the baked 8x8 fixture.
Definition main.c:51
@ k_webp_demo_bpp
RGBA8888 bytes per pixel.
Definition main.c:54
@ k_webp_demo_probe_r
Expected R at pixel (1,1).
Definition main.c:58
@ k_webp_demo_dim
Fixture width and height.
Definition main.c:53
@ k_webp_demo_scratch
Decode arena, bytes.
Definition main.c:57
@ k_webp_demo_fb_bytes
8x8 RGBA.
Definition main.c:56
@ k_webp_demo_probe_a
Expected A at pixel (1,1).
Definition main.c:59
@ k_webp_demo_baud
Console baud rate.
Definition main.c:52
@ k_webp_demo_stride
Row stride.
Definition main.c:55
static uint8_t s_webp_demo_scratch[k_webp_demo_scratch]
Decode arena backing store (static SRAM, NASA P10 Rule 3).
Definition main.c:76
static void webp_demo_setup_or_halt(void)
Bring CGC + module-stop + SysTick + console up, or panic-halt.
Definition main.c:99
static bool webp_demo_decode_ok(void)
Decode the baked fixture and confirm a known pixel round-trips.
Definition main.c:126
static void webp_demo_panic_halt(void)
Park the CPU forever after a fatal init failure.
Definition main.c:86
static const uint8_t k_webp_demo_pass[]
PASS banner (HIL scrape target).
Definition main.c:71
static uint8_t s_webp_demo_fb[k_webp_demo_fb_bytes]
Decoded RGBA8888 output framebuffer.
Definition main.c:78
static const uint8_t k_webp_demo_fail[]
FAIL banner (HIL scrape target).
Definition main.c:73
Board-support layer for the Renesas EK-RA8D2 v1 evaluation kit.
ra8_err_t ra8_board_uart_console_write(const uint8_t *data, size_t len)
Polled blocking write to the J-Link OB VCOM console.
ra8_err_t ra8_board_uart_console_init(uint32_t baud)
Configure SCI8 + PD02/PD03 as the debug-console UART.
Boot entry points shared between a vector table and its startup code.
High-level Clock Generation Circuit driver.
ra8_err_t ra8_cgc_get_clock_hz(ra8_clock_id_t id, uint32_t *out_hz)
Query the current frequency of a clock-tree domain.
Definition ra8_cgc.c:132
@ k_ra8_clock_id_cpuclk0
Cortex-M85 CPUCLK0.
Definition ra8_cgc.h:70
ra8_err_t ra8_cgc_init(void)
Configure the clock tree to a safe default.
Definition ra8_cgc.c:727
Error Code Definitions for ra8-firmware.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
Definition ra8_err.h:119
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Definition ra8_err.h:546
Ref-counted Module Stop Control wrapper for the RA8D2.
ra8_err_t ra8_mstp_init(void)
Re-establish the ra8_mstp ref-count table from current hardware state.
Definition ra8_mstp.c:291
SysTick-based tick counter, delay and timestamp helpers.
ra8_err_t ra8_time_init(uint32_t cpu_hz)
Initialise SysTick for a 1 kHz tick interrupt.
Definition ra8_time.c:59
Zero-heap WebP (VP8 / VP8L) decode facade over the vendored libwebp.
ra8_err_t ra8_webp_decode_rgba(const uint8_t *data, size_t size, ra8_webp_arena_t *arena, uint8_t *out_rgba, size_t out_stride, size_t out_capacity, uint32_t *out_w, uint32_t *out_h)
Decode a WebP into a caller-owned RGBA8888 buffer, heap-free.
Definition ra8_webp.c:187
Heap-free scratch allocator hooks for the vendored libwebp decoder.
Caller-owned bump arena backing a single WebP decode.