Skip to content

Commit

Permalink
Enable USB gadgets with sun8i/legacy, small nand-sata-install fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasKaiser committed Jun 17, 2016
1 parent 2a79527 commit 24ea1d3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
16 changes: 9 additions & 7 deletions config/kernel/linux-sun8i-default.config
Original file line number Diff line number Diff line change
Expand Up @@ -3168,23 +3168,25 @@ CONFIG_USB_SUNXI_UDC0=y
CONFIG_USB_GADGET_DUALSPEED=y
# CONFIG_USB_ZERO is not set
# CONFIG_USB_AUDIO is not set
# CONFIG_USB_ETH is not set
CONFIG_USB_ETH=m
CONFIG_USB_ETH_RNDIS=y
CONFIG_USB_ETH_EEM=y
# CONFIG_USB_G_NCM is not set
# CONFIG_USB_GADGETFS is not set
# CONFIG_USB_FUNCTIONFS is not set
# CONFIG_USB_FILE_STORAGE is not set
# CONFIG_USB_MASS_STORAGE is not set
# CONFIG_USB_G_SERIAL is not set
CONFIG_USB_MASS_STORAGE=m
CONFIG_USB_G_SERIAL=m
# CONFIG_USB_MIDI_GADGET is not set
# CONFIG_USB_G_PRINTER is not set
CONFIG_USB_G_ANDROID=y
CONFIG_USB_G_PRINTER=m
# CONFIG_USB_CDC_COMPOSITE is not set
# CONFIG_USB_G_ACM_MS is not set
# CONFIG_USB_G_MULTI is not set
CONFIG_USB_G_MULTI=m
CONFIG_USB_G_MULTI_RNDIS=y
CONFIG_USB_G_MULTI_CDC=y
# CONFIG_USB_G_HID is not set
# CONFIG_USB_G_DBGP is not set
# CONFIG_USB_G_WEBCAM is not set
# CONFIG_USB_SUNXI_G_WEBCAM is not set

