Tag Archives: Angstrom

Cross-Compiling for BeagleBone Using a Linux VM on the Mac

BeagleBone Cross Compiling using OSX on the Mac (using Linux)

Although it may seem more complicated, I decided the best way to cross-compile from my Mac would be to do it from a Linux system.

I would of course love to have my BeagleBone cross-development environment running directly on OSX, but that’s an effort for another day – my goal here was to be able to cross-compile for the BeagleBone.

Yes, in theory this should be possible on a Mac since it’s Unix-based, but it appears to me that may be more pain. More pain than just setting up an Ubuntu system using VMWare Fusion anyway. This is quite easy these days – both VMWare and Parallels make it almost effortless. There are many many resources on how to do this, so I’m not going to cover that here.

With Ubuntu 12.04 running happily in a VMWare VM on my MacBook Pro, away I went.

So to just cross-compile, it doesn’t appear that you really need the OpenEmbedded and Angstrom kernel stuff, so I went with just the Angstrom pre-built toolchain available at:
http://www.angstrom-distribution.org/toolchains/

I used angstrom-2011.03-i686-linux-armv7a-linux-gnueabi-toolchain.tar.bz2
This is the 32-bit version, which matches my Ubuntu VM setup. There is a 64-bit version there as well, if you are running a 64-bit version of Linux on your host system.

Step-by-Step

On the Cross-development Host

Extract the pre-built angstrom toolchain:

    $ cd /
    $ sudo tar -xf <path to the angstrom toolchain>

Which creates the new directories /usr/local/angstrom and /var/lib/opkg.

Run the environment setup script, which puts the new tools in the path as well as sets up several other environment variables:

    $ . /usr/local/angstrom/arm/environment-setup

Create a simple “Hello, world” program using whatever editor you prefer. I named mine “hello.c”.

    #include <stdio.h>

    int main()
    {
        printf( "Hello, worldn" );
    }

And finally, do a test build.

    $ arm-angstrom-linux-gnueabi-gcc hello.c -o hello

This should result in an executable file named hello. (This is a Csource file, so I used gcc, but you can also change the gcc at the end of the command to g++ to compile C++ source code.

On the BeagleBone

If you transfer the executable binary output file hello to your BeagleBone (e.g. via FTP), you should be able to run it and see the text “Hello, world” printed out in the BeagleBone terminal.

    $ ./hello
    Hello, world

Resources

This guide is based on bits of information gleaned from a variety of sources, including:

Linux To Go
electrons on radio
Trey Weaver’s Blog
gpio.kaltpost.de

Thanks to everyone who has blogged about their experiences with the BeagleBone!

Advertisements

Writing a BeagleBone SD Card Image From the Mac Revisited

Since I last dealt with writing an SD card image to update the BeagleBone software, some things have changed. So, here’s an updated guide to the process.

Download the Image

The latest images are available here: http://beagleboard.org/latest-images

The one I downloaded was named: Angstrom-Cloud9-IDE-GNOME-eglibc-ipk-v2012.05-beaglebone-2012.11.22.img.xz

Uncompress the Image

The latest BeagleBone images are not compressed in a format that tar or unzip can deal with. Fortunately there is a free application The Unarchiver that can. It’s available here: The Unrchiver.

Run this application on the .xz image file to get a (much larger) file that ends in .img. This is the file you’ll write to the SD card.

Unmount the SD Card

To write the image to the SD card, it first needs to be unmounted.

    $ diskutil unmount /volumes/YourCardNameHere

Find the Device Name

This step is critical.

Using the wrong device name can destroy the data on your computer’s hard drive, so be very very sure to get the device name correct in the following steps!

This can be found in a couple of ways. You can use the “Disk Utility” application, or the command line diskutil or df commands.

Diskutil

From the command line:

    $ diskutil list

df

    $ df

This may show you the partition, something like disk7s2. You want to entire SD card, not any partitions so drop the s2 part.

Write the Image

Then, write the image to your SD card. Note that the diskXXX should be the actual disk device assigned when the SD card is connected, and Angstrom-XXX should be the name of the actual card image you downloaded and extracted previously.

Again be sure to use the right device name for the SD card in this step!

Don’t be surprised if this takes a while – on my system it took about 37 minutes, and there are no “in progress” indications of any sort, so be patient! (note that this time is more a function of how big the image is – ~3.4G – and the speed of your micro-SD card then how fast your computer is)

    $  dd if=Angstrom-XXX.img of=/dev/diskXXX bs=4096

If you aren’t logged in as root, you may need to use sudo, in which case the command is:

    $  sudo dd if=Angstrom-XXX.img of=/dev/diskXXX bs=4096