Open main menu

DAVE Developer's Wiki β

Difference between revisions of "DESK-XZ7-L/Peripherals/USB OTG"

< DESK-XZ7-L
(Created page with "<section begin="History" /> {| style="border-collapse:collapse; " ! colspan="4" style="width:100%; text-align:left" ; border-bottom:solid 2px #ededed" |History |- |style="bord...")
 
 
(3 intermediate revisions by one other user not shown)
Line 1: Line 1:
<section begin="History" />
+
<section begin=History/>
 
{| style="border-collapse:collapse; "
 
{| style="border-collapse:collapse; "
! colspan="4" style="width:100%; text-align:left" ; border-bottom:solid 2px #ededed" |History
+
!colspan="4" style="width:100%; text-align:left"; border-bottom:solid 2px #ededed"|History
 +
|-
 +
!style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#73B2C7; padding:5px; color:white"|Issue Date
 +
!style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#73B2C7; padding:5px; color:white"|Notes
 
|-
 
|-
|style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#ededed; padding:5px; color:#000000"|2023/01/23
+
|style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#edf8fb; padding:5px; color:#000000"|2024/01/23
|style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#ededed; padding:5px; color:#000000"|DESK-XZ7-L-1.0.1 release
+
|style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#edf8fb; padding:5px; color:#000000"|DESK-XZ7-L-1.0.1 release
 
|-
 
|-
 
|}
 
|}
<section end="History" />
+
<section end=History/>
<section begin="Body" />
+
__FORCETOC__
 +
<section begin=Body/>
  
 
==Peripheral USB OTG ==
 
==Peripheral USB OTG ==
Line 14: Line 18:
 
=== Device tree configuration ===
 
=== Device tree configuration ===
  
This configuration work for Bora, Boralite and BoraX platforms.
+
Here below an example of device tree configuration used on standard DAVE's kit for the [[BORA SOM | BORA]], [[BORA Xpress SOM| BORA Xpress]] and [[BORA Lite SOM | BORA Lite]]:
 
 
Here below an example of device tree configuration used on standard DAVE's kit for the Bora, Boralite and BoraX platforms:
 
  
 
From <code>bora.dtsi</code>:
 
From <code>bora.dtsi</code>:
  
 
<pre>
 
<pre>
 +
...
 +
...
 +
 +
/ {
 +
 
...
 
...
 
...
 
...
Line 30: Line 37:
 
         drv-vbus;
 
         drv-vbus;
 
     };
 
     };
 +
 +
...
 +
...
 +
 +
};
 +
 
...
 
...
 
...
 
...
 +
 