#
# OTG and related infrastructure
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ create_armbian() {
rsync -avrltD --delete --exclude-from=$EX_LIST / /mnt/rootfs | nl | awk '{ printf "%.0f\n", 100*$1/"'"$TODO"'" }' \
| dialog --backtitle "$backtitle" --title "$title" --gauge "\n\n Creating rootfs on $2 ($USAGE Mb). Please wait!" 10 80

# run rsync again to silently catch outstanding changes between / and /mnt/rootfs/
rsync -avrltD --delete --exclude-from=$EX_LIST / /mnt/rootfs >/dev/null 2>&1

# creating fstab - root partition
sed -e 's,'"$root_partition"','"$2"',g' -i /mnt/rootfs/etc/fstab

Expand Down

8 comments on commit 24ea1d3

@ThomasKaiser
Copy link
Contributor

@ThomasKaiser ThomasKaiser commented on 24ea1d3 Jun 17, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Printer and Mass Storage gadgets appear then like this on the connected host (OS X in my case) after switching otg_role to 2:

            Printer Gadget:

              Product ID: 0xa4a8
              Vendor ID: 0x0525  (PLX Technology, Inc.)
              Version: 2.33
              Serial Number: 1
              Speed: Up to 480 Mb/sec
              Manufacturer: Linux 3.4.112-sun8i with sunxi_usb_udc
              Location ID: 0x14112000 / 14
              Current Available (mA): 500
              Current Required (mA): 2
              1284 Device ID: MFG:linux;MDL:g_printer;CLS:PRINTER;SN:1;

            Mass Storage Gadget:

              Product ID: 0xa4a5
              Vendor ID: 0x0525  (PLX Technology, Inc.)
              Version: 0.00
              Speed: Up to 480 Mb/sec
              Manufacturer: Linux 3.4.112-sun8i with sunxi_usb_udc
              Location ID: 0x14112000 / 19
              Current Available (mA): 500
              Current Required (mA): 2

dmesg output on the OPi (without doing any of the necessary configuration, just switching /sys/bus/platform/devices/sunxi_usb_udc/otg_role between 0 and 2):

Ethernet gadget:

[  173.743389] g_ether gadget: using random self ethernet address
[  173.743471] g_ether gadget: using random host ethernet address
[  173.745329] usb0: MAC e2:7b:31:c5:00:5e
[  173.745367] usb0: HOST MAC f6:8a:4e:fe:c4:01
[  173.745545] ep_matches, wrn: endpoint already claimed, ep(0xc09fb564, 0xee7bb3c0, ep1in-bulk)
[  173.745592] ep_matches, wrn: endpoint already claimed, ep(0xc09fb564, 0xee7bb3c0, ep1in-bulk)
[  173.745632] ep_matches, wrn: endpoint already claimed, ep(0xc09fb5b0, 0xee7bb3c0, ep1out-bulk)
[  173.745666] gadget_is_softwinner_otg is not -int
[  173.745685] gadget_is_softwinner_otg is not -int
[  173.745740] ep_matches, wrn: endpoint already claimed, ep(0xc09fb564, 0xee7bb3c0, ep1in-bulk)
[  173.745785] g_ether gadget: Ethernet Gadget, version: Memorial Day 2008
[  173.745844] g_ether gadget: g_ether ready
[  515.189731] g_ether gadget: high-speed config #1: CDC Ethernet (EEM)
[  622.510061] usb0: no IPv6 routers present

Printer gadget:

[  819.334029] ep_matches, wrn: endpoint already claimed, ep(0xc09fb564, 0xc09fb564, ep1in-bulk)
[  819.334126] Printer Gadget: Printer Gadget, version: 2007 OCT 06
[  819.334137] Printer Gadget: using sunxi_usb_udc, OUT ep1out-bulk IN ep1in-bulk
[  837.931947] Printer Gadget: high-speed config #1: 2 mA, Printer Gadget
[  837.931973] Printer Gadget: Using interface 0

Mass Storage gadget (see also USBootPi based on Armbian)

[  919.146460] g_mass_storage gadget: Mass Storage Function, version: 2009/09/11
[  919.146479] g_mass_storage gadget: Number of LUNs=1
[  919.146489]  lun0: LUN: removable file: (no medium)
[  919.146522] ep_matches, wrn: endpoint already claimed, ep(0xc09fb564, 0xbf1528a4, ep1in-bulk)
[  919.146537] g_mass_storage gadget: Mass Storage Gadget, version: 2009/09/11
[  919.146550] g_mass_storage gadget: userspace failed to provide iSerialNumber
[  919.146576] g_mass_storage gadget: g_mass_storage ready
[  939.953615] g_mass_storage gadget: high-speed config #1: Linux File-Backed Storage
[  940.162491] WRN:L1132(drivers/usb/sunxi_usb/udc/sunxi_udc.c):handle_ep0: ep0 setup end
[  940.162525] g_mass_storage gadget: error in submission: ep0 --> -51
[  941.164901] WRN:L1132(drivers/usb/sunxi_usb/udc/sunxi_udc.c):handle_ep0: ep0 setup end
[  941.164944] g_mass_storage gadget: error in submission: ep0 --> -51

@zador-blood-stained
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you try serial gadget too?

@ThomasKaiser
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea was to have all this stuff ready with 5.15 and then let our users join in, test and provide documentation for all these (quite cool) features. Personally I'm just interested in Ethernet and am writing a sort of tutorial right now where g_ether gets handy.

@ThomasKaiser
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... if I understood correctly we could use either g_ether or g_serial to allow access to H3 devices with legacy kernel by default. If I also understood correctly then using g_ether is PITA when trying it from Windows (which the majority of our users might use) so maybe enabling g_serial on sun8i and providing a root shell on /dev/ttyGS0 might help setting up H3 boards without an USB-UART dongle (not a real replacement though since u-boot and kernel booting are missing).

@zador-blood-stained
Copy link
Member

@zador-blood-stained zador-blood-stained commented on 24ea1d3 Jun 20, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I also understood correctly then using g_ether is PITA when trying it from Windows (which the majority of our users might use)

It's easy with clear instructions (like xda-developers post I linked) and more or less modern Windows version (Win 7 should be modern enough)

so maybe enabling g_serial on sun8i and providing a root shell on /dev/ttyGS0 might help setting up H3 boards without an USB-UART dongle (not a real replacement though since u-boot and kernel booting are missing).

It's easy to add serial-getty on ttyGS0, but I won't wouldn't enable loading kernel modules by default since seems like there are issues when unloading and reloading gadget modules

@ThomasKaiser
Copy link
Contributor

@ThomasKaiser ThomasKaiser commented on 24ea1d3 Jun 20, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I won't enable loading kernel modules by default since seems like there are issues when unloading and reloading gadget modules

Agreed, then making these modules available is enough for now and everything else stuff for improved documentation (maybe adding both modules in commented form to /etc/modules on all H3 devices to give a hint?)

@zador-blood-stained
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, then making these modules available is enough for now and everything else stuff for improved documentation (maybe adding both modules in commented form to all H3 devices to give a hint?)

We have OTG on all Allwinner devices (well, except Pine64 and Beelink X2, where you need special cable to use OTG features), so I don't know about adding this only for H3.

@ThomasKaiser
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... seems this stuff is enabled everywhere with sunxi legacy kernels except in linux-sun5i-default.config (huh? we support A13 devices?!). So you're right and we could handle all sunxi devices equal but on the other hand it seems not that simple to get this gadget support with mainline kernel (I read something from ssvb) so we simply leave everything as it is now and maybe this stuff will be covered by improved documentation later.

Please sign in to comment.