Jump to content

g_ether driver (H3 device as Ethernet dongle)


tkaiser

Recommended Posts

Hi!

 

I'm trying to implement a OTG USB ethernet interface on a Orange pi one...

 

I'm not an advanced Linux user and the information that I found on the Internet is very confused...

 

The instructions on the first post of this topic i think is the most easy to follow...

 

 

But the link for the kernel (http://kaiser-edv.de..._kernel.tar.bz2) is not working anymore...

 

Can someone reupload it somewhere?

 

Thanks in advance,

Dimitris

Link to comment
Share on other sites

tkaiser thanks for the really fast reply!!

 

I have done the installation yesterday followed by a apt-get update, apt-get upgrade so I must have the latest release for this board...

 

When I run the commands from first post:

 

echo -n 0 > /sys/bus/platform/devices/sunxi_usb_udc/otg_role

modprobe g_ether

echo -n 2 > /sys/bus/platform/devices/sunxi_usb_udc/otg_role

 

Nothing happens... the pc didn't find any new device and the orange pi don't show any error...

Link to comment
Share on other sites

 the pc didn't find any new device and the orange pi don't show any error...

 

If the PC is running Windows then I'm out of ideas (deal only sometimes with this and then it's Windows Server and I can use SSH).  At least checking dmesg and lsmod output before and after should help (maybe the module is already loaded?)

Link to comment
Share on other sites

The pc is indeed a windows machine but the goal is to use it on a synology nas box that is running a custom Linux...

 

The wired thing is that Windows not seen any new hardware...

 

I will post later the output of dmesg and lsmod because I don't have the board with me now...

 

Thanks for your help!

Link to comment
Share on other sites

tkaiser than you so much for your help!

 

after checking with dmesg and lsmod i found that the modules is loaded fine...

 

so i connected the board with a rooted android phone and from terminal emulator i tried the command lsusb and guess what: the phone detect the usb device as RNDIS/Ethernet Gadget!!!

 

after that i found three problems with my pc:

1st: for some reason if i have connected on the 2 front usb ports of my pc the orange pi board and my FTDI usb to serial adaper, only the second show up on device manager of windows...

2nd: on the /etc/network/interfaces file i must add the line allow-hotplug usb0. if not the device is not detected by windows...

3rd: the windows don't load the drivers automatically. i flowed the instructions from this page and everything is working fine now...

 

So after all its very easy:

 

1) Add the g_ether module to /etc/modules

2) Add the following config to /etc/network/interfaces :

 

allow-hotplug usb0
iface usb0 inet static
address 169.254.1.1
netmask 255.255.0.0
pre-up /bin/sh -c 'echo 2 > /sys/bus/platform/devices/sunxi_usb_udc/otg_role'

 

3) Manual install the drivers for windows.

Now you can use putty or any other SSH client to connect to orange pi IP (in the above example 169.254.1.1)
 

Once again thanks for your help!!

Link to comment
Share on other sites

tkaiser:

 

I'm a noob when it comes to compiling things. The link to download from your site is not working. I have the latest Armbian installed, but as you know, no g_ether module. I also got Igor2's "lib" off of github, but it doesn't have g_ether installed (I thought it might).

 

Could you post an up to date link, or teach me the magic so I don't have to keep asking everybody for help? I really don't understand what I'm doing, but I learn fast and will spread the knowledge!

Link to comment
Share on other sites

tkaiser

 

Starting personal conversations like this or even worse via PM is really no good idea. I'm not a paid supporter here and this is a community forum where users help users. :)

 

Using g_ether is possible with every recent Armbian image built or updated within the last months, everything is included now and everything is explained here in detail. In case you need someone to walk you through the steps simply ask and it will happen (but not by me, will spend my time on different things)

Link to comment
Share on other sites

If I don't have to compile, that is a plus.

 

