EBC Exercise 08 Installing Development Tools 4.4

From eLinux.org
Revision as of 11:50, 20 July 2016 by Yoder (talk | contribs) (The 3.8 Kernel: Updated for 4.4 kernel)
Jump to: navigation, search

thumb‎ Embedded Linux Class by Mark A. Yoder

Early in the class most of the exercises we will do will all run on the BeagleBoard. You'll be able to edit (cloud9), compile (gcc) and run all on the Beagle. Later, when we start compiling the kernel or the boot loader, (U-boot) you will need to cross compile on a Linux machine and copy the results to the Beagle.

The purpose of this exercise is to install all the tools needed for compiling on your host so they will be ready when you need them.

Tip: Run this exercise using a wired connection if you can. The Ubuntu wireless driver can be finicky, and if it stops working you'll have to restart some of this.

The 4.4 Kernel

Getting the 4.4 Kernel

These notes taken from Beaglebone: Adding USB Wi-Fi & Building a Linux Kernel starting around 4 minutes and ending around 21 minutes. Uses kernel from Robert C. Nelson's BeagleBone Black page.

host$ git clone https://github.com/RobertCNelson/bb-kernel.git  (35M)
host$ cd bb-kernel
host$ git checkout am33x-v4.4
host$ ./build_kernel.sh
+ Detected build host [Ubuntu 14.04.4 LTS]
+ host: [x86_64]
+ git HEAD commit: [1bfef360bf49784906529778b681f6cafa32c566]
‘/home/yoder/BeagleBoard/bb-kernel/system.sh.sample’ -> ‘/home/yoder/BeagleBoard/bb-kernel/system.sh’

At this point the scripts are downloading the crosscompiler, the kernel sources and anything else you need to compile the kernel for the bone.

Building the 4.4 Kernel

At some point you will see


Hit the right arrow to select Exit and then hit ENTER. The compilation will continue.

Stop at this point We'll continue on at a later time.

Installing the 3.8 Kernel on Your Black Bone

Updating and running off the eMMC

EBC_Exercise_23_Configuring_the_Kernel#Making_and_Installing_the_kernel has instructions for copying the correct files to the eMMC to update the kernel.

Booting off the SD card

Here are some optional instructions for booting off the SD card rather than the eMMC.

So far you'be been running everything off the onboard 2G flash. You can continue to do so, but when installing a new kernel there is a good chance you mess up your image and it will be another 45 minutes to reflash it. Instead go back to EBC_Exercise_03_Installing_a_Beagle_OS an instead of installing the eMMC flasher image from [1], install the BeagleBone (Runs on BeagleBone Black as well without flashing the eMMC) image (first list).

This time when you plug in the SD and boot the bone will boot from the SD card (rather than copying a new image to the 2G builting flash). I suggest programming 2 or 3 SD cards with this image. That way if you really mess up one you can always switch to a another card and keep going.

Also, if you are booting from the SD and mess up something, you can plug the messed up card into your host computer and fix things and try it again.

Copying to the SD Card

Now install by inserting the SD to be installed on into your host machine and run:

host$ ./tools/install_kernel.sh

Mine failed because there wasn't enough space on the VFAT partition for uImage, however uImage isn't needed there, so I just editted install_kernel.sh and commented out line 160

#			mmc_partition_discover

This keeps it from installing on the VFAT partition.

Updating to a new version of the kernel

When you build your kernel the uImage file has some version information in the name. For example uImage-3.8.13-bone20. The 3.8.13 is the version of the kernel and the bone20 is the version of the patches applied to the kernel for the BeagleBone. Over time new patches will be posted. These instructions show how to get the latest version.

How do you know if you have the latest version? Run

beagle$ uname -a
Linux yoder-black-bone 3.8.13-bone28 #1 SMP Wed Oct 16 15:32:18 EDT 2013 armv7l GNU/Linux

to see what version you are running. This site lists many different versions. See if yours is the newest, if not continue on.

This post to the Google Group lists the steps as "You need to recheckout master, delete your old branch and re-pull". Here's how you do it.

host$ cd linux-dev
host$ git checkout master
error: Your local changes to the following files would be overwritten by checkout:
Please, commit your changes or stash them before you can switch branches.

Hmm.... something has changed. See what it is.

host$ git diff patches/defconfig
diff --git a/patches/defconfig b/patches/defconfig
index d903776..3268287 100644
--- a/patches/defconfig
+++ b/patches/defconfig
@@ -2041,6 +2041,7 @@ CONFIG_JHD629_I2C=y
 # CONFIG_N_GSM is not set
 # CONFIG_TRACE_SINK is not set

It looks like some configuration setting have changed. Since we are getting a new version of the kernel, let's revert back to the previous file and try again.

host$ git checkout patches/defconfig
host$ git checkout master
Switched to branch 'master'

Success, now step 2.

host$ git branch -d am33x-v3.8
warning: deleting branch 'am33x-v3.8' that has been merged to
         'refs/remotes/origin/am33x-v3.8', but not yet merged to HEAD.
Deleted branch am33x-v3.8 (was 3fc8a73).

Now repull

host$ git pull

Then start over again

host$ git checkout origin/am33x-v3.8 -b am33x-v3.8
Branch am33x-v3.8 set up to track remote branch am33x-v3.8 from origin.
Switched to a new branch 'am33x-v3.8'

Your system.sh file should be unchanged, so start building

host$ ./build_kernel.sh

Mine took some 26 minutes on an 8 core machine.

DAS U-boot

These instructions came from Robert C Nelson's eewiki.net.


While we're at it, let's get the boot loader we'll be using. It takes some 40 seconds.

host$ cd ~/BeagleBoard
host$ git clone git://git.denx.de/u-boot.git
host$ cd u-boot/
host$ git checkout v2013.07 -b tmp

U-Boot Patches

host$ wget https://raw.github.com/eewiki/u-boot-patches/master/v2013.07/0001-am335x_evm-uEnv.txt-bootz-n-fixes.patch
host$ patch -p1 < 0001-am335x_evm-uEnv.txt-bootz-n-fixes.patch


Now configure and build. The first time takes some 1.5 minutes. After that it's only 5 seconds or so.

host$ source ~/crossCompileEnv.sh 
host$ make distclean
host$ make am335x_evm_config
host$ make


host$ scp u-boot.img root@beagle:.
beagle$ mkdir /media/BONE
beagle$ mount /dev/mmcblk0p1 /media/BONE
beagle$ cd /media/BONE
beagle$ mv u-boot.img u-boot.img.orig  # Save the working u-boot
beagle$ cp ~/u-boot.img u-boot.img.new
beagle$ cp u-boot.img.new u-boot.img

Once installed you are ready for u-boot work.


If your Beagle fails to boot, follow the EBC_Exercise_22_Recovering instructions to recover.

thumb‎ Embedded Linux Class by Mark A. Yoder