Compiling Debian kernel for BBB

I’m pulling together some notes for my students[1] on installing and compiling different kernels for BeagleBone Black.

The installing side is now easy with the latest (2014-7-16) Debian image. Run:

apt-cache pkgnames | grep linux-image

to see what images are out there and then:

apt-get install linux-image-3.8.13-bone60

to install the image of your choice. But what if you want to compile your own?

Are these the best way to do it from scratch?

host$ git clone git://github.com/RobertCNelson/linux-dev.git
host$ cd linux-dev
host$ git checkout origin/am33x-v3.8 -b am33x-v3.8
host$ cp system.sh.sample system.sh

host$ ./build_kernel.sh

How do I see what versions are available for checkout? How do I compile a specific version, such as 3.8.13-bone60?

Once I’ve gotten something to compile and work should I:

host$ git checkout -b myBranch

so I can easily track the changes I make? Do I just run ./build_kernel.sh again to recompile?

Thanks, your answers will help me guide my students…

–Mark

[1] http://elinux.org/EBC_Exercise_08_Installing_Development_Tools#Getting_the_3.8_Kernel

I'm pulling together some notes for my students[1] on installing and
compiling different kernels for BeagleBone Black.

The installing side is now easy with the latest (2014-7-16) Debian image.
Run:

apt-cache pkgnames | grep linux-image

to see what images are out there and then:

apt-get install linux-image-3.8.13-bone60

to install the image of your choice. But what if you want to compile your
own?

Are these the best way to do it from scratch?

host$ git clone git://github.com/RobertCNelson/linux-dev.git
host$ cd linux-dev

Use "bb-kernel" instead of "linux-dev" (less 'other' noise for users
going on in that repo)

host$ git checkout origin/am33x-v3.8 -b am33x-v3.8
host$ cp system.sh.sample system.sh
host$ ./build_kernel.sh

How do I see what versions are available for checkout? How do I compile a
specific version, such as 3.8.13-bone60?

There is also:
https://github.com/RobertCNelson/linux-stable-rcn-ee/branches/all

Just prototyping it right now, planning to move it to:

https://github.com/beagleboard/linux

Once I've gotten something to compile and work should I:

host$ git checkout -b myBranch

so I can easily track the changes I make? Do I just run ./build_kernel.sh
again to recompile?

So "./build_kernel.sh" will always "nuke" ./KERNEL/ but it'll build it
based on patches/defconfig & patch.sh

"./tools/rebuild.sh" will allow you to 'rebuild" ./KERNEL/ as is, say
your working on a kernel patch but haven't commited it to the
patch.sh/patches_dir...

Thanks, your answers will help me guide my students...

--Mark

[1]
http://elinux.org/EBC_Exercise_08_Installing_Development_Tools#Getting_the_3.8_Kernel

Regards,

BTW, here's a couple things to help out:

If you do:

git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
~/linux-src

The scripts will automatically find that location, so you can ignore
changing system.sh

and do me a favor on precise, run:

./repo_maintenance/dpkg_check.sh

Regards,

Let me summarize… Here is what I tell my students:

host$ sudo apt-get install gcc-arm-linux-gnueabi
host$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git ~/linux-src

host$ git clone https://github.com/RobertCNelson/bb-kernel.git
host$ cd bb-kernel
host$ git tab (This shows what versions are available)
host$ git checkout 3.8.13-bone60 -b v****3.8.13-bone60
host$ ./build_kernel.sh

If we don’t edit system.sh is it able to figure out what cross compilers to use and how to set ZRELADDR?

host$ ./dpkg_check.sh
trusty
ii libncurses5-dev:amd64 5.9+20140118-1ubuntu1 amd64 developer’s libraries for ncurses

–Mark

Are you scripts smart enough to install the right cross compilers? Do I need sudo apt-get install gcc-arm-linux-gnueabi?

–Mark

IS that the right compiler ? I do not think so . . . should be the hf compiler for the BBB. Maybe I’m wrong ?

