ARM – Raspberry Pi 2 – Kernel Compile..
Finally got the Raspberry Pi 2, and installed Fedora 21 (armv7hl) with no problems.. Temporarily used object code 3.18.7-v7+ from the repository, and then tested kernel compile options..
The system seems (so far..) to be relatively sluggish compared to my other quad-core armv7 systems.. Compiling on the Pi 2 itself seemed relatively slow, but at least it was a realistic option..!
I got the latest (3.19.0) kernel from https://github.com/raspberrypi/linux/tree/rpi-3.19.y
Compiling the kernel + device tree was somewhat different from the Classic armv6 Pi… As usual, there are other ways of doing this, but this works, for me..
First time, run # make bcm2709_defconfig to get correct Pi 2 config..
or
Create config from (running) /proc/config.gz
make xconfig (if necessary..) make make modules_install make firmware_install cp System.map /boot cp arch/arm/boot/dts/bcm2709-rpi-2-b.dtb /boot rm -f /boot/kernel7.img.old mv /boot/kernel7.img /boot/kernel7.img.old (save the old/good kernel, just in case..) cp arch/arm/boot/Image /boot/kernel7.img
One thing to remember is that kernel7.img is just a copy of arch/arm/boot/Image, and there is no longer a requirement for tools/imagetool-uncompressed.py
If you want to call the kernel7.img file something else, just put a kernel=xxxxxx parameter in /boot/config.txt
If all goes well, you should see a clean boot…
$ uname -a Linux rgpi2 3.19.0-v7 #2 SMP PREEMPT Wed Feb 18 19:31:57 PST 2015 armv7l armv7l armv7l GNU/Linux
I did get the kernel compile to crash gcc at one point, but when I re-ran it, all was well.. I did check the cpu temperature while compiling, and it was around 41C..
Robert Gadsdon. February 18, 2015.
Thanks for this useful guide. I was unable to find the kernel source branch which actually matched the 3.18.7 kernel in the Raspbian distro I downloaded, so I had to rebuild from known source in order to go on to build matching ZFS kernel modules, and that’s working nicely now (using 3.18.9 kernel and 0.6.3-1.3 ZFS).
There are a some packages you need to add to make the kernel build work. I don’t remember all those I have added (some may have been added originally for other reasons), but I was caught out during the first build attempt as I was still missing “bc” (arbitrary precision calculator language) which the kernel build uses.
The Raspberry Pi 2 can be made to build the kernel much more quickly using ‘make -j5’. This sets up five jobs concurrently, when possible, and makes full use of all the cores.
The build is also quicker if done on a hard drive.
Thanks from me too for this useful guide. I have my Pi 2 running Fedora 21 3.18.7, but I’d like to move up to kernel 4.0.x.
Is it ‘safe’ to use the config from /proc/config.gz to configure a 4.0 kernel? Or is there a recognised way of “upgrading” a running config to ensure successful build? Right now, the Pi does not boot if I use a newly built kernel. I notice that the original kernel7.img is about 3.5Mbytes, whilst /arch/arm/boot/Image after build is over double that size – which makes me think the boot loader might need to know about that.
And thanks, Tim, for the -j5 tip – should speed things up a little for me!
There were many changes from 3.18 to 4.x, so best to run # make bcm2709_defconfig, which will generate an appropriate kernel config..
RG.