|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
examples/ek_ra8d2/hil_needs_revalidation/usb_selftest_wlun/src/usb_selftest_wlun_host.c More...
#include <stdint.h>#include <string.h>#include "ra8_board_ek_ra8d2.h"#include "ra8_err.h"#include "ra8_usb_hmsc.h"#include "tx_api.h"#include "usb_selftest_wlun_steps.h"Go to the source code of this file.
Functions | |
| static ra8_err_t | wlun_write_disk (uint32_t lun) |
| WRITE(10) the per-LBA pattern across the whole RAM disk. | |
| static ra8_err_t | wlun_verify_one (uint32_t lun) |
| Read + verify one LUN's full sector range against its pattern. | |
| static ra8_err_t | wlun_print_lun_ok (uint32_t lun) |
| Print "LUN n OK" for the verified writable unit. | |
| static ra8_err_t | wlun_host_enumerate (ra8_usb_hmsc_device_t *device) |
| Enumerate the looped device and print its PID + GET_MAX_LUN. | |
| static ra8_err_t | wlun_host_pass (void) |
| One full host-side pass: enumerate, WRITE(10) then verify. | |
| VOID | wlun_host_worker (ULONG arg) |
| Host-side worker: retry the full pass until it succeeds. | |
Variables | |
| 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_max_lun |
| Device-reported GET_MAX_LUN value (expect 0, single LUN). | |
| static volatile uint32_t | s_dbg_mismatch = (uint32_t)k_wlun_no_mismatch |
| First mismatching sector, or k_wlun_no_mismatch. | |
| static volatile uint32_t | s_dbg_pass_count |
| Completed full passes (sticky success counter). | |
examples/ek_ra8d2/hil_needs_revalidation/usb_selftest_wlun/src/usb_selftest_wlun_host.c
Host-side MSC ladder: enumerate, WRITE(10) the disk, read-verify it
The polled host-side worker of the writable-LUN self-loop. It enumerates the looped-back FS device, WRITE(10)s a deterministic per-LBA pattern across the whole RAM disk, then READ(10)s it back and byte-checks every sector – proving the device bulk-OUT WRITE data phase round-trips intact. Streams its verdicts over SCI8 via the shared console formatters and mirrors host-ladder progress in J-Link-readable probes (s_dbg_*). Split out of main.c so each translation unit stays under the per-file line cap. The wlun_host_worker contract lives in usb_selftest_wlun_steps.h.
Definition in file usb_selftest_wlun_host.c.
|
staticnodiscard |
Enumerate the looped device and print its PID + GET_MAX_LUN.
Sets the enum phase, runs ra8_usb_hmsc_enumerate, records the reported max-LUN in s_dbg_max_lun, and streams the enumerated pid=... GET_MAX_LUN=... banner. On enumerate failure the host controller is closed so the next retry re-attaches clean.
| [out] | device | Receives the enumerated descriptor snapshot. |
| k_ra8_ok | Device enumerated and the banner printed. |
device is non-null. Definition at line 203 of file usb_selftest_wlun_host.c.
References k_ra8_ok, k_wlun_hex_chars_u16, k_wlun_phase_enum, ra8_usb_hmsc_device_t::max_lun, ra8_usb_hmsc_device_t::product_id, ra8_usb_hmsc_close(), ra8_usb_hmsc_enumerate(), s_dbg_max_lun, s_dbg_phase, wlun_print(), wlun_print_dec(), wlun_print_fail(), and wlun_print_hex().
Referenced by wlun_host_pass().
|
staticnodiscard |
One full host-side pass: enumerate, WRITE(10) then verify.
Phases mirror wlun_phase_t. On any failure the host controller is closed so the next retry starts from a clean attach.
| k_ra8_ok | The pass printed WRITABLE-LUN PASS. |
Definition at line 249 of file usb_selftest_wlun_host.c.
References k_ra8_board_led2, k_ra8_ok, k_ra8_usb_speed_hs, k_wlun_count, k_wlun_phase_init, k_wlun_phase_pass, k_wlun_phase_verify, ra8_board_led_on(), ra8_usb_hmsc_close(), ra8_usb_hmsc_init(), s_dbg_luns_ok, s_dbg_pass_count, s_dbg_phase, wlun_host_enumerate(), wlun_print(), wlun_print_fail(), wlun_print_lun_ok(), wlun_verify_one(), and wlun_write_disk().
Referenced by wlun_host_worker().
| VOID wlun_host_worker | ( | ULONG | arg | ) |
Host-side worker: retry the full pass until it succeeds.
Waits for the device side to attach, then loops the full enumerate / WRITE(10) / verify pass with a retry pause until the writable LUN verifies; afterwards parks so the verdict stays on the wire.
| [in] | arg | ThreadX entry argument (unused). |
Definition at line 298 of file usb_selftest_wlun_host.c.
References k_ra8_ok, k_wlun_boot_wait_ticks, k_wlun_idle_ticks, k_wlun_retry_ticks, tx_thread_sleep, and wlun_host_pass().
Referenced by tx_application_define().
|
staticnodiscard |
Print "LUN n OK" for the verified writable unit.
| [in] | lun | The LUN that just verified. |
| k_ra8_ok | The line is queued. |
lun. Definition at line 169 of file usb_selftest_wlun_host.c.
References k_ra8_ok, wlun_print(), and wlun_print_dec().
Referenced by wlun_host_pass().
|
staticnodiscard |
Read + verify one LUN's full sector range against its pattern.
READ_CAPACITY (must report k_wlun_sectors), then a raw multi-block READ(10) sweep in 8-block bursts, checking each sector against wlun_pattern_fill for this lun.
| [in] | lun | Logical unit to verify (0..1). |
| k_ra8_ok | The whole LUN matched its pattern. |
| k_ra8_err_invalid_size | READ_CAPACITY reported wrong geometry. |
| k_ra8_err_invalid_state | A byte differed from the pattern. |
lun is below k_wlun_count. Definition at line 118 of file usb_selftest_wlun_host.c.
References k_ra8_err_invalid_size, k_ra8_err_invalid_state, k_ra8_ok, k_wlun_block_size, k_wlun_burst_blocks, k_wlun_burst_bytes, k_wlun_mismatch_lun_shift, k_wlun_sectors, memcmp(), ra8_usb_hmsc_read10(), ra8_usb_hmsc_read_capacity(), s_dbg_mismatch, wlun_pattern_fill(), and wlun_print_fail().
Referenced by wlun_host_pass().
|
staticnodiscard |
WRITE(10) the per-LBA pattern across the whole RAM disk.
Fills an 8-block burst from wlun_pattern_fill and pushes it with raw ra8_usb_hmsc_write10 until every sector is written. This is the host data-OUT phase that drives the device bulk-OUT receive path (the gating mechanism for every writable / repeated-bulk matrix item).
| [in] | lun | Logical unit to write (0). |
| k_ra8_ok | The whole disk was written. |
| k_ra8_err_hw_timeout | A WRITE(10) data-OUT phase did not complete. |
Definition at line 79 of file usb_selftest_wlun_host.c.
References k_ra8_ok, k_wlun_block_size, k_wlun_burst_blocks, k_wlun_burst_bytes, k_wlun_sectors, ra8_usb_hmsc_write10(), wlun_pattern_fill(), and wlun_print_fail().
Referenced by wlun_host_pass().
|
static |
Sectors that read back correctly after the write pass.
Definition at line 45 of file usb_selftest_wlun_host.c.
Referenced by microsd_host_pass(), mlun_host_pass(), ospirw_host_pass(), and wlun_host_pass().
|
static |
Device-reported GET_MAX_LUN value (expect 0, single LUN).
Definition at line 47 of file usb_selftest_wlun_host.c.
Referenced by microsd_host_enumerate(), mlun_host_enumerate(), ospirw_host_enumerate(), and wlun_host_enumerate().
|
static |
First mismatching sector, or k_wlun_no_mismatch.
Definition at line 49 of file usb_selftest_wlun_host.c.
Referenced by cdc_echo_round(), dfu_host_pass(), dfu_upload_verify(), hid_read_round(), hid_read_round(), microsd_verify_one(), mlun_verify_one(), ospirw_verify_one(), and wlun_verify_one().
|
static |
Completed full passes (sticky success counter).
Definition at line 51 of file usb_selftest_wlun_host.c.
Referenced by cdc_host_pass(), dfu_host_pass(), dfu_host_pass(), hid_host_pass(), hid_host_pass(), microsd_host_pass(), mlun_host_pass(), ospirw_host_pass(), selftest_host_pass(), selftest_host_pass(), and wlun_host_pass().
|
static |
Host-ladder phase marker (wlun_phase_t).
Definition at line 43 of file usb_selftest_wlun_host.c.
Referenced by cdc_host_pass(), dfu_host_enumerate(), dfu_host_pass(), dfu_host_pass(), hid_host_pass(), hid_host_pass(), microsd_host_enumerate(), microsd_host_pass(), mlun_host_enumerate(), mlun_host_pass(), ospirw_host_enumerate(), ospirw_host_pass(), selftest_host_enumerate(), selftest_host_enumerate(), selftest_host_enumerate(), selftest_host_enumerate(), selftest_host_enumerate(), selftest_host_pass(), selftest_host_pass(), wlun_host_enumerate(), and wlun_host_pass().