Thursday, May 7, 2015

Debian Jessie Host Setup for Embedded Linux Development Part 3 - BeagleBone Black

This is the third in a series of tutorials to set up a Debian Jessie host for BeagleBone Black development.  It uses scripts and instructions from  Part 1 and Part 2 cover Debian host cross development setup for most any Linux target.  Part 4 continues with building the u-boot, the Linux kernel and preparing a Debian Jessie root filesystem for the BeagleBone Black.  Part 5 goes through the steps to create a micro SD image from your builds to and copying it to eMMC. Part 6 shows how to set up remote debugging in eclipse using gdb for an application.

3 Debian Host Cross-Compiler Setup

This section is based on the website Linux on ARM at, hosted by DigiKey and maintained by Digi-Key Application Engineer Robert Nelson.
Another good reference for working with the Beaglebone Black is
It covers building Debian kernels for BeagleBone Black and includes links to the latest images.

3.1 Create Tool and Source directories

Make sure you aren’t logged in as root for this section.

Create a directory to store the development tools in the user home directory.
user@debian:~$ mkdir ~/am335x

Create a user work directory for the board you are working on to store source files.
user@debian:~$ mkdir ~/bbb

3.2 Install ARM Cross-Compiler GCC

The commands below will download, uncompress and set up the GCC cross-compiler for ARM.

user@debian:~$ cd ~/am335x
user@debian:~/am355x$ wget -c

user@debian:~/am335x$ tar xf gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux.tar.xz

user@debian:~/am335x$ echo export CC=`pwd`/gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux/bin/arm-linux-gnueabihf- > armcc-vars

This created a file we can source to set up the environment for building with the toolchain.
user@debian:~/am335x$ source ~/am335x/armcc-vars

At this step we are using a pre-built 32-bit version of Linaro gcc so some 32-bit libraries must be installed.
user@debian:~/am335x$ sudo dpkg --add-architecture i386
user@debian:~/am335x$ sudo apt-get update
user@debian:~/am335x$ sudo apt-get install libc6:i386 libstdc++6:i386 libncurses5:i386 zlib1g:i386

Now the CC variable is set and we can run a simple test of the compiler installation.

user@debian:~/am335x$ ${CC}gcc --version
arm-linux-gnueabihf-gcc (crosstool-NG linaro-1.13.1-4.9-2014.09 - Linaro GCC 4.9-2014.09) 4.9.2 20140904 (prerelease)
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO

A few other variables need to be set for building u-boot and the Linux kernel; they can be added to the armcc-vars file as well.

user@debian:~/am335x$ echo 'export ARCH=arm' >> armcc-vars
user@debian:~/am335x$ echo 'export CROSS_COMPILE=${CC}' >> armcc-vars

Update the environment.  
user@debian:~/am335x$ source ~/am335x/armcc-vars
When you close the terminal emulator, the variables settings will not be retained.  If you open a new terminal you need to source this file again before building code.

Update the linux packages that are installed and add a few more that are needed to build the Linux kernel.

If you are logged in as root:
root@debian# apt-get install bc device-tree-compiler lsb-release lzma lzop u-boot-tools libncurses5-dev

If you installed sudo and you are logged in as a user:

user@debian:~$ sudo apt-get install bc device-tree-compiler lsb-release lzma lzop u-boot-tools libncurses5-dev

No comments: