EBC Installing Kernel Source

Early in the class most of the exercises we will do will all run on BeagleBone Black. You'll be able to edit (via Cloud9), compile (gcc) and run all on the Bone. 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 Current Kernel
We are using the Debian kernel from Robert C. Nelson's BeagleBone Black page.

host$ git clone git://github.com/RobertCNelson/bb-kernel.git host$ cd bb-kernel host$ git tag (This shows what versions can be checked out.) host$ git checkout 3.8.13-bone67 -b 3.8.13-bone67

Now build the kernel. host$ ./build_kernel.sh + Detected build host [Ubuntu 14.04 LTS] + host: [x86_64] + git HEAD commit: [58ee2121370badd3c0a22e39f67068f242d5e068] Debian/Ubuntu/Mint: missing dependencies, please install: - sudo apt-get update sudo apt-get install build-essential device-tree-compiler fakeroot lzma lzop u-boot-tools  libncurses5-dev:amd64 libc6:i386 libncurses5:i386 libstdc++6:i386 zlib1g:i386 - * Failed dependency check

The build script is telling you what you need to install. Do the installs and rerun the build command.

Building the 3.8 Kernel
Rerun the kernel build host$ ./build_kernel.sh At some point you will see



Here you can configure the kernel, however no changes are needed at this time. 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. (About 15 minutes on an eight core machine.)

Installing on a Running Bone
(Check here https://groups.google.com/forum/#!topic/beagleboard/hFqBo_ziBnE for a better way)

If your Bone is running and talking to your host computer, you can install a new kernel without shutting down the Bone and taking the SD card out. This approach uses fuse to mount the Bone's files on the host computer. First, install fuse 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/kernel/may_install_kernel.sh tools host$ tools/may_install_kernel.sh Note, the command must be run from bb-kernel, not the tools directory.

The script will mount the Bone's root file system in bb-kernel/deploy/disk and then copy the needed files to it. Once done you can reboot your bone. If you are done with the mounted files you can unmout them with host$ sudo umount deploy/disk

Installing on an SD card
If you are running off the SD card (rather than the eMMC) installing is easy. Now install by inserting the SD to be installed on into your host machine and run: host$ ./tools/install_kernel.sh

All the needed files are copied to your SD.

Switching Kernels
It is possible to have multiple kernels on the SD card. The file /boot/uEnv.txt tells which kernel to boot.

bone$ head /boot/uEnv.txt uname_r=3.8.13-bone60 cmdline=quiet init=/lib/systemd/systemd This one is set up to boot the 3.8.13-bone60 kernel. Edit /boot/uEnv.txt if you want to change the kernel you are booting.
 * 1) Docs: http://elinux.org/Beagleboard:U-boot_partitioning_layout_2.0
 * 1) dtb=
 * 1) Example
 * 2) cape_disable=capemgr.disable_partno=

Updating to a new version of the kernel
When you build your kernel the files have some version information in the name. For example  vmlinuz-3.16.0-rc5-bone0. The 3.16.03 is the version of the kernel and the bone0 is the version of the patches applied to the kernel for the Bone. 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-debian-bone 3.8.13-bone60 #1 SMP Mon Jul 21 18:22:58 EDT 2014 armv7l GNU/Linux

to see what version you are running. git tag will show what versions are available. 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 bb-kernel 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.15 -b am33x-v3.15 Branch am33x-v3.15 set up to track remote branch am33x-v3.15 from origin. Switched to a new branch 'am33x-v3.15' Your system.sh file should be unchanged, so start building host$ ./build_kernel.sh Mine took some 26 minutes on an 8 core machine.