|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
ra8_io fabric over OSPI NOR flash (epic #155, #156) on the EK-RA8D2. More...
#include <stdint.h>#include "ra8_board_ek_ra8d2.h"#include "ra8_boot_entry.h"#include "ra8_cgc.h"#include "ra8_check.h"#include "ra8_err.h"#include "ra8_io.h"#include "ra8_io_roundtrip.h"#include "ra8_log.h"#include "ra8_port_constants.h"#include "ra8_port_utils.h"#include "ra8_sci.h"#include "ra8_time.h"#include "ra8_xspi.h"Go to the source code of this file.
Enumerations | |
| enum | demo_const_t : uint32_t { k_demo_uart_chan = 8U , k_demo_uart_baud = 115200U , k_demo_xspi_inst = 0U , k_demo_xspi_base = 0U , k_demo_disk_blocks = 512U , k_demo_payload = 256U , k_demo_pin_shift = 8U } |
| Console + volume + OSPI knobs (no magic numbers). More... | |
Functions | |
| static void | demo_print (const char *msg) |
| Print a NUL-terminated string on the UART stream. | |
| static void | demo_setup_or_halt (void) |
| Bring up CGC + SysTick + the SCI8 console; halt on any failure. | |
| static ra8_err_t | demo_run (void) |
| Bring up the OSPI block device, then run the shared FAT round-trip. | |
| void | main (void) |
| Firmware entry point. | |
Variables | |
| static const ra8_port_pin_t | k_demo_txd |
| SCI8 console TXD = PD02. | |
| static const ra8_port_pin_t | k_demo_rxd |
| SCI8 console RXD = PD03. | |
| static ra8_io_blockdev_t | s_bd |
| Block-device handle + its OSPI NOR backend state. | |
| static ra8_io_blockdev_xspi_state_t | s_xstate |
| static ra8_fs_backend_t | s_be |
| ra8_fs backend bridged onto the OSPI block device. | |
| static ra8_io_stream_t | s_uart |
| UART output stream + its sink state. | |
| static ra8_io_stream_uart_state_t | s_ust |
| static const char *const | s_tag = "ra8_io_xspi_demo" |
| Module log tag. | |
| static const ra8_io_roundtrip_params_t | s_params |
| Shared round-trip parameters for this OSPI-backed FAT12 volume. | |
ra8_io fabric over OSPI NOR flash (epic #155, #156) on the EK-RA8D2.
The third storage tier for the ra8_io fabric. Where ra8_io_demo proves the fabric over RAM and ra8_io_sd_demo over an SD card, this app proves it over the on-board Octo-SPI (OSPI / xSPI) NOR flash – an erase-before-write medium. NOR can only clear bits (1 -> 0) on a program, so a 4 KiB sector must be erased back to all-ones before any byte in it is re-written. The xSPI block-device backend hides this behind the block vtable: an arbitrary 512-byte block write triggers a whole-4-KiB-sector read-modify-write inside the backend. The ra8_fs + VFS layers above are identical to the other FAT demos and shared through ra8_io_roundtrip.{h,c} (a self-contained local copy); this app differs only by the OSPI controller bring-up (ra8_xspi_init) plus the ONE backend bind line (ra8_io_blockdev_xspi_init) and its own PASS banner.
The window and payload are deliberately small (512 blocks = 256 KiB volume, 256-byte payload) because every 512-byte write drives a 4 KiB erase + reprogram RMW that is slow in ra8_emulator; a large volume would blow the run budget. ra8_emulator models the 2 MiB OSPI NOR array internally, so the run is headless and observable: a successful run prints ra8_io_xspi_demo: xs:/CFG/SET.BIN 256 bytes PASS.
Definition in file main.c.
| enum demo_const_t : uint32_t |
Console + volume + OSPI knobs (no magic numbers).
| Enumerator | |
|---|---|
| k_demo_uart_chan | SCI8 J-Link OB console. |
| k_demo_uart_baud | Console baud. |
| k_demo_xspi_inst | xSPI controller instance index. |
| k_demo_xspi_base | Flash byte offset of logical blk 0. |
| k_demo_disk_blocks | 256 KiB OSPI window (FAT12). |
| k_demo_payload | Bytes written + read back. |
| k_demo_pin_shift | Port byte position in ra8_port_pin_t. |
|
static |
Print a NUL-terminated string on the UART stream.
Thin wrapper over ra8_io_stream_puts that fixes the demo's UART stream sink, so callers do not repeat the sink handle.
| [in] | msg | NUL-terminated ASCII string (CR/LF included by the caller). |
msg is non-NULL and NUL-terminated. msg are queued on the UART stream. Definition at line 110 of file main.c.
References ra8_io_stream_puts(), and s_uart.
|
static |
Bring up the OSPI block device, then run the shared FAT round-trip.
Initialises the xSPI controller in 1S-1S-1S link mode, binds an erase-before-write block device over a 256 KiB flash window (the two per-demo bring-up lines), mounts the FAT12 volume through the shared helper, then runs the shared mkdir + nested round-trip into xs:/CFG/SET.BIN. The first failing step short-circuits with its code.
| k_ra8_ok | The "xs" volume mounted and the payload round-tripped. |
| k_ra8_err_* | The first failing bring-up / mount / round-trip step's code. |
Definition at line 178 of file main.c.
References k_demo_disk_blocks, k_demo_xspi_base, k_demo_xspi_inst, k_ra8_xspi_lio_1s1s1s, ra8_board_xspi_pins_init(), ra8_io_blockdev_xspi_init(), ra8_io_roundtrip_mount(), ra8_io_roundtrip_subdir_file(), RA8_RETURN_ON_ERROR, ra8_xspi_init(), s_bd, s_be, s_params, s_tag, and s_xstate.
Referenced by main().
|
static |
Bring up CGC + SysTick + the SCI8 console; halt on any failure.
Initialises the clock-generation circuit, reads the CPU and PCLKA rates, starts the millisecond time base, routes the SCI8 console pins, and opens the SCI8 UART. Any failure spins forever so a debugger can inspect the halt; there is no console yet to report on.
Definition at line 133 of file main.c.
References k_demo_rxd, k_demo_txd, k_demo_uart_baud, k_demo_uart_chan, k_ra8_clock_id_cpuclk0, k_ra8_clock_id_pclka, k_ra8_ok, k_ra8_psel_sci_async, k_ra8_sci_data_8, k_ra8_sci_parity_none, k_ra8_sci_stop_1, ra8_cgc_get_clock_hz(), ra8_cgc_init(), ra8_pfs_route_peripheral(), ra8_sci_init(), and ra8_time_init().
| void main | ( | void | ) |
Firmware entry point.
The application entry point Reset_Handler hands control to.
Initialises logging and the console, brings up the OSPI NOR volume, runs the erase-before-write round-trip, and prints a single PASS/FAIL verdict line over SCI8 before parking in an infinite loop.
Definition at line 218 of file main.c.
References demo_print(), demo_run(), demo_setup_or_halt(), k_demo_uart_chan, k_ra8_ok, ra8_io_log_attach(), ra8_io_stream_uart_init(), ra8_log_init(), ra8_sci_flush(), s_uart, and s_ust.
|
static |
SCI8 console RXD = PD03.
|
static |
SCI8 console TXD = PD02.
|
static |
|
static |
|
static |
Shared round-trip parameters for this OSPI-backed FAT12 volume.
|
static |
|
static |
|
static |
|
static |
Definition at line 68 of file main.c.
Referenced by demo_run().