Checked it in the meantime on a host where the g_ether connection is used to act as some sort of a heartbeat connection (to test whether the other SBC is still reachable when all network routes aren't available any more). It's really just definition of an 'usb0' interface with legacy kernel in the following way (more details in post #4 of this thread):

 

 

tk@bananapim2plus:~$ grep -A5 'allow-hotplug usb0' /etc/network/interfaces

allow-hotplug usb0

iface usb0 inet static

address 169.254.2.1

netmask 255.255.0.0

pre-up /bin/sh -c 'echo 2 > /sys/bus/platform/devices/sunxi_usb_udc/otg_role'

 

tk@bananapim2plus:~$ /sbin/ifconfig usb0

usb0      Link encap:Ethernet  HWaddr ea:10:28:46:e5:7a  

          inet addr:169.254.2.1  Bcast:169.254.255.255  Mask:255.255.0.0

          inet6 addr: fe80::e810:28ff:fe46:e57a/64 Scope:Link

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

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

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

          collisions:0 txqueuelen:1000 

          RX bytes:17569 (17.5 KB)  TX bytes:15497 (15.4 KB)

 

tk@bananapim2plus:~$ ping 169.254.2.2

PING 169.254.2.2 (169.254.2.2) 56(84) bytes of data.

64 bytes from 169.254.2.2: icmp_seq=1 ttl=64 time=1.09 ms

64 bytes from 169.254.2.2: icmp_seq=2 ttl=64 time=0.539 ms

^C

--- 169.254.2.2 ping statistics ---

2 packets transmitted, 2 received, 0% packet loss, time 1001ms

rtt min/avg/max/mdev = 0.539/0.819/1.099/0.280 ms

tk@bananapim2plus:~$ iperf3 -c 169.254.2.2

Connecting to host 169.254.2.2, port 5201

[  4] local 169.254.2.1 port 52106 connected to 169.254.2.2 port 5201

[ ID] Interval           Transfer     Bandwidth       Retr  Cwnd

[  4]   0.00-1.00   sec  15.3 MBytes   128 Mbits/sec    0    800 KBytes       

[  4]   1.00-2.02   sec  15.9 MBytes   131 Mbits/sec    0   1004 KBytes       

[  4]   2.02-3.00   sec  13.5 MBytes   115 Mbits/sec    0   1.10 MBytes       

[  4]   3.00-4.01   sec  15.1 MBytes   126 Mbits/sec    0   1.20 MBytes       

[  4]   4.01-5.00   sec  14.4 MBytes   121 Mbits/sec    0   1.27 MBytes       

[  4]   5.00-6.00   sec  14.4 MBytes   120 Mbits/sec    0   1.32 MBytes       

[  4]   6.00-7.01   sec  14.5 MBytes   121 Mbits/sec    0   1.36 MBytes       

[  4]   7.01-8.00   sec  13.9 MBytes   118 Mbits/sec    0   1.38 MBytes       

[  4]   8.00-9.00   sec  14.9 MBytes   125 Mbits/sec    0   1.39 MBytes       

[  4]   9.00-10.01  sec  14.8 MBytes   122 Mbits/sec    0   1.01 MBytes       

- - - - - - - - - - - - - - - - - - - - - - - - -

[ ID] Interval           Transfer     Bandwidth       Retr

[  4]   0.00-10.01  sec   147 MBytes   123 Mbits/sec    0             sender

[  4]   0.00-10.01  sec   145 MBytes   122 Mbits/sec                  receiver

 

iperf Done.

 

 

Link to comment
Share on other sites

hi g_ether work fine but only for kernel 3.4

i try to do same on last kernel 4.9.0-sun8i but without success

lsmod 
libcomposite           34616  1 usb_f_rndis
u_ether                 9963  1 usb_f_rndis
usb_f_rndis            12443  0
insmod g_ether
failed to insert /lib/modules/4.9.0-sun8i/g_ether.ko
dmesg -c
[ 2404.192826] g_ether musb-hdrc.1.auto: failed to start g_ether: -2

some recommendation for me ?

insmod g_ether
Link to comment
Share on other sites

g_ether work fine but only for kernel 3.4 i try to do same on last kernel 4.9.0-sun8i but without success lsmod libcomposite 34616 1 usb_f_rndis u_ether 9963 1 usb_f_rndis usb_f_rndis 12443 0 insmod g_ether failed to insert /lib/modules/4.9.0-sun8i/g_ether.ko dmesg -c [ 2404.192826] g_ether musb-hdrc.1.auto: failed to start g_ether: -2 some recommendation for me ?

What board exactly? Not all boards enable OTG in DT by default, and OTG driver is still WIP/experimental so it may not work perfectly.

And you should probably grab the latest nightly image or kernel which should have version 4.9.2 4.9.3.

Link to comment
Share on other sites

What board exactly? Not all boards enable OTG in DT by default, and OTG driver is still WIP/experimental so it may not work perfectly.

And you should probably grab the latest nightly image or kernel which should have version 4.9.2 4.9.3.

 

Hi i check last kernel 4.9.3 its same

have error

[ 1241.108446] g_ether musb-hdrc.1.auto: failed to start g_ether: -2

 

my device Orange Pi Zero - g_ether work fine with 3.4.113

Link to comment
Share on other sites

Hi i check last kernel 4.9.3 its same

have error

[ 1241.108446] g_ether musb-hdrc.1.auto: failed to start g_ether: -2

my device Orange Pi Zero - g_ether work fine with 3.4.113

Because why do you use insmod? It doesn't check for module dependencies. You should use modprobe instead

root@orangepizero:~# uname -r
4.9.3-sun8i
root@orangepizero:~# modprobe sunxi
root@orangepizero:~# modprobe g_ether
root@orangepizero:~# ifconfig usb0 up
root@orangepizero:~# ifconfig usb0
usb0      Link encap:Ethernet  HWaddr be:99:65:70:8b:8a
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0   TX bytes:0 (0.0 

root@orangepizero:~#
Link to comment
Share on other sites

 

Because why do you use insmod? It doesn't check for module dependencies. You should use modprobe instead

root@orangepizero:~# uname -r
4.9.3-sun8i
root@orangepizero:~# modprobe sunxi
root@orangepizero:~# modprobe g_ether
root@orangepizero:~# ifconfig usb0 up
root@orangepizero:~# ifconfig usb0
usb0      Link encap:Ethernet  HWaddr be:99:65:70:8b:8a
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0   TX bytes:0 (0.0 

root@orangepizero:~#

hi

what is it modprobe sunxi ? i cant find this module sunxi.ko

can u provide your lsmod output

 

i use insmod, because  i try test 4.3.9 kernel in openwrt env )))

yes its lil ugly but

sure i have check dep kernel/drivers/usb/gadget/legacy/g_ether.ko: kernel/drivers/usb/gadget/function/usb_f_rndis.ko kernel/drivers/usb/gadget/function/u_ether.ko kernel/drivers/usb/gadget/libcomposite.ko

 

 

 

Link to comment
Share on other sites

hi

what is it modprobe sunxi ? i cant find this module sunxi.ko

can u provide your lsmod output

 

i use insmod, because  i try test 4.3.9 kernel in openwrt env )))

