Jump to content

sunxi_usb_udc


Recommended Posts

I am trying to create my own USB gadget based on sunxi_usb_udc and GadgetFS with Orange Pi PC. I can't find any details about sunxi_usb_udc and after successful startup and detection, I am unable to get data sent by host side. How can I proceed?

Link to comment
Share on other sites

It looks like the link contains only release files (image and readme) and can't be a source for studying. Am I wrong? Could you advise me any other open-source USB gadget project to study from?

Link to comment
Share on other sites

Most basic useage, I simply connected an USB disk to OPi PC:

  • ensure that no other gadget modules are already loaded (remove from /etc/modules and reboot)
  • modprobe g_mass_storage file=/dev/sda
  • echo 2 > /sys/bus/platform/devices/sunxi_usb_udc/otg_role
Now disk appears on the Mac, I partitioned it, now it looks like this from OS X:
bash-3.2# diskutil list disk2
/dev/disk2
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *1.0 TB     disk2
   1:                        EFI EFI                     209.7 MB   disk2s1
   2:                  Apple_HFS USB Gadget              999.9 GB   disk2s2

And from the Linux side:

root@orangepipcplus:~# partprobe /dev/sda
root@orangepipcplus:~# cat /proc/partitions 
major minor  #blocks  name

 179        0    7634944 mmcblk0
 179        1    7633920 mmcblk0p1
 179       32       4096 mmcblk0boot1
 179       16       4096 mmcblk0boot0
   8        0  976762584 sda
   8        1     204800 sda1
   8        2  976426672 sda2

Quick test using LanTest locally:

Bildschirmfoto%202016-06-21%20um%2014.31

 

Now a 'diskutil eject disk2' on the Mac and on the Linux side:

echo 0 > /sys/bus/platform/devices/sunxi_usb_udc/otg_role
rmmod g_mass_storage

I then attached the same USB disk directly to the Mac, it again appears as disk2 and everything that was present through the gadget mode is identical when connecting locally (partition table, UUIDs and so on):

 

 

bash-3.2# diskutil info disk2s2
   Device Identifier:        disk2s2
   Device Node:              /dev/disk2s2
   Part of Whole:            disk2
   Device / Media Name:      USB Gadget

   Volume Name:              USB Gadget

   Mounted:                  Yes
   Mount Point:              /Volumes/USB Gadget

   File System Personality:  Journaled HFS+
   Type (Bundle):            hfs
   Name (User Visible):      Mac OS Extended (Journaled)
   Journal:                  Journal size 81920 KB at offset 0x1d1c000
   Owners:                   Disabled

   Partition Type:           Apple_HFS
   OS Can Be Installed:      Yes
   Media Type:               Generic
   Protocol:                 USB
   SMART Status:             Verified
   Volume UUID:              CEF73CE8-FEEB-3B87-8534-AC17D16E0044
   Disk / Partition UUID:    A9B8EE8D-1F99-4092-A0D3-2959F809487E

   Total Size:               999.9 GB (999860912128 Bytes) (exactly 1952853344 512-Byte-Units)
   Volume Free Space:        999.2 GB (999197192192 Bytes) (exactly 1951557016 512-Byte-Units)
   Device Block Size:        512 Bytes
   Allocation Block Size:    4096 Bytes

   Read-Only Media:          No
   Read-Only Volume:         No
   Ejectable:                Yes

   Whole:                    No
   Internal:                 No 

 

 

 

 

Of course performance is better when connected locally:

Bildschirmfoto%202016-06-21%20um%2014.36

But all in all this is quite useful when making use of more advanced stuff (sharing an ISO image as CD-ROM for example to boot a PC from and stuff like that)

Link to comment
Share on other sites

Thank you for this explanation! I believe this will help for others looking for mass storage gadget solution. But I am working about custom USB gadget. I had some progress in looking for working examples.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines