Connecting CHIP to your network over USB


#1

I am experimenting with the USB ethernet gadget and I though I would share how to connect multiple CHIPs to your home network using the USB ethernet gadget instead of the WiFi. My CHIPs are running version 4.4, the ethernet gadget is not enabled in 4.3.

You will need to connect your CHIPs to USB ports on your Linux computer. After they boot up, you should get an ethernet interface from each of them. You can run ifconfig to list the interfaces on your computer.

Now you need to create a bridge. On your computer run:
brctl addbr br0
This creates a bridge interface named “br0”.

Next, add each interface (your computer & CHIPs) to the bridge with:
brctl addif br0 eth0
Where “eth0” is the name of the interface you want to add to the bridge.

In my case, I ran this with “eth1”, which is the my computers ethernet connection and “eth3” & “eth4” which is the names of the USB ethernet adapters from my CHIPs.

Now assign an IP address to the bridge:
ifconfig br0 192.168.1.123 netmask 255.255.0.0
192.168.1.123 should be a free IP address on your network that’s not in your routers DHCP pool and 255.255.0.0 should be a suitable subnet mask for your network.

Now, you will probably not have internet access on your computer because the default route has not set correctly, to fix that, run:
route add default gw 192.168.1.1
192.168.1.1 should be the IP address of your router.

Now you need to setup the network connections on your CHIPs.
If you have a GUI up on them, you can setup the connections with the network manager applet.
If you don’t want to use the GUI, then on each CHIP, run:
nmcli connection add type ethernet con-name USB_Bridge ifname usb0
nmcli connection up USB_Bridge
This creates a new DHCP connection and connects it.

Now your CHIPs should be connected to the network. They should have internet access over the USB port and you should be able to access them from any device on your network.

I ran a benchmark with iperf between two CHIPs and get about 11MB/s each way and 7-10MB/s both ways at the same time. This is quite a bit faster than the WiFi connection, and I haven’t had it drop a connection yet.

To shutdown the bridge, on your computer, run:
ifconfig br0 down
brctl delbr br0


C.H.I.P. Headless 4.4 no brctl
Jumping in the deep end
#2

Yes This what I found on an earlier post .
https://bbs.nextthing.co/t/network-speed-between-c-h-i-p-s/8177?u=danjperron

I did a cluster of Chip and Pi and it was working but because USB can’t run the network like a ethernet switch the speed gain will degrade on every add-on device on the USB port.


#3

Yes, unfortunately the bandwidth is shared between all devices on the same USB controller. You can get a bit more speed by connecting your CHIPs to different USB controllers though.
My desktop has 3 different controllers in it, I could connect two CHIPs to each controller and still get a good speed. Of course there is a limit to how many USB controllers you can have.
If you have more than one computer on your network, you can connect a couple of CHIPs to each one and they will still be able to connect to each other.


#4

What is a use case for this? I’m trying to imagine a reason this would be useful but general tinkering is all I’m coming up with.


#5

It’s faster than WiFi and you don’t have to worry about the connection dropping out.


#6

Yes, I understand that is a benefit of a hard connection vs wireless. What I meant though, is what would be a use for that?

If I have to connect it to an already running machine with a network connection, then why wouldn’t I just use that pc instead? The only useful reason I can think of is to use this to configure the chip if I didn’t have a monitor and keyboard to use with it.


#7

One project I am planning that will use it is a fancy computer case fan and light controller for my desktop.
I will have CHIP and a 5" touch screen mounted in a couple of 5.25" drive bays. It will control fan speeds, RGB case lights, as well as display temperature and system load information. With it being inside a PC case which is basically a faraday cage, the WiFi won’t work well, maybe not at all.
CHIP will already be connected to a USB header on the motherboard, so I might as well use it for the network connection.

This is quite useful where you need some high speed, low level interfaces on your computer such as SPI, SDIO, CSI, or an RGB LCD interface.


#8

That sounds pretty cool.


#9

how can i ssh to a chip through usb? i cant conect :-/


#10

Did you configure everything on both CHIP and your PC?
You should be able to SSH in once you setup the connection.


#11

i don’t know how to configure any of both. at laptop i think it take automatic configuration, but in chip, i dont know if is just config or something else,

could you iluminate to me about config ??


#12

If you just want a simple connection for SSH without a connection to the rest of your network, do this:

To setup your laptop:

  1. Right click the network icon & click “Edit Connections”
  2. Click “Add”
  3. Select “Ethernet” & click “Create”
  4. Set a connection name. Something like “CHIP” will do.
  5. Select CHIPs ethernet adaptor in the “Device MAC address” dropdown.
  6. Go to the “IPv4 Settings” tab.
  7. Select “Manual” in the “Method” dropdown.
  8. Click “Add”.
  9. Enter an address of “10.0.0.1”, a netmask of “24”, & a gateway of “10.0.0.1”
  10. Click Routes, select “Use this connection only for resources on its network”, then click “OK”
  11. Click “Save”

To setup CHIP:
Do the same thing on CHIP as you did with your laptop, but use “10.0.0.2” for the address.

Then you can just run ssh chip@10.0.0.2 on your laptop to ssh into CHIP.
By default the MAC address for CHIPs USB ethernet adapter will be chosen randomly each time you reboot. You can fix that by putting options g_ether dev_addr=cc:79:cf:23:d3:b6 host_addr=cc:79:cf:23:d3:b7 in /etc/modprobe.d/g_ether.conf


#13

Thank you very much.
On my mac it was very easy to setup.
Just run the commands

nmcli connection add type ethernet con-name USB_Bridge ifname usb0
nmcli connection up USB_Bridge

On the chip and share the internet connection on my MACs share settings.
Thanks!


#14

@dsnielo515. Thanks.
can you please elaborate on the steps to share the settings?

and share the internet connection on my MACs share settings.

i am getting the following error

chip@chip:~$ sudo nmcli connection up USB_Bridge
Error: Timeout 90 sec expired.

regards
Vijay


#15

Is there a way to do this on a windows computer easily?


#16

Also wondering if there’s a way to get this working under windows?


#17

You can go back to 4.3 and load g_ether. (Disable g_serial) No way to do Windows in 4.4.


#18

Hi,
What if I want to do the opposite ?
Can I use the CHIP has a tethering device connected over wifi ?


#19

Of course. That would be the normal use case.


#20

I’ve tried to create a bridge connection on CHIP with:
nmcli connection add type bridge con-name USB_Bridge ifname br0
and I tried nmcli connection up USB_Bridge I received an error:
_Error: Connection activation failed: Failed to create virtual interface_

Does anyone have a clue about where I got it wrong pls ? :confused: