BeagleBoardAndOpenEmbeddedGit

This guide briefly describes the steps that need to be taken in order to create an OpenEmbedded (OE) based image for the BeagleBoard. It was created while performing an install on ubuntu804jeos (a minimal console only vmware appliance). This guide differs in that the official GettingStarted uses monotone while we will be using git. The second difference is that this guide only focuses on running on Ubuntu and developing for beagle.

The first step is to get a working Open Embedded installation. This can seam a daunting task at first but the rewards are great so here we go. This guide tries to be self containing. We therefore will not push you to use Google or read the other manuals.

Prerequisites
OE tries to be as self supporting as possible. OE will both compile the cross compiler and the tools needed to compile a whole system. Still some dependencies are to be met using the "host" system. During the install we will be able to run almost all the commands as normal user but right now we will install the basic set of packages that are required to make OE to be happy.

Host tools to install: sudo apt-get install ccache sed wget cvs subversion git-core coreutils unzip texi2html texinfo libsdl1.2-dev sudo apt-get install docbook-utils gawk help2man diffstat gtk-doc-tools file g++

Nice to have optional tools to install: sudo apt-get install python-psyco minicom

OE and many tools and scripts that are used contain bashisms. We therefore want to change the default "/bin/sh" to point to bash. sudo dpkg-reconfigure dash
 * 1) and select no

An other change need need to perform as root is to change some default settings of the kernel. sudo vi /etc/sysctl.conf vm.vdso_enabled = 0 vm.mmap_min_addr = 0

Run sudo sysctl -p

The effective install
We are going install the OpenEmbedded system under the user's home directory in a directory called "oe". We will need about 10 gig of free disk space. Under that we will be putting the different components of the OE system. Those components are Bitbake, the OpenEmbedded meta-data and the beagle configuration. The Bitbake task executor will be put under "opt". The OpenEmbedded meta-data ( Bitbake recipes ), classes ( Bitbake extentions) and configuration (machine and arch setup) will be located under the "openembedded" directory. The BeagleBoard configuration will be placed under "beagleboard" directory.

OpenEmbedded and Bitbake install
This part really is not that difficult after all.

Set the dir where everything will be done export OE_HOME=$HOME/oe

Install Bitbake

mkdir -p $OE_HOME/opt cd $OE_HOME/opt svn co svn://svn.berlios.de/bitbake/branches/bitbake-1.8/ bitbake svn co http://svn.berlios.de/svnroot/repos/bitbake/branches/bitbake-1.8 bitbake
 * 1) or if your are behind a firewall

Install the OpenEmbedded meta-data using git cd $OE_HOME git clone git://git.openembedded.net/openembedded git clone http://repo.or.cz/r/openembedded.git
 * 1) or if you are behind a firewall

Creating the BeagleBoard configuration and profile
We now need to tweak OpenEmbedded to fit our Beagle needs. We create a profile script that we can run whenever we feel like playing with beagle. This script will perform a few tasks. It will add bitbake to our PATH so we can run the bitbake command from anywhere. It will then export the BBPATH and BBFILES. This tells bitbake where to find it's meta-data. BBPATH will both point to our own beagleboard files and openembedded.

But first we create a local.conf containing the most important choices we need to make. Change at least the MACHINE to beagleboard. Select angstrom-2008.1 as distro.

mkdir -p $OE_HOME/beagleboard/beagleboard/conf cat > $OE_HOME/beagleboard/beagleboard/conf/local.conf <<_EOF DISTRO = "angstrom-2008.1" BBFILES = "$OE_HOME/openembedded/packages/*/*.bb" TMPDIR = "$OE_HOME/tmp" MACHINE = "beagleboard" ENABLE_BINARY_LOCALE_GENERATION = "0" _EOF

If you have a multicore machine, you can also add these two variables to speed up things (a value of 2 is safe in most cases), see here:

BB_NUMBER_THREADS = "2" # Depends on your machine PARALLEL_MAKE = "-j 2" # Depends on your cluster

Now we create our profile. There are TWO CHOICES here.

CHOICE 1) If you are going to operate directly connected to the internet (i.e. NO Proxy Firewall), then do:

cd $OE_HOME cat > $OE_HOME/beagleboard/beagleboard/profile.sh <<_EOF export OE_HOME=\$HOME/oe export MY_OE_CONF="beagleboard" export BBPATH=\$OE_HOME/beagleboard/:\$OE_HOME/beagleboard/\$MY_OE_CONF:\$OE_HOME/openembedded export BBFILES="\$OE_HOME/openembedded/packages/*/*.bb" export PATH=\$OE_HOME/opt/bitbake/bin:\$PATH if [ "\$PS1" ]; then if [ "\$BASH" ]; then export PS1="\[\033[01;32m\]OE:\$MY_OE_CONF\[\033[00m\] \${PS1}" fi fi _EOF

CHOICE 2) If you will be operating from behind a Proxy Firewall, then do:

cd $OE_HOME cat > $OE_HOME/beagleboard/beagleboard/profile.sh <<_EOF export OE_HOME=\$HOME/oe export MY_OE_CONF="beagleboard" export BBPATH=\$OE_HOME/beagleboard/:\$OE_HOME/beagleboard/\$MY_OE_CONF:\$OE_HOME/openembedded export BBFILES="\$OE_HOME/openembedded/packages/*/*.bb" export PATH=\$OE_HOME/opt/bitbake/bin:\$PATH export CVS_TARBALL_STASH="http://oesources.org/sources/current/" if [ "\$PS1" ]; then if [ "\$BASH" ]; then export PS1="\[\033[01;32m\]OE:\$MY_OE_CONF\[\033[00m\] \${PS1}" fi fi _EOF

Now make the profile executable:

