18

I would like to understand more about how the kernel works. Part of this is to compile it myself. How do I cross-compile the Kernel on a Ubuntu host?

Peter Mortensen
2,0042 gold badges15 silver badges18 bronze badges
asked Jun 13, 2012 at 10:14

3 Answers 3

25

Preparation

First, we need to install the required prerequisites. I assume you have sudo access.

sudo apt-get install git ncurses-dev make gcc-arm-linux-gnueabi
  • git is the version control system used by the Linux kernel team.
  • ncurses is a library for build console menus. It is necessary for menuconfig.
  • make runs the compilation for us.
  • gcc-arm-linux-gnueabi is the cross-compiler.

Next, we need to retrieve the source, run:

git clone https://github.com/raspberrypi/linux raspberrypi-linux
cd raspberrypi-linux

This will clone the source code to a directory called raspberrypi-linux and change to it.

Compilation

We first need to move the config file by running

cp arch/arm/configs/bcmrpi_cutdown_defconfig .config

Then configure the kernel build

make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- oldconfig

Optional: Customise the build using menuconfig

make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- menuconfig

Then run the compilation

make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- -k
References
answered Jun 13, 2012 at 10:14
2
  • 1
    Thank you very much for providing an alternative to using crosstool-ng. Commented Jul 14, 2012 at 21:38
  • In my case CROSS_COMPILE is just a prefix, so the follow should be enough (without gcc at the end): make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- -k Commented Jun 28, 2014 at 14:21
4

I think Alex is right but the gcc-arm-linux-gnueabi is compiled for arm cpus without hardware floating point unit. You can find a cross-compiler with armhf support on: https://github.com/raspberrypi/tools and a good tutorial to start with here: http://hertaville.com/2012/09/28/development-environment-raspberry-pi-cross-compiler/

answered May 12, 2013 at 22:33
1

Official documentation

https://www.raspberrypi.org/documentation/linux/kernel/building.md (GitHub)

I would recommend that you just follow the steps there, or send a pull request if something becomes outdated or is not clear enough: those instructions are the most likely ones to be correct and up to date since they are part of the official documentation of the project.

answered Apr 24, 2018 at 4:08

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.