Difference between revisions of "EBC Exercise 02 Out-of-the-Box, Bone"

From eLinux.org
Jump to: navigation, search
m (Added 3.2 kernel tag)
m (Added 3.8 instructions)
Line 1: Line 1:
== Kernel 3.8 ==
{{EBC3.8}}If you are running the 3.9 kernel, check out these [http://beagleboard.org/Getting%20Started instructions] for getting started.
== Kernel 3.2 ==
{{EBC3.2}}'''These instructions are for the 3.2 kernel.'''
{{EBC3.2}}'''These instructions are for the 3.2 kernel.'''

Revision as of 18:01, 27 May 2013

thumb‎ Embedded Linux Class by Mark A. Yoder

Kernel 3.8

3.8 Kernel

If you are running the 3.9 kernel, check out these instructions for getting started.

Kernel 3.2

3.2 Kernel‎

These instructions are for the 3.2 kernel.

The BeagleBone can do many neat things right out of the box using just the USB cable and SD card that come with it. Before hooking up anything, if you are running Linux or OSX on your host computer, open a terminal at run:

host$ ls /dev/tty* > /tmp/tty

This will record what devices are present on you host computer. Once you plug the bone in it will create a new device. Windows users don't have to do anything here.

Install the SD card (not the one that says Linux SDK on it) and attach the Bone to a host computer via the USB cable. The little USB connector goes to the Beagle in the connector on the bottom of the board near the Ethernet connector. Connect the large end of the USB cable to a host computer. The host can be either Linux, Mac, or Windows (though if you are doing development, consider running Linux on the host.) I give instructions for each.

The Beagle, powered via the USB, will boot up. You should initially see two LEDs blinking, near the Ethernet connector. The one labeled 0 blinks a heartbeat pattern. LED 1 blinks when the SD card is being accessed. After about 30 seconds LED 1 will stop blinking. The Bone is booted.

Here are some of the things it can do.

YouTube Introduction

Here's a nice overview of the BeagleBone. It shows how to work with it using a Windows host.

USB Drive

On your host you will notice a new folder appearing. On Linux and OSX it's call BEAGLE_BONE. On Windows it's Beagle Bone Getting Started. Open it up and look around. The README.html gives lots of information about getting going with the Bone. Look at it in detail after going though this page.

When you are doing exploring the files, eject the drive (don't select SAFELY REMOVE DRIVE). Once the drive is ejected, the network will start up over the USB.

Built in USB to serial adapter

The Beagle xM has a serial port connector on board, but the Bone doesn't. Instead you access the serial port through the USB connector. The trick is figuring out how to access it.

Linux, OSX

Run the following:

host$ ls /dev/tty* > /tmp/tty2
host$ diff /tmp/tty*
host$ screen /dev/ttyUSB1 115200   (Linux)
host$ screen /dev/tty.usb*B 115200 (OSX)

The first line lists what devices are out there. The second compares that list to the list made earlier. What appears is the USB to serial device on the Bone. The last line starts a serial port program that attaches to that device. Notice the ttyUSB1 is the same string as returned by the diff command.


To find where the serial port appears in Windows, click on the start menu and search for Device Manager and run it.


Select Ports and look for USB Serial Port. In my case the port appears at COM6.


Start up a ECE497_Tips_and_Tricks#Serial_Port serial port program and connect. The baud rate is 115200.

Logging in

Hit RETURN and you'll see the following. Login as root and look around.

|       |                  .-.           o o        
|   |   |-----.-----.-----.| |   .----..-----.-----.
|       |     | __  |  ---'| '--.|  .-'|     |     |
|   |   |  |  |     |---  ||  --'|  |  |  '  | | | |
'---'---'--'--'--.  |-----------'  '-----'-'-'-'
                -'  |

The Angstrom Distribution beaglebone ttyO0 

Angstrom v2012.01-core - Kernel 3.2.5+

beaglebone login: root
Last login: Fri Jul 13 01:28:06 UTC 2012 on ttyO0

Internet Connection

One of the slickest features of the Bone is it's ability to access the Internet through the USB connection. The network connection starts up after you've ejected the BEAGLE_BONE drive that appears. Do it now.


After ejecting, run:

host$ ifconfig
eth0     Link encap:Ethernet  HWaddr 00:18:8b:72:b8:c2  
         inet addr:  Bcast:  Mask:
         inet6 addr: fe80::218:8bff:fe72:b8c2/64 Scope:Link
         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)

eth4     Link encap:Ethernet  HWaddr d4:94:a1:39:ff:ff  
         inet addr:  Bcast:  Mask:
         inet6 addr: fe80::d694:a1ff:fe39:ffff/64 Scope:Link
         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:  Mask:
         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 at new network has appear, eth4 in my case. The IP address is There's a good chance the Bone is at Try connecting to it.

host$ ssh -X root@

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 things. 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

# 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


if [ `cat $ip_forward` == 0 ]
    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
    echo "IP forwarding is set on host."
# Setup  IP masquerading on the host
sudo iptables -t nat -A POSTROUTING -s -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 /etc/resolv.conf - << EOF > /tmp/resolv.conf
search rose-hulman.edu
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"

Now run:

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 root@
beagle$ ping google.com

You should see Google responding. Hit Ctrl-C to stop.

Note: If you are using Ubuntu 12.04 and having an issue connecting to the internet, you may need to add a line to the /etc/resolv.conf file on the Bone. If ping google.com returns an "unknown host" error, this means that the Bone cannot resolve the url google.com to an IP address. Users with an Ubuntu 12.04 host may see this issue because the resolv.conf that Ubuntu uses (and is copied to the Bone in the host.ipForward.sh script) is not compatible with the Bone. The solution is to run the host.ipForward script as normal, then add the line "nameserver" above the existing entry in /etc/resolv.conf (run "nano /etc/resolv.conf" on the Bone to edit the file). This configures the Bone to use Google's Public DNS Server.

Congratulations! Your Beagle is now on the network through your host computer.


After ejecting

  1. go to System Preferences and select Network
  2. You should see RNDIS/...Gadget. This is the network connection to the Beagle. Select it
  3. Wait for the IP address to appear
  4. Click Show All and select Sharing
  5. Select Internet Sharing
  6. 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 to the Internet.

Windows 7

There are several ways of running ssh on Windows 7. Below are a couple of tools that you can use.


Install msysgit. This is a version of git for Windows based on msys (a unix like shell for Windows) which includes ssh. This solution is simple if all you need to do is connect to your bone.


Install Cygwin. There are many packages that you can install that aren't installed by default:


  1. openssh


  1. make
  2. gcc-core
  3. gcc-g++
  4. gdb
  5. git

This solution is more involved, but it allows you to install development tools.

Environment Setup

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

  1. Run regedit
  2. Navigate to Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Tcpip\Parameters
  3. Change IPEnableRouter from 0 to 1
  4. Close regedit
  5. Run services
  6. Make sure the following are set to Automatic and are started
    1. Routing and Remote Access
    2. Internet Connection Sharing (ICS)

Connecting to the Internet

After ejecting

  1. Navigate to Control Panel\Network and Internet\Network and Sharing Center\Change adapter settings
  2. Right click your wired/wireless internet connection and go to Properties
  3. Go to the Sharing tab
  4. Check the box to Allow other network users to connect through this computer's Internet connection
  5. 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

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 root@

Login as root and run the following:

beagle$ echo "nameserver" > /etc/resolv.conf
beagle$ echo "nameserver" >> /etc/resolv.conf
beagle$ /sbin/route add default gw
beagle$ ping google.com

Congratulations, you now have a connection to the Internet.

On the Network

Once you have your Beagle on the network there are many things you can do. Try these from your host.

  • Point your browser to You'll see a nice slide show about the Beagle
  • Point your browser to to see the Cloud9 IDE running on the Beagle

thumb‎ Embedded Linux Class by Mark A. Yoder