Getting Started with Beaglebone

27 03 2012

So, a few weeks ago, I got my hands on a Beaglebone for getting myself into Embedded Linux world again. I have messed with Gumstix Overo series during my thesis so I had some knowledge. But my previous experience was limited as I was not able to compile kernels and I only managed to compile things on board (which is slow for computer vision programs) as I had limited time and no knowledge of cross-compile.

But things have changed: My Linux-fu is definitely better compared to a few years ago, I have more experience in electronics & programming and also I got my hands onto a fast PC which I can use for kernel compiling, cross compiling and other tasks which take lots of time. Believe me, I tried compiling kernel with my trusty EeePC (which was my only Linux running PC at that time) and it was still not half done after 6 hours. Now I have a 6 core 64-bit AMD machine which is used for all this stuff. Still it takes some time but at least watching a movie or two will be enough. ๐Ÿ™‚

So, here we go: I will talk about backing up the uSD cards that came with the Beaglebone, talk about compiling the kernel, formatting the uSD card if you are using a brand new one, copying files to your uSD card and then booting up the system and playing around for a while. I don’t claim any originality in the work presented here, I will present here a collection of information scattered around the web that I had to find out after following may links so that others can access it easily and I don’t have to search around again if I cannot remember something. ๐Ÿ™‚ So as references, the backup part is from a Coder’s Talk blog post and the rest is from BeagleBone demo files page.

The Setup

I’m using an EeePC as my main machine as it has an SD card slot and I’ll SSH into the AMD PC for compiling and transfer files by SCP. I’ll also power up my Beaglebone by a DC adapter and SSH into it to test out the system. Why? Because I’m comfortable with that, but you can just use one PC for compiling and preparing the uSD card.

Backup the uSD Card

First thing I’ll do is to back up one of the two uSD cards that arrived with my Beaglebone. One of them was labeled and had an Angstrom distribution on it and the other one was not marked. It contained some files related to Beaglebone and apparently an Angstrom distribution too but I was not able to boot my Beaglebone with the unmarked one. So I’ll use that for my new kernel. But before I want to have a backup in case things go south.

As I’m running Linux, I have some really nice tools in my system by default. The two I’ll be using for this is dd and tar. Also dmesg is useful for seeing which drive name is assigned for the uSD card but I usually check out /dev/ directory for it. Whatever suits your needs. So upon inserting the card, I learn that my uSD card is at /dev/sdb with some partitions mapped as /dev/sdb1, /dev/sdb2 etc. which are automatically mounted. Do not safely remove these partitions, the following codes will not work. Create a new folder for Beaglebone related things and get an image of the uSD card. It will take ~4 GB of space (size of the uSD card) so it is better to use tar and gzip to compress the file and remove the uncompressed image afterwards to free up some space.

$ mkdir beaglebone
$ cd beaglebone
$ sudo dd if=/dev/sdb of=unmarked_sd
$ tar zcvf unmarked_sd.tar.gz
$ sudo rm unmarked_sd

If you want to have this original copy on the uSD card again, you can use the following command. Be sure to use a card with same size or bigger.

$ sudo su
# tar Ozxf unmarked_sd.tar.gz | dd of=/dev/sdb

Compile a Brand New Angstrom Image

For this I SSH into my AMD PC and do things there. It is a good idea to use screen for this step as if you lose your connection somehow, the process stops. So we SSHed into the machine, we have a beaglebone folder under our home directory and we are under that. And of course we are using screen while running these commands because especially the last one takes a long one and if your SSH connection drops, everything stops, I cannot stress this enough as I have left it running during my sleep and I had nothing in the morning as my laptop went to sleep and I’ve lost my connection. Also a fast internet connection is a good thing as you’ll download lots of things during this step. So go ahead and run these commands:

$ git clone git://github.com/Angstrom-distribution/setup-scripts.git
$ cd setup-scripts
$ ./oebb.sh config beaglebone
$ MACHINE=beaglebone ./oebb.sh bitbake systemd-image

Now go sleep, clean up the house, go for a walk, watch a movie or take a hint from the comic down there. It’ll take a while.

Once the kernel is compiled, I like to transfer them to another folder under my beaglebone folder so that I can transfer all of them to my EeePC by SCP using one command and the files are hidden pretty down below. Believe me, you don’t want to enter the whole path while using SCP. Also during this step I rename these files so that I can transfer them to the uSD card without changing their names. We are under the beaglebone folder while running these.

$ mkdir image
$ cd image
$ cp ../setup-scripts/build/tmp-angstrom_2010_x-eglibc/deploy/images/beaglebone/MLO ./
$ cp ../setup-scripts/build/tmp-angstrom_2010_x-eglibc/deploy/images/beaglebone/u-boot.img ./
$ cp ../setup-scripts/build/tmp-angstrom_2010_x-eglibc/deploy/images/beaglebone/uImage-beaglebone.bin ./uImage
$ cp ../setup-scripts/build/tmp-angstrom_2010_x-eglibc/deploy/images/beaglebone/Angstrom*.tar.bz2 ./

