[beagleboard] g_ether automatic IP configuration

1,044 views
Skip to first unread message

Marcel Laurijsse

unread,
May 25, 2010, 9:37:25 AM5/25/10
to Beagle Board
Hello,

I want to connect multiple beagleboards (running Angstrong) to my
laptop (windows) and access them using a usb link. G_ether module is
loaded automatically and drivers on my laptop are working. But the
problem is I've to configure a static ip-address (using serial port)
every time I connect the beagleboard.

I've tried configuring the IP address when booting, prior and after
the g_ether module is loaded, but these settings are reset when the
usb cable is plugged in

Plugging in the usb cable before booting won't work since the BB
crashes on boot.

I've tried configuring the g_ether module, but could only find ways to
set MAC address and vendor specifications.

I've also tried using udev, but plugging in usb didn't generate an
udev event.

Does anyone know a way to set the IP address after connecting the usb
cable?

Thanks in advance,

Marcel

--
You received this message because you are subscribed to the Google Groups "Beagle Board" group.
To post to this group, send email to beagl...@googlegroups.com.
To unsubscribe from this group, send email to beagleboard...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/beagleboard?hl=en.

Michael Evans

unread,
May 25, 2010, 3:52:17 PM5/25/10
to beagl...@googlegroups.com
There's a number of problems you'll hit doing this (especially trying to get it to be done automagically).  First of all you should have a quick re-read of TCP/IP subnetting as each BeagleBoard will need to sit on a separate network with no overlaps.  Second you need to configure the BeagleBoards and the host's usb network interfaces so that the BeagleBoard and the *appropriate* host side usb interface are on the same network.  The main problem comes if you connect the boards in a different order each time as usb0 on the host can change...
 
The static IP address configuration is kept in /etc/network/interfaces on most distros including Angstrom and Ubuntu, so:
 
On BeagleBoard 1 put/edit these entries in /etc/network/interfaces:
auto usb0
iface usb0 inet static
        address 192.168.100.1
        netmask 255.255.255.252
        network 192.168.100.0
        gateway 192.168.100.2
 
On BeagleBoard 2 put/edit these entries in /etc/network/interfaces:
auto usb0
iface usb0 inet static
        address 192.168.100.5
        netmask 255.255.255.252
        network 192.168.100.4
        gateway 192.168.100.6
 
On the host PC put/edit these entries in /etc/network/interfaces:
auto usb0
iface usb0 inet static
        address 192.168.100.2
        netmask 255.255.255.252
        network 192.168.100.0
auto usb1
iface usb1 inet static
        address 192.168.100.6
        netmask 255.255.255.252
        network 192.168.100.4
 
Then connect BeagleBoard 1 and check both computer's have the right ip address configuration (ifconfig -a).  Make sure you can ping each address from each computer.  Then connect BeagleBoard 2 and redo the checks to make sure everything is set up right.  If you need to add more BeagleBoards then add 4 to each of the IP addresses to get to the next mini subnet.

If you have a lot of BeagleBoards to connect then you can use DHCP to automate the assignment of IP addresses.  That way all the BeagleBoards can use a single generic image.  However, I've found this to be somewhat unreliable (because the BeagleBoard sends out a dhcp request before the host's new usb interface is ready).  To get it working I needed to create a bridge and change the ifup/ifdown scripts to plumb the new usb interfaces into the br0 interface and have dhcpd listening to br0.
 
All of this is from my head so some of my IP addressing/masks could well be wrong.  Finally, if you want the BeagleBoards to be able to talk to each other as well as the host computer then you'll need to enable IP forwarding / routing on the host and probably change the firewall to enable the relevant traffic.  (Do a google for "linux IP routing" for more info).
 
> Date: Tue, 25 May 2010 06:37:25 -0700
> Subject: [beagleboard] g_ether automatic IP configuration
> From: gen...@gmail.com
> To: beagl...@googlegroups.com

Get a new e-mail account with Hotmail - Free. Sign-up now.

fabio ferrario

unread,
May 25, 2010, 4:14:14 PM5/25/10
to beagl...@googlegroups.com
Hi this works pretty well I use it to mount my host pc shares.
On the other hand I never had luck in bridging the usb network to the ethernet, so that the beagle eventually connects to the internet. I must be missign something..
Can you help me?

Fabio

Daniel Poirot

unread,
May 25, 2010, 5:05:11 PM5/25/10
to beagl...@googlegroups.com
On Tue, May 25, 2010 at 2:52 PM, Michael Evans <horse...@hotmail.com> wrote:


> If you have a lot of BeagleBoards to connect then you can use DHCP to
> automate the assignment of IP addresses.  That way all the BeagleBoards can
> use a single generic image.  However, I've found this to be somewhat
> unreliable (because the BeagleBoard sends out a dhcp request before the
> host's new usb interface is ready).  To get it working I needed to create a
> bridge and change the ifup/ifdown scripts to plumb the new usb interfaces
> into the br0 interface and have dhcpd listening to br0.


...so what happens if you configure the g_ether device directly into
the kernel and avoid the absurd loading of the module nonsense?

(ah, the good old days of sysgen)

Windows doesn't know what to do with the USB Composite Gadget so that
has to go first.

Once you get into it, one would think that a statically configured
kernel would be more predictable anyway...

- dan

Daniel Poirot

unread,
May 25, 2010, 5:14:31 PM5/25/10
to beagl...@googlegroups.com
On Tue, May 25, 2010 at 3:14 PM, fabio ferrario <ferra...@gmail.com> wrote:
> Hi this works pretty well I use it to mount my host pc shares.
> On the other hand I never had luck in bridging the usb network to the
> ethernet, so that the beagle eventually connects to the internet. I must be
> missign something..
> Can you help me?
>
> Fabio

What is missing is that the host is typically not routing.

The Beagleboard needs a route through the host and then to the same
default gateway used by the host.

'netstat -rn' is your friend.


...don't forget that the Angstrom distribution is also running the X
server on the VNC port.

It is really cool to run the BB from one USB cable for power, network
and display...

- dan

fabio

unread,
May 26, 2010, 3:55:34 AM5/26/10
to beagl...@googlegroups.com
Let me understand :

on the PC I'll add a bridge that bridges the say 192.168.4.1 (host PC
usb_g) to the ethernet 192.168.0.46 (host PC eth0), brctl will help.
My beagle will be 192.168.4.100 and the beagle routing table will have a
default gateway entry that is 192.168.0.46.
Will this work?

Thanks

Fabio

Michael Evans

unread,
May 26, 2010, 5:24:12 AM5/26/10
to beagl...@googlegroups.com
Nope - you are mixing bridging and routing.  Bridging connects two bits of the same network whereas routing is used to connect different networks together.  Technically either could be used in your situation.  The best solution in this case would be to use routing with address translation.  Have a look here: http://www.linux-magazine.com/Online/Blogs/Beagleblog/Connecting-to-the-world
 
> Subject: Re: [beagleboard] g_ether automatic IP configuration
> From: ferra...@gmail.com
> To: beagl...@googlegroups.com
> Date: Wed, 26 May 2010 09:55:34 +0200
> --
> You received this message because you are subscribed to the Google Groups "Beagle Board" group.
> To post to this group, send email to beagl...@googlegroups.com.
> To unsubscribe from this group, send email to beagleboard...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/beagleboard?hl=en.
>


Get a free e-mail account with Hotmail. Sign-up now.

Michael Evans

unread,
May 26, 2010, 5:32:29 AM5/26/10
to beagl...@googlegroups.com

> ...so what happens if you configure the g_ether device directly into
> the kernel and avoid the absurd loading of the module nonsense?

> Once you get into it, one would think that a statically configured
> kernel would be more predictable anyway...

Its just quicker by a few milliseconds as the module doesn't need to be loaded from disk.  Its more reliable as you can't get confused with incorrect module versions but then the cost is that it is less flexible as you can't change the USB-OTG behaviour without a recompile and reboot.

Marcel Laurijsse

unread,
May 26, 2010, 9:34:29 AM5/26/10
to Beagle Board
Thanks for all the info, but my main question isn't answered yet. So
let me rephrase it.

I've loads of experience with networking and bridging or basic routing
in windows XP on my host pc is quite easy. Last time I've worked with
Linux was around ten years ago, so these skills might lack a little.

DHCP works sometimes, but isn't really reliable, hence I want to use
static IP's.

I've configured /etc/default/usb-gadget so g_ether loads and
beagleboard works with windows xp

I've configured /etc/network/interfaces:
iface usb0 inet static
address 192.168.0.11
netmask 255.255.255.0
network 192.168.0.0
gateway 192.168.0.1


Before plugging in usb:
ifconfig:
lo .....(nothing special here so I skipped it)
usb0 Link encap:Ethernet HWaddr 00:00:00:00:00:10
UP BROADCAST RUNNING 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 b) TX bytes:0 (0.0 b)

After plugging in usb:
[ 1161.503417] g_ether gadget: high speed config #2: RNDIS
[ 1161.509063] ADDRCONF(NETDEV_CHANGE): usb0: link becomes ready

