USB === The Universal Serial Bus (USB) can be utilized for many functions on the development kit, including external media. The phyCORE-AM62Ax development kit provides two USB 2.0 Dual-Role Devices (DRD) subsystems via the three USB connectors (X43, X36, and X34). This guide will show you how to use the USB Host capabilities featured on the phyCORE-AM62Ax development kit. To learn more information about the phyCORE-AM62Ax USB interface, please see section 7.6 in the `Hardware Manual `_. The USB0 interface is brought out as a type-C connector (X34). The USB1 interface uses a USB HUB to split the bus to 3x locations. .. list-table:: USB Locations :header-rows: 1 * - Type - Qty - Header Location - Speed - Bus * - USB A Double Stacked - 2 - X43 - 2.10 - 001 * - Mini PCIe - 1 - X36 - 2.10 - 001 * - USB C - 1 - X34 - 2.10 - 003 .. image:: ../../images/phycore-am62ax/pb-07524_usb-frontside.png :width: 600px :alt: phyCORE-AM62Ax USB .. image:: ../../images/phycore-am62x/pb-07124_usb-backside.png :width: 600px :alt: phyCORE-AM62Ax USB backside Requirements ------------ * `USB Storage Device `_ Verifying USB Interface ------------------------ * With the development kit booted into Linux, verify that there are 2 USB devices. .. code-block:: none :caption: Target (Linux) lsusb .. code-block:: none :caption: Expected Output root@phyboard-lyra-am62axx-2:~# lsusb Bus 001 Device 002: ID 0424:2514 Bus 001 Device 001: ID 1d6b:0002 Linux 6.1.33-bsp-yocto-ampliphy-am62ax-pd23.1.0 xhci-hcd xHCI Host Controller * Insert a USB device into either x43 (Double stack USB-A port) or x34 (USB-C). This guide demonstrates the USB-A bottom port. .. code-block:: none :caption: Expected Output root@phyboard-lyra-am62axx-2:~# [ 1103.995685] usb 1-1.2: new high-speed USB device number 3 using xhci-hcd [ 1104.101203] usb 1-1.2: New USB device found, idVendor=0781, idProduct=5591, bcdDevice= 1.00 [ 1104.109724] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3 [ 1104.117146] usb 1-1.2: Product: SanDisk 3.2Gen1 [ 1104.121870] usb 1-1.2: Manufacturer: USB [ 1104.125981] usb 1-1.2: SerialNumber: 0401b360e7f994fa1045253b46381e7f4adf9e70e08383c7595d67e9a36da3592f6c0000000000000000000000c41f01009e5d18915581076e2cc63b [ 1104.197541] usb-storage 1-1.2:1.0: USB Mass Storage device detected [ 1104.204385] scsi host0: usb-storage 1-1.2:1.0 [ 1104.209411] usbcore: registered new interface driver usb-storage [ 1105.232338] scsi 0:0:0:0: Direct-Access USB SanDisk 3.2Gen1 1.00 PQ: 0 ANSI: 6 [ 1105.242820] sd 0:0:0:0: [sda] 30031872 512-byte logical blocks: (15.4 GB/14.3 GiB) [ 1105.251756] sd 0:0:0:0: [sda] Write Protect is off [ 1105.257122] sd 0:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA [ 1105.274728] sd 0:0:0:0: [sda] Attached SCSI removable disk * Verify that the USB was properly recongnized by development kit. .. code-block:: none :caption: Target (Linux) lsusb .. code-block:: none :caption: Expected Output root@phyboard-lyra-am62axx-2:~# lsusb Bus 001 Device 003: ID 0781:5591 USB SanDisk 3.2Gen1 Bus 001 Device 002: ID 0424:2514 Bus 001 Device 001: ID 1d6b:0002 Linux 6.1.33-bsp-yocto-ampliphy-am62ax-pd23.1.0 xhci-hcd xHCI Host Controller * To list more information about the USB device and buses on the development kit use the following command. This command will output a good chunk of information. This guide will only show a snippet of the expected output for the USB drive that was just connected. .. code-block:: none :caption: Target (Linux) lsusb -v -s 001:003 .. note:: "001" refers to bus 001 and "003" refers to the device number, both of these can be found in the *lsusb* command. .. code-block:: none :caption: Expected Output for Example USB Drive Bus 001 Device 003: ID 0781:5591 USB SanDisk 3.2Gen1 Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 2.10 bDeviceClass 0 bDeviceSubClass 0 bDeviceProtocol 0 bMaxPacketSize0 64 idVendor 0x0781 idProduct 0x5591 bcdDevice 1.00 iManufacturer 1 USB iProduct 2 SanDisk 3.2Gen1 iSerial 3 0401b360e7f994fa1045253b46381e7f4adf9e70e08383c7595d67e9a36da3592f6c0000000000000000000000c41f01009e5d18915581076e2cc63b bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 0x0020 bNumInterfaces 1 bConfigurationValue 1 iConfiguration 0 bmAttributes 0x80 (Bus Powered) .. continues .. * The speed of the USB device can be determined with either the *lsusb -v* from above or by reading the device's "speed" .. code-block:: none :caption: Target (Linux) root@phyboard-lyra-am62axx-2:~# cat /sys/bus/usb/devices/1-1.2/speed 480 .. note:: USB2.0 has transmission speeds up to 480Mbit/s, also known as "full speed". Mounting USB Stroage Devices ----------------------------- * Verify that a device directory was established for the USB drive. #. Run the following command to confirm the USB device name. .. code-block:: none :caption: Target (Linux) ls /dev/sd* .. code-block:: none :caption: Expected Output root@phyboard-lyra-am62axx-2:~# ls /dev/sd* /dev/sda #. Remove the USB drive and re-insert it. #. The output log that appears when connecting the USB device will indicate the devices name. .. code-block:: none :caption: Expected Output root@phyboard-lyra-am62axx-2:~# [ 1103.995685] usb 1-1.2: new high-speed USB device number 3 using xhci-hcd [ 1104.101203] usb 1-1.2: New USB device found, idVendor=0781, idProduct=5591, bcdDevice= 1.00 [ 1104.109724] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3 [ 1104.117146] usb 1-1.2: Product: SanDisk 3.2Gen1 [ 1104.121870] usb 1-1.2: Manufacturer: USB [ 1104.125981] usb 1-1.2: SerialNumber: 0401b360e7f994fa1045253b46381e7f4adf9e70e08383c7595d67e9a36da3592f6c0000000000000000000000c41f01009e5d18915581076e2cc63b [ 1104.197541] usb-storage 1-1.2:1.0: USB Mass Storage device detected [ 1104.204385] scsi host0: usb-storage 1-1.2:1.0 [ 1104.209411] usbcore: registered new interface driver usb-storage [ 1105.232338] scsi 0:0:0:0: Direct-Access USB SanDisk 3.2Gen1 1.00 PQ: 0 ANSI: 6 [ 1105.242820] sd 0:0:0:0: [sda] 30031872 512-byte logical blocks: (15.4 GB/14.3 GiB) [ 1105.251756] sd 0:0:0:0: [sda] Write Protect is off [ 1105.257122] sd 0:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA [ 1105.274728] sd 0:0:0:0: [sda] Attached SCSI removable disk .. note:: In this example the device name for the USB drive is "sda". * Make a directory for mounting the USB device. .. code-block:: none :caption: Target (Linux) mkdir ~/usb_sda * Format file type. .. code-block:: none :caption: Target (Linux) mkfs.vfat /dev/sda * Mount the USB device to the directory. .. code-block:: none :caption: Target (Linux) mount /dev/sda ~/usb_sda/ * See what media is on the USB drive. .. code-block:: none :caption: Target (Linux) ls ~/usb_sda/ Write to the USB Host Device ------------------------------ * Generate a random 10 MB file to test transferring data from the storage device. .. code-block:: none :caption: Target (Linux) dd if=/dev/urandom of=test.file count=10 bs=1M .. code-block:: none :caption: Expected Output root@phyboard-lyra-am62axx-2:~# dd if=/dev/urandom of=test.file count=10 bs=1M 10+0 records in 10+0 records out 10485760 bytes (10 MB, 10 MiB) copied, 0.156214 s, 67.1 MB/s * Copy the file to your storage device. .. code-block:: none :caption: Target (Linux) cp test.file ~/usb_sda/ && sync Read from the USB Host Device ------------------------------ * Copy the test file we previously created during the write process back to the host: .. code-block:: none :caption: Target (Linux) cp ~/usb_sda/test.file readback-usb.file && sync * We can double check that the file was successfully copied to and from the USB device by checking the md5sum of the file: .. code-block:: none :caption: Target (Linux) md5sum test.file readback-usb.file .. code-block:: none :caption: Expected Output root@phyboard-lyra-am62axx-2:~# md5sum test.file readback-usb.file c6d65bf33f37847bad9f79ce241e59ed test.file c6d65bf33f37847bad9f79ce241e59ed readback-usb.file Unmounting the Drive --------------------- .. warning:: **Make sure the drive is unmounted prior to physically disconnecting the device.** Failure to do so may result in loss of data and corruption of files .. code-block:: none :caption: Target (Linux) umount ~/usb_sda/ umount /dev/sda