ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
usb_selftest_ospi_steps.h
Go to the documentation of this file.
1
31
32#pragma once
33
34#include <stdint.h>
35
36#include "ra8_err.h"
37
38/* -------------------------------------------------------------------------- */
39/* Tunables */
40/* -------------------------------------------------------------------------- */
41
68
80
85typedef enum : uint32_t {
89
103
117
127typedef enum : uint32_t {
129 k_ospi_test_offset = 0x00100000U,
130 k_ospi_bytes = 0x00100000U,
131 k_ospi_erase_sector = 0x00001000U,
134
144typedef enum : uint32_t {
150
157
159typedef enum : uint8_t {
163
190
210
243
248typedef enum : uint32_t {
250 k_word_mask = 0xFFFFU,
252
253#ifndef RA8_OFF_TARGET
254
255#include "ra8_fs.h"
256#include "ra8_usb_hmsc.h"
257#include "tx_api.h"
258
259/* -------------------------------------------------------------------------- */
260/* FAT16 synthesis + storage media callbacks (usb_selftest_ospi_format.c) */
261/* -------------------------------------------------------------------------- */
262
282void selftest_pattern_fill(uint32_t win_sector, UCHAR* out);
283
313UINT selftest_msc_read(VOID* storage,
314 ULONG lun,
315 UCHAR* data_pointer,
316 ULONG number_blocks,
317 ULONG lba,
318 ULONG* media_status);
319
345UINT selftest_msc_write(VOID* storage,
346 ULONG lun,
347 UCHAR* data_pointer,
348 ULONG number_blocks,
349 ULONG lba,
350 ULONG* media_status);
351
373UINT selftest_msc_status(VOID* storage, ULONG lun, ULONG media_id, ULONG* media_status);
374
375/* -------------------------------------------------------------------------- */
376/* Console helpers (usb_selftest_ospi_format.c) */
377/* -------------------------------------------------------------------------- */
378
397[[nodiscard]] ra8_err_t selftest_print(const char* text);
398
417[[nodiscard]] ra8_err_t selftest_print_dec(uint32_t value);
418
438[[nodiscard]] ra8_err_t selftest_print_hex(uint32_t value, uint8_t digits);
439
460[[nodiscard]] ra8_err_t selftest_print_fail(const char* what, ra8_err_t err);
461
462/* -------------------------------------------------------------------------- */
463/* Host-side pass ladder (usb_selftest_ospi_host.c) */
464/* -------------------------------------------------------------------------- */
465
484[[nodiscard]] ra8_err_t selftest_host_pass(void);
485
486#endif /* !RA8_OFF_TARGET */
scsi_sense_code_t
SCSI sense triple for an unsupported / out-of-range request.
Definition main.c:144
@ k_scsi_ascq_none
ASCQ: none.
Definition main.c:147
@ k_scsi_asc_write_protected
ASC: WRITE PROTECTED.
Definition main.c:149
@ k_scsi_sense_illegal_request
Sense key: ILLEGAL REQUEST.
Definition main.c:145
@ k_scsi_sense_data_protect
Sense key: DATA PROTECT.
Definition main.c:148
@ k_scsi_asc_lba_out_of_range
ASC: LBA out of range.
Definition main.c:146
Error Code Definitions for ra8-firmware.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Definition ra8_err.h:546
Minimal FAT12/FAT16/FAT32 filesystem adapter (read + write).
@ k_dir_off_attr
MS FAT spec sec 6 "DIR_Attr".
@ k_byte_mask
Byte mask.
@ k_word_mask
Word mask.
Native USB host-side MSC (Mass Storage Class) class layer.
unsigned int UINT
ThreadX-compatible unsigned int (host stub).
unsigned long ULONG
ThreadX-compatible unsigned long (host stub).
selftest_hex_t
Hex/decimal text-formatter sizing constants.
@ k_selftest_hex_digit_split
Threshold between '0-9'/'A-F'.
@ k_selftest_hex_chars_u16
16-bit value -> "ABCD".
@ k_selftest_dec_chars_u32
Max digits for a 32-bit count.
@ k_selftest_hex_chars_u32
32-bit value -> "ABCDEF01".
@ k_selftest_nibble_bits
Bits per hex nibble.
selftest_phase_t
J-Link probe values marking host-ladder progress.
@ k_selftest_phase_wp
Write-protect rejection test.
@ k_selftest_phase_mount
Mounting the FAT16 volume.
@ k_selftest_phase_boot
Host thread not yet started.
@ k_selftest_phase_enum
Enumerating the FS device.
@ k_selftest_phase_pass
Full config A pass.
@ k_selftest_phase_host_init
ra8_usb_hmsc_init issued.
@ k_selftest_phase_verify
Streaming + comparing MRAM.BIN.
selftest_verify_t
Content-verification geometry over the device's FAT16 volume.
@ k_selftest_wp_probe_lba
Data-region LBA for WP test.
@ k_selftest_ms_per_sec
Milliseconds per second.
@ k_selftest_target_lun
Single-LUN device.
@ k_selftest_burst_bytes
8 x 512 B burst buffer size.
@ k_selftest_burst_blocks
Blocks per READ(10) burst.
@ k_selftest_no_mismatch
Probe: no mismatch found.
@ k_selftest_bytes_per_kib
Bytes per KiB (rate math).
selftest_mask_t
Bit-mask constants used by the text formatters.
@ k_selftest_dec_radix
Base for decimal conversion.
@ k_selftest_nibble_mask
4-bit nibble mask.
scsi_wp_sense_t
SCSI sense triple for a write to the protected medium.
selftest_fat_boot_t
Boot-sector field values (MS FAT spec 1.03 sec 3.1).
@ k_boot_sig_hi_off
Signature high-byte offset.
@ k_boot_jmp0
Short JMP opcode.
@ k_boot_num_heads
Geometry filler.
@ k_boot_sig_lo_off
Signature low-byte offset.
@ k_boot_sig_hi
Boot signature high byte.
@ k_boot_jmp1
JMP displacement.
@ k_boot_sig_lo
Boot signature low byte.
@ k_boot_media
Fixed-disk media byte.
@ k_boot_sec_per_trk
Geometry filler.
@ k_boot_ext_sig
Extended boot signature.
@ k_boot_drive_num
BIOS drive number.
@ k_boot_jmp2
NOP.
@ k_boot_volume_id
Arbitrary volume serial.
selftest_word_pack_t
32-bit little-endian split constants.
@ k_word_shift
Bits per half-word.
selftest_fat_geom_t
Synthesized FAT16 volume geometry (MS FAT spec 1.03).
@ k_fat_root_entries
Root directory entries.
@ k_fat_eoc
End-of-chain marker.
@ k_fat_data_sectors
Padded data region (>= 4085).
@ k_fat_data_lba
First data sector (cluster 2).
@ k_fat_root_sectors
512 entries x 32 B / 512 B.
@ k_fat_root_lba
First root-directory sector.
@ k_fat_fat_sectors
FAT16 size for 4098 entries.
@ k_fat_fat_lba
First FAT sector.
@ k_fat_first_cluster
FAT data area starts at cluster 2.
@ k_fat_entry0
FAT[0]: media F8 + filler.
@ k_fat_reserved_sectors
Boot sector only.
@ k_fat_entries_per_sec
FAT16 entries per 512-byte sector.
@ k_fat_total_sectors
1 + 17 + 32 + 4096.
@ k_fat_num_fats
Single FAT copy.
selftest_fat_off_t
Byte offsets inside the boot sector and directory entries.
@ k_dir_entry_bytes
Directory entry size.
@ k_bpb_off_spt
Sectors per track.
@ k_bpb_off_label
Volume label (11 bytes).
@ k_dir_attr_volume
Volume-label attribute.
@ k_bpb_off_media
Media descriptor.
@ k_bpb_off_bps
Bytes per sector.
@ k_dir_off_size
File size (32-bit LE).
@ k_bpb_off_jmp
Jump instruction.
@ k_bpb_off_heads
Head count.
@ k_bpb_off_oem
OEM name (8 bytes).
@ k_bpb_off_volid
Volume serial (4 bytes).
@ k_bpb_off_bootsig
Extended boot signature.
@ k_bpb_off_fatsz16
Sectors per FAT.
@ k_bpb_off_rsvd
Reserved sector count.
@ k_bpb_off_drvnum
Drive number.
@ k_bpb_off_fstype
Filesystem type (8 bytes).
@ k_bpb_off_rootent
Root entry count.
@ k_dir_name_bytes
8.3 name field length.
@ k_byte_shift
Bits per byte for LE packing.
@ k_dir_off_cluster_lo
First cluster (low word).
@ k_bpb_off_nfats
Number of FATs.
@ k_bpb_off_spc
Sectors per cluster.
@ k_bpb_off_totsec16
Total sectors (16-bit).
@ k_dir_attr_read_only
Read-only attribute.
selftest_config_t
Compile-time settings: threads, pool, console, retry cadence.
@ k_selftest_boot_wait_ticks
Host start delay (1 ms ticks).
@ k_selftest_thread_stack
Device worker stack (bytes).
@ k_selftest_block_size
SCSI logical block size (bytes).
@ k_selftest_idle_ticks
Parked-loop back-off (ticks).
@ k_selftest_retry_ticks
Pause between ladder retries.
@ k_selftest_usbx_pool_bytes
USBX memory pool (bytes).
@ k_selftest_host_priority
Host worker: BELOW the USBX storage class thread (UX_THREAD_PRIORITY_CLASS = 20).
@ k_selftest_dev_priority
Device bring-up worker priority.
@ k_selftest_host_stack
Host worker stack (bytes).
@ k_selftest_print_cap
Bound for console-string scans.
@ k_selftest_baud
J-Link OB CDC log baud.
ra8_err_t selftest_print_hex(uint32_t value, uint8_t digits)
Print a value as fixed-width uppercase hex.
UINT selftest_msc_status(VOID *storage, ULONG lun, ULONG media_id, ULONG *media_status)
Storage media-status callback.
ra8_err_t selftest_host_pass(void)
One full host-side pass: enumerate, mount, verify, WP.
ra8_err_t selftest_print_fail(const char *what, ra8_err_t err)
Print "FAIL <what> err=0xNNNNNNNN" on its own line.
@ k_fat_last_data_clus
Last cluster of MRAM.BIN.
@ k_fat_data_clusters
Clusters backed by MRAM (1 MiB).
UINT selftest_msc_read(VOID *storage, ULONG lun, UCHAR *data_pointer, ULONG number_blocks, ULONG lba, ULONG *media_status)
Storage media-read callback: synthesize sectors over MRAM.
void selftest_pattern_fill(uint32_t win_sector, UCHAR *out)
Compute the deterministic pattern for one window data sector.
selftest_pattern_t
Deterministic sector-pattern coefficients (device + host agree).
@ k_ospi_pat_bias
Constant bias.
@ k_ospi_pat_mask
Byte mask.
@ k_ospi_pat_smul
Per-sector multiplier.
@ k_ospi_pat_imul
Per-byte multiplier.
ra8_err_t selftest_print(const char *text)
Print a NUL-terminated ASCII string over the console.
UINT selftest_msc_write(VOID *storage, ULONG lun, UCHAR *data_pointer, ULONG number_blocks, ULONG lba, ULONG *media_status)
Storage media-write callback: always rejects (write-protected).
selftest_ospi_t
OSPI flash geometry the device-side volume is backed by.
@ k_ospi_erase_count
1 MiB / 4 KiB = 256 erases.
@ k_ospi_bytes
1 MiB exposed window size.
@ k_ospi_test_offset
1 MiB into the chip (scratch).
@ k_ospi_erase_sector
IS25LX512M 4 KiB erase sector.
@ k_ospi_instance
xSPI controller instance.
ra8_err_t selftest_print_dec(uint32_t value)
Print a uint32_t as ASCII decimal.