yes its lil ugly but

sure i have check dep kernel/drivers/usb/gadget/legacy/g_ether.ko: kernel/drivers/usb/gadget/function/usb_f_rndis.ko kernel/drivers/usb/gadget/function/u_ether.ko kernel/drivers/usb/gadget/libcomposite.ko

 

i have find it but only on build in modules modules.builtin kernel/drivers/usb/musb/sunxi.ko

i will try test again

Link to comment
Share on other sites

what is it modprobe sunxi ? i cant find this module sunxi.ko

OK, "sunxi" is built-in here, so you don't need to modprobe it. This is the OTG driver for sunxi devices and it was built as a module previously.

 

can u provide your lsmod output

root@orangepizero:~# lsmod
Module                  Size  Used by
usb_f_eem               4914  1
g_ether                 4851  0
usb_f_rndis            12519  2 g_ether
u_ether                 9963  3 g_ether,usb_f_rndis,usb_f_eem
libcomposite           34756  3 g_ether,usb_f_rndis,usb_f_eem
sunxi_cir               3825  0
evdev                  10043  0
xradio_wlan            92375  1
mac80211              322651  1 xradio_wlan
sun8i_ths               3284  0
cfg80211              191902  2 mac80211,xradio_wlan
rfkill                 10928  1 cfg80211
gpio_keys               8453  0
cpufreq_dt              3586  0
uio_pdrv_genirq         3354  0
uio                     8012  1 uio_pdrv_genirq
thermal_sys            42239  2 cpufreq_dt,sun8i_ths
fuse                   70616  1
uas                    11678  0
root@orangepizero:~#

You can use modinfo with absolute path to the module file to check module dependencies (should work on OpenWRT too)

Link to comment
Share on other sites

sure i have check dep kernel/drivers/usb/gadget/legacy/g_ether.ko: kernel/drivers/usb/gadget/function/usb_f_rndis.ko kernel/drivers/usb/gadget/function/u_ether.ko kernel/drivers/usb/gadget/libcomposite.ko

Each module may have some dependencies too, and you need to load them in the right order  :)

You may try to move all .ko files in /lib/modules/`uname -r` in OpenWRT because at least on my router it is organized in that way (without subdirectories) and modprobe may work after that.

Link to comment
Share on other sites

Each module may have some dependencies too, and you need to load them in the right order  :)

You may try to move all .ko files in /lib/modules/`uname -r` in OpenWRT because at least on my router it is organized in that way (without subdirectories) and modprobe may work after that.

 

 

tnx for help after 1 hour i have success, ( modprobe u_ether not work without  modprobe usb_f_eem before )

 

i have troubles becouse openwrt have another kernel module loading system ( without some automate )

 

my script for startup g_ether

modprobe usb_f_eem
modprobe usb_f_ecm
modprobe usb_f_ncm
modprobe usb_f_rndis
modprobe libcomposite
modprobe u_ether

insmod g_ether iProduct=opizero \
    iManufacturer=hyphop \
    dev_addr=62:ef:11:22:11:22 \
    host_addr=ea:c9:35:d4:66:87 \
    use_eem=0

