|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Shared ra8_io VFS round-trip implementation for the FAT demos (#155). More...
Go to the source code of this file.
Enumerations | |
| enum | ra8_io_roundtrip_const_t : uint32_t { k_ra8_io_roundtrip_max_payload = 512U , k_ra8_io_roundtrip_seed_mul = 7U , k_ra8_io_roundtrip_seed_add = 1U , k_ra8_io_roundtrip_note_base = 65U , k_ra8_io_roundtrip_note_mod = 26U } |
| Fixed sizing + payload-pattern knobs (no magic numbers). More... | |
Functions | |
| static void | ra8_io_roundtrip_fill_linear (uint32_t len) |
| Fill s_payload with a deterministic linear byte pattern. | |
| static void | ra8_io_roundtrip_fill_alpha (uint32_t len) |
| Fill s_payload with a deterministic rolling-alphabet pattern. | |
| static ra8_err_t | ra8_io_roundtrip_read_verify (const char *path, uint32_t len, const char *tag) |
| Read a VFS file back into s_readback and compare against s_payload. | |
| ra8_err_t | ra8_io_roundtrip_mount (ra8_io_blockdev_t *bd, const ra8_io_roundtrip_params_t *p, ra8_fs_backend_t *be, ra8_fs_mount_t **out_mount) |
| Bridge a bound block device to ra8_fs, format + mount FAT, VFS-register. | |
| ra8_err_t | ra8_io_roundtrip_root_file (ra8_fs_mount_t *mnt, const ra8_io_roundtrip_params_t *p) |
| Whole-file write at the volume root, VFS read-back, and byte-compare. | |
| ra8_err_t | ra8_io_roundtrip_subdir_file (const ra8_io_roundtrip_params_t *p) |
| mkdir a subdirectory via the VFS, then round-trip a nested file. | |
Variables | |
| static uint8_t | s_payload [k_ra8_io_roundtrip_max_payload] |
| Shared payload + read-back scratch (no heap; NASA Rule 3). | |
| static uint8_t | s_readback [k_ra8_io_roundtrip_max_payload] |
Shared ra8_io VFS round-trip implementation for the FAT demos (#155).
Implements ra8_io_roundtrip_mount, ra8_io_roundtrip_root_file, and ra8_io_roundtrip_subdir_file – the backend-agnostic core that the RAM, SDRAM, OSPI/xSPI NOR, and SD-over-SPI demos all share. The block device is bound by the caller (its ra8_io_blockdev_*_init already ran); everything above the block-device seam is identical, so it lives here once. The helpers are silent: each demo's main.c owns its PASS banner so the existing ra8_emulator smoke expectations stay byte-identical.
Definition in file ra8_io_roundtrip.c.
| enum ra8_io_roundtrip_const_t : uint32_t |
Fixed sizing + payload-pattern knobs (no magic numbers).
The scratch buffers are sized to the largest payload any demo round-trips (the SD demo's 512-byte sector); a payload longer than this is rejected at runtime. The pattern constants make the written bytes deterministic so the read-back compare is a strong end-to-end check of the whole stack.
Definition at line 36 of file ra8_io_roundtrip.c.
|
static |
Fill s_payload with a deterministic rolling-alphabet pattern.
Writes byte[i] = 'A' + (i % 26) over the first len bytes of the shared payload buffer – the same note pattern the original per-demo subdir round-trips used, kept distinct from the linear root pattern so a swapped buffer would be caught.
| [in] | len | Number of bytes to fill (must be <= the buffer capacity). |
len is at most k_ra8_io_roundtrip_max_payload. len bytes of s_payload hold the alphabet pattern. Definition at line 96 of file ra8_io_roundtrip.c.
References k_ra8_io_roundtrip_note_base, k_ra8_io_roundtrip_note_mod, and s_payload.
|
static |
Fill s_payload with a deterministic linear byte pattern.
Writes byte[i] = i * mul + add over the first len bytes of the shared payload buffer, giving a reproducible content whose read-back compare validates the whole fabric path. The pattern is the same one the original per-demo main.c files used for their root payloads.
| [in] | len | Number of bytes to fill (must be <= the buffer capacity). |
len is at most k_ra8_io_roundtrip_max_payload. len bytes of s_payload hold the reproducible pattern. Definition at line 68 of file ra8_io_roundtrip.c.
References k_ra8_io_roundtrip_seed_add, k_ra8_io_roundtrip_seed_mul, and s_payload.
|
nodiscard |
Bridge a bound block device to ra8_fs, format + mount FAT, VFS-register.
The backend-agnostic mount core shared by every FAT demo. The caller has already bound bd with the appropriate ra8_io_blockdev_*_init; this function bridges it to an ra8_fs_backend_t, formats it to p->fat_type with p->volume_label, mounts it, and registers the mount in the VFS under p->vfs_prefix. The first failing step short-circuits with its error code (logged under p->log_tag).
| [in] | bd | Bound block device (its ra8_io_blockdev_*_init already ran). |
| [in] | p | Per-demo parameters (prefix, FAT type, label, log tag). |
| [out] | be | Caller-owned backend storage populated by the bridge; it out-lives the mount (the VFS keeps pointers into it). |
| [out] | out_mount | Receives the mount handle on success, nullptr on error. |
| k_ra8_ok | The volume is formatted, mounted, and registered. |
| k_ra8_err_null_ptr | bd, p, be, or out_mount was NULL. |
| (other) | The first failing fabric step's code. |
bd, p, be, and out_mount are all non-NULL. bd is initialised and reachable. Definition at line 150 of file ra8_io_roundtrip.c.
References ra8_io_roundtrip_params_t::fat_type, k_ra8_ok, ra8_fs_format_opts_t::label, ra8_io_roundtrip_params_t::log_tag, RA8_CHECK_NULL_PTR, ra8_fs_format(), ra8_fs_mount(), ra8_io_blockdev_as_fs_backend(), ra8_io_vfs_mount(), RA8_RETURN_ON_ERROR, ra8_fs_format_opts_t::type, ra8_io_roundtrip_params_t::vfs_prefix, and ra8_io_roundtrip_params_t::volume_label.
|
static |
Read a VFS file back into s_readback and compare against s_payload.
Opens path for reading through the VFS, reads up to len bytes into the shared read-back buffer, closes the handle on every path, then verifies both the returned length and every byte match the payload most recently written by a fill helper.
| [in] | path | Full <prefix>:/... VFS path to read. |
| [in] | len | Expected byte count (the payload length just written). |
| [in] | tag | ra8_log tag for the open/read step diagnostics. |
| k_ra8_ok | Length and content both matched. |
| k_ra8_err_invalid_size | The returned length differed from len. |
| k_ra8_err_checksum_mismatch | The byte content differed. |
| (other) | The first failing VFS / ra8_fs step's code. |
path and tag are non-NULL. len is at most k_ra8_io_roundtrip_max_payload. path. Definition at line 130 of file ra8_io_roundtrip.c.
References k_ra8_err_checksum_mismatch, k_ra8_err_invalid_size, k_ra8_fs_mode_read, k_ra8_ok, memcmp(), memset(), ra8_fs_close(), ra8_fs_read(), ra8_io_vfs_open(), RA8_RETURN_ON_ERROR, s_payload, and s_readback.
|
nodiscard |
Whole-file write at the volume root, VFS read-back, and byte-compare.
Builds a deterministic p->root_bytes payload, writes it to p->root_file with the whole-file ra8_fs_write_file API (supported by every backend), reads it back through the VFS name p->root_path, and compares both the length and every byte.
| [in] | mnt | The mount handle returned by ra8_io_roundtrip_mount. |
| [in] | p | Per-demo parameters (root file name, path, payload length). |
| k_ra8_ok | The payload round-tripped intact. |
| k_ra8_err_null_ptr | mnt or p was NULL. |
| k_ra8_err_invalid_size | The read-back length differed. |
| k_ra8_err_checksum_mismatch | The read-back bytes differed. |
| (other) | The first failing fabric step's code. |
mnt and p are non-NULL and the volume is mounted. p->root_file holds the verified payload. Definition at line 173 of file ra8_io_roundtrip.c.
References k_ra8_err_invalid_size, k_ra8_io_roundtrip_max_payload, ra8_io_roundtrip_params_t::log_tag, RA8_CHECK_NULL_PTR, ra8_fs_write_file(), ra8_io_roundtrip_fill_linear(), ra8_io_roundtrip_read_verify(), RA8_RETURN_ON_ERROR, ra8_io_roundtrip_params_t::root_bytes, ra8_io_roundtrip_params_t::root_file, ra8_io_roundtrip_params_t::root_path, and s_payload.
|
nodiscard |
mkdir a subdirectory via the VFS, then round-trip a nested file.
Creates p->subdir_path through the VFS, builds a deterministic p->subdir_bytes note, writes it to p->subdir_file via VFS open(write) + ra8_fs_write + close, reads it back via VFS open(read) + ra8_fs_read + close, and byte-compares – exercising mkdir + nested-path resolution over the mounted FAT volume.
| [in] | p | Per-demo parameters (subdir path, nested file path, length). |
| k_ra8_ok | The note round-tripped intact. |
| k_ra8_err_null_ptr | p was NULL. |
| k_ra8_err_invalid_size | The read-back length differed. |
| k_ra8_err_checksum_mismatch | The read-back bytes differed. |
| (other) | The first failing VFS / ra8_fs step's code. |
p is non-NULL and its volume is mounted (see ra8_io_roundtrip_mount). p->subdir_file holds the verified note. Definition at line 188 of file ra8_io_roundtrip.c.
References k_ra8_err_invalid_size, k_ra8_fs_mode_write, k_ra8_io_roundtrip_max_payload, ra8_io_roundtrip_params_t::log_tag, RA8_CHECK_NULL_PTR, ra8_fs_close(), ra8_fs_write(), ra8_io_roundtrip_fill_alpha(), ra8_io_roundtrip_read_verify(), ra8_io_vfs_mkdir(), ra8_io_vfs_open(), RA8_RETURN_ON_ERROR, s_payload, ra8_io_roundtrip_params_t::subdir_bytes, ra8_io_roundtrip_params_t::subdir_file, and ra8_io_roundtrip_params_t::subdir_path.
|
static |
Shared payload + read-back scratch (no heap; NASA Rule 3).
Definition at line 45 of file ra8_io_roundtrip.c.
|
static |
Definition at line 46 of file ra8_io_roundtrip.c.