|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
ThreadX + ra8_fs-on-LevelX-on-OSPI wear-levelled FAT demo for EK-RA8D2. 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 for the ra8_fs-on-LevelX FAT demo. More... | |
Functions | |
| static void | demo_panic_halt (void) |
| Halt forever in WFI, after draining the SCI8 TX shift register. | |
| static void | demo_setup_or_halt (void) |
| Bring CGC + SCI8 up. | |
| static void | demo_print (const char *s) |
| Convenience wrapper to write a NUL-terminated string to SCI8. | |
| 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 void | demo_lx_open_or_panic (void) |
| Format + open the LevelX partition. | |
| static void | demo_fs_format_or_panic (void) |
| Bind the backend, format + mount the FAT volume on top of LevelX. | |
| static void | demo_write_test_file (void) |
| Create + write /levelx_test.txt with the demo test message. | |
| static void | demo_read_test_file (void) |
| Open + read /levelx_test.txt back to SCI8. | |
| static void | demo_thread_entry (ULONG thread_input) |
| ThreadX worker entry: bring up LevelX + ra8_fs, exercise the file. | |
| 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_demo_test_message [] = "Hello from wear-leveled FAT!" |
| Test message written into /levelx_test.txt. | |
| static const char | s_demo_file_path [] = "/levelx_test.txt" |
| Path under the FAT root that holds the demo payload. | |
| static LX_NOR_FLASH | s_nor_flash |
| static ra8_fs_backend_t | s_fs_backend |
| static ra8_fs_mount_t * | s_fs_mount |
| static TX_MUTEX | s_fs_mutex |
| ThreadX mutex the ra8_fs lock seam is bound to (#608). | |
| static TX_THREAD | s_demo_thread |
| static UCHAR | s_demo_stack [k_demo_thread_stack] |
| static char | s_lx_flash_name [] = "ra8_xspi_nor" |
| LevelX flash name (mutable so ThreadX/LevelX can take CHAR*). | |
| static char | s_demo_thread_name [] = "fslx_demo" |
| Worker-thread name (mutable so ThreadX can take CHAR*). | |
ThreadX + ra8_fs-on-LevelX-on-OSPI wear-levelled FAT demo for EK-RA8D2.
Brings the chip up the same way uart_hello does (CGC -> SCI8 @ 115200 8N1), then hands control to ThreadX. tx_application_define spawns one worker thread that:
Recipe (see also the README.md alongside this main.c):
Definition in file main.c.
| enum demo_config_t : uint32_t |
|
static |
Bind the backend, format + mount the FAT volume on top of LevelX.
Calls lx_fs_backend_bind first so ra8_fs has a block device to dispatch into, then ra8_fs_format to lay down a fresh FAT12 superblock (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), then ra8_fs_mount to parse it back.
Definition at line 245 of file main.c.
References demo_panic_halt(), 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_fs_backend, s_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 187 of file main.c.
References tx_mutex_get, and TX_WAIT_FOREVER.
|
static |
ra8_fs lock-seam release: hand the ThreadX mutex back.
| [in] | ctx | The bound TX_MUTEX*. |
Definition at line 200 of file main.c.
References tx_mutex_put.
|
static |
Format + open the LevelX partition.
Panics on any failure.
Definition at line 213 of file main.c.
References demo_panic_halt(), demo_print(), lx_nor_driver_ra8_xspi_initialize(), s_lx_flash_name, and s_nor_flash.
Referenced by demo_thread_entry().
|
static |
Halt forever in WFI, after draining the SCI8 TX shift register.
Calls ra8_board_uart_console_flush so any panic message previously queued via ra8_board_uart_console_write finishes clocking onto the wire before WFI gates the SCI clock. Without the flush, only the first 1-3 bytes of the failure log reach the host UART because WFI silences the peripheral mid-frame. Return code is intentionally discarded – if the flush times out we still want to halt rather than spin.
Definition at line 125 of file main.c.
References ra8_board_uart_console_flush().
|
static |
Convenience wrapper to write a NUL-terminated string to SCI8.
| [in] | s | NUL-terminated ASCII string. Must not be NULL. |
Definition at line 169 of file main.c.
References ra8_board_uart_console_write(), and strlen().
|
static |
Open + read /levelx_test.txt back to SCI8.
Definition at line 298 of file main.c.
References demo_print(), k_demo_file_chunk, k_ra8_fs_mode_read, k_ra8_ok, ra8_board_uart_console_write(), ra8_fs_close(), ra8_fs_open(), ra8_fs_read(), s_demo_file_path, and s_fs_mount.
Referenced by demo_thread_entry().
|
static |
Bring CGC + SCI8 up.
Panic-halts on any failure.
Definition at line 141 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 + ra8_fs, exercise the file.
| [in] | thread_input | Unused. |
Definition at line 331 of file main.c.
References demo_fs_format_or_panic(), demo_lx_open_or_panic(), demo_print(), demo_read_test_file(), demo_write_test_file(), ra8_fs_unmount(), s_fs_mount, and s_nor_flash.
|
static |
Create + write /levelx_test.txt with the demo test message.
Definition at line 274 of file main.c.
References demo_print(), k_ra8_ok, ra8_fs_write_file(), s_demo_file_path, s_demo_test_message, s_fs_mount, and strlen().
Referenced by demo_thread_entry().
| void main | ( | void | ) |
Application entry.
The application entry point Reset_Handler hands control to.
Brings up clocks + UART, then enters ThreadX.
Definition at line 413 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 | Pointer to the start of free RAM provided by the ThreadX port; unused – we statically allocate. |
Definition at line 374 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_demo_thread_name, s_fs_mutex, TX_AUTO_START, tx_mutex_create, TX_NO_INHERIT, TX_NO_TIME_SLICE, and tx_thread_create.
|
static |
Path under the FAT root that holds the demo payload.
Definition at line 83 of file main.c.
Referenced by demo_read_test_file(), and demo_write_test_file().
|
static |
|
static |
Test message written into /levelx_test.txt.
Definition at line 80 of file main.c.
Referenced by demo_write_test_file().
|
static |
|
static |
|
static |
Definition at line 92 of file main.c.
Referenced by demo_fs_format_or_panic(), demo_read_test_file(), demo_thread_entry(), and demo_write_test_file().
|
static |
|
static |