59typedef enum : uint32_t {
75 "ra8_sdhi_card_demo test LBA must be above block 0 (the FAT BPB)");
82static const uint8_t
k_msg_boot[] =
"ra8_sdhi_card_demo: boot\r\n";
83static const uint8_t
k_msg_card_ok[] =
"ra8_sdhi_card_demo: card ready\r\n";
85static const uint8_t
k_msg_pass[] =
"ra8_sdhi_card_demo: native SDHI block round-trip PASS\r\n";
86static const uint8_t
k_msg_fail[] =
"ra8_sdhi_card_demo: FAIL\r\n";
89static const char*
const s_tag =
"ra8_sdhi_card_demo";
122#define SDHI_CARD_PUTS(lit) sdhi_card_print((lit), (uint32_t)sizeof(lit) - 1U)
143 __asm__
volatile(
"wfi");
172 uint32_t cpuclk0_hz = 0U;
278 uint32_t blocks = 0U;
392 __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 const uint8_t k_msg_pass[]
static const uint8_t k_msg_card_ok[]
static const uint8_t k_msg_init_fail[]
static void sdhi_card_print(const uint8_t *msg, uint32_t len)
Write a byte run on the J-Link OB VCOM console.
static void sdhi_card_panic_halt(void)
Halt forever in WFI – panic stop on irrecoverable failure.
static ra8_err_t sdhi_card_block_roundtrip(void)
Write the payload, read it back, and byte-compare (raw SDHI blocks).
sdhi_card_config_t
Compile-time settings for the native-SDHI raw-block round-trip.
@ k_sdhi_card_prng_mul
Numerical Recipes LCG multiplier.
@ k_sdhi_card_prng_byte_shift
Bit shift selecting the PRNG byte.
@ k_sdhi_card_uart_baud
J-Link OB CDC console baud.
@ k_sdhi_card_byte_mask
Low-byte mask.
@ k_sdhi_card_instance
SDHI0 drives the micro-SD bus.
@ k_sdhi_card_prng_seed
Deterministic payload seed.
@ k_sdhi_card_block_count
Round-trip one block.
@ k_sdhi_card_block_bytes
One SD block.
@ k_sdhi_card_prng_add
Numerical Recipes LCG increment.
@ k_sdhi_card_test_lba
Block to round-trip (clear of the BPB).
static void sdhi_card_fill_payload(void)
Fill the payload buffer with a deterministic LCG byte sequence.
static ra8_err_t sdhi_card_check_capacity(void)
Confirm the card capacity covers the test block, then check it is sane.
static void sdhi_card_init_or_halt(void)
Init the SD card over native SDHI, panic-halt on failure.
static void sdhi_card_setup_or_halt(void)
Bring up CGC + SysTick + the board console + SDHI bus pins; panic on fail.
#define SDHI_CARD_PUTS(lit)
Emit a NUL-terminated literal (length via sizeof at the call site).
static ra8_err_t sdhi_card_roundtrip(void)
Run the capacity check + raw-block round-trip in order.
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_err_out_of_range
Sensor or peripheral output out of valid range.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
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.
static uint8_t s_readback[k_ra8_io_roundtrip_max_payload]
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_write_blocks(uint32_t lba, const uint8_t *buf, uint32_t count)
Write count 512-byte blocks starting at lba.
ra8_err_t ra8_sdcard_get_capacity(uint32_t *out_blocks)
Return card capacity in 512-byte blocks.
ra8_err_t ra8_sdcard_init(const ra8_sdcard_cfg_t *cfg)
Bring up the SDHI block and perform full SD card initialization.
ra8_err_t ra8_sdcard_read_blocks(uint32_t lba, uint8_t *buf, uint32_t count)
Read count 512-byte blocks starting at lba.
SD/MMC Host Interface (SDHI) driver scaffold.
@ k_ra8_sdhi_bus_width_4bit
Four data lanes (SD default-speed wide).
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.
User-supplied configuration for ra8_sdcard_init.