You are here: romanrm.net » Using the Allwinner A10/A20 as a home server » Cross-compiling an Allwinner ARM Linux kernel on Debian amd64
Cross-compiling an Allwinner ARM Linux kernel on Debian amd64
0. Before you begin
In case you just want some particular kernel feature to be enabled in the config, check out my pre-built kernels, maybe these will already have what you need (and save you some time compiling).
1. Install various tools you will need
apt-get install git build-essential fakeroot kernel-package u-boot-tools zlib1g-dev libncurses5-dev
2. Install the Emdebian toolchain
Into your /etc/apt/sources.list
add:1)
deb http://www.emdebian.org/debian/ unstable main
Then:
apt-get update apt-get install emdebian-archive-keyring apt-get install gcc-4.7-arm-linux-gnueabihf ln -sf `which arm-linux-gnueabihf-gcc-4.7 ` /usr/local/bin/arm-linux-gnueabihf-gcc # ^ FIXME: find/fix why the version-less filename is not created automatically
3. Get the kernel source code
git clone https://github.com/linux-sunxi/linux-sunxi linux-sunxi cd linux-sunxi git checkout sunxi-3.4
4. Get a kernel config
I suggest my configs available at:
Save the config file you downloaded as ”.config
” in the kernel source directory.
If you wish to check and adjust settings, run:
ARCH=arm make menuconfig
5. Compile your kernel
In the kernel source directory do:
export ARCH=arm export DEB_HOST_ARCH=armhf export CONCURRENCY_LEVEL=`grep -m1 cpu\ cores /proc/cpuinfo | cut -d : -f 2` fakeroot make-kpkg --arch arm --cross-compile arm-linux-gnueabihf- --initrd --append-to-version=-custom1 kernel_image kernel_headers make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- EXTRAVERSION=-custom1 uImage cp arch/arm/boot/uImage ../uImage
You can save the above as a script for convenience. You can also replace custom1
with something else, e.g. your nickname and a number that represents the order number of the new package of this particular kernel (as it is common to recompile the same kernel version a few times to get everything just right in the config, or to try out different patches).
After the compilation, in the directory one level above the kernel source tree, you will get:
linux-image-*.deb
, a Debian package with the kernel;linux-headers-*.deb
, a Debian package with kernel headers (mostly unneeded);- an
uImage
, the kernel itself in the u-boot compatible format.
6. Install and test your kernel
Now you will need to:
- copy
linux-image-*.deb
to your target device and install it there; - copy
uImage
into the device's/boot/
partition.
Until you have ensured that the new kernel works, keep the previous uImage
that already was there, just rename it into something different (e.g. uImage.bak
). In case your new kernel doesn't boot, you can simply insert your the SD card into some other device, mount the boot partition and restore the previous uImage
.