Let me summarize.... Here is what I tell my students:

host$ sudo apt-get install gcc-arm-linux-gnueabi
host$ git clone
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
~/linux-src
host$ git clone https://github.com/RobertCNelson/bb-kernel.git
host$ cd bb-kernel
host$ git tab (This shows what versions are available)
host$ git checkout 3.8.13-bone60 -b v3.8.13-bone60
host$ ./build_kernel.sh

If we don't edit system.sh is it able to figure out what cross compilers to
use and how to set ZRELADDR?

By default, the am335x-v3.8 branch will use linaro's:
gnueabihf-4.7-2013.04 cross compiler:

https://github.com/RobertCNelson/bb-kernel/blob/am33x-v3.8/version.sh#L23

https://github.com/RobertCNelson/bb-kernel/blob/am33x-v3.8/scripts/gcc.sh#L94

https://releases.linaro.org/13.04/components/toolchain/binaries/gcc-linaro-arm-linux-gnueabihf-4.7-2013.04-20130415_linux.tar.xz

ZRELADDR is ignored, we are in a bootz/zImage world now. :wink:

host$ ./dpkg_check.sh
trusty
ii libncurses5-dev:amd64
5.9+20140118-1ubuntu1 amd64 developer's
libraries for ncurses

Ah, yeah it correctly detects. Trusty, i was reading your wiki and saw
the mention of precise, so i thought there might still be a bug in the
host checker script.

Regards,

I don't bother using ubuntu's default "gcc-arm-linux-gnueabi(hf)"
compilers, they eol their release's way to fast and they vary from
distro release.

I always pull them down from: http://releases.linaro.org/

I have the am335x-v3.8 locked in on the last linaro 4.7 gnueabihf,
such that it'll still build the branch today and 2 years from now.

You can always override CC= in system.sh and do what you want.

Regards,

Robert, your kernel building tools are really impressive. There’s one more thing I’m trying to figure out.

I’ve run:

host$ git checkout 3.8.13-bone60 -b v****3.8.13-bone60
host$ ./build_kernel.sh

and got the right kernel and it works. Now I want to switch to a newer kernel. Here’s what I tried:

host$ git checkout 3.16-rc6-bone1 -b v3.16-rc6-bone1
host$ tools/rebuild.sh
It compiled the wrong version. It did 3.8.13-bone1 instead, so I tried

host$ ./build_kernel.sh

and got the 3.8.13-bone1 kernel again.

What do I do to switch to a whole different version of the kernel?

–Mark

Robert, your kernel building tools are really impressive. There's one more
thing I'm trying to figure out.

I've run:
host$ git checkout 3.8.13-bone60 -b v3.8.13-bone60
host$ ./build_kernel.sh
and got the right kernel and it works. Now I want to switch to a newer
kernel. Here's what I tried:

host$ git checkout 3.16-rc6-bone1 -b v3.16-rc6-bone1

After a "checkout" always run "./build_kernel.sh" first to reset the
./KERNEL/ directory.

host$ tools/rebuild.sh
It compiled the wrong version. It did 3.8.13-bone1 instead, so I tried

host$ ./build_kernel.sh

and got the 3.8.13-bone1 kernel again.

What do I do to switch to a whole different version of the kernel?

Regards,

It works! So you only use tools/rebuild.sh if you are working with the same version of the kernel.

tools/install_kernel.sh: 233: tools/install_kernel.sh: Syntax error: “(” unexpected (expecting “then”)

Looks like features are being added, but aren’t there yet…

–Mark

This is fixed in the HEAD of the v3.16-rc branch.

Just fine tuning, the updating process of /boot/uEnv.txt (uname_r)
along with some error checks.

Regards,

I always use these instructions. They are all-sufficient

http://eewiki.net/display/linuxonarm/BeagleBone+Black

That is an excellent reference. I’ve finally bookmarked it.

–Mark