| | 706 | [=#ethgadget] |
| | 707 | ==== USB Ethernet Gadget |
| | 708 | The USB ethernet gadget support allows you to use a USB connection to a host PC as an ethernet device and can be very handy if you are on a board that lacks an ethernet jack. |
| | 709 | |
| | 710 | For this support you must have the 'usb_ether' driver enabled (CONFIG_USB_ETHER) and use the bind command (CONFIG_CMD_BIND) to bind it to a USB host that supports dual-role. The binding of the driver requires you to know the device-tree path of the host. |
| | 711 | |
| | 712 | This is enabled on the Venice bootloaders and can be used as such on boards that have a dual role controller with a USB OTG or Type-C connector: |
| | 713 | - IMX8MM boards (GW71xx/GW72xx/GW73xx/GW74xx): |
| | 714 | {{{#!bash |
| | 715 | bind /soc@0/bus@32c00000/usb@32e40000 usb_ether && setenv ethact usb@32e40000 |
| | 716 | }}} |
| | 717 | - IMX8MP boards (GW71xx/GW72xx/GW73xx/GW74xx): |
| | 718 | {{{#!bash |
| | 719 | bind /soc@0/usb@32f10100/usb@38100000 usb_ether && setenv ethact usb@38100000 |
| | 720 | }}} |
| | 721 | |
| | 722 | After binding the driver a new network interface will be available (named per the dt path above): |
| | 723 | {{{#!bash |
| | 724 | setenv ipaddr 10.0.0.2 |
| | 725 | setenv netmask 255.255.255.0 |
| | 726 | ping 10.0.0.1 |
| | 727 | }}} |
| | 728 | |
| | 729 | on a connected Linux host PC you will see usb0 enumerate and can do a 'sudo ifconfig usb0 10.0.0.1' at which point the ping will complete. Note that the USB device will not enumerate on the host PC until you use a network operation in U-Boot therefore you are likely best configuring your host PC for a static IP upon device recognition so the uboot operations do not time out while you are setting up your network with something like: |
| | 730 | {{{#!bash |
| | 731 | cat << EOF > /etc/udev/rules.d/70-usb-ethernet.rules |
| | 732 | SUBSYSTEM=="net", ACTION=="add", ATTR{idVendor}=="0525", ATTR{idProduct}=="a4a5", NAME="eth_usb" |
| | 733 | EOF |
| | 734 | udevadm control --reload-rules |
| | 735 | udevadm trigger |
| | 736 | cat << EOF >> /etc/network/interfaces |
| | 737 | auto eth1 |
| | 738 | iface eth1 inet static |
| | 739 | address 10.0.0.1 |
| | 740 | netmask 255.255.255.0 |
| | 741 | EOF |
| | 742 | }}} |
| | 743 | |
| | 744 | |