Sunday, May 11, 2014

I just got my BeagleBone Black, now what?

When I received my BeagleBone, I wanted to start build my Robot right away but I quickly realized that I needed to start off by setting up my BeagleBone and configuring the Linux Distribution.  You can install several different distributions on your BeagleBone but I would recommend starting with standardAngstrom distribution.  Once you are more familiar with your BeagleBone then you can try other distributions.  When you first login into the standard Angstrom distribution, you will login as the root user with no password.

A great place to start is BeagleBone’s Getting started page.  This page walks you though the initial setup, installation of the drivers on your local computer and flashing the latest software onto your BeagleBone.  This page documents these steps very well so I will not rehash them here but I did have one problem when I went though this page.   The problem was I have an Ubuntu laptop and a MacBook Pro but no Windows machine to write the image to the SD card as documented on the getting started page.  After a brief Google search, I found Adafruit’spage that walked me though using PiFiller to write the image to a SD card.  The total time for this setup was approximately two and a half hours for me so patience is needed. 

I connected my BeagleBone black to an old monitor I had lying around the house by using a micro HDMI to VGA converter.  I also bought a mini wireless keyboard with a trackpad so I was able to program my BeagleBone like a desktop computer.  While this is not necessary, it makes learning the BeagleBone a lot easer.  I used Cable Matters Active Micro HDMI to VGA Male to Female Adapter with 3 Feet USB Power Cable in Black  and Logitech Wireless Touch Keyboard K400 with Built-In Multi-Touch Touchpad  they both worked out of the box with no configuration.  I am also using a powered USB hub to connect and power USB devices.  I can also use the USB hub to power my BeagleBone.  The USB hub that I am using is the Belkin Ultra-Slim Series 7-Port USB 2.0 Hub .

Here is a picture of my rather messy setup.  

The USB hub is plugged into a wall outlet and the white cable from the hub goes into the USB port of the BeagleBone.   Below the white cable is the mini HDMI cable that is connected to the mini HDMI to VGA converted.  The USB hub also powers this converter.  The yellow cable, on the opposite side of the BeagleBone, is an Ethernet cable that connects the BeagleBone to my network (and the Internet).  The black cable next to the Ethernet cable goes from the USB client port to the USB hub to power the BeagleBone.  The USB client cable can also connect directly to your computer instead of the USB hub.  The dongle you see connected to the USB hub is for the Logitech keyboard.

If you do not want to connect your BeagleBone to a monitor and keyboard, you can access your board by connecting it to your computer’s USB port.  You could then use a SSH client to connect to your BeagleBone.  If you have a Windows machine you will need to download a SSH client like Putty.  If you have a Linux or Mac machine, you already have a SSH client installed.  If your BeagleBone is connected to the USB port on your local machine and the drivers are properly installed you can SSH to root@192.168.7.2 to access your BeagleBone.

Now lets spend a little bit of time setting up our Linux environment.  Note, To download and install new software you will need to connect your BeagleBone Black to the Internet using the Ethernet port or by adding a WIFI adapter.

Setting a root password:
By default, the root user on your BeagleBone Black does not have a password.  Obviously this is not good so lets set a password by running the following command:

passwd

Setting up NTP:
Now we will want to setup NTP (Network Time Protocol) because the BeagleBone Black does not contain a Real Time Clock therefore it loses its time/date settings each time it powers off. 

Lets begin by setting the timezone, for me this is the Eastern timezone.  We will then set the correct time so we can use the opkg utility to install the ntp software:

ln –s /usr/share/zoneinfo/America/New_York /etc/localtime
ntpdate –u pool.ntp.org

opkg update
opkg install ntp

Now we need to configure NTP.  We will start off by editing the /etc/ntp.conf file.  Since I live in the US, I use the US servers.  You can go to www.pool.ntp.org to find your local servers.  My ntp.conf file looks like this:

driftfile /etc/ntp.drift
logfile /var/log/ntp.log

server 0.us.pool.ntp.org
server 1.us.pool.ntp.org
server 2.us.pool.ntp.org
server 3.us.pool.ntp.org

# Defining a default security setting
restrict default

Now lets enable the NTP services but running the following commands:

systemctl enable ntpdate.service
systemctl enable ntpd.service

Finally we need to modify the /lib/system/system/ntpdate.service file.  My ntpdate.service file looks like this:
[Unit]
Description=Network Time Service (one-shot ntpdate mode)
Before=ntpd.service

[Service]
Type=oneshot
ExecStart=/usr/bin/ntpd -q -g -x
ExecStart=/sbin/hwclock --systohc
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

Now your BeagleBone Black will have the correct time when you start it up, if it is connected to the Internet.

Setting the terminal prompt:
We will be doing a lot of work from the Linux terminal and the default terminal prompt does not tell you much.  Lets set the terminal prompt so it shows the logged in user, machine and the directory names.  To do this, edit the /etc/profile file and add the following line at the end of the file:

export PS1="\u@\h \w> "

Setup Python:
We will be making extensive use of Python and the Adafruit library.  Python is already installed and setup but we need to install the Adafruit library.  To do this, we need to first install some Python utilities:

opkg install python-pip python-setuptools python-smbus

Now we can use the Python package management tool to install the Adafruit library.

pip install Adafruit_BBIO

Browse Local Documentation:
If you installed the standard Angstrom image, your BeagleBone will have a local web server running that contains a lot of useful information.  I would recommend reviewing the information on this page and going though some of the basic demos.  I would also recommend printing out the Hardware Documentation section that contains the layout of the expansion headers.  The reason for this is you will want to power off the BeagleBone when you are connecting items to the expansion headers and will not have access to the images showing the layout.

To access the local documentation when the BeagleBone is connected to the USB port on your local machine, open a web browser and go to 192.168.7.2.

If your BeagleBone Black is connected to your local network, you can put the IP Address of your BeagleBone Black into your web browser to see the documentation.

Beginning some projects:
Your BeagleBone is now setup and ready to go.  As I mentioned earlier, you will probably want to try some of the demos in the local documentation.  My next few posts will show some basic projects that have helped me learn how to connect items to the expansion headers and how use the Adafruit library with Python.

2 comments:

  1. Is this keyboard works with beaglebone black.
    I saw some reviews and specs, there its said this keyboard works only for PC controlled TVs.

    ReplyDelete
  2. This is another version by Logitech that only works for TVs but the one that I link to in the post works great for the Beaglebone Black, Raspberry Pi and C.H.I.P.

    ReplyDelete