Beaglebone Black (BBB) is a very nice single-board PC that offers numerous features. When it comes to building robots that can do nontrivial tasks, it is my first choice. Installing an OS on the BBB and getting it ready to use can be time consuming. By following the simple steps provided in this post, large amounts of time can be saved and devoted instead to development of the software to accomplish the targeted tasks of the robot.
Although BBB comes with a pre-installed copy of the Debian Jessie Linux distribution, ROS developers do not currently build packages for Kinetic Jessie for armhf architecture; they only provide builds for amd64 and arm64 (as mentioned here). However, they have armhf builds for Ubuntu Xenial. Because Ubuntu is my favorite Linux distribution, this was a breeze for me!
I hope this post will help you save some time. Also, please don’t hesitate to share your comments and suggestions to help make this post better. I will be using it as a living document that I will always try to update to reflect best approaches reached.
Installing Ubuntu Xenial on BBB
Using an SD card to flash the eMMC is easy for Windows users. An SD card ≥ 2GB is needed (I used 16GB). I will cover the necessary steps using Windows as this is what I used.
- Get the latest image here.
- Download SD Formatter here or here. You will need to use this if you decide to rewrite the image on the card as you’ll notice that formatting the card the normal way results in a shrunk card size.
- Download Win32 Disk Imager here. You will need this to burn the image onto the SD card.
- Download 7-Zip here. You will need this to extract the .xz compression of the .img file.
Now that you’ve downloaded these files, follow the below steps to prepare your SD card for burning the image to the BBB’s eMMC.
- Use 7-Zip to extract the compressed image. This results a .img file.
- Open Win32 Disk Imager, select your BBB’s drive letter, and select your Ubunutu .img file.
- Once you are done, safely remove the SD card.
I would like to note here that, having read a few articles here and there during the many installs that I’ve done on the BBB, I always had the misconception that connecting the BBB to the USB port of my laptop is not a good idea when running the install and it is better to use 5V adapter for that purpose. THIS IS NOT TRUE. Continue reading to learn what really matters to initiate a successful install.
The important thing to keep in mind when starting to burn the image on the BBB is to do the following:
- Insert the card into the BBB. It doesn’t really matter whether it is on or off.
- Connect the BBB to the USB port of your computer if not connected.
- Press the reset button.
- To tell if an install has been successfully initiated, the four user LEDs should start to light in a sweeping sequence and continue for around 20 minutes.
Sometimes, the sweeping sequence may stop after a couple of minutes and the install will fail. You will know this by observing that the LEDs will all stay on. If this happens, just redo step 3 until the sweeping persists roughly for the amount of time mentioned above.
When the install finishes, the LEDs will light up steadily. You can then remove the SD card and press the restart button.
Congratulations! you have just installed Ubuntu on your BBB.
Connecting to BBB through Putty
The next step is to be able to connect to the BBB through USB. Do the following:
- Get and install Putty from here.
- With the BBB plugged in to the USB port of your computer, browse to your BBB’s drive, find the suitable drivers for your Windows architecture, e.g. 64-bit vs 32-bit and install them.
- Run Putty and enter the IP address 192.168.7.2 in Host Name and 22 in Port.
- Pick a suitable name for your session (e.g. BBB) then click Save.
- With the saved session selected, click Open.
- A terminal will be opened and, if Ubuntu installation was successful, you will be prompted to enter a username.
- Type ubuntu and hit Enter.
- Enter temppwd for the password.
- You are now logged into your embedded Ubuntu instance.
You can display the release info of your Ubuntu instance using the
catcommand as follows:
Connecting your BBB to the Internet through USB
If you try pinging 126.96.36.199 (www.google.com), you will not get any response. This is because the BBB doesn’t know how to connect to the internet through USB. Hitting
Ctrl+c will show that no packets have been received.
To enable internet access through USB on Windows, follow these steps:
1) Bridging your network connection
- Go to Control Panel\Network and Internet\Network Connections.
- Identify the two adapters that represent the connection used by your computer and the one representing the BBB. In my case, these were WiFi and Ethernet 3, respectively. BBB’s connection will contain Linux USB Ethernet/RNDIS Gadget in its device description section of the name.
- Go to the Sharing tab in the properties of the connection used by your computer and check Allow other users to connect through this computer’s internet connection. Next, select BBB’s connection from the dropdown menu.
- Switch to the Networking tab and edit the Properties of Internet Protocol Version 4 (TCP/IPv4) to make sure that IP and DNS server addresses are obtained automatically.
- Repeat the previous step for BBB’s network adapter.
2) Configuring internet connectivity on your BBB
Now that we have created the bridge between the USB connection that connects the BBB to the computer and the one that connects the computer to the internet, it is time to configure the BBB to be able to utilize that bridge.
Switch to Putty and do the following steps:
- Set the default gateway of your BBB to your computer’s IP address by using the command:
sudo /sbin/route add default gw 192.168.7.1
- If you try to ping googe’s IP address (188.8.131.52) now, you should be able to receive packets.
- To be able to use domain names instead of IP address, you need to configure the name servers in your resolve.conf. You can do this by editing that file and adding google’s name servers as follows:
sudo nano /etc/resolv.conf
Add these to the file:
domain localdomain search localdomain nameserver 184.108.40.206 nameserver 220.127.116.11
- If you try to ping www.google.com, you will get a similar response to this:
There is a caveat with this approach:
CAVEAT 1 – Sometimes, the bridged connection can fail and attempting to connect to the internet from the BBB will not work. This can be fixed by unchecking the “Allow other users to connect through this computer’s internet connection” in the Sharing tab of the main connection’s settings then re-applying it and selecting the second connection from the menu.
The other thing to keep in mind is that running the above steps enables internet connectivity only until the BBB is restarted. If you’d like these changes between restarts (the almost certain scenario), you need to add the commands that set the default gateway and name servers to the rc.local file as follows:
- Edit the rc.local file in you favorite editor.
sudo nano /etc/rc.local
- Add the two following lines to the end of the file.
# set default gateway /sbin/route add default gw 192.168.7.1 || exit 1 # append nameservers to the end of the /etc/resolve.conf file # echo "domain localdomain\nsearch localdomain\nnameserver 18.104.22.168\nnameserver 22.214.171.124" > /etc/resolv.conf || exit 2
Installing ROS on Ubuntu on BBB
Now that you are connected to the internet, you can install ROS on your Ubuntu. The following sections show you how to do this and are adapted versions from ROS’s installation instructions on Ubuntu install of ROS Kinetic page.
1) Updating APT Configuration
First you need to configure
apt‘s sources list to allow it to accept packages from all kinds of repositories that Ubuntu recognizes (Main, Universe, Restricted, and Multiverse). This can be done using the following steps:
- Use your favorite text editor to edit the
sudo nano /etc/apt/sources.list
restricted, universe, and multiverseafter
mainto the two entries containing Ubuntu’s release name and updates (
xenial-updatesin my case). These entries represent the URI’s of the binaries or pre-compiled packages for Xenial and its updates.
- Save the file and quit.
Next, ROS’s packages repository URI need to be added to
sources.list. Although this will work, it is better to use the
sources.list.d directory to add dedicated file to list ROS sources. This can be done as follows:
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
This command basically says: run the shell command
echo, plugging in Ubuntu’s release name in the args section of the source’s entry and redirect the standard output to the file ros-latest.list.
The last step of this configuration is to add an authentication key to
apt to make it trust the packages supplied by ROS’s repository. This can be done using this command:
wget http://packages.ros.org/ros.key -O - | sudo apt-key add -
-O option of
wget specifies where to direct the output of the download. By using the
'-', we are telling it to direct it to standard output. Similarly, the use of the
'-' when adding the key using
apt‘s key management utility
apt-key, means read it from standard input.
At this point, you should be ready to start the installation process for ROS …
2) ROS Install
Now that package sources have been specified, we need to resynchronize
apt‘s package index files from their sources. Run the following command:
sudo apt-get update
To confirm that ROS Kinetic packages are now available and can be installed, you can search the cache as follows:
apt-cache search ros-kinetic
On ROS’s Kinetic install on Ubuntu (here) under Section 1.4 Installation, different install options based on the different needs. In my case, I selected ros-base (bare bones) as I believe this should do the job on a BBB. If any specific packages are found to be needed later, individual install can be performed. To make sure that ros-base is available, you may want to run the above command piping the output to
apt-cache search ros-kinetic | grep ros-base
You can now install ros-kinetic-ros-base using
apt as follows:
sudo apt-get install ros-kinetic-ros-base
Congratulations!! you now have ROS Kinetic on BBB … but there are a few things that you need do before starting to play with ROS and start building robots …
3) Initializing Some Tools
One of the tools you will likely need is rosdep, which is a command line system dependency installation tool. It is especially useful if you are a developer and want to build packages from source. It is also required by some ROS core components. Because it has been already installed as part of ROS install, we only need to initialize it and update it to get any new definitions. To confirm it is already installed, you can run:
In my case, the installed version was 0.11.5. To initialize and update rosdep, you can run the two following commands:
sudo rosdep init rosdep update
As recommended by ros.org, it is useful to configure ROS environment variables to be automatically set on shell start. This can be done by adding the command that sources ROS’s setup.bash to your .bashrc. This can be done as follows:
echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc source ~/.bashrc
The first command appends the setup.bash sourcing command to the end of the .bashrc file so that it can be run at the start of every bash session. The second command sources the .bashrc file for the current session to make it source setup.bash.
Another useful tool for downloading ROS package sources is rosinstall. This can obtained using apt as follows:
sudo apt-get install python-rosinstall
- Nootrix: ROS Installation Made Easy
- ROS.org: Ubuntu install of ROS Kinetic
- apt-key man page
- Ubuntu Repositories
- Ubuntu Repositories/CommandLine
- BeagleBoard Ubuntu
- ROS Answers: Incomplete packages for kinetic armhf jessie
- How to Connect a Beaglebone Black to the Internet via USB