47 "ra8d2 usb-hs host file-ops payload 0123456789 the quick brown fox\r\n";
70 return (uint8_t)((uint8_t)
'0' + (uint8_t)nibble);
92 if (text[len] ==
'\0') {
158 out[0] = (uint8_t)
'0';
166 for (uint8_t i = 0U; i < count; i++) {
167 out[i] = scratch[count - 1U - i];
175 uint8_t width = digits;
179 for (uint8_t i = 0U; i < width; i++) {
355 if (c->
want !=
nullptr) {
360 if (c->
avoid !=
nullptr) {
414 if (want !=
nullptr) {
420 if (avoid !=
nullptr) {
461 err =
ra8_fs_read(file, s_read_buf, (uint32_t)
sizeof(s_read_buf), &got);
467 if (got != payload_len) {
471 for (uint32_t i = 0U; i < payload_len; i++) {
558 err =
fileops_print(
"ra8d2 fileops: [2/9] baseline root listing\r\n");
574 err =
fileops_print(
"ra8d2 fileops: [4/9] read back + verify payload\r\n");
584 err =
fileops_print(
"ra8d2 fileops: [5/9] listdir must show USBTEST.TXT\r\n");
609 err =
fileops_print(
"ra8d2 fileops: [7/9] old name gone, new name intact\r\n");
623 err =
fileops_print(
"ra8d2 fileops: [8/9] listdir must show USBDONE.TXT only\r\n");
633 err =
fileops_print(
"ra8d2 fileops: [9/9] unlink USBDONE.TXT\r\n");
674 for (uint32_t i = 0U; i < len; i++) {
Board-support layer for the Renesas EK-RA8D2 v1 evaluation kit.
ra8_err_t ra8_board_led_toggle(ra8_board_led_id_t led)
Toggle led's output state.
@ k_ra8_board_led2
LED2, GREEN, P303 (jumper E26).
ra8_err_t ra8_board_uart_console_write(const uint8_t *data, size_t len)
Polled blocking write to the J-Link OB VCOM console.
Error Code Definitions for ra8-firmware.
@ k_ra8_err_exists
Item already exists – cannot create again.
@ k_ra8_err_invalid_state
Module in wrong state for requested operation.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
@ k_ra8_err_not_found
Requested item not found (lookup / search missed).
@ 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.
Minimal FAT12/FAT16/FAT32 filesystem adapter (read + write).
ra8_err_t ra8_fs_listdir(const ra8_fs_mount_t *handle, const char *path, ra8_fs_listdir_cb_t cb, void *ctx)
Enumerate directory entries; invoke cb once per visible entry.
ra8_err_t ra8_fs_rename(const ra8_fs_mount_t *handle, const char *old_path, const char *new_path)
Rename a file within its own directory.
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_unlink(const ra8_fs_mount_t *handle, const char *path)
Delete a file: mark its dir entry deleted and free its clusters.
ra8_err_t ra8_fs_open(ra8_fs_mount_t *handle, const char *path, ra8_fs_mode_t mode, ra8_fs_file_t **out_file)
Open or create a file by path, 8.3 or long.
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).
ra8_fs_type_t
FAT variant detected from the BPB cluster-count rule.
@ k_ra8_fs_type_fat12
count_of_clusters < 4085.
@ k_ra8_fs_type_fat32
count_of_clusters >= 65525.
@ k_ra8_fs_type_exfat
exFAT (read + streaming write + format).
@ k_ra8_fs_type_fat16
4085 <= count_of_clusters < 65525.
@ k_ra8_fs_type_unknown
Not yet detected / mount failed.
@ k_ra8_fs_attr_directory
MS FAT spec sec 6 "ATTR_DIRECTORY".
@ k_ra8_fs_mode_read
Read-only, must exist.
ra8_io block-device fabric – one LBA vtable across every storage medium.
ra8_err_t ra8_io_blockdev_read(const ra8_io_blockdev_t *bd, uint32_t lba, uint32_t count, uint8_t *buf)
Read count logical blocks starting at lba into buf.
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_io block-device backend over a hosted USB mass-storage device.
ra8_err_t ra8_io_blockdev_usbmsc_init(ra8_io_blockdev_t *bd, ra8_io_blockdev_usbmsc_state_t *state, uint8_t lun)
Bind a hosted USB mass-storage backend into a caller-owned handle.
Cookie carried through ra8_fs_listdir for printing + matching.
uint32_t count
Total entries reported.
const char * want
Name expected present (nullptr = none).
uint8_t found_want
1 when want was seen.
const char * avoid
Name expected absent (nullptr = none).
uint8_t found_avoid
1 when avoid was seen.
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.
Caller-owned private state for a USB mass-storage block device.
void fileops_probe_layout(void)
Dump the partition table + LBA1/LBA2 heads after a mount failure.
static ra8_err_t fileops_read_back(ra8_fs_mount_t *mount, const char *path)
Open path and verify it reads back the known payload.
static void fileops_dump_rows(const uint8_t *data, uint32_t offset, uint32_t len)
Hex-dump len bytes of data starting at offset.
static uint8_t fileops_nibble_to_hex(uint32_t nibble)
Format one nibble (0..15) into an uppercase hex character.
static const uint8_t k_fileops_payload[]
Known payload written to and read back from the drive.
static uint32_t fileops_str_len(const char *text)
Bounded ASCII string length (cap k_fileops_print_cap).
ra8_err_t fileops_print_dec(uint64_t value)
Print a uint32_t as ASCII decimal.
ra8_err_t fileops_suite_mutate(ra8_fs_mount_t *mount)
Suite steps 6..9: rename, old-gone/new-intact, list, delete.
static ra8_io_blockdev_usbmsc_state_t s_fileops_usb_state
Caller-owned backend state for s_fileops_usb_dev.
static const char k_fileops_name_a[]
Name the payload file is created under (8.3-safe, <= 15 chars).
static ra8_err_t fileops_expect_absent(ra8_fs_mount_t *mount, const char *path)
Require that path no longer resolves on the volume.
ra8_err_t fileops_suite_create(ra8_fs_mount_t *mount)
Suite steps 1..5: cleanup, baseline listdir, write, verify, list.
static const char k_fileops_name_b[]
Name the payload file is renamed to (8.3-safe, <= 15 chars).
static void fileops_listdir_cb(const char *name, uint8_t attr, uint64_t size, void *ctx)
Listdir callback: print one entry, match the expectation names.
static const char * fileops_fs_type_name(ra8_fs_type_t type)
Map a detected filesystem type to a printable name.
ra8_err_t fileops_mount_volume(ra8_fs_mount_t **out_mount)
Mount the attached drive through the USB-MSC backend.
static bool fileops_name_eq(const char *a, const char *b)
Bounded ASCII string equality (cap k_fileops_name_cap).
static ra8_io_blockdev_t s_fileops_usb_dev
Block device fronting the hosted MSC volume for this ladder.
ra8_err_t fileops_print_fail(const char *what, ra8_err_t err)
Print "FAIL <what> err=0xNNNNNNNN" on its own line.
static ra8_err_t fileops_step_write(ra8_fs_mount_t *mount)
Step 3: print the banner and write the payload file.
ra8_err_t fileops_print_hex(uint32_t value, uint8_t digits)
Print a value as fixed-width uppercase hex.
static ra8_err_t fileops_sci_write(const uint8_t *data, uint32_t len)
Push a literal block over SCI8 polled.
static ra8_err_t fileops_step_listdir(ra8_fs_mount_t *mount, const char *want, const char *avoid)
List the root directory and check presence/absence expectations.
ra8_err_t fileops_print(const char *text)
Print a NUL-terminated ASCII string over the console.
examples/ek_ra8d2/hw_validated/manual/usb_host_file_ops/inc/usb_host_file_ops_steps....
@ k_fileops_probe_lba_max
Probe reads LBAs 0..2.
@ k_fileops_probe_tbl_off
LBA0 dump start (partition table).
@ k_fileops_probe_head_len
LBA1/LBA2 head dump length.
@ k_fileops_probe_row
Hex bytes per dump row.
@ k_fileops_probe_tbl_len
LBA0 dump length (incl.
@ k_fileops_name_cap
Listdir name compare bound.
@ k_fileops_sector_bytes
One SCSI block / FAT sector.
@ k_fileops_target_lun
Exercise LUN 0 (typical stick).
@ k_fileops_print_cap
Bound for console-string scans.
@ k_fileops_hex_chars_u32
32-bit value -> "ABCDEF01".
@ k_fileops_hex_digit_split
Threshold between '0-9'/'A-F'.
@ k_fileops_nibble_bits
Bits per hex nibble.
@ k_fileops_hex_chars_u16
16-bit value -> "ABCD".
@ k_fileops_dec_chars_u64
Max digits for a 64-bit count.
@ k_fileops_nibble_mask
4-bit nibble mask.
@ k_fileops_dec_radix
Base for decimal conversion.