chmod +x $OE_HOME/beagleboard/beagleboard/profile.sh

Running
We now have finished the installation. If everything goes well we can now create images for the BeagleBoard

source $OE_HOME/beagleboard/beagleboard/profile.sh

Pull down any changes in the git tree.

cd $OE_HOME/openembedded git pull git checkout

Now build the console image.

cd $OE_HOME bitbake console-image

If this goes well your computer will be compiling for a long time. A long time can be several hours.

If you receive an error of the form "ERROR: Unable to open conf/bitbake.conf" check that your profile.sh created earlier has the correct BBPATH setting (copy/pasting from this page may cause a line-break between the export command and the BBPATH var).

Preparing the system for booting
The output of the bitbake command will ultimately be found under the $OE_HOME/tmp/deploy/glibc/images/beagleboard. In there you can find at least 3 interesting files:
 * console-image-beagleboard.tar
 * console-image-beagleboard.jffs2 and
 * uImage-beagleboard.bin

The console images are representations of a full and self containing file system *including* a kernel. The uImage is a linux kernel image that is suitable to be loaded by the U-boot bootloader. The difference between the tar file and the jffs2 image is that the later is better suited to directly put on a raw partition.

We are going to use the U-boot that is already provided in the NAND flash of the beagleboard as that one already support the MMC can load kernel images from a fat file system. What we will do is to format a SD-card to hold both a fat and an ext2 file system. We will put the kernel in the fat file system as U-boot failed to load the image from a ext2 file system. We will unpack the console-image under the ext2 file system.

Create partitions and format the SD-card
We usually create two partitions, the first one has a FAT partition type and the second one a Linux file system type. We then format them and put content on them. We are not going the describe the formating other then briefly because it just if to easy to format the wrong partition. There are a few reasons for having a first partition as FAT but his is not the scope of this document ( Think of U-boot, windows, mass-storage ). Instruction for formatting the SD-card correctly can be found at: Boot Disk Format

Here is the output of the fdisk -l command after creating the new partitions. Disk /dev/mmcblk0: 2032 MB, 2032664576 bytes 1 heads, 16 sectors/track, 248128 cylinders Units = cylinders of 16 * 512 = 8192 bytes Disk identifier: 0x2f3dffc4

Device Boot     Start         End      Blocks   Id  System /dev/mmcblk0p1              2       12209       97664    b  W95 FAT32 /dev/mmcblk0p2          12210      248128     1887352   83  Linux

We now format the file systems ext2 file system under /mnt. Some system will perform a automount of the newly created file system. Try to disable this automount feature if possible (it is not easy) or use gparted mkfs.vfat /dev/mmcblk0p1 mkfs.ext2 /dev/mmcblk0p2

Mount the ext2 file system and unpack the archive. Do not forget the -C option. mount /dev/mmcblk0p2 /mnt tar xvf system/angstrom/deploy/glibc/images/beagleboard/console-image-beagleboard.tar -C /mnt umount /mnt

Mount the fat file system and copy the kernel image to there. mount /dev/mmcblk0p1 /mnt cp system/angstrom/deploy/glibc/images/beagleboard/uImage-beagleboard.bin /mnt/uImage umount /mnt

Booting
We can put the SD-card in the beagleboard and wait for the U-boot prompt. The kernel we compiled only gave serial output if we first ran the coninfo command we therefore type coninfo and ask U-Boot to initialise the mmc stack. After that we set the kernel command line telling what the console is and where our root file system is located. We then load the image from the fat file system into memory and boot the kernel

coninfo mmcinit setenv bootargs console=ttyS2,115200n8 root=/dev/mmcblk0p2 rw rootdelay=1 fatload mmc 0:1 0x80000000 uImage bootm

One very important note:
It's important to have an X-Loader on your Beagleboard that uses the uBoot on the SD Card that goes with the Angstrom uImage. The B5 Beagleboards do not appear to come with such an X-Loader / U-Boot combination (i.e. the B5 standard uBoot will lead to problems with the sound driver and other things, but will not tell you that it's creating a problem).

The fix is to load a new X-Loader which will in turn automatically load the uBoot from the SD card, which again in turn will load the uImage properly.

So you likely will have to upgrade the X-Loader. Here's what to do:

* Make an SD Card with the Angstrom Demo files. See the Beagleboard Wiki Page for more info on making the SD Card. * Put the SD Card in the Beagle, and boot up to the U-Boot Prompt. * Do the first six instructions in the Flashing Commands with U-Boot section. * Reboot the Beagle to see that the new X-Loader is properly loaded.

This will update the X-Loader to a newer version that will automatically load uBoot from the SD card, and then load uImage from the SD card, rather than always using the uBoot in the Beagleboard NAND.

Setting the video resolution:
The Angstrom kernels since 2.6.27 have used "DSS2", which is a candidate for replacing the OMAP framebuffer driver in the mainline Linux kernel. It provides greater flexibility for support of the S-Video port on the BeagleBoard and more monitor resolutions than previous mainline kernels. Documentation for the driver is in the kernel source at [Documentation/arm/OMAP/DSS http://groups.google.com/group/beagleboard/msg/4c64b2c614622053].

Below is one example:

setenv bootargs console=ttyS2,115200n8 root=/dev/mmcblk0p2 rw rootwait omap-dss.def_disp=lcd omapfb.video_mode=640x480MR-16@60

Using the OpenEmbedded Environment
If you have not used bitbake / OpenEmbedded before, a helpful example for creating packages that can be installed on a beagle linux install (such as the one created above) can be found at Hello World Tutorial for Gumstix.

OpenEmbedded development
See OpenEmbedded development guide for one way how to modify and build packages contained within OpenEmbedded (OE) for the BeagleBoard.