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
25
26#include <stddef.h>
27#include <stdint.h>
28
29#include "ra8_attributes.h"
30#include "ra8_board_ek_ra8d2.h"
32#include "ra8_boot_entry.h"
33#include "ra8_cgc.h"
34#include "ra8_check.h"
35#include "ra8_err.h"
36#include "ra8_io.h"
37#include "ra8_io_roundtrip.h"
38#include "ra8_log.h"
39#include "ra8_time.h"
40
42typedef enum : uint32_t {
43 k_demo_uart_baud = 115200U,
48
50static uint8_t s_disk[(size_t)k_demo_disk_blocks * (size_t)k_ra8_io_block_size_bytes];
58
60static const char* const s_tag = "ra8_io_demo";
61
64 .vfs_prefix = "ram",
65 .fat_type = k_ra8_fs_type_fat12,
66 .volume_label = "RAIO",
67 .log_tag = s_tag,
68 .root_file = "HELLO.TXT",
69 .root_path = "ram:/HELLO.TXT",
70 .root_bytes = (uint32_t)k_demo_payload,
71 .subdir_path = "ram:/SUB",
72 .subdir_file = "ram:/SUB/NOTE.TXT",
73 .subdir_bytes = (uint32_t)k_demo_note_len,
74};
75
94RA8_INTERNAL static void internal_demo_print(const char* msg)
95{
96 (void)ra8_io_stream_puts(&s_uart, msg);
97}
98
119{
120 uint32_t cpuclk0_hz = 0U;
121 if ((ra8_cgc_init() != k_ra8_ok) ||
123 (ra8_time_init(cpuclk0_hz) != k_ra8_ok) ||
126 while (true) {
127 }
128 }
129}
130
154{
157 s_tag,
158 "blockdev init");
160 return ra8_io_roundtrip_root_file(*out_mount, &s_params);
161}
162
168void main(void)
169{
170 ra8_log_init();
172 (void)ra8_io_log_attach(&s_uart); /* route ra8_log into the console stream too */
173 internal_demo_print("ra8_io_demo: boot\r\n");
174
175 ra8_fs_mount_t* mnt = nullptr;
176 const ra8_err_t e = internal_demo_run(&mnt);
177 if (e == k_ra8_ok) {
178 internal_demo_print("ra8_io_demo: wrote/read 128 bytes ram:/HELLO.TXT PASS\r\n");
180 internal_demo_print("ra8_io_demo: mkdir+nested ram:/SUB/NOTE.TXT PASS\r\n");
181 } else {
182 internal_demo_print("ra8_io_demo: mkdir FAIL\r\n");
183 }
184 } else {
185 internal_demo_print("ra8_io_demo: FAIL\r\n");
186 }
188 while (true) {
189 }
190}
void main(void)
Secure fallback main entry point.
Definition main.c:37
static void internal_demo_print(const char *s)
Convenience wrapper to write a NUL-terminated string to SCI8.
Definition main.c:326
static void internal_demo_setup_or_halt(void)
Bring CGC + the J-Link OB VCOM console + on-board Ethernet + RSIP up.
Definition main.c:285
static ra8_err_t internal_demo_run(uint32_t *out_blob_len)
Bind both backends and run the transparent round-trip on each.
Definition main.c:303
static uint8_t s_disk[(size_t) k_demo_disk_blocks *(size_t) k_ra8_io_block_size_bytes]
256 KiB RAM-disk backing buffer (in SRAM .bss) for the "ram" mount.
Definition main.c:75
demo_const_t
Console + volume + payload knobs (no magic numbers).
Definition main.c:56
@ k_demo_payload
Source bytes (compressible).
Definition main.c:60
@ k_demo_disk_blocks
256 KiB per volume (FAT12).
Definition main.c:59
@ k_demo_uart_baud
Console baud.
Definition main.c:58
static ra8_io_stream_t s_uart
UART output stream + its sink state.
Definition main.c:88
static ra8_fs_backend_t s_be
ra8_fs backend bridged onto the cached block device.
Definition main.c:71
static const ra8_io_roundtrip_params_t s_params
Shared round-trip parameters for this RAM-backed FAT12 volume.
Definition main.c:63
@ k_demo_note_len
Bytes round-tripped in the subdir.
Definition main.c:46
static ra8_io_blockdev_ram_state_t s_bstate
Definition main.c:53
static ra8_io_blockdev_t s_bd
Block-device handle + its RAM backend state.
Definition main.c:52
static const char * s_tag
Logging / check tag.
Definition ra8_app.c:17
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Board-support layer for the Renesas EK-RA8D2 v1 evaluation kit.
EK-RA8D2 debug console as an ra8_io_stream byte sink.
ra8_err_t ra8_board_console_stream(ra8_io_stream_t *out)
Bind the J-Link OB VCOM console into a caller-owned stream handle.
ra8_err_t ra8_board_uart_console_init(uint32_t baud)
Configure SCI8 + PD02/PD03 as the debug-console UART.
ra8_err_t ra8_board_uart_console_flush(void)
Block until every byte queued on the J-Link OB VCOM console has finished clocking out on the wire.
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
Validation and Error-Checking Macros for ra8-firmware.
#define RA8_RETURN_ON_ERROR(err, tag, message)
Early return on error, propagating the code upward.
Definition ra8_check.h:184
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
@ k_ra8_fs_type_fat12
count_of_clusters < 4085.
ra8_io – unified peripheral-agnostic I/O fabric (umbrella header).
@ k_ra8_io_block_size_bytes
Bytes per logical block (the only size).
ra8_err_t ra8_io_blockdev_ram_init(ra8_io_blockdev_t *bd, ra8_io_blockdev_ram_state_t *state, uint8_t *storage, uint32_t block_count, bool read_only)
Bind a RAM block-device backend into a caller-owned handle.
ra8_err_t ra8_io_roundtrip_root_file(ra8_fs_mount_t *mnt, const ra8_io_roundtrip_params_t *p)
Whole-file write at the volume root, VFS read-back, and byte-compare.
ra8_err_t ra8_io_roundtrip_mount(ra8_io_blockdev_t *bd, const ra8_io_roundtrip_params_t *p, ra8_fs_backend_t *be, ra8_fs_mount_t **out_mount)
Bridge a bound block device to ra8_fs, format + mount FAT, VFS-register.
ra8_err_t ra8_io_roundtrip_subdir_file(const ra8_io_roundtrip_params_t *p)
mkdir a subdirectory via the VFS, then round-trip a nested file.
ra8_err_t ra8_io_log_attach(ra8_io_stream_t *s)
Route ra8_log output to a bound ra8_io stream.
Definition ra8_io_log.c:61
ra8_err_t ra8_io_stream_puts(ra8_io_stream_t *s, const char *str)
Write a NUL-terminated string (without the NUL) to the bound sink.
Lightweight Logging Interface for ra8-firmware.
void ra8_log_init(void)
Initialise the logging backend.
Definition ra8_log.c:379
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
Block-device interface that ra8_fs runs on top of.
Cached parse of one mounted FAT volume.
Caller-owned private state for a RAM block device.
Caller-allocated block-device handle binding a backend to its context.
Per-demo knobs for the shared ra8_io round-trip.
Caller-allocated byte-stream handle binding a sink to its context.