18#include "ra8_io_roundtrip.h"
37typedef enum : uint32_t {
71 for (uint32_t i = 0U; i < len; ++i) {
99 for (uint32_t i = 0U; i < len; ++i) {
161 *out_mount =
nullptr;
static uint8_t s_payload[(size_t) k_demo_payload]
Original payload, compressed-blob staging, and the inflated copy.
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Validation and Error-Checking Macros for ra8-firmware.
#define RA8_RETURN_ON_ERROR(err, tag, message)
Early return on error, propagating the code upward.
#define RA8_CHECK_NULL_PTR(ptr, tag, message)
Reject nullptr pointer, returning k_ra8_err_null_ptr.
@ k_ra8_err_checksum_mismatch
Stored / transmitted checksum does not match computed value.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
@ k_ra8_err_invalid_size
Invalid size parameter (too large, too small, or misaligned).
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.
ra8_err_t ra8_fs_format(const ra8_fs_backend_t *backend, const ra8_fs_format_opts_t *opts)
Format a block device as a fresh, empty FAT12/FAT16/FAT32/exFAT volume.
ra8_err_t ra8_fs_write(ra8_fs_file_t *file, const uint8_t *buf, uint32_t len)
Write len bytes; allocate new clusters from FAT free-space scan as needed.
ra8_err_t ra8_fs_mount(const ra8_fs_backend_t *backend, ra8_fs_mount_t **out_handle)
Mount a FAT volume from a block-device backend, auto-selecting the first partition.
ra8_err_t ra8_fs_read(ra8_fs_file_t *file, uint8_t *buf, uint32_t max_len, uint32_t *got_len)
Read up to max_len bytes; advance the cluster chain on cluster crossings.
ra8_err_t ra8_fs_close(ra8_fs_file_t *file)
Close an open file, stamping its final modification time.
ra8_err_t ra8_fs_write_file(ra8_fs_mount_t *handle, const char *path, const uint8_t *data, uint32_t len)
Create a whole file in one call (provisioning helper).
@ k_ra8_fs_mode_read
Read-only, must exist.
@ k_ra8_fs_mode_write
Truncate (or create) for writing.
ra8_err_t ra8_io_blockdev_as_fs_backend(const ra8_io_blockdev_t *bd, ra8_fs_backend_t *out)
Expose a bound block device as an ra8_fs_backend_t for ra8_fs.
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_io_roundtrip_const_t
Fixed sizing + payload-pattern knobs (no magic numbers).
@ k_ra8_io_roundtrip_note_mod
Subdir note alphabet size.
@ k_ra8_io_roundtrip_seed_add
Root payload pattern additive bias.
@ k_ra8_io_roundtrip_max_payload
Largest payload (SD sector).
@ k_ra8_io_roundtrip_note_base
Subdir note alphabet base ('A').
@ k_ra8_io_roundtrip_seed_mul
Root payload pattern multiplier.
static uint8_t s_readback[k_ra8_io_roundtrip_max_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_subdir_file(const ra8_io_roundtrip_params_t *p)
mkdir a subdirectory via the VFS, then round-trip a nested file.
static void internal_ra8_io_roundtrip_fill_alpha(uint32_t len)
Fill s_payload with a deterministic rolling-alphabet pattern.
static ra8_err_t internal_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.
static void internal_ra8_io_roundtrip_fill_linear(uint32_t len)
Fill s_payload with a deterministic linear byte pattern.
ra8_err_t ra8_io_vfs_mount(const char *name, ra8_fs_mount_t *mount)
Register a mounted volume under a name.
ra8_err_t ra8_io_vfs_open(const char *path, ra8_fs_mode_t mode, ra8_fs_file_t **out_file)
Open a file by "name:/path".
ra8_err_t ra8_io_vfs_mkdir(const char *path)
Create a directory named "name:/path".
Block-device interface that ra8_fs runs on top of.
Cached parse of one mounted FAT volume.
Caller-allocated block-device handle binding a backend to its context.
Per-demo knobs for the shared ra8_io round-trip.
const char * volume_label
11-char-max FAT volume label literal.
const char * root_path
Full VFS path of the root file for read-back.
const char * subdir_path
Full VFS path of the directory to create.
ra8_fs_type_t fat_type
FAT variant laid down by the format step.
const char * root_file
Root file name for the whole-file write.
const char * log_tag
ra8_log tag used on every step failure.
const char * subdir_file
Full VFS path of the nested file.
const char * vfs_prefix
VFS volume name, e.g.
uint32_t subdir_bytes
Deterministic payload length in the subdir.
uint32_t root_bytes
Deterministic payload length at the root.