ifconfig usb0 10.1.1.1 netmask 255.255.255.0

TNX u again

Link to comment
Share on other sites

Hello, I've used your method for nanopi air, every thing goes well but it completely destroyed WiFi connection and wlan0 not listed on /sys/class/net ... Please help me on this issue, I need both connection, how can i configured nanopi air to have usb0 as Ethernet dongle and WiFi ..

 

BR,

 

Masoud.

Link to comment
Share on other sites

Guys, doesn't matter what I do, it loads as a serial device on Win10. (g_ether module is loaded, all usb0 interface configs are OK)

I don't have modules usb_f_rndis, libcomposite or usb_f_* loaded. Do I need them? If yes, how to have them (new kernel, patches...what?)

(Running Jessie on an Orange Pi Zero)

 

Modules Loaded:

Module                  Size  Used by
ir_lirc_codec           3650  0
lirc_dev                7834  1 ir_lirc_codec
ir_mce_kbd_decoder      2885  0
ir_sanyo_decoder        1480  0
ir_sony_decoder         1422  0
ir_jvc_decoder          1452  0
ir_rc6_decoder          1941  0
ir_rc5_decoder          1412  0
ir_nec_decoder          1556  0
sunxi_cir               1601  0
rc_core                12727  10 ir_lirc_codec,ir_rc5_decoder,ir_nec_decoder,ir_sony_decoder,sunxi_cir,ir_mce_kbd_decoder,ir_jvc_decoder,ir_rc6_decoder,ir_sanyo_decoder
pcf8591                 3363  0
bmp085                  3487  0
g_ether                38566  0
xradio_wlan           210530  0
mac80211              358445  1 xradio_wlan
btrfs                 712409  0

Link to comment
Share on other sites

I am also working to get g_ether up. 

I have succeeded but I have some first boot issues. 

 

I need the usb ethernet working the first time the unit boots. 

 

I have modified  Armbian_5.27_Orangepilite_Debian_jessie_dev_4.10.1.img as follows:

I have added g_ether to /etc/modules

I have create /etc/modprobe.d/g_ether.conf with the contents

options g_ether host_addr=12:a5:cf:42:92:fd dev_addr=5e:bc:ca:27:92:b1 idVendor=1317 idProduct=42146

 

This gets me a usb0 when the system boots. But it has no IP and is otherwise not useful. 

 

I added /etc/network/interfaces.d/usb0

 

auto usb0
iface usb0 inet static
    hwaddress ether 82:bc:09:47:28:a9
    address 169.254.7.2
    netmask 255.255.0.0
    network 169.168.7.0
    gateway 169.168.7.1

 

but the armbian setup does not source interfaces.d

 

I appended 

source /etc/network/interfaces.d/*

 to /etc/network/interfaces.network-manager

but still no joy. 

 

I added /etc/NetworkManager/systemconnections/USB Network

[ethernet]
mac-address=5E:BC:CA:27:92:B1

[connection]
id=USB Network
uuid=fbffa806-7cd2-4234-b406-ea7e6423a45a
type=ethernet
timestamp=1488840639

[ipv6]
method=ignore

[ipv4]
method=link-local

 

Still No joy. 

 

HOWEVER

If I boot the SDcard, 

log in via Serial

get through the firstrun stuff including creating a new user

and reboot

the system comes up with fully working usb0

 

But I need it to work the first time. 

I need to be able to bring the system up without a serial connection. 

 

 

 

 

 

 

 

 

 

 

 

Link to comment
Share on other sites

Hello, I have all the settings reset after reboot and I have to register again:

1) echo -n 0> / sys / bus / platform / devices / sunxi_usb_udc / otg_role
Modprobe g_ether
Echo -n 2> / sys / bus / platform / devices / sunxi_usb_udc / otg_roll

2) lsmod | Grep -q g_ether && echo -n 2> / sys / bus / platform / devices / sunxi_usb_udc / otg_role \
        || (Sleep 10 && echo -n 2> / sys / bus / platform / devices / sunxi_usb_udc / otg_role)

3) nano / etc / network / interfaces
Auto lo
Iface lo inet loopback

# Wired adapter # 1
Auto eth0
Iface eth0 inet dhcp

Allow-hotplug usb0
Iface usb0 inet static
Hwaddress ether 82: bc: 09: 47: 28: a9
Address 192.168.172.2
Netmask 255.255.255.0
Pre-up / bin / sh -c 'echo 2> / sys / bus / platform / devices / sunxi_usb_udc / otg_role'

 

Did I miss something? After 1 point, I prescribe the command lsmod and see g_ether, but after the reboot there is no this module and use ifconfig-a i dont see usb0

Link to comment
Share on other sites

  • Igor unpinned this topic
Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines