Update: Cross Building Linux With ELLCC: Part 3 – Other Flavors of Pi
In a previous post I tested the waters to see how close ELLCC is to cross compiling the Linux kernel. That post was mostly a theoretical exercise to see what it would take. Over the holidays I decided that I needed to do something a little more concrete. My son, a 10 year old obsessed with Minecraft, got a Raspberry Pi for Christmas. My nefarious plan is to divert his attention away from Minecraft at least long enough to make his Pi and camera module into something he can use to spy on the family. My other nefarious plan is to use ELLCC to build the Linux kernel that we’ll be running on his Pi.
In the previous post I used the source from the LLVMLinux site. This time I started with the kernel source for the Raspberry Pi. The good news is that the source can be built for the Pi. The bad news is that it doesn’t have all the patches need to compile with a clang based compiler. It turned out that the build wasn’t too bad: I had Christmas Eve and Day off and in between family events and Santa preparations I was able to massage the source enough to boot the kernel on our Pi.
To get started I followed the instructions on Linux From Scratch on the Raspberry Pi.
Here are the exact steps I took. First I created a new directory to hold the ELLCC tool chain and the Raspberry Linux kernel source, then I downloaded and untar’d both:
mkdir ecclinux cd ecclinux wget http://ellcc.org/releases/ellcc-x86_64-linux-eng-0.1.23.tgz tar xvfp ellcc-x86_64-linux-eng-0.1.23.tgz wget https://github.com/raspberrypi/linux/archive/rpi-4.1.y.tar.gz tar xvfp rpi-4.1.y.tar.gz
I had to change the kernel sources slightly during my build. I saved a patch
file, here’s how to apply it:
patch -p0 < ellcc/libecc/llvmlinux/ecc-rpi-4.1.y.patch
There is a special little 'm' makefile that helps with the build. Copy
it into the top level of the kernel source directory:
cd linux-rpi-4.1.y/ cp ../ellcc/libecc/llvmlinux/makefile .
Now the actual build is easy:
make bcmrpi_defconfig make
I have my Raspberry Pi on my home network at 18.104.22.168. I also allowed ssh
and scp root access by follwoing the instructions here. This lets me
just copy the new kernel to my Pi:
scp ./arch/arm/boot/zImage email@example.com:/boot/kernel.img
Now I can ssh to the Pi and reboot:
[~] dev% ssh firstname.lastname@example.org email@example.com's password: The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. root@raspberrypi:~# reboot Connection to 22.214.171.124 closed by remote host. Connection to 126.96.36.199 closed. [~] dev%
I ping the Pi until it reboots and log in again:
[~] dev% ssh firstname.lastname@example.org email@example.com's password: The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. Last login: Sat Dec 26 20:27:15 2015 from 188.8.131.52 root@raspberrypi:~# dmesg | less [ 0.000000] Booting Linux on physical CPU 0x0 [ 0.000000] Initializing cgroup subsys cpuset [ 0.000000] Initializing cgroup subsys cpu [ 0.000000] Initializing cgroup subsys cpuacct [ 0.000000] Linux version 4.1.15 (rich@dev) (ecc 0.1.23 based on clang version 3.8.0 (trunk) (based on LLVM 3.8.0svn)) #1 Sat Dec 26 11:32:33 CST 2015 [ 0.000000] CPU: ARMv6-compatible processor [410fb767] revision 7 (ARMv7), cr=00c5387d ...