This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

How to implement a virtual network interface via AM335x USB?

Hi,

our boards with the AM335x will be connected to (Windows) PCs. In the PC the board should appear as an additional network interface. The StarterWare 2.0.0.7 has no example sources for a virtual network interface via USB. Are there any other resources to start with?

Thank, Rudi

  • To work with Windows PCa you need to implement a proprietary RNDIS USB class, or a standard CDC-ECM for other OSs or using specific drivers.

    You can have a look at Linux kernel USB gadgets code (RNDIS, ECM, EEM and NCM) for some hints, and take Starterware CDC-ACM implementation skeleton as reference starting point. Some basic instructions are on this page of wiki: http://processors.wiki.ti.com/index.php/StarterWare_USB#How_To_Write_a_New_CDC_Device_Application.

    Regards, Max

  • Thank you for your answer, Qmax!

    We already implemented the composite CDC example based on StarterWare and that works fine. But from the point of view of the device, CDC is rather limited compared to a virtual network interface. And as you suggest, we are looking for a solution based on Windows. There may be al lot of traps and mines along the way, so I asked this question here.

    Can you please provide a link to the Linux kernel USB gadgets (code or documentation), too?

    Thanks, Rudi

  • IMHO you want to use USBnet (as Linux describes it) documented here (with references to RNDIS): http://www.linux-usb.org/usbnet/

    This is nicely available on Beaglebone basically the following commands referenced here: http://beagleboard.org/static/beaglebone/latest/README.htm under “Launch USB-to-Ethernet interface” and in the attached screen shot.  The left Terminal Window is the Ubuntu laptop showing the TI network IP address on eth0 and the USBnet local address on eth1 of 192.168.7.1.  The right Terminal Window is the Beaglebone also showing the TI network IP address on eth0 and the USBnet local address on eth1 of 192.168.7.2. 

    Towards the bottom left you can see the Beaglebone serving up a web page (from Firefox running on Ubuntu laptop) since it is running an HTML server on its 192.168.7.2 local address (The middle terminal window just show an SSH login to the Beaglebone USBnet address so that CCSv5 RSE can eventually be used: http://processors.wiki.ti.com/index.php/How_to_setup_Remote_System_Explorer_plug-in ).

    But we also recreated this USBnet system on the AM335x EVM using the instructions here: http://processors.wiki.ti.com/index.php/UsbConfigDevRNDIS#Testing

    insmod g_ether.ko

    /sbin/ifconfig usb0 192.168.7.2 netmask 255.255.255.252

    after setting up the USB Gadget options on that page (andof course building a new uImage and g_ether.ko module).

    We were able to get a static IP network over USB working between the AM335x EVM and my (Pentium) Linux box running Ubuntu .  The only connection was a USB MicroB cable (to the EVM) with regular USB-A to the PC.  I can't explain why the USBnet local address of 192.168.7.2 is on usb0 instead of on eth1 (must be something in udev rules in the Linux EZSDK/PSP AM335X-LINUX-PSP-04.06.00.07.  The Ubuntu laptop also had usb0 for the Ethernet adaptor.  But I was using a different laptop from the Beaglebone screenshot).  But from the log below you can see I was able to ping the Ubuntu laptop USBnet local address on usb0 of 192.168.7.1.

     root@am335x-evm:~# insmod /lib/modules/3.1.0/kernel/drivers/usb/gadget/g_ether.ko

    [  119.299743]  gadget: using random self ethernet address

    [  119.305236]  gadget: using random host ethernet address

    [  119.311279] usb0: MAC 52:8a:af:93:f2:4c

    [  119.315277] usb0: HOST MAC f6:6c:8e:1e:75:0e

    [  119.319824]  gadget: Ethernet Gadget, version: Memorial Day 2008

    [  119.326110]  gadget: g_ether ready

    [  119.329650] musb-hdrc musb-hdrc.0: MUSB HDRC host driver

    [  119.335235] musb-hdrc musb-hdrc.0: new USB bus registered, assigned bus number 2

    [  119.343109] usb usb2: New USB device found, idVendor=1d6b, idProduct=0002

    [  119.350189] usb usb2: New USB device strings: Mfr=3, Product=2, SerialNumber=1

    [  119.357727] usb usb2: Product: MUSB HDRC host driver

    [  119.362915] usb usb2: Manufacturer: Linux 3.2.0 musb-hcd [  119.368438] usb usb2: SerialNumber: musb-hdrc.0

    [  119.373657] hub 2-0:1.0: USB hub found [  119.377624] hub 2-0:1.0: 1 port detected root@am335x-evm:~#

    [  195.069763]  gadget: high-speed config #1: CDC Ethernet (ECM)

     root@am335x-evm:~# [  683.531982]  gadget: high-speed config #1: CDC Ethernet (ECM)

     root@am335x-evm:~# /sbin/ifconfig usb0 192.168.7.2 netmask 255.255.255.252

     root@am335x-evm:~# ifconfig

    eth0      Link encap:Ethernet  HWaddr D4:94:A1:36:99:64 

              inet addr:158.218.121.20  Bcast:0.0.0.0  Mask:255.255.254.0

              UP BROADCAST RUNNING ALLMULTI MULTICAST  MTU:1500  Metric:1

              RX packets:3510 errors:0 dropped:732 overruns:0 frame:0

              TX packets:78 errors:0 dropped:0 overruns:0 carrier:0

              collisions:0 txqueuelen:1000

              RX bytes:500881 (489.1 KiB)  TX bytes:9164 (8.9 KiB)

              Interrupt:40

     lo        Link encap:Local Loopback 

              inet addr:127.0.0.1  Mask:255.0.0.0

              UP LOOPBACK RUNNING  MTU:16436  Metric:1

              RX packets:135 errors:0 dropped:0 overruns:0 frame:0

              TX packets:135 errors:0 dropped:0 overruns:0 carrier:0

              collisions:0 txqueuelen:0

              RX bytes:252414 (246.4 KiB)  TX bytes:252414 (246.4 KiB)

     usb0      Link encap:Ethernet  HWaddr 52:8A:AF:93:F2:4C 

              inet addr:192.168.7.2  Bcast:192.168.7.3  Mask:255.255.255.252

              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

              RX packets:36 errors:0 dropped:9 overruns:0 frame:0

              TX packets:43 errors:0 dropped:0 overruns:0 carrier:0

              collisions:0 txqueuelen:1000

              RX bytes:8396 (8.1 KiB)  TX bytes:19470 (19.0 KiB)

     root@am335x-evm:~# [ 1718.576385] PHY: 0:00 - Link is Down

     root@am335x-evm:~# ping 192.168.7.1

    PING 192.168.7.1 (192.168.7.1): 56 data bytes

    64 bytes from 192.168.7.1: seq=0 ttl=64 time=2.075 ms

    64 bytes from 192.168.7.1: seq=1 ttl=64 time=1.159 ms

    64 bytes from 192.168.7.1: seq=2 ttl=64 time=1.221 ms

    64 bytes from 192.168.7.1: seq=3 ttl=64 time=1.038 ms

    64 bytes from 192.168.7.1: seq=4 ttl=64 time=1.098 ms

  • Rudi,

    Joe has already given a lot of hints about Linux and Usbnet world. If having an OS is your case, Linux can help you quickly and easily, and SDK already supports this feature for BBone and EVM. But it sounds really different if you plan to have no OS on your system (talking about Starterware, I supposed that was your case).

    The source code for g_ether gadget is in drivers/usb/gadget/ether.c. This module can support multiple and different configurations (CDC-ECM EEM and RNDIS) depending on compile-time and run-time specs, and implements the "peripheral side" of usbnet connection. For RNDIS specific aspects, follow the USB_ETH_RNDIS macro and look at f_rndis.c and rndis.c files. BTW this module is part of the usb-gadgets framework, so some aspects of the whole architecture could be obscure looking just at the single file. Anyway hope can help.

    Regards, Max

  • Joe and Qmax,

    excellent: your answers contain exactly what I was looking for! I will dive into the information and see how to implement a solution that fits for our requirements.

    Many Thanks, Rudi