EBC Exercise 02 Out-of-the-Box, Bone
Embedded Linux Class by Mark A. Yoder
These instructions are for the 3.8 kernel. EBC Exercise 02 Out-of-the-Box, Bone 3.2 Kernel has instructions for the 3.2 kernel.
We'll be running the 3.8 kernel, check out these instructions for getting started. Then come back here to get your network set up.
One of the slickest features of the Bone is its ability to access the Internet through the USB (tether) connection. You should have already used it following the instructions above. Below shows how to set up your host and Bone so the bone can access the internet through your host.
host$ ifconfig eth0 Link encap:Ethernet HWaddr 00:18:8b:72:b8:c2 inet addr:188.8.131.52 Bcast:184.108.40.206 Mask:255.255.255.0 inet6 addr: fe80::218:8bff:fe72:b8c2/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:8481193 errors:0 dropped:0 overruns:0 frame:0 TX packets:1871287 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:3172154531 (3.1 GB) TX bytes:203188180 (203.1 MB) Interrupt:19 eth4 Link encap:Ethernet HWaddr d4:94:a1:39:ff:ff inet addr:192.168.7.1 Bcast:192.168.7.3 Mask:255.255.255.252 inet6 addr: fe80::d694:a1ff:fe39:ffff/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:8 errors:0 dropped:0 overruns:0 frame:0 TX packets:6 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:2775 (2.7 KB) TX bytes:1234 (1.2 KB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:37315 errors:0 dropped:0 overruns:0 frame:0 TX packets:37315 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:3665320 (3.6 MB) TX bytes:3665320 (3.6 MB)
You'll see a new network has appeared, eth4 in my case. The IP address of your host is 192.168.7.1. There's a good chance the Bone is at 192.168.7.2. Try connecting to it.
host$ ssh -X firstname.lastname@example.org beagle$
You are now logged into the Bone through the network. This is much faster than the serial port (.115M vs. 100M) and supports many interesting network operations. The only problem is, the Beagle doesn't know how to access the Internet through the host. Get back to the host computer by entering RETURN ~ ^Z. That is, hit RETURN, then ~ (it's up there near the ESC key) and then Ctrl-Z. This gets you back to your host, but leaves the ssh connection running.
Copy the following lines into a file call host.ipForward.sh
#!/bin/bash # These are the commands to run on the host to setup IP masquerading so the Beagle # can access the Internet through the USB connection. # Inspired by http://thoughtshubham.blogspot.com/2010/03/internet-over-usb-otg-on-beagleboard.html if [ $# -eq 0 ] ; then echo "Usage: $0 interface (such as eth0 or wlan0)" exit 1 fi interface=$1 hostAddr=192.168.7.1 beagleAddr=192.168.7.2 ip_forward=/proc/sys/net/ipv4/ip_forward if [ `cat $ip_forward` == 0 ] then echo "You need to set IP forwarding. Edit /etc/sysctl.conf using:" echo "$ sudo gedit /etc/sysctl.conf" echo "and uncomment the line \"net.ipv4.ip_forward=1\"" echo "to enable forwarding of packets. Then run the following:" echo "$ sudo sysctl -p" exit 1 else echo "IP forwarding is set on host." fi # Setup IP masquerading on the host sudo iptables -t nat -A POSTROUTING -s 192.168.0.0/16 -o $interface -j MASQUERADE # Check to see what nameservers the host is using and copy these to the same # file on the Beagle # This makes it so you can connect to the Beagle without using your password. ssh-copy-id root@$beagleAddr # Save the /etc/resolv.conf on the Beagle in case we mess things up. ssh root@$beagleAddr "mv -n /etc/resolv.conf /etc/resolv.conf.orig" # Copy the resolv.conf file to the Beagle. Now the Beagle will use the # same name servers as the host. cat - << EOF > /tmp/resolv.conf # This is installed by host.ipForward.sh on the host # Mark A. Yoder, 25-Aug-2013 search rose-hulman.edu dhcp.rose-hulman.edu wlan.rose-hulman.edu EOF # Use the campus name servers if on compus, otherwise use the Google name servers if ifconfig | grep "addr:137.112."; then cat - << EOF >> /tmp/resolv.conf nameserver 220.127.116.11 nameserver 18.104.22.168 nameserver 22.214.171.124 EOF else cat - << EOF >> /tmp/resolv.conf nameserver 126.96.36.199 nameserver 188.8.131.52 EOF fi scp /tmp/resolv.conf root@$beagleAddr:/etc # Tell the beagle to use the host as the gateway. ssh root@$beagleAddr "/sbin/route add default gw $hostAddr"
host$ chmod +x host.ipForward.sh host$ ./host.ipForward.sh eth0
This will give you instructions on how to set up your host and will remotely set up your Beagle. Note: If you are using a wireless connection you should use
host$ ./host.ipForward.sh wlan0
Once ./host.ipForward.sh has been run you can:
host$ fg ssh -X email@example.com (Hit RETURN) beagle$ ping google.com
You should see Google responding. Hit Ctrl-C to stop.
Congratulations! Your Beagle is now on the network through your host computer.
If you get an unknown host response when attempting to ping google.com, try pinging the Google DNS by IP address. Run:
beagle$ ping 184.108.40.206
If you now see responses, it is possible that a firewall on your host computer is blocking the Beagle's access to the DNS when attempting to ping by domain name. On Ubuntu/Mint, run:
host$ sudo ufw disable Firewall stopped and disabled on system startup
You should get a response, such as above, that the firewall will be disabled upon next startup. After saving anything important, restart your host through the start menu or run:
Repeat this exercise and attempt to ping Google by domain name again. If you now receive responses, then the firewall was indeed the issue. Otherwise, the internet is your friend. Use your host computer to try and find a solution. Feel free to add solutions here when you find them
I haven't checked these instructions this year. Please report your results and update if needed.
- go to System Preferences and select Network
- You should see RNDIS/...Gadget. This is the network connection to the Beagle. Select it
- Wait for the IP address 192.168.7.1 to appear
- Click Show All and select Sharing
- Select Internet Sharing
- Select RNDIS/Ethernet Gadget
In a terminal window connect to the serial port
host$ screen /dev/ttyusb*B 115200 beagle$ udhcpc -i usb0 beagle$ ping google.com
This is all nicely shown here in this silent YouTube movie.
Congratulations, you now have a connection from your BeagleBone to the Internet.
I haven't checked these either. Please report results and update if needed.
There are several ways of running ssh on Windows 7. Below are a couple of tools that you can use.
You can either run ssh from a bash terminal (i.e. C:\Program Files\Git\Git Bash or C:\cygwin\Cygwin.bat), or you can add the bin directories to your path and run from the Windows command prompt (i.e. add C:\Program Files\Git\bin or C:\cygwin\bin to your path).
Note: Be careful adding multiple bin directories to your path
First time setup
- Run regedit
- Navigate to Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Tcpip\Parameters
- Change IPEnableRouter from 0 to 1
- Close regedit
- Run services
- Make sure the following are set to Automatic and are started
- Routing and Remote Access
- Internet Connection Sharing (ICS)
Connecting to the Internet
- Navigate to Control Panel\Network and Internet\Network and Sharing Center\Change adapter settings
- Right click your wired/wireless internet connection and go to Properties
- Go to the Sharing tab
- Check the box to Allow other network users to connect through this computer's Internet connection
- Select your bone's local area connection for the Home networking connection (if you cannot choose the local area connection, turn your internet connection sharing off and then back on)
Open a command prompt or bash terminal and run the following:
host$ ping 192.168.7.2
If this ping times out then disable and re-enable your bone's local area connection and try again. Once it works run the following:
host$ ssh firstname.lastname@example.org
Login as root and run the following:
beagle$ echo "nameserver 220.127.116.11" > /etc/resolv.conf beagle$ echo "nameserver 18.104.22.168" >> /etc/resolv.conf beagle$ /sbin/route add default gw 192.168.7.1 beagle$ ping google.com
If 'ping:unknown host google.com' occurs, run this instead:
beagle$ echo "nameserver 22.214.171.124" > /etc/resolv.conf beagle$ /sbin/route add default gw 192.168.7.1 beagle$ ping google.com
Congratulations, you now have a connection from your BeagleBone through your Linux host to the Internet.
Embedded Linux Class by Mark A. Yoder