|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Shared constants + step prototypes for the USB self-loop config A app. More...
#include <stdint.h>#include "ra8_err.h"#include "ra8_fs.h"#include "tx_api.h"#include "ux_api.h"Go to the source code of this file.
Functions | |
| 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. | |
| 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). | |
| 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. | |
Shared constants + step prototypes for the USB self-loop config A app.
This header is the seam between main.c (board bring-up, ThreadX workers, USBX descriptors, MSC class registration) and the two helper translation units that carry the bulk of the self-test logic:
All app-specific compile-time constants (tunables, FAT16 geometry, boot-sector field values, byte offsets, SCSI sense triples) live in this header as C23 typed enums so every translation unit shares one definition.
Definition in file usb_selftest_hs_host_steps.h.
| enum scsi_sense_code_t : uint8_t |
SCSI sense triple for an unsupported / out-of-range request.
| Enumerator | |
|---|---|
| k_scsi_sense_illegal_request | Sense key: ILLEGAL REQUEST. |
| k_scsi_asc_lba_out_of_range | ASC: LBA out of range. |
| k_scsi_ascq_none | ASCQ: none. |
Definition at line 133 of file usb_selftest_hs_host_steps.h.
| enum scsi_wp_sense_t : uint8_t |
SCSI sense triple for a write to the protected medium.
| Enumerator | |
|---|---|
| k_scsi_sense_data_protect | Sense key: DATA PROTECT. |
| k_scsi_asc_write_protected | ASC: WRITE PROTECTED. |
Definition at line 140 of file usb_selftest_hs_host_steps.h.
| enum selftest_config_t : uint32_t |
Compile-time settings: threads, pool, console, retry cadence.
Definition at line 51 of file usb_selftest_hs_host_steps.h.
| enum selftest_fat_boot_t : uint32_t |
Boot-sector field values (MS FAT spec 1.03 sec 3.1).
Definition at line 176 of file usb_selftest_hs_host_steps.h.
| enum selftest_fat_geom_t : uint32_t |
Synthesized FAT16 volume geometry (MS FAT spec 1.03).
Identical to usb_msc_mram: one 512-byte sector per cluster, data region padded to 4096 clusters to cross the FAT16 threshold, MRAM.BIN occupying clusters 2..2049.
Definition at line 153 of file usb_selftest_hs_host_steps.h.
| enum selftest_fat_off_t : uint8_t |
Byte offsets inside the boot sector and directory entries.
Definition at line 196 of file usb_selftest_hs_host_steps.h.
| enum selftest_hex_t : uint8_t |
Hex/decimal text-formatter sizing constants.
Definition at line 78 of file usb_selftest_hs_host_steps.h.
| enum selftest_mask_t : uint32_t |
Bit-mask constants used by the text formatters.
| Enumerator | |
|---|---|
| k_selftest_nibble_mask | 4-bit nibble mask. |
| k_selftest_dec_radix | Base for decimal conversion. |
Definition at line 90 of file usb_selftest_hs_host_steps.h.
| enum selftest_mram_t : uint32_t |
The MRAM window the device-side volume exposes.
| Enumerator | |
|---|---|
| k_mram_base_addr | MRAM code window base address. |
| k_mram_bytes | 1 MiB window size. |
Definition at line 127 of file usb_selftest_hs_host_steps.h.
| enum selftest_phase_t : uint32_t |
J-Link probe values marking host-ladder progress.
Definition at line 113 of file usb_selftest_hs_host_steps.h.
| enum selftest_verify_t : uint32_t |
Content-verification geometry over the device's FAT16 volume.
Definition at line 99 of file usb_selftest_hs_host_steps.h.
| enum selftest_word_pack_t : uint32_t |
32-bit little-endian split constants.
| Enumerator | |
|---|---|
| k_word_shift | Bits per half-word. |
| k_word_mask | Low half-word mask. |
Definition at line 229 of file usb_selftest_hs_host_steps.h.
|
nodiscard |
One full host-side pass: enumerate, mount, verify, WP.
Phases mirror selftest_phase_t and are mirrored into the host-ladder phase probe for J-Link readout. On any failure the host controller is closed so the next retry starts from a clean attach. Invoked by main.c's selftest_host_worker.
| k_ra8_ok | The pass printed CONFIG A PASS. |
One full host-side pass: enumerate, mount, verify, WP.
One full host-side pass: enumerate, mount, browse, verify, WP.
One full host-side pass: enumerate, mount, verify, WP.
Drives the host-side ladder over the self-loop cable: brings the USBHS host up and enumerates the FS device, mounts and parses the FAT16 volume, browses the root directory, raw-verifies the 1 MiB MRAM data region with multi-block READ(10) bursts, then probes the write-protect rejection. Phases are mirrored into the J-Link progress probe for readout. On any failure the host controller is closed so the next retry starts from a clean attach. The host worker thread (in main.c) loops this until it returns k_ra8_ok.
| k_ra8_ok | The pass printed the BROWSE PASS banner. |
One full host-side pass: enumerate, mount, browse, verify, WP.
One full host-side pass: enumerate, mount, verify, WP.
One full host-side pass: enumerate, mount, browse, verify, WP.
Enumerates and mounts to prove FAT parse, then runs selftest_verify_mram_raw k_selftest_soak_iters times back to back – every burst is still memcmp'd vs MRAM, so a single corrupted transfer anywhere in the soak fails the run. Aggregates volume + time for a stable throughput benchmark, then confirms the RO write rejection once. s_dbg_pass_count mirrors the completed-iteration count for J-Link.
| k_ra8_ok | All iterations matched; SOAK PASS printed. |
Definition at line 738 of file usb_host_msc_browse_host.c.
| 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.
Bound checks the request against the volume, then fills each block via the FAT16 sector synthesizer. LED1 toggles per call so the self-loop traffic is visible on the board. Registered with the USBX storage class by main.c's selftest_msc_class_register.
| [in,out] | storage | USBX storage class instance (unused). |
| [in] | lun | Logical unit number (must be 0). |
| [out] | data_pointer | USBX-owned destination buffer. |
| [in] | number_blocks | Number of 512-byte blocks to produce. |
| [in] | lba | Starting LBA. |
| [out] | media_status | Filled with sense status word. |
| UX_SUCCESS | Read completed. |
| UX_ERROR | Out-of-range LBA / count. |
Bound checks the request against the volume, then fills each block via the FAT16 synthesizer. LED1 toggles per call so the self-loop traffic is visible on the board.
| [in,out] | storage | USBX storage class instance (unused). |
| [in] | lun | Logical unit number (must be 0). |
| [out] | data_pointer | USBX-owned destination buffer. |
| [in] | number_blocks | Number of 512-byte blocks to produce. |
| [in] | lba | Starting LBA. |
| [out] | media_status | Filled with sense status word. |
| UX_SUCCESS | Read completed. |
| UX_ERROR | Out-of-range LBA / count. |
Bound checks the request against the volume, then fills each block via selftest_fat_fill_sector. LED1 toggles per call so the self-loop traffic is visible on the board.
| [in,out] | storage | USBX storage class instance (unused). |
| [in] | lun | Logical unit number (must be 0). |
| [out] | data_pointer | USBX-owned destination buffer. |
| [in] | number_blocks | Number of 512-byte blocks to produce. |
| [in] | lba | Starting LBA. |
| [out] | media_status | Filled with sense status word. |
| UX_SUCCESS | Read completed. |
| UX_ERROR | Out-of-range LBA / count. |
Bound checks the request against the volume, then fills each block via the FAT16 synthesizer. LED1 toggles per call so the self-loop traffic is visible on the board.
| [in,out] | storage | USBX storage class instance (unused). |
| [in] | lun | Logical unit number (must be 0). |
| [out] | data_pointer | USBX-owned destination buffer. |
| [in] | number_blocks | Number of 512-byte blocks to produce. |
| [in] | lba | Starting LBA. |
| [out] | media_status | Filled with sense status word. |
| UX_SUCCESS | Read completed. |
| UX_ERROR | Out-of-range LBA / count. |
Bound checks the request against the volume, then fills each block via selftest_fat_fill_sector. LED1 toggles per call so the self-loop traffic is visible on the board.
| [in,out] | storage | USBX storage class instance (unused). |
| [in] | lun | Logical unit number (must be 0). |
| [out] | data_pointer | USBX-owned destination buffer. |
| [in] | number_blocks | Number of 512-byte blocks to produce. |
| [in] | lba | Starting LBA. |
| [out] | media_status | Filled with sense status word. |
| UX_SUCCESS | Read completed. |
| UX_ERROR | Out-of-range LBA / count. |
Definition at line 304 of file usb_host_msc_browse_steps.c.
Storage media-status callback.
Always reports media-present.
The synthesized volume cannot go away; status is constant 0.
| [in,out] | storage | USBX storage class instance (unused). |
| [in] | lun | Logical unit number (unused). |
| [in] | media_id | Media id (unused). |
| [out] | media_status | Filled with 0 (no fault). |
| UX_SUCCESS | Media is present and ready. |
Definition at line 347 of file usb_host_msc_browse_steps.c.
| 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).
The host side of this very app probes exactly this rejection (WRITE(10) must fail with DATA PROTECT and the transport must keep working afterwards).
| [in,out] | storage | USBX storage class instance (unused). |
| [in] | lun | Logical unit number (unused). |
| [in] | data_pointer | USBX-owned source buffer (unused). |
| [in] | number_blocks | Number of blocks the host tried (unused). |
| [in] | lba | Starting LBA (unused). |
| [out] | media_status | Filled with DATA PROTECT sense. |
| UX_ERROR | The medium is write-protected. |
Definition at line 328 of file usb_host_msc_browse_steps.c.