and ifconfig:
lo ...
usb0 Link encap:Ethernet HWaddr 00:00:00:00:00:10
inet6 addr: fe80::200:ff:fe00:10/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:18 errors:0 dropped:0 overruns:0 frame:0
TX packets:2 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:824 (824.0 b) TX bytes:748 (748.0 b)
(so no ipv4 is configured)

After ifup usb0:
ifconfig:
lo ......
usb0 Link encap:Ethernet HWaddr 00:00:00:00:00:10
inet addr:192.168.0.11 Bcast:192.168.0.255 Mask:
255.255.255.0
inet6 addr: fe80::200:ff:fe00:10/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:54 errors:0 dropped:0 overruns:0 frame:0
TX packets:18 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:4682 (4.5 KiB) TX bytes:6347 (6.1 KiB)

So now everything works fine, but I don't like to run ifup usb0
manually everytime I reboot or reconnect a BB because I have to
connect the BB to the serial port to do so. I want this step
"automated", how do I configure this?


Michael Evans

unread,
May 26, 2010, 10:58:10 AM5/26/10
to beagl...@googlegroups.com
You need "auto usb0" in /etc/network/interfaces to have the interface come up automatically.
 
> Date: Wed, 26 May 2010 06:34:29 -0700
> Subject: [beagleboard] Re: g_ether automatic IP configuration
> From: gen...@gmail.com
> To: beagl...@googlegroups.com
>
> --
> You received this message because you are subscribed to the Google Groups "Beagle Board" group.
> To post to this group, send email to beagl...@googlegroups.com.
> To unsubscribe from this group, send email to beagleboard...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/beagleboard?hl=en.
>


Marcel Laurijsse

unread,
May 26, 2010, 7:06:06 PM5/26/10
to Beagle Board
> You need "auto usb0" in /etc/network/interfaces to have the interface come up automatically.


Also tried that, but didn't work. When booting, the network interfaces
are configured before g_ether module is loaded, so the device doesn't
exist yet. It would also be possible to configure usb0 after g_ether
module is loaded, but when plugging in the usb-cable, the
configuration of usb0 is reset en ip-address is loss.

Michael Evans

unread,
May 27, 2010, 4:40:12 AM5/27/10
to beagl...@googlegroups.com
Hmmm... it works for me using the latest Angstrom.  I've had similar race conditions during boot in the past which were hacked/fixed by using an rc.local script to run the relevant commands.  If things still aren't ready in time for rc.local then just stick a sleep statement in there.

> Date: Wed, 26 May 2010 16:06:06 -0700

> Subject: [beagleboard] Re: g_ether automatic IP configuration
> From: gen...@gmail.com
> To: beagl...@googlegroups.com
>
> --
> You received this message because you are subscribed to the Google Groups "Beagle Board" group.
> To post to this group, send email to beagl...@googlegroups.com.
> To unsubscribe from this group, send email to beagleboard...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/beagleboard?hl=en.
>


Marcel Laurijsse

unread,
May 27, 2010, 12:14:50 PM5/27/10
to Beagle Board
Disabling NetworkManager and connman did the job :)

On May 27, 10:40 am, Michael Evans <horse_d...@hotmail.com> wrote:
> Hmmm... it works for me using the latest Angstrom.  I've had similar race conditions during boot in the past which were hacked/fixed by using an rc.local script to run the relevant commands.  If things still aren't ready in time for rc.local then just stick a sleep statement in there.
>
>
>
>
>
> > Date: Wed, 26 May 2010 16:06:06 -0700
> > Subject: [beagleboard] Re: g_ether automatic IP configuration

> > From: gent...@gmail.com


> > To: beagl...@googlegroups.com
>
> > > You need "auto usb0" in /etc/network/interfaces to have the interface come up automatically.
>
> > Also tried that, but didn't work. When booting, the network interfaces
> > are configured before g_ether module is loaded, so the device doesn't
> > exist yet. It would also be possible to configure usb0 after g_ether
> > module is loaded, but when plugging in the usb-cable, the
> > configuration of usb0 is reset en ip-address is loss.
>
> > --
> > You received this message because you are subscribed to the Google Groups "Beagle Board" group.
> > To post to this group, send email to beagl...@googlegroups.com.
> > To unsubscribe from this group, send email to beagleboard...@googlegroups.com.
> > For more options, visit this group athttp://groups.google.com/group/beagleboard?hl=en.
>

> _________________________________________________________________http://clk.atdmt.com/UKM/go/195013117/direct/01/
> We want to hear all your funny, exciting and crazy Hotmail stories. Tell us now

Reply all
Reply to author
Forward
0 new messages