EBC Exercise 08 Installing Development Tools 4.4

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.

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’ Installing: - 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.

Copying to SD card on a running Bone
The Bone can have multiple versions of the kernel installed on it. It's possible to update the kernel on the Bone while it's running. After compiling on the host you need to install sshfs (you only need to do this once).

host$ sudo apt-get install sshfs 

Then copy may_install_kernel.sh to the bb-kernel directory. host$ cd ~/BeagleBoard/bb-kernel host$ cp ~/BeagleBoard/exercises/linux/kernel/may_install_kernel.sh tools Now you can install the files using the following. Note, you must run may_install_kernel.sh from the directory above as shown. host$ tools/may_install_kernel.sh Mounting sshfs - sshfs mounted Installing 4.4.15-bone11 to sshfs ‘/home/yoder/BeagleBoard/bb-kernel/deploy/4.4.15-bone11.zImage’ -> ‘/home/yoder/BeagleBoard/bb-kernel/deploy/disk/zImage’ Installing 4.4.15-bone11-dtbs.tar.gz to sshfs Installing 4.4.15-bone11 to sshfs ‘/home/yoder/BeagleBoard/bb-kernel/deploy/4.4.15-bone11.zImage’ -> ‘/home/yoder/BeagleBoard/bb-kernel/deploy/disk/boot/vmlinuz-4.4.15-bone11’ Installing 4.4.15-bone11-dtbs.tar.gz to sshfs info: /boot/uEnv.txt: uname_r=4.4.15-bone11 Installing 4.4.15-bone11-modules.tar.gz to sshfs tar: ./lib/modules/4.4.15-bone11/build: Cannot utime: No such file or directory tar: ./lib/modules/4.4.15-bone11/source: Cannot utime: No such file or directory tar: Exiting with failure status due to previous errors ‘/home/yoder/BeagleBoard/bb-kernel/deploy/config-4.4.15-bone11’ -> ‘/home/yoder/BeagleBoard/bb-kernel/deploy/disk/boot/config-4.4.15-bone11’ info: [4.4.15-bone11] now installed... You may see about couple of error messages about build and source, but it seems to work anyway. If you look in /boot/uEvt.txt, you'll see it's ready to boot your new kernel. bone$ head -3 /boot/uEnv.txt uname_r=4.4.15-bone11 If you change your mind about which kernel to boot, just edit the uname line.
 * 1) Docs: http://elinux.org/Beagleboard:U-boot_partitioning_layout_2.0

Copying to the SD Card on Host
You can also install the kernel on an SD card that is mounted on your host computer. Plug it into your host and machine and run: host$ tools/install_kernel.sh

This works like the may_install_kernel.sh, but it copies it to local host. Once copied, eject the SD card and plug it into your Bone and boot.

Updating and running off the eMMC
You can also update the eMMC to boot off a new kernel. EBC_Exercise_23_Configuring_the_Kernel has instructions for copying the correct files to the eMMC to update the kernel.

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 vmlinuz-4.4.21-ti-r47. The 4.4.21 is the version of the kernel and the -ti-r47 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 bone$ uname -a Linux yoder-debian-bone 4.4.21-ti-r47 #1 SMP Fri Sep 23 22:23:02 UTC 2016 armv7l GNU/Linux

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: patches/defconfig Please, commit your changes or stash them before you can switch branches. Aborting 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_SERIAL_NONSTANDARD is not set # CONFIG_N_GSM is not set # CONFIG_TRACE_SINK is not set +CONFIG_LPD8806=m CONFIG_DEVKMEM=y # 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.

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.