Format the uSd Card and Unpack the Angstrom Image

For formatting, you have two options: Doing it manually by fdisk or using the nice mkcard.txt script provided by Angstrom. I have tried both but instead of calculating values and entering them, I really prefer the script. Unmount your uSD card if you didn’t and run it by typing

$ sudo sh mkcard.txt /dev/sdb

You remembered my uSD card is at /dev/sdb, right? Good, if yours is different, just change it. Then go ahead and remount the partitions, mine mount automatically to /media/boot/ (FAT32 partition) and /media/Angstrom/ (ext3 partition), to transfer the files. We are under the beaglebone/image/ folder where my files are.

$ cp MLO /media/boot/
$ cp u-boot.img /media/boot/
$ cp uImage /media/boot/
$ sudo tar -xjv -C /media/Angstrom/ -f Angstrom*.tar.bz2

Boot Up and Play a Little

Unmount your uSD card partitions (I just use safely remove, it syncs up the partitions and unmounts all partitions associated with that drive automatically). Then plug it to your Beaglebone, plug in an Ethernet cable and the 5V adapter. You have to wait a little for the initial boot. Once you see one of the LEDs blinking on and off (called heartbeat) you can SSH into your Beaglebone! To learn the IP of your Beaglebone, you can use various methods, I use the following nmap command before turning my Beaglebone on and after the heartbeat to find its IP address.

$ nmap -sP 192.168.1.*

Just to test it out, I’ll turn on LED3 on and then off from the shell after getting connected to it over SSH. Username is root and there is no password. These commands are run on the Beaglebone. The first command shows you possible options (LED0 is set to heartbeat, LED1 to mmc0), the second turn on the LED3 and third one turns it off.

# cat /sys/class/leds/beaglebone\:\:usr3/trigger
[none] mmc0 timer heartbeat backlight gpio default-on
# echo default-on > /sys/class/leds/beaglebone\:\:usr3/trigger
# echo none > /sys/class/leds/beaglebone\:\:usr3/trigger

If you want to mess around a little more, Make Magazine has a nice blog post & video about using GPIO pins.


Actions

Information

6 responses

9 07 2012
dipto

Getting this error, please help. I am working on a Ubuntu 11.10 VM on Windows7.

After issuing the command $ MACHINE=beaglebone ./oebb.sh bitbake systemd-image, the bitbake halts with an error as below

ERROR: Unable to parse /root/Beaglebone/setup-scripts/sources/meta-mono/conf/layer.conf: [Errno 2] No such file or directory: ‘/root/Beaglebone/setup-scripts/sources/meta-mono/conf/layer.conf’

9 07 2012
tayken

That means an important file is missing. Try running ./oebb.sh update under setup-scripts, if it does not work, it is better to delete the whole repository and clone again.

9 07 2012
dipto

Thank you, I got past that error, now the bitbake is in progress and I think it will take quite long. I made an observation though, the meta-mono software support layer failed to fetch in this step ‘ ./oebb.sh config beaglebone ‘ and the update failed everytime due to this. I checked up and separately cloned the layer from ‘git://git.yoctoproject.org/meta-mono.git’ then the update succeeded.

I have also observed a bitbake failure yesterday due to some fetch issue, when I retried, it passed that stage and now the bake is in progress. So I think we need to intervene to fix certain things, do you have any information on understanding bitbake on the whole and troubleshooting bitbake ? If you could please let me know of any comprehensive OpenEmbedded documentation, it would be really helpful.

9 07 2012
tayken

It takes a while depending on your system. If your processor has multiple cores, it automatically adjusts number of compilers running to make things faster.

Sometimes you have to intervene, for example after I wrote this post, there was a repository address change which messed up my system as each time before compile ./oebb.sh wrapper script runs an update on all repositories used. I was not able to compile because of this, I tried manually fixing the address problem but some files changed etc so I took the easy way and cloned the repo from scratch.

I also witnessed that sometimes it stops because it cannot compile one package, but if I run again, it passes and continues. I guess this is similar to what you experienced and I have no idea why. Angstrom wiki http://www.linuxtogo.org/gowiki/Angstrom is a good source that I use from time to time.

3 11 2012
Davide Facontiavide

Hi Tayken,
first of all thanks for your tutorial.
I followed your instructions, but the booting process stops at the line

[ 1.679107] Waiting for root device /dev/mmcblk0p2…

Any clue?

6 11 2012
tayken

Hmm, that sounds like an SD card problem. Try formatting and unpacking the image again. If it doesn’t work, try using a different uSD card.

Leave a comment