Beaglebone: Robotics Using the Beaglebone Black

Andrew B. Wright, Ph. D., SM ’88


Next Post: Beaglebone: remoteproc “Hello, world!”

WARNING:  Many ISPs are cracking down on man-in-the-middle attacks, so you may find that you cannot bridge a wireless connection to a wireless connection (802.1X).  Consequently, the network setup described below needs to bridge a wireless to wired connection or wired to wireless connection.

This is a blog about my experiences getting a Beaglebone Black up and running.  I am retrofitting my Control and Sensor System (CASSY) robotics project from the Vex PIC Microcontroller to something else.

The retrofit of the CASSY platform using the Beaglebone Black (rev. C) is an extension of the work that Traig Born did on the J5 robotics platform.  It is an embedded linux platform, so I’m more comfortable with maneuvering on it than on the Cortex (the new Vex platform).

A new version of the Beaglebone Black has been introduced after I started this project, the Beaglebone Black Wireless.  This blog does not currently address this platform; however, I have purchased the hardware and will start to incorporate that platform into this tutorial.  In particular, the section on wired connectivity is not relevant, since the Beaglebone Black Wireless does not have a wired connector.

In this blog, there are a total of four processors/systems in play:

the host computer (in my case a mac mini running osx)

the beaglebone arm processor running debian linux

programmable real time unit 0 (pru0) on the beablebone

programmable real time unit 1 (pru1) on the beablebone

Hardware to purchase to get started:

  1. Update the Beaglebone to the latest debian!  The Beaglebones that I received had an older version on them, and many devices (like pwms and wifi) don’t work the same as they do in the latest version.

Steps to install debian:

a. Download the latest image onto the host computer (

b. Unpack the file.  On osx, you will need to get “The Unarchiver” from the app store.

c. Copy the img file to a micro-sd drive using a low level write command.

The first task is to locate where the SD card is mapped into the filesystem.

Open a terminal on the OSX machine, and look for the disk devices on the machine.  Type

ls /dev/disk*

Plug in the SD card, wait a bit, and then repeat the above command.  The new disk is your SD disk.

In my case, it was located at /dev/disk3 with a partition /dev/disk3s1.

The next command is a very, very dangerous command to run.  If you pick an incorrect disk (e.g., your hard drive), you will wipe the contents.  Make sure you back up your data before running the command.  Make absolutely sure you have the right disk.  Make sure you enter the command correctly before hitting enter.

In order to get the dd command to work, you will first have to unmount the file system partition (not eject which will remove the /dev entry).

diskutil unmount /dev/diskNsM

where N = your disk number (3 in my case) and M is the partition number (1 in my case).

The command to write the img to your disk is:

sudo dd if=<path to your img > of = /dev/diskN bs=1000

 where <path to your img> is the location of your image file. The parameter bs is the block-size. This can be a lot of different numbers (e.g. 1, 1000, 1M).  This will affect the time of the write.

This command takes a while to complete.  Go get a cup of coffee and respond to some email.

d. Connect the Beaglebone to a monitor (through the HDMI cable) and keyboard/mouse.

e. Insert the micro-sd into a beaglebone and start it up.  You have to hold down the “user boot” button to get the BBK to boot off the sd card.

You can get to a shell by typing ctrl-alt-F5.  Login to the shell using debian:temppwd.  Set up a root password by typing “sudo su”  at the command prompt, using temppwd as the password.  Type “passwd” to set the root password.  Type in your desired root password twice.

Once you’ve booted to the sd image, edit the file ‘/boot/uEnv.txt’ (sudo nano /boot/uEnv.txt) and uncomment the line ‘cmdline=init=/opt/scripts/tools/eMMC/’ at the bottom of the file.

f. Reboot the Beaglebone off the micro-sd card as before.  Now, after a little bit, the LEDs will start to flash in a sequence which has been described as similar to a cylon’s eye.  Wait some time (30 minutes?) until the Beaglebone shuts back down.

g. Remove the micro-sd drive and reboot normally.  You will now be live with the latest debian.

Any data and config files you had on the Beaglebone before this upgrade will be wiped clean.  Back up before you start this process.  Either manually replace the key files or set up a script to replace things after the update has completed.

2. Set up root access and remote root access!

Connect the beaglebone to a monitor and keyboard.  Boot up.

In the earlier versions of the kernel, the system booted into X (the gui), and you were logged in as the debian user.   You would type ctrl-alt-F5 to get to a terminal login (this is quicker).

In later versions of debian, the X system is not installed by default.  You should see a full screen with a login prompt.  Use debian:temppwd to login.

Type uname -a to determine your OS version.  When you look for beaglebone tips on the internet, be aware that there are huge differences based on kernel.  This blog is based on 4.14.71-ti-r80 (stable version) kernel.

Set the root password with sudo su (use temppwd as the password).  Type passwd and enter the desired root password twice.

Switch directories to /etc/ssh, and edit sshd_config with nano.  Change the line “PermitRootLogin prohibit-password” to “PermitRootLogin yes” and restart sshd with “service ssh restart.”  This will allow you to ssh into the box as root using the new root password.

3. Get the beaglebone onto a wireless network!

In the latest debian, connmanctl is the way to get the wireless network working.

Plug the wireless dongle into the usb port.  Probably use a cable to keep the interference between the beaglebone and the dongle at a minimum. (see the figure for wireless network topography with a mac mini)

Make sure the adapter was detected:


Result will be the name of your adapter.  I’m using a tp-link adapter for this project.

Make sure the drivers were loaded:

lsmod | grep

You can find the linux driver name from the internet by searching for your card name (found in lsusb) and “linux lsmod.”

You can find details of the wifi using iwconfig.  This will tell you the name of your device.  I’m assuming wlan0.

Connman settings are located in /var/lib/connman/settings and /etc/connman/main.conf.

Restart connman with

systemctl restart connman.service

This step is not necessary most of the time.

a. Identify the available technologies.

connmanctl> technologies

shows what technologies are available.

b. Turn off tethering (now the default, so this may be redundant) with

connmanctl> tether wifi off

c. Scan for available networks (now done automatically, so this may be redundant) with

connmanctl> scan wifi

Wait until connman returns “Scan completed.”  Once the scan is complete,

connmanctl> services

tells you which services are available.  (It’s possible you can run this command directly without the scan.)

Look for the service that represents your access point.  It will be something like:


d. log onto your wireless network

If your wireless network has a passkey (most do), you will need to perform these steps to get onto the wireless network the first time:

connmanctl> agent on

connmanctl> connect wifi_<long.number>_managed_psk

You will be prompted for the network’s passkey.

If all goes well, then you will get a message indicating that you’re connected.  This persists through reboots.

e. (optional for static address) Depending on the network, you may need to assign parameters manually, rather than through dhcp.

connmanctl> config wifi__managed_psk --ipv4 manual <ip> <nm> <gt>
connmanctl> config wifi__managed_psk --nameservers <ns>

For example: <ip> =, <nm> =, <gt> =, <ns> = ip of your access point.

These config commands allow things to be manually set.

To view what you’ve done, type:

connmanctl> services wifi_<long.number>_managed_psk

and you will see all the settings for this service.

f. exit connman

connmanctl> quit

These changes survive reboots.

Wireless network topography with a mac mini and access point

g. On the host, open network preferences on the host computer.

Under Apple USB Ethernet Adapter, set up preferences to Manually.  Enter IP Address  Enter Subnet Mask Leave Router blank.  Leave network settings (remember to apply them!) and go to Sharing.

Share connection from your world internet (in my case Wi-Fi, but it will likely be Ethernet if your host is connected to the internet via wire) To computers using: Apple USB Ethernet Adapter.  Turn Internet Sharing on.  When you make changes on the Beaglebone, you may have to turn sharing off and back on to get things to work .  There are files on the host computer that store settings that need to get refreshed.

NOTE:  many OSX iterations ago, ONLY the 192.168.2 domain could be shared.  I have not tested in recent years if this restriction still applies.  But, that’s why this tutorial is set up to connect the wifi to the 192.168.2 subdomain.  On windows and linux, this restriction doesn’t apply, and you can use whatever subdomain you want.  In my case, I do not have so many devices that this restriction is limiting, but, you may have very good reasons to want to use multiple subdomains.

h. On the beaglebone, check for internet connectivity.  For instance, “ping” will let you know that your beaglebone is able to resolve names and connect to them if it executes successfully.

i. Return to the host and login to the remote beaglebone from a terminal window:

ssh <ip> -l root -X

Type the password when prompted.

Check the display with


which should return localhost:10.0

Check emacs with

emacs &

This should launch emacs in its own XQuartz window on the mac.  NOTE: see below regarding updating the system.  Depending on the debian build, emacs or xauth may not be installed.  You will need to update the system before installing and running this step.

In recent builds of debian, the xauth program is not installed by default.  This will make it so that you cannot open windows on the OSX system.  You need to install xauth using “apt-get install xauth” as root on the beaglebone.

You may still get an error (Xauthority does not exist).  This should be corrected by logging out and logging back in.

4. Wifi can be droppy … fix it! Get wifi to restart when it drops using cron.

Create a file, and make it executable “chmod a+x”.  This file should contain the following code:

d=$(date +%H%M%S)
if [ $(connmanctl state | grep -c "online") = 0 ] && 
[$(connmanctl state | grep -c "ready") = 0] 
     echo "not good"$d >> /root/test.txt 
     connmanctl disconnect wifi_long.number_managed_psk 
     connmanctl connect wifi_long.number_managed_psk 
     echo "good"$d >> /root/test.txt 

At this point, the state “online” might be too strict and a state of “ready” might be acceptable. The state “online” indicates connectivity as determined by actual connection to (or if that’s how you’re rolling).

Get this code to execute every five minutes using cron.  Enter the editing mode by typing “crontab -e”.  When prompted (first time only) pick your editor (e.g. emacs).

Enter the following line:

*/5 * * * * sh /root/

Save and exit.  Cron will call every 5 minutes.  If connmanctl shows that wifi is down, it will automatically disconnect and then reconnect.  It will put an entry into test.txt regardless.  These lines aren’t necessary, so they can be commented out.

This step is an amazingly important step.  Even though the beaglebone’s wireless connectivity is much better than it was when I started, you will always lose connections.  This basic step allows the system to recover.

4. Update the system! Once you have internet connectivity, update the system. As root, type

apt-get update

apt-get upgrade

Once the system is upgraded, you should have the latest wifi drivers. This will make it much easier to get wifi connectivity.

I have occasionally run into trouble at this step.  I’ve had to ctrl-Z to stop a process and then do a dpkg –configure -a.

I suspect those problems are a thing of the past with the latest debian (stretch).

5. Get back to basics and free some disk space! Check your available disk space and clean out unneeded packages.

df -h

This will tell you how much (little) space you have in bytes.  At this point, I show 49% 85% full on the beaglebone’s drive space.  So, it looks like the developers dropped a lot of junk.

Determine what packages are installed:

dpkg --get-selections | grep -v deinstall

Remove packages that you do not need and clean the cache:

apt-get remove info

apt-get remove chromium-browser

apt-get remove vim vim-common vim-runtime

apt-get remove qupzilla

apt-get remove doc-beaglebone-getting-started

apt-get remove doc-beaglebonegreen-getting-started

apt-get remove doc-seeed-bbgw-getting-started

apt-get remove gnuplot gnuplot-data gnuplot-tex gnuplot-x11

Remove files the system knows it doesn’t need and clean the cache:

apt-get autoremove

apt-get clean

At this point, I’ve reduced to 48% 83%.

Do you need all the development tools?  python, gcc, and ruby might be optional, depending on your usage.  If you’re playing around, you probably want to keep them.

Do you want to run a web server on your beaglebone?  If not, apache2 can go.

Will you use bluetooth?  If not, bluez can go.

There are a number of packages to support the old-style beaglebone … pruss and capes support.   There are some video drivers that shouldn’t be needed.

If you’re going to do any development, the nano text editor will drive you crazy.  It’s better to edit remotely and copy back to the beaglebone.  Two editors that give you more development power are gedit and emacs.  I haven’t used emacs in years and my memories of the beast are not fond.  But, if you can free the space, pick one of these to help in development.

I added emacs

apt-get install emacs

If you use any application that requires Xorg on the beaglebone, you need to install Xquartz on an osx system so that you can use the app over ssh.

Since X11 is not installed in the latest debian, you need to add xauth to the beaglebone if you want to run X11 applications on the osx side:

apt-get install xauth

Another place to go for space is under /usr/share/man.  There are man files in languages other than your preferred language.  You don’t need these.  They have to be manually deleted (rm -rf /usr/share/man/ko for example).

6. Test programming on the arm

On the beaglebone, you can create a subdirectory (I go with /root/code/hello.1) using

mkdir /root/code/hello.1

and you can create a file in this directory (cd /root/code/hello.1 first) using

emacs hello.c &

You can also create a makefile in this directory using

emacs Makefile &

You can cut the following text and paste it into the respective files.


#include <stdio.h>

void main(){ 
printf("hello, world\n");


hello: hello.c
gcc hello.c -o hello

Compile by typing “make hello” at the command prompt.

Run by typing “./hello” at the command prompt.

You should see the classic text, “hello, world” at the command prompt.

NOTE: the makefile will probably have to have a tab added before gcc.  Wordpress has done some formatting.

7. Access an LED from the arm

#include <stdio.h>
#include <unistd.h>

int main(){

FILE *fp = NULL;
int i;
const char *LED = "/sys/class/leds/beaglebone:green:usr0/brightness";

for (i=0;i<5;i++){
	if((fp = fopen(LED, "w")) != NULL){
	if((fp = fopen(LED,"w")) != NULL){


	gcc LED.c -o LED

I was reminded in makefile editing that the indented line needs to use a tab character, rather than spaces.

8. The PRU c-compiler is installed by default in the latest debian.  It lurks in /usr/bin. The header files are located in /usr/share/ti/cgt-pru/.

A nifty command to issue from the command line:

tar -zcvf beaglebone-"$(date '+%y-%m-%d').tar.gz" code3

allows you to pack up your code into an archive with a date stamp in the file name.

From the host computer

scp root@<beagle-ip>:*.gz .

will bring the file onto the host computer (where beagle-ip for this example is

2a. (0ptional) Establish a basic wired network connection with host name access!

Connect a cat5 crossover cable between the beaglebone and the ethernet port on a host computer.  I’m going to use a mac in this example.  Linux and windows will have similar features.

On the host, open network preferences on the host computer.  Under Ethernet, set up preferences to Manually.  Enter IP Address  Enter Subnet Mask Leave Router blank.  Under Advanced, DNS, enter the IP of your dns server.  If this is on another network, like wifi, which is how I’ve configured my home network, leave network settings (remember to apply them!) and go to Sharing.

Share connection from Wi-Fi To computers using Ethernet.  Turn Internet Sharing on.  When you make changes on the Beaglebone, you may have to turn sharing off and back on to get things to work .  There are files on the host computer that store settings that need to get refreshed.

On the Beaglebone, make yourself root by typing su and entering the root password set up above.

Enter connman by typing


At the prompt, enter

connmanctl> technologies

Make sure you have ethernet.

At the prompt, enter

connmanctl> services
connmanctl> config ethernet_long.number_cable --ipv4 manual <ip> <nm> <gt>
connmanctl> config ethernet_long.number_cable ---nameservers
connmanctl> quit

The ip address (<ip>) might be something like Net mask (<nm>):, Router/DNS (<gt>):

The nameserver is the name of your name server on your host computer (e.g.

There are two users into the beaglebone initially


root:no password (unless you added a password above)

Open a terminal and log into the beaglebone via ssh using the ip addr set in step 2 in this example).

ssh -l root -Y

You should be prompted for your root password.

If this works smoothly, then you can disconnect the beaglebone from the monitor and keyboard and proceed from the mac host.

All Code (optain with wget …)

hello, world! …

toggle …

time …

talk …

gpio …

analog input …

pwm … coming soon (this semester!!!!)


After installing debian, the OS will be continually tinkered with.  You will need to update (and update and update …).  It is not practical to reinstall with each update.

apt-get update

apt-get upgrade

apt-get autoremove

apt-get dist-upgrade

apt-get install linux-image-armmp (reboot?)

uname -a


This blog is going to be the starting point for the information to participate in that class.

7/11/2015 (this is pretty obsolete now)

For now, I’m working on my mac mini as the host.  Rather than connecting the Beaglebone to peripherals, I started using the USB connection.  The first problem I encountered was that the usb didn’t want to use my mac’s dns.  I’m pretty sure I have to bridge the beaglebone connection to the mac’s wifi, but this proved difficult.  I used a crossover cable to attach the BBB’s ethernet to the mac’s ethernet and bridged that connection. (NOTE:  in a later blog, I talk about how to change the beaglebone’s ip settings to use, the only ip that osx seems to want to allow to bridge by default.)

The way into the BBB is to ssh -Y -l root 192.168.x.y where x is either 2 or 7, depending on the connection (2=eth0, 7 = usb)  and y is usually 2.  The -Y switch allows me to use X and pop up graphical editing tools. It’s a little weird to command line as root anymore since my time in ubuntu.  However, unless I’m going to put the beaglebone on-line, it’s fine for an embedded application.  Actually, I discovered that accessing hardware requires root permissions (although it should be possible to play with groups and get other access).  Still, I’m in learning mode, so I might as well acquiesce and use root for now.

The work that I did in programming the ABWComm GUI for the Vex is directly translatable to the Beaglebone.  For instance, all the bluetooth work can be ported directly.  So, that learning curve ought to be a bit flatter than trying to get the serial Bluesmirf ported over to the Cortex.

(see here for an early version of this stuff.  There may be some worthwhile stuff still there, but it’s not that relevant now.).

Posted in: Robotics
Read more about:

Comments are closed.