121 return (uint8_t)((uint8_t)
'0' + (uint8_t)nibble);
148 if (text[len] ==
'\0') {
228 out[0] = (uint8_t)
'0';
239 for (uint8_t i = 0U; i < count; i++) {
240 out[i] = scratch[count - 1U - i];
267 uint8_t width = digits;
271 for (uint8_t i = 0U; i < width; i++) {
389 uint32_t block_count = 0U;
390 uint32_t block_size = 0U;
446 return ospirw_print(
" OK (64 sectors, write+read verified)\r\n");
557 err =
ospirw_print(
"ra8d2 ospirw: USB SELFTEST WRITABLE-OSPI PASS\r\n");
Board-support layer for the Renesas EK-RA8D2 v1 evaluation kit.
ra8_err_t ra8_board_led_on(ra8_board_led_id_t led)
Drive led HIGH (light it).
@ 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_invalid_state
Module in wrong state for requested operation.
@ 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.
int memcmp(const void *a, const void *b, size_t n)
Compare bytes in two memory areas.
@ k_ra8_usb_speed_hs
High-Speed controller (USBHS @ 0x40351000).
Native USB host-side MSC (Mass Storage Class) class layer.
ra8_err_t ra8_usb_hmsc_read_capacity(uint8_t target_lun, uint32_t *block_count, uint32_t *block_size)
Issue a SCSI READ CAPACITY(10) (opcode 0x25) over BBB.
ra8_err_t ra8_usb_hmsc_read10(uint8_t target_lun, uint32_t lba, uint16_t block_count, uint8_t *out_buf)
Issue a SCSI READ(10) (opcode 0x28) over BBB.
ra8_err_t ra8_usb_hmsc_enumerate(ra8_usb_hmsc_device_t *out_device)
Enumerate the attached MSC device end to end (polled).
ra8_err_t ra8_usb_hmsc_close(void)
Tear down the host-MSC driver and release the controller.
ra8_err_t ra8_usb_hmsc_init(ra8_usb_speed_t speed)
Bring up the host-MSC driver on a chosen USB controller.
ra8_err_t ra8_usb_hmsc_write10(uint8_t target_lun, uint32_t lba, uint16_t block_count, const uint8_t *in_buf)
Issue a SCSI WRITE(10) (opcode 0x2A) over BBB.
unsigned long ULONG
ThreadX-compatible unsigned long (host stub).
Snapshot of the attached MSC device, passed to the attach callback.
uint8_t max_lun
Get-Max-LUN response (0..15).
uint16_t product_id
idProduct from device descriptor.
static uint8_t ospirw_nibble_to_hex(uint32_t nibble)
Format one nibble (0..15) into an uppercase hex character.
static ra8_err_t ospirw_print_lun_ok(uint32_t lun)
Print "LUN n OK" for the verified writable unit.
static ra8_err_t ospirw_print_fail(const char *what, ra8_err_t err)
Print "FAIL <what> err=0xNNNNNNNN" on its own line.
static ra8_err_t ospirw_host_pass(void)
One full host-side pass: enumerate, WRITE(10) then verify.
static ra8_err_t ospirw_print_hex(uint32_t value, uint8_t digits)
Print a value as fixed-width uppercase hex.
static uint32_t ospirw_str_len(const char *text)
Bounded ASCII string length (cap k_ospirw_print_cap).
static ra8_err_t ospirw_print_dec(uint32_t value)
Print a uint32_t as ASCII decimal.
static ra8_err_t ospirw_host_enumerate(ra8_usb_hmsc_device_t *device)
Enumerate the looped device and print its PID + GET_MAX_LUN.
static void ospirw_pattern_fill(uint32_t lun, uint32_t lba, UCHAR *out)
Fill one 512-byte sector with this LUN/LBA's deterministic bytes.
VOID ospirw_host_worker(ULONG arg)
Host-side worker: retry the full pass until it succeeds.
static ra8_err_t ospirw_sci_write(const uint8_t *data, uint32_t len)
Push a literal block over the BSP UART console (SCI8) polled.
static ra8_err_t ospirw_verify_one(uint32_t lun)
Read + verify one LUN's full sector range against its pattern.
static ra8_err_t ospirw_print(const char *text)
Print a NUL-terminated ASCII string over the console.
static ra8_err_t ospirw_write_disk(uint32_t lun)
WRITE(10) the per-LBA pattern across the whole OSPI window.
Shared tunables + host-side worker seam for the writable-OSPI self-loop.
@ k_ospirw_idle_ticks
Parked-loop back-off (ticks).
@ k_ospirw_retry_ticks
Pause between ladder retries.
@ k_ospirw_boot_wait_ticks
Host start delay (1 ms ticks).
@ k_ospirw_print_cap
Bound for console-string scans.
@ k_ospirw_nibble_mask
4-bit nibble mask.
@ k_ospirw_dec_radix
Base for decimal conversion.
@ k_ospirw_phase_pass
All LUNs verified.
@ k_ospirw_phase_init
ra8_usb_hmsc_init issued.
@ k_ospirw_phase_verify
Reading + checking LUNs.
@ k_ospirw_phase_enum
Enumerating.
@ k_ospirw_burst_bytes
8 x 512 B burst buffer.
@ k_ospirw_no_mismatch
Probe: no mismatch.
@ k_ospirw_byte_mask
Byte mask.
@ k_ospirw_pat_lun_mul
Per-LUN pattern multiplier.
@ k_ospirw_pat_bias
Pattern constant bias.
@ k_ospirw_mismatch_lun_shift
s_dbg_mismatch: LUN in bits 31:24.
@ k_ospirw_block_size
SCSI logical block size.
@ k_ospirw_burst_blocks
Blocks per READ(10) burst.
@ k_ospirw_count
Logical units exposed (single writable).
@ k_ospirw_sectors
512-byte sectors (OSPI window = 32 KiB).
@ k_ospirw_pat_lba_mul
Per-LBA pattern multiplier.
@ k_ospirw_dec_chars_u32
Max digits for a 32-bit count.
@ k_ospirw_nibble_bits
Bits per hex nibble.
@ k_ospirw_hex_chars_u16
16-bit value -> "ABCD".
@ k_ospirw_hex_digit_split
Threshold between '0-9'/'A-F'.
@ k_ospirw_hex_chars_u32
32-bit value -> "ABCDEF01".
static volatile uint32_t s_dbg_phase
Host-ladder phase marker (wlun_phase_t).
static volatile uint32_t s_dbg_luns_ok
Sectors that read back correctly after the write pass.
static volatile uint32_t s_dbg_pass_count
Completed full passes (sticky success counter).
static volatile uint32_t s_dbg_mismatch
First mismatching sector, or k_wlun_no_mismatch.
static volatile uint32_t s_dbg_max_lun
Device-reported GET_MAX_LUN value (expect 0, single LUN).