DESK-MX6-L-AN-0008: Using USB Ethernet adapter as a second ethernet interface

From DAVE Developer's Wiki
Jump to: navigation, search
Info Box

History[edit | edit source]

Date Development Kit version
September 2023 DESK-MX6L-L 4.0.1

Introduction[edit | edit source]

In certain situations, it is necessary to have an easy and fast second ethernet interface. For example for testing some dual ethernet purposes and then properly designing the carrier board.

It is possible to buy a well-sold USB to ethernet adapter like the USB to 10/100 Mbps ethernet adapter

This Application Note (AN) shows how to use it on a system running a DESK-MX6-L-based Yocto Linux distribution in Linux userspace and even in U-Boot.

U-Boot[edit | edit source]

The main issue to be solved for getting U-Boot correctly manage the USB to ethernet adapter is to have its device driver available in the U-Boot sources.

The proposed adapter uses internally the AX88772A chipset which has a proper driver in the U-Boot sources. Moreover, the driver in already enabled in DESK-MX6L-L 4.0.1: looking at the CONFIG enabled it is possible to see:

CONFIG_USB_HOST_ETHER
CONFIG_USB_ETHER_ASIX

which enables the proper driver.

Using the adapter[edit | edit source]

The usb start command should identify the adapter like this:

=> usb start
starting USB...
USB0:   MXC USB port 0 not yet supported
lowlevel init failed
USB1:   USB EHCI 1.00
scanning bus 1 for devices... 2 USB Device(s) found
       scanning usb for storage devices... 0 Storage Device(s) found
       scanning usb for ethernet devices... 1 Ethernet Device(s) found
=>

and the related usb info command will display the detected Ethernet device:

=> usb info 2
config for device 2
2: Vendor specific,  USB Revision 2.0
 - ASIX Elec. Corp. AX88772A 0005AF
 - Class: Vendor specific
 - PacketSize: 64  Configurations: 1
 - Vendor: 0x0b95  Product 0x7720 Version 0.1
   Configuration: 1
   - Interfaces: 1 Bus Powered Remote Wakeup 250mA
   - String: "0"
     Interface: 0
     - Alternate Setting 0, Endpoints: 3
     - Class Vendor specific
     - String: "0"
     - Endpoint 1 In Interrupt MaxPacket 8 Interval 11ms
     - Endpoint 2 In Bulk MaxPacket 512
     - Endpoint 3 Out Bulk MaxPacket 512

=>

For enabling the adapter ethernet interface, the variable ethact has to be set:

=> print ethact
ethact=FEC
=> setenv ethact asx0
=>

and then it is possible to use the second ethernet interface, for example:

=> ping 192.168.0.23
Using asx0 device
host 192.168.0.23 is alive
=> run loadfdt
Using asx0 device
TFTP from server 192.168.0.13; our IP address is 192.168.0.89
Filename 'desk-mx6/linux/desk-mx6-l-4.0.1_imx6dl-sbcx-cb0012.dtb'.
Load address: 0x18000000
Loading: ###########
         500 KiB/s
done
Bytes transferred = 52271 (cc2f hex)
=>

As observed, the interface used is the USB to ethernet adapter:

Using asx0 device


Linux[edit | edit source]

The Linux kernel has the driver built-in in the kernel, so the adapter is correctly detected and ifconfig will show the second ethernet interface

root@desk-mx6:~# dmesg | grep eth
[    3.213431] fec 2188000.ethernet eth0: registered PHC device 0
[    3.232354] usbcore: registered new interface driver cdc_ether
[    5.723095] asix 1-1:1.0 eth1: register 'asix' at usb-ci_hdrc.1-1, ASIX AX88772 USB 2.0 Ethernet, 00:0e:c6:59:eb:aa
[   12.459264] asix 1-1:1.0 eth1: Link is Down
[   12.528340] Micrel KSZ9031 Gigabit PHY 2188000.ethernet-1:07: attached PHY driver (mii_bus:phy_addr=2188000.ethernet-1:07, irq=POLL)
[   14.642260] IPv6: ADDRCONF(NETDEV_CHANGE): eth1: link becomes ready
[   14.646438] asix 1-1:1.0 eth1: Link is Up - 100Mbps/Full - flow control off
root@desk-mx6:~# ifconfig
eth0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether 12:a2:da:95:87:e1  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 fe80::20e:c6ff:fe59:ebaa  prefixlen 64  scopeid 0x20<link>
        ether 00:0e:c6:59:eb:aa  txqueuelen 1000  (Ethernet)
        RX packets 140  bytes 11472 (11.2 KiB)
        RX errors 0  dropped 7  overruns 0  frame 0
        TX packets 21  bytes 3405 (3.3 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 92  bytes 7838 (7.6 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 92  bytes 7838 (7.6 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

root@desk-mx6:~#

Once the IP address is set, the eth1 interface can be used.

root@desk-mx6:~# ifconfig eth1 192.168.0.90
root@desk-mx6:~# ping 192.168.0.23
PING 192.168.0.23 (192.168.0.23) 56(84) bytes of data.
64 bytes from 192.168.0.23: icmp_seq=1 ttl=64 time=1.12 ms
64 bytes from 192.168.0.23: icmp_seq=2 ttl=64 time=0.720 ms
^C
--- 192.168.0.23 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 0.720/0.919/1.119/0.199 ms
root@desk-mx6:~#