EBC Exercise 02 Out-of-the-Box, Bone
Embedded Linux Class by Mark A. Yoder
These instructions are for the 3.8 and newer kernels. EBC Exercise 02 Out-of-the-Box, Bone 3.2 Kernel has instructions for the 3.2 kernel.
- 1 Local Internet Connection, Cloud 9
- 2 Internet Connection to the Outside World
- 2.1 Linux
- 2.1.1 Setting up VirtualBox
- 2.1.2 See your networks with ip a
- 2.1.3 ssh and changing the password
- 2.1.4 Setting up shortcuts to make life easier
- 2.1.5 Setting up a root login
- 2.1.6 Set Up Git
- 2.1.7 Make Room for Files
- 2.1.8 Get the Files
- 2.1.9 Running ipMasquerade.sh
- 2.1.10 Troubleshooting
- 2.2 OS X
- 2.3 Windows 7
- 2.1 Linux
Local Internet Connection, Cloud 9
One of the slickest features of the Bone is its ability to access the Internet through the USB (tether) connection. Plug a USB cable into your bone and plug the other end into your host computer and wait for the Bone to boot up. Once the lights settle down to a heartbeat pattern, point a browser on your host computer to 192.168.7.2. Here you will see the Cloud 9 IDE (integrated development environment).
This is being served up by the Bone over a local internet connection. Go and explore it.
Internet Connection to the Outside World
Once the Bone can connect to the host, the host can be used for forward requests from the Bone to the Internet. Follow the instructions below to set up your host and Bone so the bone can access the internet through your host.
Setting up VirtualBox
If you are running a virtual machine make sure the guest OS (Ubuntu) has captured the USB from the host OS (Windows).
EBC_Exercise_01_Start_Here#The_Linux_host_computer shows how to install Guest Additions on VirtualBox. Once installed
be sure to capture the USB by going to
Devices:USB and select the Beagle. Then go to
Click on the Add icon on the right and check the Beagle. This will make it permanent.
See your networks with ip a
host$ ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: enp0s25: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 54:ee:75:19:8d:53 brd ff:ff:ff:ff:ff:ff inet 10.0.4.102/24 brd 10.0.4.255 scope global dynamic noprefixroute enp0s25 valid_lft 84299sec preferred_lft 84299sec inet6 fe80::e6d0:8d85:4488:6b5f/64 scope link noprefixroute valid_lft forever preferred_lft forever 5: wlp3s0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000 link/ether 28:b2:bd:03:68:d0 brd ff:ff:ff:ff:ff:ff 6: gpd0: <POINTOPOINT,MULTICAST,NOARP> mtu 1400 qdisc fq_codel state DOWN group default qlen 500 link/none inet 184.108.40.206/32 scope global gpd0 valid_lft forever preferred_lft forever 28: enx1cba8ca2ed6d: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 1c:ba:8c:a2:ed:6d brd ff:ff:ff:ff:ff:ff inet 192.168.6.1/24 brd 192.168.6.255 scope global dynamic noprefixroute enx1cba8ca2ed6d valid_lft 932sec preferred_lft 932sec inet6 fe80::3ad0:6711:a2ec:50f0/64 scope link noprefixroute valid_lft forever preferred_lft forever 29: enx1cba8ca2ed6b: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UNKNOWN group default qlen 1000 link/ether 1c:ba:8c:a2:ed:6b brd ff:ff:ff:ff:ff:ff inet 192.168.7.1/24 brd 192.168.7.255 scope global dynamic noprefixroute enx1cba8ca2ed6b valid_lft 1125sec preferred_lft 1125sec inet6 fe80::cd04:f44f:cf68:f98a/64 scope link noprefixroute valid_lft forever preferred_lft forever
Note the name associated with the local connection between you Linux host and the Internet. In my case it's enp0s25. We'll use it later.
ssh and changing the password
You'll see two new networks have appeared, enx1cba8ca2ed6d and enx1cba8ca2ed6b 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. The default password is temppwd.
host$ ssh firstname.lastname@example.org bone$
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.
Take a look around. What do you find?
Since everyone knows the default password, change it to something else.
bone$ passwd Changing password for debian. (current) UNIX password: Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully
The only problem is, the Beagle doesn't know how to access the Internet through the host. Get back to the host computer:
Setting up shortcuts to make life easier
We'll be ssh'ing from the host to the bone often, here are some shortcuts I use so instead of typing ssh email@example.com and a password every time. I can enter ssh bone and no password.
First edit /etc/hosts and add a couple of lines.
host$ sudo nano /etc/hosts
You may use whatever editor you want. I suggest nano since it's easy to figure out. Add the following to the end of /etc/hosts and quit the editor.
192.168.7.2 bone 192.168.8.1 bone2
Now you can connect with
host$ ssh debian@bone
Let's make it so you don't have to enter debian. On your host computer, put the following in ~/.ssh/config (Note: ~ is a shortcut for your home directory.)
Host bone User debian UserKnownHostsFile /dev/null StrictHostKeyChecking no Host bone2 User debian UserKnownHostsFile /dev/null StrictHostKeyChecking no
These say that whenever you login to bone or bone2, login as debian. Now you can enter.
host$ ssh bone
One last thing, let's make it so you don't have to add a password. Back to your host.
Accept all the defaults and then
host$ ssh-copy-id bone
Now all you have to enter is
host$ ssh bone
and no password is required. If you, especially virtual machine users, get an error says "sign_and_send_pubkey: signing failed: agent refused operation", you can solve this by entering
which adds the private key identities to the authentication agent. Then you should be able to
host$ ssh bone
Setting up a root login
By default the image we are running doesn't allow a root login. You can always sudo from debian, but sometimes it's nice to login as root. Here's how to setup root so you can login from your host without a password.
host$ ssh bone bone$ sudo bash root@bone# nano /etc/ssh/sshd_config
Search for the line
and change it to
(The # symbol indicates a comment and must be removed in order for the setting to take effect.)
Save the file and quit the editor. Restart ssh so it will reread the file.
root@bone# systemctl restart sshd
And assign a password to root.
Now open another window on your host computer and enter:
host$ ssh-copy-id root@bone
and enter the root password. Test it with:
host$ ssh root@bone
You should be connected without a password. Now go back to the Bone and turn off the root password access.
root@bone# nano /etc/ssh/sshd_config
Restore the line:
and restart sshd.
root@bone# systemctl restart sshd root@bone# exit bone$ exit
You should now be able to got back to your host computer and login as root on the bone without a password.
host$ ssh root@bone
You have access to your bone without passwords only from you host computer. Try it from another computer and see what happens.
Set Up Git
We need to run some files that are in the class git repository. We'll learn more about using git later. Here I'll just show you how to get the files. Here we are installing these files on your host computer, later we'll install them on your Beagle.
On my host computer I had to run
host$ sudo apt update host$ sudo apt install git
Make Room for Files
Connect to your Beagle and see how much free disk space you have:
host$ ssh bone bone$ df -h Filesystem Size Used Avail Use% Mounted on udev 215M 0 215M 0% /dev tmpfs 49M 1.6M 47M 4% /run /dev/mmcblk0p1 7.4G 3.7G 3.4G 53% / tmpfs 243M 0 243M 0% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 243M 0 243M 0% /sys/fs/cgroup tmpfs 49M 0 49M 0% /run/user/1000
/dev/mmcblk0p1 has some 7.4G and 3.4G is still available. You probably have just shy of 4G and not much available. What's going on here? You should have a least an 8G card, but 8G isn't showing up? It turns out the image you downloaded was for a 4G card, so it isn't set up to use you whole memory card. The solution is one command away.
This will grow your partition to fill your whole card. A reboot is necessary:
host$ ssh bone bone$ df -h
and you should see plenty of disk space.
Get the Files
It only takes one command to pull down all the files.
host$ git clone https://github.com/MarkAYoder/BeagleBoard-exercises.git exercises --depth=1
(The whole repo is some 1013M. Using --depth=1 you only get the recent history and it only takes 200M.)
This will take a while since it's getting all the course files, including pdf files of the course PowerPoint.
Now that the files are installed, run:
host$ cd exercises/setup host$ ./ipMasquerade.sh enp0s25
Plug in for enp0s25 whatever is returned when you run ip a earlier. This will give you instructions on how to set up your host. Note: If you are using a wireless connection you should use
host$ ./ipMasquerade.sh wlp16s0
where wlp16s0 is what is returned by ip a for your wireless connection on your host.
Once ./ipMasquerade.sh has been run you can:
Now you should have network access on the Bone.
bone$ ping -c2 google.com
You should see Google responding.
Congratulations! Your Beagle is now on the network through your host computer.
You will have to run ipMasquerade.sh only after rebooting your host computer and run firstssh.sh after rebooting your bone. Once firstssh has be run you should ssh from your host with the standard ssh command.
If you get an unknown host response when attempting to ping google.com, and you are off campus, try pinging the Google DNS by IP address. Run:
bone$ ping 220.127.116.11
If you are on campus, run:
bone$ ping 18.104.22.168
If you now see responses by pinging a specific IP, 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
If you continue to have problems with firstssh.sh and receive errors regarding the network manager command line tool (nmcli) such as:
mv: cannot stat '/etc/resolv.conf'
nmcli failed, trying older 'list' instead of 'show' nmncli failed again, giving up. . .
then you may have success with the following solution.
Access your bone with ssh bone and check to see which network interface is tethered to your host. It should be usb0, already assigned the ip address of 192.168.7.2. If so, simply enter the following in the command line:
bone$ route add default gw 192.168.7.1
Now return to your host machine and check what your internet facing interface is. It should be some eno interface for a wired connection or wlp interface for wireless. Your Bone should be on one of the usb ports, starting with enx and showing an ip address for your host machine of 192.168.7.1. The example commands below will use wlp in place of the internet facing interface and enx in place of the Bone interface.
host$ iptables --table nat --append POSTROUTING --out-interface wlp -j MASQUERADE host$ iptables --append FORWARD --in-interface enx -j ACCEPT host$ echo 1 > /proc/sys/net/ipv4/ip_forward
You should now ssh into your Bone and see if the routing change has worked. These commands are essentially what the ipMasquerade.sh and firstssh.sh scripts already do, but I started to encounter problems with them and had more success performing the operations manually.
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 bone$ udhcpc -i usb0 bone$ 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)
- Return to Change adapter settings
- Right click your Bone's internet connection and go to Properties
- Select Internet Protocol Version 4 (TCP/IPv4) and choose Properties
- Choose Obtain an IP address automatically and Obtain DNS server address automatically
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:
bone$ echo "nameserver 22.214.171.124" > /etc/resolv.conf bone$ echo "nameserver 126.96.36.199" >> /etc/resolv.conf bone$ /sbin/route add default gw 192.168.7.1 bone$ ping google.com
If 'ping:unknown host google.com' occurs, run this instead:
bone$ echo "nameserver 188.8.131.52" > /etc/resolv.conf bone$ /sbin/route add default gw 192.168.7.1 bone$ 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