ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
usb_host_file_ops_steps.h File Reference

examples/ek_ra8d2/hw_validated/manual/usb_host_file_ops/inc/usb_host_file_ops_steps.h More...

#include <stdint.h>
#include "ra8_err.h"
#include "ra8_fs.h"
#include "ra8_usb.h"
#include "ra8_usb_hmsc.h"
Include dependency graph for usb_host_file_ops_steps.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Enumerations

enum  usb_fileops_config_t : uint32_t {
  k_fileops_baud = 115200U ,
  k_fileops_idle_ms = 50U ,
  k_fileops_retry_ms = 5000U ,
  k_fileops_target_lun = 0U ,
  k_fileops_print_cap = 160U
}
 Compile-time settings for the host file-ops suite. More...
enum  usb_fileops_size_t : uint16_t {
  k_fileops_sector_bytes = 512U ,
  k_fileops_name_cap = 64U
}
 Buffer sizing constants. More...
enum  usb_fileops_hex_t : uint8_t {
  k_fileops_hex_chars_u16 = 4U ,
  k_fileops_hex_chars_u32 = 8U ,
  k_fileops_dec_chars_u64 = 20U ,
  k_fileops_nibble_bits = 4U ,
  k_fileops_hex_digit_split = 10U
}
 Hex/decimal text-formatter sizing constants. More...
enum  usb_fileops_mask_t : uint32_t {
  k_fileops_nibble_mask = 0xFU ,
  k_fileops_dec_radix = 10U
}
 Bit-mask constants used by the text formatters. More...
enum  usb_fileops_probe_t : uint32_t {
  k_fileops_probe_tbl_off = 432U ,
  k_fileops_probe_tbl_len = 80U ,
  k_fileops_probe_head_len = 64U ,
  k_fileops_probe_row = 16U ,
  k_fileops_probe_lba_max = 3U
}
 Sizing for the on-mount-failure disk-layout probe dump. More...

Functions

ra8_err_t fileops_print (const char *text)
 Print a NUL-terminated ASCII string over the console.
ra8_err_t fileops_print_dec (uint64_t value)
 Print a uint32_t as ASCII decimal.
ra8_err_t fileops_print_hex (uint32_t value, uint8_t digits)
 Print a value as fixed-width uppercase hex.
ra8_err_t fileops_print_fail (const char *what, ra8_err_t err)
 Print "FAIL <what> err=0xNNNNNNNN" on its own line.
ra8_err_t fileops_mount_volume (ra8_fs_mount_t **out_mount)
 Mount the attached drive through the USB-MSC backend.
ra8_err_t fileops_suite_create (ra8_fs_mount_t *mount)
 Suite steps 1..5: cleanup, baseline listdir, write, verify, list.
ra8_err_t fileops_suite_mutate (ra8_fs_mount_t *mount)
 Suite steps 6..9: rename, old-gone/new-intact, list, delete.
void fileops_probe_layout (void)
 Dump the partition table + LBA1/LBA2 heads after a mount failure.

Detailed Description

examples/ek_ra8d2/hw_validated/manual/usb_host_file_ops/inc/usb_host_file_ops_steps.h

Console helpers + ra8_fs file-op suite for the USB host file-ops app.

Tag
[Ring 6 / APP] {World: S}

Declares the shared compile-time configuration enums, the polled-console print helpers, and the ra8_fs-over-USB-MSC suite routines that back the usb_host_file_ops manual HIL test. The definitions live in usb_host_file_ops_steps.c; main.c keeps only the boot/bring-up code and the retry ladder and calls into this interface.

Author
Brighton Sikarskie
Date
2026-06-12
Since
0.1.0

Definition in file usb_host_file_ops_steps.h.

Enumeration Type Documentation

◆ usb_fileops_config_t

enum usb_fileops_config_t : uint32_t

Compile-time settings for the host file-ops suite.

Enumerator
k_fileops_baud 

J-Link OB CDC log baud.

k_fileops_idle_ms 

Idle tick in the parked main loop.

k_fileops_retry_ms 

Pause between ladder retries.

k_fileops_target_lun 

Exercise LUN 0 (typical stick).

k_fileops_print_cap 

Bound for console-string scans.

Definition at line 41 of file usb_host_file_ops_steps.h.

◆ usb_fileops_hex_t

enum usb_fileops_hex_t : uint8_t

Hex/decimal text-formatter sizing constants.

Enumerator
k_fileops_hex_chars_u16 

16-bit value -> "ABCD".

k_fileops_hex_chars_u32 

32-bit value -> "ABCDEF01".

k_fileops_dec_chars_u64 

Max digits for a 64-bit count.

k_fileops_nibble_bits 

Bits per hex nibble.

k_fileops_hex_digit_split 

Threshold between '0-9'/'A-F'.

