Difference between revisions of "EBC Exercise 08a Cross-Compiling"

From eLinux.org
Jump to: navigation, search
m (Get the setup scripts)
(Point to the git snapshot that was used to create the image: Added cd sources/openembedded)
Line 165: Line 165:
  
 
<pre>
 
<pre>
 +
$ cd sources/openembedded
 
$ git remote add myrepo git://gitorious.org/~Jadon/angstrom/jadon-openembedded.git
 
$ git remote add myrepo git://gitorious.org/~Jadon/angstrom/jadon-openembedded.git
 
$ git remote update
 
$ git remote update

Revision as of 18:04, 29 March 2011


This class is about developing software for embedded Linux. The eLinux site is a good source for embedded Linux in general. There are many ongoing embedded efforts going on many platforms. Poke around the site a while to get a feel for what's happening.

We are going to use the Ångström Distribution. It's available many platforms. Look around the site, you may recognize some of them.

Get my setup from dfs

I like to keep all things Beagle in a BeagleBoard directory. Here's how to match my setup:

$ cd
$ mkdir -p BeagleBoard/oe
$ cd BeagleBoard
$ sftp username@dfs.rose-hulman.edu
Connecting to dfs.rose-hulman.edu...
username@rose-hulman.edu's password:
sftp> cd Users/Y/yoder/Shared/BeagleBoard/oe
sftp> ls
sftp> get oebb.sh.tar.gz
sftp> get sources.tar.gz
sftp> get build.tar.gz
exit
$ cd oe
$ tar xvf oebb.sh.tar.gz
$ tar xvf sources.tar.gz
$ tar xvf build.tar.gz

Once you have everything in place you need to create the script that will get the environmental variables.

$ rm -rf build/conf
$ ./oebb.sh config beagleboard

The first command removes the configuration files that were set up for my machine. The second command will create them for your machines. It will also create the file ~/.oe/environment-2008 and make sure your repositories are up to date.

One last thing is to

$ cd build/tmp-angstrom_2008_1
$ rm saved_tmpdir

The saved_tmpdir file remembers where you last had your TMPDIR. Removing the file makes it forget that you've moved things since the time I built everything.

Compile the Kernel and u-boot via bitbake

Before bitbaking be sure to source this file:

$ source ~/.oe/environment-2008

Now you can now compile your own kernel and u-boot:

$ time bitbake linux-omap-psp-2.6.32
$ time bitbake u-boot

I've added the time command to the bitbake to see how long it takes. Tell me how long it takes on your system.

Compile via make

When you use bitbake it sets up all the paths to use the correct cross compilers. You can also build the kernel or u-boot by using make if you set the paths yourself. Here's what you need to do.

$ 

If you would prefer to maintain your own kernel source tree outside of OE, see these directions: BeagleBoardLinuxKernel

Alternatively it is possible to run the official omap branch of the linux kernel. Take a peek at this page. BeagleBoard#Linux_kernel (Please continue reading for the modifications I needed)

  • Since we are using OE, our paths are set up slightly different, I have made the relevant changes below that I needed to do it manually. Take note on the second path command is arch specific (if you get an error about mkimage not being found, make sure you have the second path right)
PATH=~/oe/angstrom-dev/cross/armv7a/bin:~/oe/angstrom-dev/staging/i686-linux/usr/bin:$PATH  # add cross tools to your path
make ARCH=arm CROSS_COMPILE=arm-angstrom-linux-gnueabi- distclean
make ARCH=arm CROSS_COMPILE=arm-angstrom-linux-gnueabi- omap3_beagle_defconfig
make ARCH=arm CROSS_COMPILE=arm-angstrom-linux-gnueabi- menuconfig  # only needed if you want to change the default configuration
make ARCH=arm CROSS_COMPILE=arm-angstrom-linux-gnueabi- uImage
  • It is important to note that the kernel in the official branch will be newer then the ones that OE provides (2.6.33 at the time of this writing), and as such there are no OE related patches to apply.
  • There is no reason why you can't steal the OE kernel config, and apply it to the newer kernel. See if you can figure out how to do this. (Hint: You will need to combine both above links directions)
  • Alternatively if you've previously built the kernel, take a peek in your ${OETREE}/downloads. This is where the old kernel source (pre-patches) was downloaded, and see if you can manually apply the OE patches.

Finding the Kernel to copy it

Once your compile has finished, where is uImage? One way to find it is

$ cd ~/BeagleBoard/oe
$ find . -name "*uImage*"

You'll find several files with uImage in the name. The one you want is

$ cd ~/BeagleBoard/oe/build/tmp-angstrom_2008
$ ls

Here you'll see several directories here. If you cd work you will find the source code. We are going to go this way.

$ cd deploy/glibc

Here you will find some more directories worth exploring. What do you find in sources? Finally

$ cd images/beagleboard

Now you have found uImage. Load away.

Here's what I did to create the files above

You don't have to do the following. This is what I have already done.

Instructions for building Ångström are given here; however there are a few changes you have to make. Here's what I did.

Get the setup scripts

I have everything in a ~/BeagleBoard, so here is how I setup things:

$ cd
$ mkdir -p BeagleBoard
$ cd BeagleBoard
$ git clone git://git.angstrom-distribution.org/setup-scripts oe
$ cd oe

This creates a directory for open embedded (oe) and gets the script to download Ångström. What files do you see?

Edit oebb.sh and replace every place you find

git://git.openembedded.org/openembedded

with

git://git.openembedded.org/openembedded.git

Also replace

INHERIT += "rm_work"

with

# INHERIT += "rm_work"

Save the file and then run

MACHINE=beagleboard ./oebb.sh update

This will bring in all the tools you need. It took about 30 minutes on my machine.

Point to the git snapshot that was used to create the image

The original SD card image came from here. The file ec2buld.sh shows how the image was build. There are a couple of interesting things in this file.

Line 564 shows an additional git repository was used.

$ cd sources/openembedded
$ git remote add myrepo git://gitorious.org/~Jadon/angstrom/jadon-openembedded.git
$ git remote update

Run this git command to get access to this repository. Line 21 shows the hash tag for the build.

ANGSTROM_REPO_ID=24805033b1205acc35f8b4d75cc42f8b9c2a1b38

If we pull from this tag we will have the same files as were used to generate the SD image. So do the following

git checkout 24805033b1205acc35f8b4d75cc42f8b9c2a1b38

Compile the Kernel

Now if you do

$ source ~/.oe/enviroment-2008
$ bitbake linux-omap-psp-2.6.32

you should get a kernel that will work.

To ensure you keep the kernel source, check your .../oe/build/conf/local.conf and comment out the line that says

INHERIT += "rm_work"

If you accidentally run bitbake without commenting out the above line, after it runs you can comment out the INHERIT line and then run

$ bitbake -c clean linux-omap-psp-2.6.32
$ bitbake -f -c compile linux-omap-psp-2.6.32

This second run should take less time (one timing: first run took 3.5 hours; the recompiling took 25 minutes).

Note from Joel: I had to run

$ ./oebb.sh config beagleboard

at some point before the bitbake command would run for me.