66typedef enum : uint32_t {
82static const uint8_t
k_msg_boot[] =
"ra8_io_sdhi_demo: boot\r\n";
83static const uint8_t
k_msg_card_ok[] =
"ra8_io_sdhi_demo: card ready\r\n";
85static const uint8_t
k_msg_pass[] =
"ra8_io_sdhi_demo: sd:/LOGS/A.TXT 512 bytes PASS\r\n";
86static const uint8_t
k_msg_fail[] =
"ra8_io_sdhi_demo: FAIL\r\n";
94static const char*
const s_tag =
"ra8_io_sdhi_demo";
127#define SDHI_DEMO_PUTS(lit) sdhi_demo_print((lit), (uint32_t)sizeof(lit) - 1U)
149 __asm__
volatile(
"wfi");
179 uint32_t cpuclk0_hz = 0U;
293 opts.
label =
"RAIOSD";
446 __asm__
volatile(
"wfi");
void main(void)
Secure fallback main entry point.
static uint8_t s_payload[(size_t) k_demo_payload]
Original payload, compressed-blob staging, and the inflated copy.
static const uint8_t k_msg_boot[]
static const uint8_t k_msg_fail[]
static ra8_fs_backend_t s_be
ra8_fs backend bridged onto the cached block device.
static ra8_io_blockdev_t s_bd
Block-device handle + its RAM backend state.
static const uint8_t k_msg_pass[]
static const uint8_t k_msg_card_ok[]
static ra8_err_t sdhi_demo_mount_via_io(void)
Bind the native-SDHI block device, bridge it to ra8_fs, format + mount FAT16, and register it in the ...
static const char k_file_path[]
sdhi_demo_config_t
Compile-time settings for the ra8_io native-SDHI backend demo.
@ k_sdhi_demo_prng_add
Numerical Recipes LCG increment.
@ k_sdhi_demo_instance
SDHI0 drives the micro-SD bus.
@ k_sdhi_demo_prng_seed
Deterministic payload seed.
@ k_sdhi_demo_payload_bytes
One-sector deterministic test payload.
@ k_sdhi_demo_byte_mask
Low-byte mask.
@ k_sdhi_demo_prng_mul
Numerical Recipes LCG multiplier.
@ k_sdhi_demo_prng_byte_shift
Bit shift selecting the PRNG byte.
@ k_sdhi_demo_uart_baud
J-Link OB CDC console baud.
#define SDHI_DEMO_PUTS(lit)
Emit a NUL-terminated literal (length via sizeof at the call site).
static const char k_mount_name[]
VFS mount name and target path for the round-trip file.
static ra8_err_t sdhi_demo_write_payload(const char *path)
Write s_payload to the VFS path through ra8_io_vfs_open + ra8_fs_write.
static void sdhi_demo_setup_or_halt(void)
Bring up CGC + SysTick + the board console + SDHI bus pins; panic on fail.
static const uint8_t k_msg_init_fail[]
static void sdhi_demo_panic_halt(void)
Halt forever in WFI – panic stop on irrecoverable failure.
static ra8_err_t sdhi_demo_read_and_verify(const char *path)
Read the VFS file back and byte-compare against s_payload.
static const char k_dir_path[]
static void sdhi_demo_print(const uint8_t *msg, uint32_t len)
Write a byte run on the J-Link OB VCOM console.
static ra8_err_t sdhi_demo_roundtrip(void)
Run the full ra8_io round-trip: mount, mkdir, write, read-back, verify.
static void sdhi_demo_init_card_or_halt(void)
Init the SD card over native SDHI, panic-halt on failure.
static void sdhi_demo_fill_payload(void)
Fill the payload buffer with a deterministic LCG byte sequence.
static const char * s_tag
Logging / check tag.
Board-support layer for the Renesas EK-RA8D2 v1 evaluation kit.
ra8_err_t ra8_board_sdhi_pins_init(void)
Route the eight SDHI0 bus pins to the SDHI peripheral function.
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.
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.
@ k_ra8_clock_id_cpuclk0
Cortex-M85 CPUCLK0.
ra8_err_t ra8_cgc_init(void)
Configure the clock tree to a safe default.
Validation and Error-Checking Macros for ra8-firmware.
#define RA8_RETURN_ON_ERROR(err, tag, message)
Early return on error, propagating the code upward.
Error Code Definitions for ra8-firmware.
@ k_ra8_err_checksum_mismatch
Stored / transmitted checksum does not match computed value.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
@ k_ra8_err_invalid_size
Invalid size parameter (too large, too small, or misaligned).
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
void * memset(void *dst, int value, size_t n)
Fill memory with a constant byte value.
int memcmp(const void *a, const void *b, size_t n)
Compare bytes in two memory areas.
Minimal FAT12/FAT16/FAT32 filesystem adapter (read + write).
ra8_err_t ra8_fs_format(const ra8_fs_backend_t *backend, const ra8_fs_format_opts_t *opts)
Format a block device as a fresh, empty FAT12/FAT16/FAT32/exFAT volume.
ra8_err_t ra8_fs_write(ra8_fs_file_t *file, const uint8_t *buf, uint32_t len)
Write len bytes; allocate new clusters from FAT free-space scan as needed.
ra8_err_t ra8_fs_mount(const ra8_fs_backend_t *backend, ra8_fs_mount_t **out_handle)
Mount a FAT volume from a block-device backend, auto-selecting the first partition.
ra8_err_t ra8_fs_read(ra8_fs_file_t *file, uint8_t *buf, uint32_t max_len, uint32_t *got_len)
Read up to max_len bytes; advance the cluster chain on cluster crossings.
ra8_err_t ra8_fs_close(ra8_fs_file_t *file)
Close an open file, stamping its final modification time.
@ k_ra8_fs_type_fat16
4085 <= count_of_clusters < 65525.
@ k_ra8_fs_mode_read
Read-only, must exist.
@ k_ra8_fs_mode_write
Truncate (or create) for writing.
ra8_io – unified peripheral-agnostic I/O fabric (umbrella header).
ra8_err_t ra8_io_blockdev_as_fs_backend(const ra8_io_blockdev_t *bd, ra8_fs_backend_t *out)
Expose a bound block device as an ra8_fs_backend_t for ra8_fs.
ra8_err_t ra8_io_blockdev_sdhi_init(ra8_io_blockdev_t *bd)
Bind the native-SDHI SD-card backend into a caller-owned handle.
static uint8_t s_readback[k_ra8_io_roundtrip_max_payload]
ra8_err_t ra8_io_vfs_mount(const char *name, ra8_fs_mount_t *mount)
Register a mounted volume under a name.
ra8_err_t ra8_io_vfs_open(const char *path, ra8_fs_mode_t mode, ra8_fs_file_t **out_file)
Open a file by "name:/path".
ra8_err_t ra8_io_vfs_mkdir(const char *path)
Create a directory named "name:/path".
ra8_err_t ra8_io_vfs_init(void)
Reset the VFS mount table to empty.
NVIC + ICU IELSR allocator.
void ra8_isr_globals_enable(void)
Globally enable maskable interrupts (PRIMASK = 0).
Lightweight Logging Interface for ra8-firmware.
void ra8_log_init(void)
Initialise the logging backend.
SD card driver layered on top of the RA8D2 SDHI peripheral.
ra8_err_t ra8_sdcard_init(const ra8_sdcard_cfg_t *cfg)
Bring up the SDHI block and perform full SD card initialization.
SD/MMC Host Interface (SDHI) driver scaffold.
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.
Block-device interface that ra8_fs runs on top of.
Cached parse of one mounted FAT volume.
Caller-allocated block-device handle binding a backend to its context.
User-supplied configuration for ra8_sdcard_init.