&usb0 {
 
&usb0 {
 
     dr_mode = "otg";
 
     dr_mode = "otg";
Line 98: Line 112:
  
 
<pre class="workstation-terminal">
 
<pre class="workstation-terminal">
root@desk-mx8mm:~# dd if=/dev/zero of=mass_storage count=256 bs=1M
+
root@bora:~# dd if=/dev/zero of=/tmp/mass count=16 bs=1M
2root@bora:~# dd if=/dev/zero of=/tmp/mass count=16 bs=1M
 
 
16+0 records in
 
16+0 records in
 
16+0 records out
 
16+0 records out
Line 133: Line 146:
  
 
<pre class="workstation-terminal">
 
<pre class="workstation-terminal">
[ 726.762914] g_mass_storage gadget: Mass Storage Gadget, version: 2009/09/11
+
[   34.208769] Mass Storage Function, version: 2009/09/11
[ 726.762928] g_mass_storage gadget: g_mass_storage ready
+
[  34.208790] LUN: removable file: (no medium)
 +
[  34.208929] LUN: file: /var/volatile/tmp/mass
 +
[  34.208940] Number of LUNs=1
 +
[  34.209181] g_mass_storage gadget: Mass Storage Gadget, version: 2009/09/11
 +
[   34.209194] g_mass_storage gadget: g_mass_storage ready
 
</pre>
 
</pre>
  
 
and the Windows PC activate the driver and the disk is available as a Drive Unit (with the ''usb.txt'' file available).
 
and the Windows PC activate the driver and the disk is available as a Drive Unit (with the ''usb.txt'' file available).
  
----
+
<section end=Body/>
  
[[Category:BORA]]
+
[[Category:BORA]] [[Category:BORA Xpress]] [[Category:BORA Lite]]

Latest revision as of 15:18, 25 January 2024

History
Issue Date Notes
2024/01/23 DESK-XZ7-L-1.0.1 release



Contents

Peripheral USB OTGEdit

Device tree configurationEdit

Here below an example of device tree configuration used on standard DAVE's kit for the BORA, BORA Xpress and BORA Lite:

From bora.dtsi:

...
...

/ {

...
...
    usb_phy0: phy0@e0002000{
        compatible = "ulpi-phy";
        #phy-cells = <0x00>;
        reg = <0xe0002000 0x1000>;
        view-port = <0x170>;
        drv-vbus;
    };

...
...

};

...
...

&usb0 {
    dr_mode = "otg";
    usb-phy = <&usb_phy0>;

};

...
...

Accessing the peripheralEdit

Linux messages in host modeEdit

When a USB2.0 peripheral is inserted, in the following example a memory mass storage device, the kernel recognizes the device (i.e. class, vendor id, product id, etc.)

[  456.139975] ci_hdrc ci_hdrc.0: EHCI Host Controller
[  456.140014] ci_hdrc ci_hdrc.0: new USB bus registered, assigned bus number 1
[  456.165598] ci_hdrc ci_hdrc.0: USB 2.0 started, EHCI 1.00
[  456.165904] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 5.10
[  456.165921] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[  456.165932] usb usb1: Product: EHCI Host Controller
[  456.165941] usb usb1: Manufacturer: Linux 5.10.0-xilinx-v2021.2 ehci_hcd
[  456.165951] usb usb1: SerialNumber: ci_hdrc.0
[  456.166730] hub 1-0:1.0: USB hub found
[  456.166800] hub 1-0:1.0: 1 port detected
[  457.115612] usb 1-1: new high-speed USB device number 2 using ci_hdrc
[  457.316438] usb 1-1: New USB device found, idVendor=0781, idProduct=557d, bcdDevice= 1.00
[  457.316454] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[  457.316465] usb 1-1: Product: Cruzer Force
[  457.316474] usb 1-1: Manufacturer: SanDisk
[  457.316483] usb 1-1: SerialNumber: 03021401121621082422
[  457.317184] usb-storage 1-1:1.0: USB Mass Storage device detected
[  457.318430] scsi host0: usb-storage 1-1:1.0
[  458.336628] scsi 0:0:0:0: Direct-Access     SanDisk  Cruzer Force     1.00 PQ: 0 ANSI: 6
[  458.338116] sd 0:0:0:0: Attached scsi generic sg0 type 0
[  458.338359] sd 0:0:0:0: [sda] 60088320 512-byte logical blocks: (30.8 GB/28.7 GiB)
[  458.339341] sd 0:0:0:0: [sda] Write Protect is off
[  458.339358] sd 0:0:0:0: [sda] Mode Sense: 43 00 00 00
[  458.340543] sd 0:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[  458.401467]  sda: sda1
[  458.409036] sd 0:0:0:0: [sda] Attached SCSI removable disk
[  458.416048] usb 1-1: Get one byte OTG status failed

Additional informationEdit

If the root file system configuration does not automatically mount the partition, it is possible to mount the device using the following command:

root@bora:~# mkdir -p /mnt/usb
root@bora:~# mount /dev/sda1 /mnt/usb
root@bora:~# ls -la /mnt/usb/
total 116
drwxr-xr-x 4 root root 65536 Jan  1  1970 .
drwxr-xr-x 3 root root  4096 Mar 12 16:05 ..
drwxr-xr-x 2 root root 16384 Feb  3  2023 System Volume Information
drwxr-xr-x 3 root root 16384 Aug  1  2023 phytool
-rwxr-xr-x 1 root root    13 Oct  6  2022 uboot_testfile.txt

Accessing the deviceEdit

Usage with mass-storageEdit

root@bora:~# dd if=/dev/zero of=/tmp/mass count=16 bs=1M
16+0 records in
16+0 records out
16777216 bytes (17 MB, 16 MiB) copied, 0.0903981 s, 186 MB/s
root@bora:~# mkfs.ext4 /tmp/mass
mke2fs 1.45.6 (20-Mar-2020)
Discarding device blocks: done
Creating filesystem with 16384 1k blocks and 4096 inodes
Filesystem UUID: 3f0fa651-33af-4001-b6c0-8774cf2d2f56
Superblock backups stored on blocks:
        8193

Allocating group tables: done
Writing inode tables: done
Creating journal (1024 blocks): done
Writing superblocks and filesystem accounting information: done

root@bora:~# mkdir -p /tmp/loop
root@bora:~# mount /tmp/mass /tmp/loop
Mar 12 16:08:24 bora kernel: [  659.854210] ext4 filesystem being mounted at /var/volatile/tmp/loop supports timestamps until 2038 (0x7fffffff)
root@bora:~# echo "Hello from desk-xz7-l" > /tmp/loop/usb.txt
root@bora:~# umount /tmp/loop
root@bora:~#

then insert the g_mass_storage kernel module driver enabling an Windows PC to see it as a removable device

root@bora:~# modprobe --first-time g_mass_storage file=/tmp/mass iSerialNumber=USBOTGCHECK

Once the USB cable is connected to the PC, the kernel prints the following messages:

[   34.208769] Mass Storage Function, version: 2009/09/11
[   34.208790] LUN: removable file: (no medium)
[   34.208929] LUN: file: /var/volatile/tmp/mass
[   34.208940] Number of LUNs=1
[   34.209181] g_mass_storage gadget: Mass Storage Gadget, version: 2009/09/11
[   34.209194] g_mass_storage gadget: g_mass_storage ready

and the Windows PC activate the driver and the disk is available as a Drive Unit (with the usb.txt file available).