Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Altera_Forum
Honored Contributor I
2,525 Views

Ethernet gadget for Altera SoCKit

Hi, 

 

I have an Altera SoCKit board (from terasic) on which I'm trying to get Ethernet functioning over the USB 2.0 OTG port. I'm running Linux 3.18. I've seen several posts on getting the mass storage to work, but none for Ethernet. I'd like to SSH over the USB OTG port. 

 

I've configured the Linux kernel with options: 

 

# CONFIG_USB_DWC2_HOST is not set 

CONFIG_USB_DWC2_PERIPHERAL=y 

 

CONFIG_USB_GADGET=y 

CONFIG_USB_GADGET_VBUS_DRAW=2 

CONFIG_USB_GADGET_STORAGE_NUM_BUFFERS=2 

 

# # USB Peripheral Controller 

CONFIG_USB_LIBCOMPOSITE=m 

CONFIG_USB_U_ETHER=m 

CONFIG_USB_F_ECM=m 

CONFIG_USB_F_SUBSET=m 

CONFIG_USB_F_RNDIS=m 

CONFIG_USB_CONFIGFS=m 

 

CONFIG_USB_CONFIGFS_RNDIS=y 

 

CONFIG_USB_ETH=m 

CONFIG_USB_ETH_RNDIS=y 

 

