EBC Exercise 08 Installing Development Tools 3.8

See EBC Exercise 08 Installing Development Tools 3.2 if you are working with the 3.2 kernel.

Early in the class most of the exercises we will do will all run on the BeagleBoard. You'll be able to edit (gedit), 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.

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

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 3.8 Kernel
Make sure you installed the cross compiler (EBC Exercise 08a Cross-Compiling) before doing this exercise.

Getting the 3.8 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 git://github.com/RobertCNelson/linux-dev.git host$ cd linux-dev.git host$ git checkout origin/am33x-v3.8 -b am33x-v3.8 host$ time git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git (21 minutes) host$ cp system.sh.sample system.sh Now make the following changes to system.sh. The  shows what's in system.sh.sample. The  shows what you should change it to. host$ diff system.sh* 15c15 < CC=arm-linux-gnueabi- --- > #CC=arm-linux-gnueabi- 21c21 < LINUX_GIT=~/BeagleBoard/linux-stable/ --- > #LINUX_GIT=/home/user/linux-stable/ 31c31 < ZRELADDR=0x80008000 --- > #ZRELADDR=0x80008000

Now build the kernel. host$ ./build_kernel.sh + Detected build host [Ubuntu 12.04.3 LTS] + host: [x86_64] + git HEAD commit: [6a8557f75f5b35a79729308379adc13b43535806] Debian/Ubuntu/Mint: missing dependicies, please install: - sudo apt-get update sudo apt-get install build-essential device-tree-compiler fakeroot lzma lzop u-boot-tools libncurses5-dev ia32-libs - * Failed dependency check

The build script is telling you what you need to install. Do the installs and rerun the build command. host$ ./build_kernel.sh + Detected build host [Ubuntu 12.04.2 LTS] Debian/Ubuntu/Mint: missing dependicies, please install: - sudo apt-get update sudo apt-get install libncurses5-dev - * Failed dependency check If you don't get this error, move to the next step. I fixed this error by editing  and commenting out the line: It was looking for amd64 in the  listing and it wasn't appearing.
 * 1) 	dpkg -l | grep libncurses5-dev | grep ${deb_arch} >/dev/null || deb_pkgs="${deb_pkgs}libncurses5-dev "

Building the 3.8 Kernel
Rerun the kernel build host$ ./build_kernel.sh At some point you will see Go back to the video above and forward to 13:30. Here you will see how to configure the kernel. Once you've exited the configuration tool the kernel will start compiling. If you have a multicore machine you will see all the cores busy. It's only a few more minutes before it is done.

Booting off the SD card
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, 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  and commented out line 160 This keeps it from installing on the VFAT partition.
 * 1) 			mmc_partition_discover

Updating and running off the eMMC
EBC_Exercise_23_Configuring_the_Kernel has instructions for copying the correct files to the eMMC to update the kernel.

DAS U-boot
These instructions came from Robert C Nelson's eewiki.net.

download
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

compile
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

install
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.

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