Definition at line 62 of file usb_host_file_ops_steps.h.

◆ usb_fileops_mask_t

enum usb_fileops_mask_t : uint32_t

Bit-mask constants used by the text formatters.

Enumerator
k_fileops_nibble_mask 

4-bit nibble mask.

k_fileops_dec_radix 

Base for decimal conversion.

Definition at line 74 of file usb_host_file_ops_steps.h.

◆ usb_fileops_probe_t

enum usb_fileops_probe_t : uint32_t

Sizing for the on-mount-failure disk-layout probe dump.

Enumerator
k_fileops_probe_tbl_off 

LBA0 dump start (partition table).

k_fileops_probe_tbl_len 

LBA0 dump length (incl.

0x55AA).

k_fileops_probe_head_len 

LBA1/LBA2 head dump length.

k_fileops_probe_row 

Hex bytes per dump row.

k_fileops_probe_lba_max 

Probe reads LBAs 0..2.

Definition at line 83 of file usb_host_file_ops_steps.h.

◆ usb_fileops_size_t

enum usb_fileops_size_t : uint16_t

Buffer sizing constants.

Enumerator
k_fileops_sector_bytes 

One SCSI block / FAT sector.

k_fileops_name_cap 

Listdir name compare bound.

Definition at line 53 of file usb_host_file_ops_steps.h.

Function Documentation

◆ fileops_mount_volume()

ra8_err_t fileops_mount_volume ( ra8_fs_mount_t ** out_mount)
nodiscard

Mount the attached drive through the USB-MSC backend.

Parameters
[out]out_mountReceives the mount handle on success.
Returns
ra8_err_t from the block-device bind, the ra8_fs bridge, or ra8_fs_mount.
Return values
k_ra8_okVolume mounted; the type line was printed.
Precondition
ra8_usb_hmsc_enumerate completed on the attached drive.
out_mount is non-NULL.
Postcondition
On k_ra8_ok the mount handle is live and must be unmounted later.
The "mounted fs=" line is queued on success.
Note
Reads the MBR/BPB chain over USB.
Since
0.1.0

Definition at line 272 of file usb_host_file_ops_steps.c.

References fileops_fs_type_name(), fileops_print(), fileops_print_dec(), fileops_print_fail(), k_fileops_target_lun, k_ra8_ok, ra8_fs_mount(), ra8_io_blockdev_as_fs_backend(), ra8_io_blockdev_usbmsc_init(), s_fileops_usb_dev, and s_fileops_usb_state.

Referenced by fileops_run_ladder().

◆ fileops_print()

ra8_err_t fileops_print ( const char * text)
nodiscard

Print a NUL-terminated ASCII string over the console.

Parameters
[in]textString to print (CR/LF included by the caller).
Returns
ra8_err_t propagated from the SCI helper.
Return values
k_ra8_okAll bytes queued.
Precondition
SCI8 init already ran; text is non-NULL.
text is NUL-terminated within k_fileops_print_cap bytes.
Postcondition
The string bytes are in the SCI8 TX FIFO.
No other state changes.
Note
Blocking polled TX.
Since
0.1.0

Definition at line 146 of file usb_host_file_ops_steps.c.

References fileops_sci_write(), and fileops_str_len().

Referenced by fileops_dump_rows(), fileops_listdir_cb(), fileops_mount_volume(), fileops_print_attach(), fileops_print_fail(), fileops_probe_layout(), fileops_run_ladder(), fileops_step_listdir(), fileops_step_write(), fileops_suite_create(), fileops_suite_mutate(), and main().

◆ fileops_print_dec()

ra8_err_t fileops_print_dec ( uint64_t value)
nodiscard

Print a uint32_t as ASCII decimal.

Parameters
[in]valueValue to print.
Returns
ra8_err_t propagated from the SCI helper.
Return values
k_ra8_okAll bytes queued.
Precondition
SCI8 init already ran.
None beyond console readiness.
Postcondition
One ASCII decimal token is in the SCI8 TX FIFO.
No other state changes.
Note
Blocking polled TX.
Since
0.1.0

Definition at line 151 of file usb_host_file_ops_steps.c.

References fileops_sci_write(), k_fileops_dec_chars_u64, and k_fileops_dec_radix.

Referenced by fileops_listdir_cb(), fileops_mount_volume(), fileops_probe_layout(), fileops_step_listdir(), and fileops_step_write().

◆ fileops_print_fail()

ra8_err_t fileops_print_fail ( const char * what,
ra8_err_t err )
nodiscard

Print "FAIL <what> err=0xNNNNNNNN" on its own line.

