ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
usb_selftest_fs_host_fatdisk.c
Go to the documentation of this file.
1
33
34#include <stdint.h>
35#include <string.h>
36
38
39#ifndef RA8_OFF_TARGET
40
41#include "ra8_board_ek_ra8d2.h"
42#include "ra8_err.h"
43#include "ra8_usb.h"
44#include "tx_api.h"
45#include "ux_api.h"
46#include "ux_dcd_ra8_usb.h"
47#include "ux_device_class_storage.h"
48#include "ux_device_stack.h"
49
50/* -------------------------------------------------------------------------- */
51/* USBX pool storage */
52/* -------------------------------------------------------------------------- */
53
60
61/* SCSI INQUIRY strings -- 8 / 16 / 4 byte fields per SBC-3. */
62static UCHAR s_msc_vendor_id[] = "RA8D2 ";
63static UCHAR s_msc_product_id[] = "SELFTEST MRAM RO";
64static UCHAR s_msc_product_rev[] = "0001";
65
67static const UCHAR s_fat_oem_name[8] = {'R', 'A', '8', 'D', '2', 'F', 'W', ' '};
68
70static const UCHAR s_fat_volume_label[11] = {'R', 'A', '8', 'D', '2', ' ', 'M', 'R', 'A', 'M', ' '};
71
73static const UCHAR s_fat_fs_type[8] = {'F', 'A', 'T', '1', '6', ' ', ' ', ' '};
74
76static const UCHAR s_fat_file_name[11] = {'M', 'R', 'A', 'M', ' ', ' ', ' ', ' ', 'B', 'I', 'N'};
77
78/* -------------------------------------------------------------------------- */
79/* J-Link probes (device side) */
80/* -------------------------------------------------------------------------- */
81
83static volatile uint32_t s_dbg_read_calls;
85static volatile uint32_t s_dbg_dev_state;
87static volatile uint32_t s_dbg_ux_speed;
89static volatile uint32_t s_dbg_thr_runs;
91static volatile uint32_t s_dbg_thr_state;
93static volatile uint32_t s_dbg_state3_seen;
95static volatile uint32_t s_dbg_framework;
97static volatile uint32_t s_dbg_fw_len;
99static volatile uint32_t s_dbg_fw_fs_addr;
101static volatile uint32_t s_dbg_fw_hs_addr;
102
103/* -------------------------------------------------------------------------- */
104/* USB descriptors (DEVICE + CONFIG + MSC interface + endpoints) */
105/* -------------------------------------------------------------------------- */
106
107/* High-speed framework for the USBHS device controller: the device
108 * descriptor + the mandatory Device Qualifier (USB 2.0 sec 9.6.2) +
109 * 512-byte bulk wMaxPacketSize. The FS host enumerates this device at
110 * full speed, so the stack actually serves the FS framework below; the
111 * HS framework is still required for _ux_device_stack_initialize's
112 * primary (HS) slot. PID 0x000F marks config B apart from config A
113 * (0x000E) and the Mac-facing MRAM apps (0x000C / 0x000D). */
114static UCHAR s_device_framework_hs[] = {
115 /* Device descriptor (USB 2.0 sec 9.6.1) -- 18 bytes. */
116 0x12U,
117 0x01U,
118 0x00U,
119 0x02U,
120 0x00U, /* class = per-interface */
121 0x00U,
122 0x00U,
123 0x40U,
124 0x09U,
125 0x12U,
126 0x0FU, /* PID = 0x000F (pid.codes test). */
127 0x00U,
128 0x00U,
129 0x01U,
130 0x01U,
131 0x02U,
132 0x03U,
133 0x01U,
134 /* Device Qualifier descriptor (USB 2.0 sec 9.6.2) -- 10 bytes. */
135 0x0AU,
136 0x06U,
137 0x00U,
138 0x02U,
139 0x00U,
140 0x00U,
141 0x00U,
142 0x40U,
143 0x01U,
144 0x00U,
145 /* Configuration descriptor (32 bytes total). */
146 0x09U,
147 0x02U,
148 0x20U,
149 0x00U,
150 0x01U,
151 0x01U,
152 0x00U,
153 0x80U,
154 0x32U,
155 /* Interface descriptor -- MSC, SCSI, BBB. */
156 0x09U,
157 0x04U,
158 0x00U,
159 0x00U,
160 0x02U,
161 0x08U,
162 0x06U,
163 0x50U,
164 0x00U,
165 /* Bulk-IN endpoint (EP1 IN, 512-byte MPS at HS). */
166 0x07U,
167 0x05U,
168 0x81U,
169 0x02U,
170 0x00U,
171 0x02U,
172 0x00U,
173 /* Bulk-OUT endpoint (EP2 OUT, 512-byte MPS at HS). */
174 0x07U,
175 0x05U,
176 0x02U,
177 0x02U,
178 0x00U,
179 0x02U,
180 0x00U,
181};
182
183/* Full-speed (fallback) framework -- what the FS host actually
184 * enumerates. EP1 IN + EP2 OUT, 64-byte MPS. */
185static UCHAR s_device_framework_fs[] = {
186 /* Device descriptor (USB 2.0 sec 9.6.1) -- 18 bytes. */
187 0x12U,
188 0x01U,
189 0x00U,
190 0x02U,
191 0x00U, /* class = per-interface */
192 0x00U,
193 0x00U,
194 0x40U,
195 0x09U,
196 0x12U,
197 0x0FU, /* PID = 0x000F (pid.codes test). */
198 0x00U,
199 0x00U,
200 0x01U,
201 0x01U,
202 0x02U,
203 0x03U,
204 0x01U,
205 /* Configuration descriptor (32 bytes total). */
206 0x09U,
207 0x02U,
208 0x20U,
209 0x00U,
210 0x01U,
211 0x01U,
212 0x00U,
213 0x80U,
214 0x32U,
215 /* Interface descriptor -- MSC, SCSI, BBB. */
216 0x09U,
217 0x04U,
218 0x00U,
219 0x00U,
220 0x02U,
221 0x08U,
222 0x06U,
223 0x50U,
224 0x00U,
225 /* Bulk-IN endpoint (EP1 IN, 64-byte MPS). */
226 0x07U,
227 0x05U,
228 0x81U,
229 0x02U,
230 0x40U,
231 0x00U,
232 0x00U,
233 /* Bulk-OUT endpoint (EP2 OUT, 64-byte MPS). */
234 0x07U,
235 0x05U,
236 0x02U,
237 0x02U,
238 0x40U,
239 0x00U,
240 0x00U,
241};
242
250static UCHAR s_string_framework[] = {
251 /* idx 1: "Brighton Sikarskie". */
252 0x09U,
253 0x04U,
254 0x01U,
255 0x12U,
256 'B',
257 'r',
258 'i',
259 'g',
260 'h',
261 't',
262 'o',
263 'n',
264 ' ',
265 'S',
266 'i',
267 'k',
268 'a',
269 'r',
270 's',
271 'k',
272 'i',
273 'e',
274 /* idx 2: "RA8D2 SELFTEST". */
275 0x09U,
276 0x04U,
277 0x02U,
278 0x0EU,
279 'R',
280 'A',
281 '8',
282 'D',
283 '2',
284 ' ',
285 'S',
286 'E',
287 'L',
288 'F',
289 'T',
290 'E',
291 'S',
292 'T',
293 /* idx 3: serial. */
294 0x09U,
295 0x04U,
296 0x03U,
297 0x08U,
298 '0',
299 '0',
300 '0',
301 '0',
302 '0',
303 '0',
304 '0',
305 '6',
306};
307
308/* USBX LANGID descriptor 0x0409 (English-US): ::usb_langid_byte_t lives in
309 * the shared header so all three units agree on the byte pair. */
310
317
318/* -------------------------------------------------------------------------- */
319/* FAT16 synthesis (identical layout to usb_msc_mram) */
320/* -------------------------------------------------------------------------- */
321
338static void selftest_put16(UCHAR* dst, uint16_t value)
339{
340 dst[0] = (UCHAR)(value & (uint16_t)k_byte_mask);
341 dst[1] = (UCHAR)((value >> (uint16_t)k_byte_shift) & (uint16_t)k_byte_mask);
342}
343
360static void selftest_put32(UCHAR* dst, uint32_t value)
361{
362 selftest_put16(dst, (uint16_t)(value & (uint32_t)k_word_mask));
363 selftest_put16(dst + 2U, (uint16_t)(value >> (uint32_t)k_word_shift));
364}
365
382static void selftest_fat_fill_boot(UCHAR* out)
383{
384 out[k_bpb_off_jmp] = (UCHAR)k_boot_jmp0;
385 out[k_bpb_off_jmp + 1U] = (UCHAR)k_boot_jmp1;
386 out[k_bpb_off_jmp + 2U] = (UCHAR)k_boot_jmp2;
387 (void)memcpy(&out[k_bpb_off_oem], s_fat_oem_name, sizeof(s_fat_oem_name));
389 out[k_bpb_off_spc] = 1U;
391 out[k_bpb_off_nfats] = (UCHAR)k_fat_num_fats;
394 out[k_bpb_off_media] = (UCHAR)k_boot_media;
399 out[k_bpb_off_bootsig] = (UCHAR)k_boot_ext_sig;
402 (void)memcpy(&out[k_bpb_off_fstype], s_fat_fs_type, sizeof(s_fat_fs_type));
403 out[k_boot_sig_lo_off] = (UCHAR)k_boot_sig_lo;
404 out[k_boot_sig_hi_off] = (UCHAR)k_boot_sig_hi;
405}
406
426static void selftest_fat_fill_fat(uint32_t fat_sector, UCHAR* out)
427{
428 const uint32_t first_entry = fat_sector * (uint32_t)k_fat_entries_per_sec;
429 for (uint32_t j = 0U; j < (uint32_t)k_fat_entries_per_sec; j++) {
430 const uint32_t entry = first_entry + j;
431 uint16_t value = 0U;
432 if (entry == 0U) {
433 value = (uint16_t)k_fat_entry0;
434 } else if (entry == 1U) {
435 value = (uint16_t)k_fat_eoc;
436 } else if (entry < (uint32_t)k_fat_last_mram_clus) {
437 value = (uint16_t)(entry + 1U);
438 } else if (entry == (uint32_t)k_fat_last_mram_clus) {
439 value = (uint16_t)k_fat_eoc;
440 } else {
441 value = 0U;
442 }
443 selftest_put16(&out[j * 2U], value);
444 }
445}
446
465static void selftest_fat_fill_root(uint32_t root_sector, UCHAR* out)
466{
467 if (root_sector != 0U) {
468 return;
469 }
470 /* Entry 0: volume label. */
471 (void)memcpy(&out[0], s_fat_volume_label, (size_t)k_dir_name_bytes);
472 out[k_dir_off_attr] = (UCHAR)k_dir_attr_volume;
473 /* Entry 1: MRAM.BIN, read-only, cluster 2, 1 MiB. */
474 UCHAR* entry = &out[k_dir_entry_bytes];
475 (void)memcpy(entry, s_fat_file_name, (size_t)k_dir_name_bytes);
476 entry[k_dir_off_attr] = (UCHAR)k_dir_attr_read_only;
478 selftest_put32(&entry[k_dir_off_size], (uint32_t)k_mram_bytes);
479}
480
500static void selftest_fat_fill_sector(uint32_t lba, UCHAR* out)
501{
502 (void)memset(out, 0, (size_t)k_selftest_block_size);
503 if (lba == 0U) {
505 return;
506 }
507 if (lba < (uint32_t)k_fat_root_lba) {
508 selftest_fat_fill_fat(lba - (uint32_t)k_fat_fat_lba, out);
509 return;
510 }
511 if (lba < (uint32_t)k_fat_data_lba) {
512 selftest_fat_fill_root(lba - (uint32_t)k_fat_root_lba, out);
513 return;
514 }
515 const uint32_t cluster = (lba - (uint32_t)k_fat_data_lba) + (uint32_t)k_fat_first_cluster;
516 if (cluster <= (uint32_t)k_fat_last_mram_clus) {
517 const uint32_t offset =
518 (cluster - (uint32_t)k_fat_first_cluster) * (uint32_t)k_selftest_block_size;
519 const UCHAR* mram = (const UCHAR*)(uintptr_t)((uint32_t)k_mram_base_addr + offset);
520 (void)memcpy(out, mram, (size_t)k_selftest_block_size);
521 }
522}
523
524/* -------------------------------------------------------------------------- */
525/* Storage class media callbacks (read / write / status) */
526/* -------------------------------------------------------------------------- */
527
558 ULONG lun,
559 UCHAR* data_pointer,
560 ULONG number_blocks,
561 ULONG lba,
562 ULONG* media_status)
563{
564 (void)storage;
565 (void)lun;
567 if ((lba + number_blocks) > (ULONG)k_fat_total_sectors) {
568 *media_status = UX_DEVICE_CLASS_STORAGE_SENSE_STATUS(k_scsi_sense_illegal_request,
571 return UX_ERROR;
572 }
573 for (ULONG i = 0UL; i < number_blocks; i++) {
574 selftest_fat_fill_sector((uint32_t)(lba + i), &data_pointer[i * (ULONG)k_selftest_block_size]);
575 }
576 *media_status = 0UL;
578 return UX_SUCCESS;
579}
580
607 ULONG lun,
608 UCHAR* data_pointer,
609 ULONG number_blocks,
610 ULONG lba,
611 ULONG* media_status)
612{
613 (void)storage;
614 (void)lun;
615 (void)data_pointer;
616 (void)number_blocks;
617 (void)lba;
618 *media_status = UX_DEVICE_CLASS_STORAGE_SENSE_STATUS(k_scsi_sense_data_protect,
621 return UX_ERROR;
622}
623
645UINT selftest_msc_status(VOID* storage, ULONG lun, ULONG media_id, ULONG* media_status)
646{
647 (void)storage;
648 (void)lun;
649 (void)media_id;
650 *media_status = 0UL;
651 return UX_SUCCESS;
652}
653
654/* -------------------------------------------------------------------------- */
655/* Threads */
656/* -------------------------------------------------------------------------- */
657
676{
677 if (_ux_system_initialize(s_usbx_pool, k_selftest_usbx_pool_bytes, UX_NULL, 0) != UX_SUCCESS) {
678 return UX_ERROR;
679 }
680 return _ux_device_stack_initialize(s_device_framework_hs,
681 sizeof(s_device_framework_hs),
683 sizeof(s_device_framework_fs),
685 sizeof(s_string_framework),
688 UX_NULL);
689}
690
709{
710 UX_SLAVE_CLASS_STORAGE_PARAMETER msc_params;
711 (void)memset(&msc_params, 0, sizeof(msc_params));
712 msc_params.ux_slave_class_storage_parameter_number_lun = 1UL;
713 msc_params.ux_slave_class_storage_parameter_vendor_id = s_msc_vendor_id;
714 msc_params.ux_slave_class_storage_parameter_product_id = s_msc_product_id;
715 msc_params.ux_slave_class_storage_parameter_product_rev = s_msc_product_rev;
716
717 msc_params.ux_slave_class_storage_parameter_lun[0].ux_slave_class_storage_media_last_lba =
719 msc_params.ux_slave_class_storage_parameter_lun[0].ux_slave_class_storage_media_block_length =
721 msc_params.ux_slave_class_storage_parameter_lun[0].ux_slave_class_storage_media_type =
722 UX_SLAVE_CLASS_STORAGE_MEDIA_FAT_DISK;
723 msc_params.ux_slave_class_storage_parameter_lun[0].ux_slave_class_storage_media_removable_flag =
724 UX_SLAVE_CLASS_STORAGE_MEDIA_IS_REMOVABLE;
725 msc_params.ux_slave_class_storage_parameter_lun[0].ux_slave_class_storage_media_read_only_flag =
726 UX_TRUE;
727 msc_params.ux_slave_class_storage_parameter_lun[0].ux_slave_class_storage_media_read =
729 msc_params.ux_slave_class_storage_parameter_lun[0].ux_slave_class_storage_media_write =
731 msc_params.ux_slave_class_storage_parameter_lun[0].ux_slave_class_storage_media_status =
733
734 static UCHAR s_class_name[] = "ux_slave_class_storage";
735
736 return _ux_device_stack_class_register(s_class_name,
737 _ux_device_class_storage_entry,
738 1,
739 0,
740 &msc_params);
741}
742
762{
763 (void)arg;
764
765 if (selftest_usbx_stack_up() != UX_SUCCESS) {
766 return;
767 }
768 if (selftest_msc_class_register() != UX_SUCCESS) {
769 return;
770 }
772 return;
773 }
775 return;
776 }
777
778 /* Sample device-side USBX state into J-Link probes so the HS device's
779 * FS-fallback bring-up is observable, and kick the storage class
780 * thread if it parks SUSPENDED while the device is CONFIGURED. */
781 s_dbg_fw_fs_addr = (uint32_t)(uintptr_t)s_device_framework_fs;
782 s_dbg_fw_hs_addr = (uint32_t)(uintptr_t)s_device_framework_hs;
783 while (1) {
784 s_dbg_dev_state = (uint32_t)_ux_system_slave->ux_system_slave_device.ux_slave_device_state;
785 s_dbg_ux_speed = (uint32_t)_ux_system_slave->ux_system_slave_speed;
786 s_dbg_framework = (uint32_t)(uintptr_t)_ux_system_slave->ux_system_slave_device_framework;
787 s_dbg_fw_len = (uint32_t)_ux_system_slave->ux_system_slave_device_framework_length;
788 s_dbg_thr_state = (uint32_t)_ux_system_slave->ux_system_slave_class_array[0]
789 .ux_slave_class_thread.tx_thread_state;
790 s_dbg_thr_runs = (uint32_t)_ux_system_slave->ux_system_slave_class_array[0]
791 .ux_slave_class_thread.tx_thread_run_count;
792 if (s_dbg_dev_state == (uint32_t)UX_DEVICE_CONFIGURED) {
794 if (s_dbg_thr_state == (uint32_t)TX_SUSPENDED) {
795 (void)tx_thread_resume(
796 &_ux_system_slave->ux_system_slave_class_array[0].ux_slave_class_thread);
797 }
798 }
799 tx_thread_sleep(1U);
800 }
801}
802
803#endif /* !RA8_OFF_TARGET */
static UCHAR s_msc_product_id[]
Definition main.c:197
static UCHAR s_string_framework[]
USBX string descriptor table (vendor / product / serial).
Definition main.c:299
@ 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
static UCHAR s_usbx_pool[k_wlun_usbx_pool_bytes]
USBX memory pool (USBX uses tx_byte_pool internally).
Definition main.c:193
@ k_usb_langid_en_us_lo
LANGID 0x0409 low byte.
Definition main.c:359
@ k_usb_langid_en_us_hi
LANGID 0x0409 high byte.
Definition main.c:360
static UCHAR s_device_framework_fs[]
Definition main.c:234
static UCHAR s_msc_product_rev[]
Definition main.c:198
static UCHAR s_language_id_framework[]
USBX language-id table – US English.
Definition main.c:368
static volatile uint32_t s_dbg_read_calls
Device-side media_read invocations.
Definition main.c:213
static UCHAR s_msc_vendor_id[]
Definition main.c:196
Board-support layer for the Renesas EK-RA8D2 v1 evaluation kit.
ra8_err_t ra8_board_led_toggle(ra8_board_led_id_t led)
Toggle led's output state.
@ k_ra8_board_led1
LED1, BLUE, P600 (jumper E27).
Error Code Definitions for ra8-firmware.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
Definition ra8_err.h:119
void * memset(void *dst, int value, size_t n)
Fill memory with a constant byte value.
void * memcpy(void *dst, const void *src, size_t n)
Copy memory area between non-overlapping regions.
@ k_dir_off_attr
MS FAT spec sec 6 "DIR_Attr".
@ k_byte_mask
Byte mask.
@ k_word_mask
Word mask.
Native USB controller driver public API (device + host modes).
ra8_err_t ra8_usb_device_attach(ra8_usb_speed_t speed, bool attached)
Raise / drop the D+ pull-up to advertise the device to the host.
@ k_ra8_usb_speed_hs
High-Speed controller (USBHS @ 0x40351000).
unsigned int UINT
ThreadX-compatible unsigned int (host stub).
#define tx_thread_sleep
unsigned long ULONG
ThreadX-compatible unsigned long (host stub).
static const UCHAR s_fat_oem_name[8]
Boot-sector OEM name (8 bytes, space padded).
static const UCHAR s_fat_fs_type[8]
Filesystem-type tag, 8 bytes space padded.
static const UCHAR s_fat_volume_label[11]
Volume label, 11 bytes space padded (also the root entry).
@ 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.
static const UCHAR s_fat_file_name[11]
8.3 directory name of the exposed file: "MRAM.BIN".
@ k_word_shift
Bits per half-word.
UINT selftest_msc_status(VOID *storage, ULONG lun, ULONG media_id, ULONG *media_status)
Storage media-status callback.
@ k_fat_root_entries
Root directory entries.
@ k_fat_eoc
End-of-chain marker.
@ k_fat_data_lba
First data sector (cluster 2).
@ 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_last_mram_clus
Last cluster of MRAM.BIN.
@ k_fat_num_fats
Single FAT copy.
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.
@ 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.
@ k_mram_bytes
1 MiB window size.
@ k_mram_base_addr
MRAM code window base address.
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).
@ k_selftest_block_size
SCSI logical block size (bytes).
@ k_selftest_usbx_pool_bytes
USBX memory pool (bytes).
static volatile uint32_t s_dbg_thr_state
Storage class thread ThreadX state (see tx_api TX_* states).
static volatile uint32_t s_dbg_thr_runs
Storage class thread ThreadX run-count (0 = never scheduled).
UINT selftest_msc_status(VOID *storage, ULONG lun, ULONG media_id, ULONG *media_status)
Storage media-status callback.
static void selftest_put16(UCHAR *dst, uint16_t value)
Write a 16-bit value little-endian into a byte buffer.
static volatile uint32_t s_dbg_fw_hs_addr
Address of the HS framework array (compare vs s_dbg_framework).
VOID selftest_device_worker(ULONG arg)
Device-side worker: bring the HS device stack up, then park.
static void selftest_fat_fill_root(uint32_t root_sector, UCHAR *out)
Synthesize one root-directory sector.
static volatile uint32_t s_dbg_fw_fs_addr
Address of the FS framework array (compare vs s_dbg_framework).
static UCHAR s_device_framework_hs[]
static volatile uint32_t s_dbg_state3_seen
Times the device sampler observed UX_DEVICE_CONFIGURED.
static volatile uint32_t s_dbg_ux_speed
Device-side USBX negotiated speed (0 = HS, 1 = FS in UX terms).
static void selftest_fat_fill_sector(uint32_t lba, UCHAR *out)
Synthesize one 512-byte sector of the read-only volume.
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.
static volatile uint32_t s_dbg_dev_state
Device-side ux_slave_device_state sample (3 = CONFIGURED).
static void selftest_fat_fill_boot(UCHAR *out)
Synthesize the FAT16 boot sector (MS FAT spec 1.03 sec 3.1).
static volatile uint32_t s_dbg_fw_len
Current device framework length (32 = FS cfg, 42 = HS cfg).
static UINT selftest_usbx_stack_up(void)
Brings USBX system + FS device stack up.
static void selftest_fat_fill_fat(uint32_t fat_sector, UCHAR *out)
Synthesize one FAT16 sector of the cluster chain.
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).
static void selftest_put32(UCHAR *dst, uint32_t value)
Write a 32-bit value little-endian into a byte buffer.
static volatile uint32_t s_dbg_framework
Current device framework pointer (HS vs FS array address).
static UINT selftest_msc_class_register(void)
Registers the Mass-Storage class with the read-only MRAM LUN.
examples/ek_ra8d2/hw_validated/hil/usb_selftest_fs_host/inc/usb_selftest_fs_host_steps....
USBX device-controller-driver (DCD) bridge to ra8_usb.
ra8_err_t ux_dcd_ra8_usb_initialize(ra8_usb_speed_t speed)
Register the ra8_usb bridge as the active USBX DCD.