|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
ThreadX + ra8_fs file-operations demo on the on-board OSPI flash. More...
#include <stdint.h>#include <string.h>#include "ra8_board_ek_ra8d2.h"#include "ra8_boot_entry.h"#include "ra8_cgc.h"#include "ra8_err.h"#include "ra8_fs.h"#include "ra8_isr.h"#include "ra8_time.h"#include "lx_api.h"#include "lx_fs_backend.h"#include "lx_nor_driver_ra8_xspi.h"#include "tx_api.h"Go to the source code of this file.
Enumerations | |
| enum | demo_config_t : uint32_t { k_demo_baud = 115200U , k_demo_thread_stack = 8192U , k_demo_file_chunk = 64U } |
| Compile-time settings (console + worker geometry). More... | |
Functions | |
| static void | demo_panic_halt (void) |
| Halt forever in WFI. | |
| static void | demo_setup_or_halt (void) |
| Bring CGC + the J-Link OB VCOM console up. | |
| static void | demo_print (const char *s) |
| Write a NUL-terminated ASCII string to the console. | |
| static void | demo_fs_lock_acquire (void *ctx) |
| ra8_fs lock-seam acquire: block on the ThreadX mutex. | |
| static void | demo_fs_lock_release (void *ctx) |
| ra8_fs lock-seam release: hand the ThreadX mutex back. | |
| static bool | demo_lx_open (void) |
| Format + open the LevelX NOR partition on the OSPI flash. | |
| static bool | demo_fs_format_mount (ra8_fs_backend_t *out_backend, ra8_fs_mount_t **out_mount) |
| Bind the backend, lay down + mount a FAT volume on the LevelX partition. | |
| static bool | demo_read_verify (ra8_fs_mount_t *mount, const char *path, const char *expected) |
Read path back and verify its bytes equal expected. | |
| static void | demo_list_entry (const char *name, uint8_t attr, uint64_t size, void *ctx) |
| ra8_fs_listdir callback: print one root-directory entry name. | |
| static void | demo_file_ops (ra8_fs_mount_t *mount) |
| Run the file-ops sequence; print the pass banner only if all pass. | |
| static void | demo_thread_entry (ULONG thread_input) |
| ThreadX worker entry: bring up LevelX + FAT, run the file ops. | |
| void | tx_application_define (void *first_unused_memory) |
| ThreadX system-define hook: build the worker + the ra8_fs lock seam. | |
| void | main (void) |
| Application entry. | |
Variables | |
| static const char | s_readme_text [] = "ra8_fs FAT on OSPI flash via LevelX.\r\n" |
| Test payload written into both demo files. | |
| static const char | s_readme_path [] = "/readme.txt" |
| Path of the file that is read back and verified. | |
| static const char | s_scratch_path [] = "/scratch.txt" |
| Path of the file that is deleted and confirmed gone. | |
| static LX_NOR_FLASH | s_nor_flash |
| static TX_THREAD | s_demo_thread |
| static UCHAR | s_demo_stack [k_demo_thread_stack] |
| static TX_MUTEX | s_fs_mutex |
| ThreadX mutex the ra8_fs lock seam is bound to (#608). | |
| static char | s_lx_flash_name [] = "ra8_xspi_nor" |
ThreadX + ra8_fs file-operations demo on the on-board OSPI flash.
An ra8_fs FAT file-operations exerciser backed by the EK-RA8D2's on-board Octo-SPI NOR flash (via LevelX wear-levelling), NOT an SD card: the board's microSD is on Pmod2 / SCI0 Simple-SPI, and the always-present OSPI flash needs no card at all. It is the file-ops counterpart to threadx_fs_levelx_demo (which proves the LevelX integration); this one drives the ra8_fs FAT API itself, from an RTOS world through the ra8_fs_set_lock() seam bound to a ThreadX mutex (#608).
Brings the chip up like uart_hello (CGC -> SCI8 @ 115200 8N1), then hands control to ThreadX. tx_application_define spawns one worker that:
No card, no jumpers – the flash is soldered on the board, so this runs unattended on the HIL bench.
Definition in file main.c.
| enum demo_config_t : uint32_t |
|
static |
Run the file-ops sequence; print the pass banner only if all pass.
create two files -> list root -> read+verify readme -> delete scratch -> confirm the delete. Any failure returns without the banner.
| [in,out] | mount | Mounted FAT volume. |
mount is mounted for read/write. Definition at line 311 of file main.c.
References demo_list_entry(), demo_print(), demo_read_verify(), k_ra8_err_not_found, k_ra8_ok, ra8_fs_listdir(), ra8_fs_stat(), ra8_fs_unlink(), ra8_fs_write_file(), s_readme_path, s_readme_text, s_scratch_path, and strlen().
Referenced by demo_thread_entry().
|
static |
Bind the backend, lay down + mount a FAT volume on the LevelX partition.
lx_fs_backend_bind wires the three ra8_fs_backend_t callbacks onto s_nor_flash; ra8_fs_format then writes a FAT12 superfloppy (the xSPI driver exposes a 64-block LevelX window – 384 usable 512-byte sectors – so FAT12 is the band that fits, exactly as the retired FileX format auto-selected) and ra8_fs_mount parses it back.
| [out] | out_backend | Receives the bound backend (must outlive the mount). |
| [out] | out_mount | Receives the mount handle. |
Definition at line 219 of file main.c.
References demo_print(), k_ra8_fs_type_fat12, k_ra8_ok, ra8_fs_format_opts_t::label, lx_fs_backend_bind(), ra8_fs_format(), ra8_fs_mount(), s_nor_flash, and ra8_fs_format_opts_t::type.
Referenced by demo_thread_entry().
|
static |
ra8_fs lock-seam acquire: block on the ThreadX mutex.
| [in] | ctx | The bound TX_MUTEX*. |
Definition at line 155 of file main.c.
References tx_mutex_get, and TX_WAIT_FOREVER.
Referenced by tx_application_define().
|
static |
ra8_fs lock-seam release: hand the ThreadX mutex back.
| [in] | ctx | The bound TX_MUTEX*. |
Definition at line 168 of file main.c.
References tx_mutex_put.
Referenced by tx_application_define().
|
static |
ra8_fs_listdir callback: print one root-directory entry name.
| [in] | name | Entry name (NUL-terminated UTF-8). |
| [in] | attr | FAT attribute bits (unused). |
| [in] | size | Entry size in bytes (unused). |
| [in] | ctx | Unused cookie. |
Definition at line 290 of file main.c.
References demo_print().
Referenced by demo_file_ops().
|
static |
Format + open the LevelX NOR partition on the OSPI flash.
The LevelX NOR driver owns the OCTA bus bring-up (pin routing, the 8D/1S software-reset recovery, ra8_xspi_init, RDID probe) inside lx_nor_driver_ra8_xspi_initialize, so this must NOT also call ra8_xspi_init (a second PFS route is rejected and format then fails). Let the driver own it.
Definition at line 186 of file main.c.
References demo_print(), lx_nor_driver_ra8_xspi_initialize(), s_lx_flash_name, and s_nor_flash.
Referenced by demo_thread_entry().
|
static |
|
static |
Write a NUL-terminated ASCII string to the console.
| [in] | s | NUL-terminated ASCII string (NULL is ignored). |
Definition at line 137 of file main.c.
References ra8_board_uart_console_write(), and strlen().
|
static |
Read path back and verify its bytes equal expected.
| [in,out] | mount | Mounted FAT volume. |
| [in] | path | NUL-terminated path at the root. |
| [in] | expected | NUL-terminated bytes the file must contain. |
expected exactly. mount is mounted and path exists. Definition at line 250 of file main.c.
References demo_print(), k_demo_file_chunk, k_ra8_fs_mode_read, k_ra8_ok, memcmp(), ra8_fs_close(), ra8_fs_open(), ra8_fs_read(), and strlen().
Referenced by demo_file_ops().
|
static |
Bring CGC + the J-Link OB VCOM console up.
Panic-halts on any failure.
Definition at line 112 of file main.c.
References demo_panic_halt(), k_demo_baud, k_ra8_clock_id_cpuclk0, k_ra8_ok, ra8_board_uart_console_init(), ra8_cgc_get_clock_hz(), ra8_cgc_init(), and ra8_time_init().
|
static |
ThreadX worker entry: bring up LevelX + FAT, run the file ops.
| [in] | thread_input | Unused. |
Definition at line 353 of file main.c.
References demo_file_ops(), demo_fs_format_mount(), demo_lx_open(), demo_print(), ra8_fs_unmount(), and s_nor_flash.
| void main | ( | void | ) |
Application entry.
The application entry point Reset_Handler hands control to.
Brings up clocks + UART, then enters ThreadX.
Definition at line 426 of file main.c.
References demo_panic_halt(), demo_print(), demo_setup_or_halt(), and ra8_isr_globals_enable().
| void tx_application_define | ( | void * | first_unused_memory | ) |
ThreadX system-define hook: build the worker + the ra8_fs lock seam.
Creates the mutex first and installs it through ra8_fs_set_lock() before the worker can issue a filesystem call, per the seam's init-time contract (#608). LevelX's core is initialised here too.
| [in] | first_unused_memory | Free-RAM sentinel from the port (unused; control blocks are static). |
Definition at line 387 of file main.c.
References demo_fs_lock_acquire(), demo_fs_lock_release(), demo_print(), demo_thread_entry(), k_ra8_ok, ra8_fs_set_lock(), s_demo_stack, s_demo_thread, s_fs_mutex, s_thread_name, TX_AUTO_START, tx_mutex_create, TX_NO_INHERIT, TX_NO_TIME_SLICE, and tx_thread_create.
|
static |
|
static |
ThreadX mutex the ra8_fs lock seam is bound to (#608).
Definition at line 85 of file main.c.
Referenced by tx_application_define().
|
static |
Definition at line 88 of file main.c.
Referenced by demo_lx_open(), and demo_lx_open_or_panic().
|
static |
Path of the file that is read back and verified.
Definition at line 73 of file main.c.
Referenced by demo_file_ops().
|
static |
Test payload written into both demo files.
Definition at line 70 of file main.c.
Referenced by demo_file_ops().
|
static |
Path of the file that is deleted and confirmed gone.
Definition at line 76 of file main.c.
Referenced by demo_file_ops().