Parameters
[in]whatShort description of the failed step.
[in]errError code returned by the step.
Returns
ra8_err_t propagated from the SCI helpers.
Return values
k_ra8_okThe diagnostic line is queued.
Precondition
SCI8 init already ran.
what is NUL-terminated within the print cap.
Postcondition
One diagnostic line is in the SCI8 TX FIFO.
No other state changes.
Note
Blocking polled TX.
Since
0.1.0

Definition at line 186 of file usb_host_file_ops_steps.c.

References fileops_print(), fileops_print_hex(), k_fileops_hex_chars_u32, and k_ra8_ok.

Referenced by fileops_expect_absent(), fileops_mount_volume(), fileops_read_back(), fileops_run_ladder(), fileops_step_listdir(), fileops_step_write(), fileops_suite_mutate(), and main().

◆ fileops_print_hex()

ra8_err_t fileops_print_hex ( uint32_t value,
uint8_t digits )
nodiscard

Print a value as fixed-width uppercase hex.

Parameters
[in]valueValue to print.
[in]digitsHex digit count (4 for u16, 8 for u32).
Returns
ra8_err_t propagated from the SCI helper.
Return values
k_ra8_okAll bytes queued.
Precondition
SCI8 init already ran.
digits is at most k_fileops_hex_chars_u32.
Postcondition
One fixed-width hex token is in the SCI8 TX FIFO.
No other state changes.
Note
Blocking polled TX.
Since
0.1.0

Definition at line 172 of file usb_host_file_ops_steps.c.

References fileops_nibble_to_hex(), fileops_sci_write(), k_fileops_hex_chars_u32, k_fileops_nibble_bits, and k_fileops_nibble_mask.

Referenced by fileops_dump_rows(), fileops_print_attach(), and fileops_print_fail().

◆ fileops_probe_layout()

void fileops_probe_layout ( void )

Dump the partition table + LBA1/LBA2 heads after a mount failure.

Reads LBA 0 (MBR partition entries at 0x1BE), LBA 1, and LBA 2 straight through the USB backend and prints hex excerpts, so an unrecognized disk layout (e.g. GPT) can be identified from the log.

Precondition
ra8_usb_hmsc_enumerate completed on the attached drive.
SCI8 init already ran.
Postcondition
Three dump blocks are queued on the console.
No filesystem state changes.
Note
Print/read errors are swallowed – diagnostic only.
Since
0.1.0

Definition at line 688 of file usb_host_file_ops_steps.c.

References fileops_dump_rows(), fileops_print(), fileops_print_dec(), k_fileops_probe_head_len, k_fileops_probe_lba_max, k_fileops_probe_tbl_len, k_fileops_probe_tbl_off, k_fileops_sector_bytes, k_ra8_ok, ra8_io_blockdev_read(), and s_fileops_usb_dev.

Referenced by fileops_run_ladder().

◆ fileops_suite_create()

ra8_err_t fileops_suite_create ( ra8_fs_mount_t * mount)
nodiscard

Suite steps 1..5: cleanup, baseline listdir, write, verify, list.

Parameters
[in]mountLive mount handle.
Returns
First failing step's error, or k_ra8_ok.
Return values
k_ra8_okSteps 1-5 all passed and printed their verdicts.
Precondition
mount is a live handle from ra8_fs_mount.
SCI8 init already ran.
Postcondition
On k_ra8_ok the volume holds k_fileops_name_a with the payload.
Each completed step toggled LED2 and queued its verdict line.
Note
Mutates the volume (creates the test file).
Since
0.1.0

Definition at line 548 of file usb_host_file_ops_steps.c.

References fileops_print(), fileops_read_back(), fileops_step_listdir(), fileops_step_write(), k_fileops_name_a, k_fileops_name_b, k_ra8_board_led2, k_ra8_ok, ra8_board_led_toggle(), and ra8_fs_unlink().

Referenced by fileops_run_ladder().

◆ fileops_suite_mutate()

ra8_err_t fileops_suite_mutate ( ra8_fs_mount_t * mount)
nodiscard

Suite steps 6..9: rename, old-gone/new-intact, list, delete.

Parameters
[in]mountLive mount handle.
Returns
First failing step's error, or k_ra8_ok.
Return values
k_ra8_okSteps 6-9 all passed and printed their verdicts.
Precondition
fileops_suite_create completed on this mount.
SCI8 init already ran.
Postcondition
On k_ra8_ok the volume no longer holds either test name.
Each completed step toggled LED2 and queued its verdict line.
Note
Mutates the volume (rename + unlink).
Since
0.1.0

Definition at line 596 of file usb_host_file_ops_steps.c.

References fileops_expect_absent(), fileops_print(), fileops_print_fail(), fileops_read_back(), fileops_step_listdir(), k_fileops_name_a, k_fileops_name_b, k_ra8_board_led2, k_ra8_ok, ra8_board_led_toggle(), ra8_fs_rename(), and ra8_fs_unlink().

Referenced by fileops_run_ladder().