The correct drivers get built. When I go to insmod g_ether.ko (from the directory that I can see that it's in) I get: 

 

 

# insmod g_ether.ko 

Error: could not insert module g_ether.ko: No such device 

 

Has anybody been able to get this to work? Can you post your kernel configuration / device tree / or just the necessary details? 

 

I've noticed that the device tree entry for the USB OTG port usb@ffb00000 (in socfpga.dtsi) is by default "disabled", but my attempts to enable it have not yet resolved this issue. 

 

 

Thanks in advance for any advice! 

--George Broz 

 

 

 

 

 

0 Kudos
5 Replies
Altera_Forum
Honored Contributor I
217 Views

Hi! 

First check in Qsys which USB are you using! Then write a "okay" on the device tree for the USB controller youre using! 

 

For the gadget: (it will be diferent in your case because we are using another distribution) 

we have 

Step 1 

 

make kernel_menuconfig 

 

Device Drivers ---> 

USB support ---> 

[*] OTG support 

<*> USB Gadget Support ---> 

<*> USB Gadget Driver (Ethernet Gadget (with CDC Ethernet support)) ---> 

Ethernet Gadget (with CDC Ethernet support) 

[*] RNDIS support---> 

 

Step 2 

 

make menuconfig 

 

Kernel Modules ---> 

USB Support ---> 

<*> kmod-usb-core.......................Support for USB 

<*> kmod-usb-net........................Kernel modules for USB-to-Ethernet converters 

<*> kmod-usb-net-cdc-eem..............Support for CDC EEM connectin 

<*> kmod-usb-net-cdc-ether............Support for cdc ethernet connections 

 

 

then compile your image 

 

$make 

 

copy the image to your board 

 

list the active modules 

 

$lsmod 

$ ls /lib/modules/x.x/ 

 

mount module 

$modprobe usbnet.ko 

 

then you have to create a usb0 interface and change your etc/config/network 

 

config interface 'usbnet' 

option ifname 'usb0' 

option proto 'static' 

option ipaddr '1.0.0.x' 

option netmask '255.255.255.0' 

 

reboot and 

check for usb0 on boot 

$dmesg | grep -in usb0 

 

make a ping!! 

hope it help 

c
Altera_Forum
Honored Contributor I
217 Views

Hi murillo, 

 

Thanks for your help! But I'm still not able to get it working. 

 

I enabled the modules from "step 2" in your post (I was lacking those - thanks!).  

 

Also in socfpga_cyclone_5_sockit.dts for &usb1 I have tried both: 

 

&usb1 { 

status = "okay" 

}; 

 

and 

 

&usb1 { 

status = "okay"; 

dr_mode = "peripheral"; 

}; 

 

I can modprobe usbnet just fine. When I modprobe g_ether I still see: 

modprobe: ERROR: could not insert 'g_ether': No such device 

 

In the dmesg log I observe (usb1 corresponds to ffb40000):  

[ 2.031222] dwc2 ffb40000.usb: no platform data or transceiver defined 

[ 2.047574] platform ffb40000.usb: Driver dwc2 requests probe deferral 

[ 2.054240] dwc2 ffb40000.usb: no platform data or transceiver defined 

[ 2.060772] platform ffb40000.usb: Driver dwc2 requests probe deferral 

 

(The dwc2 driver - DesignWare USB2 DRD Core - was selected by defconfig for this board). 

 

The "usb-nop-xceiv" is associated with usb1 for this board. But the h/w for the board uses an SMSC USB3300 transceiver, for which I cannot locate a driver. Do you (or anyone else) know how the USB3300 can be used with ARM SoC? 

 

Thanks, 

--George
Altera_Forum
Honored Contributor I
217 Views

HI! 

your dts should look like this: 

 

usbphy0: usbphy@0 { /* NOP USB Transceiver(part of phy in USB IP and ULPI link hps<-> phy) - bindings/usb/usb-nop-xceiv.txt */ 

compatible = "usb-nop-xceiv"; /* drivers/usb/phy/phy-generic.c */ 

# phy-cells = <0>; 

status = "okay"; 

}; //end usbphy0 

 

 

usb0: usb@ffb00000 { /* bindings/usb/dwc2.txt | If CONFIG_OF defined, add extra parameters(drivers/usb/dwc2/gadget.c) */ 

compatible = "snps,dwc2"; /* drivers/usb/dwc2/platform.c | dwc_otg(many param)->obsolete */ 

reg = <0xffb00000 0x40000>; 

interrupts = <0 125 4>; 

clocks = <&usb_mp_clk>; 

clock-names = "otg"; /* from dwc2.txt */ 

phys = <&usbphy0>; 

phy-names = "usb2-phy"; /* from dwc2.txt */ 

status = "disabled"; 

}; //end usb0 

 

 

usb1: usb@ffb40000 { /* bindings/usb/dwc2.txt | If CONFIG_OF defined, add extra parameters(drivers/usb/dwc2/gadget.c) */ 

compatible = "snps,dwc2"; /* drivers/usb/dwc2/platform.c | dwc_otg(many param)->obsolete */ 

reg = <0xffb40000 0x40000>; 

interrupts = <0 128 4>; 

clocks = <&usb_mp_clk>; 

clock-names = "otg";/* from dwc2.txt */ 

phys = <&usbphy0>; 

phy-names = "usb2-phy";/* from dwc2.txt */ 

status = "okay"; 

}; //end usb1 

 

 

Just be careful with the clocks parameters (&usb_mp_clk)... they will maybe havea different name at your dts. 

And I'm using kernel4.0 ...so... I hope all paths and files are correct. (drivers/usb/dwc2/platform.c) (drivers/usb/phy/phy-generic.c). I also dont know if the compatible parameter snps,dwc-otg was already obsolete by 3.18. You have to check it!  

 

extra info 

Primary DTS Sources: 

Devicetree docu - kernel -> Documentation/devicetree/bindings/ 

Drivers Sourcecode - kernel -> drivers/ 

Devicetree examples - kernel -> arch/arm/boot/dts 

ePAPR v1.0 and v 1.1 from power.org 

www.devicetree.org/device_tree_usage (http://www.devicetree.org/device_tree_usage)  

 

 

Also... you will not need to modprobe g_ether!! 

bye
Altera_Forum
Honored Contributor I
217 Views

Thanks again, murillo. 

 

I got it working. My last problem was that the generic USB phy driver (the driver behind "usb-nop-xceiv" ) was not selected in the kernel configuration. 

 

Under Device Drivers -> USB Support -> USB Physical Layer Drivers: 

<M> NOP USB Transceiver Driver 

 

This seems to be what's needed to drive the SMSC USB3300. I no longer see: 

[ 2.031222] dwc2 ffb40000.usb: no platform data or transceiver defined 

[ 2.047574] platform ffb40000.usb: Driver dwc2 requests probe deferral 

 

Instead I see: 

[ 1.961204] soc:usbphy@0 supply vcc not found, using dummy regulator 

[ 1.974959] ffb40000.usb supply vusb_d not found, using dummy regulator 

[ 1.981659] ffb40000.usb supply vusb_a not found, using dummy regulator 

[ 1.988336] dwc2 ffb40000.usb: EPs: 15, dedicated fifos, 8064 entries in SPRAM 

 

 

some additional comments: 

 

My dts matches yours with two exceptions: 

 

usb1: usb@ffb40000 { 

reg = <0xffb40000 0xffff>; /* yours - <0xffb40000 0x40000> */ 

dl_mode = "peripheral"; /* not sure if necessary, was there from a previous attempt */ 

}; 

 

However, I have to 'modprobe g_ether' before I can configure usb0. When I 'modprobe g_ether' I see: 

 

root@cyclone5:~# modprobe g_ether 

[ 157.243834] using random self ethernet address 

[ 157.248273] using random host ethernet address 

[ 157.253375] usb0: HOST MAC 5e:1c:8b:99:74:e4 

[ 157.257698] usb0: MAC 9e:36:2b:41:a9:25 

[ 157.261548] using random self ethernet address 

[ 157.266028] using random host ethernet address 

[ 157.270499] g_ether gadget: Ethernet Gadget, version: Memorial Day 2008 

[ 157.277122] g_ether gadget: g_ether ready 

[ 157.281125] dwc2 ffb40000.usb: bound driver g_ether 

root@cyclone5:~# [ 157.418463] dwc2 ffb40000.usb: new device is high-speed 

[ 157.478204] dwc2 ffb40000.usb: new device is high-speed 

[ 157.518190] dwc2 ffb40000.usb: new address 11 

[ 159.433006] g_ether gadget: high-speed config# 2: RNDIS 

 

After which I can 'ifconfig usb0 192.168.0.32' to set the interface. It is also at this point when my Windows PC recognizes the USB Ethernet gadget ("Linux USB Ethernet/RNDIS Gadget# 5"). 

 

As the last step, I configure the IP address of the Ethernet USB adapter in Windows to be on the same subnet and then I am able to SSH to the board. 

 

Thanks for the help! 

--George Broz
Altera_Forum
Honored Contributor I
217 Views

Cool! 

 

PS:  

For dl_mode ...refer to your kernel x.x -> Documentation/devicetree/bindings//usb/dwc2.txt 

And the usb1 size = 0x40000 (256KB ), got it from Table 1-3 : Peripheral region Address Map (p.1-19) cv_5v4.pdf (Cyclone V Hard Processor System Tech Ref Manual)