One thing leads to another and suddenly you want to compile a new Raspberry Pi kernel, and your most convenient host is a Mac.
I started with some existing notes about this — but I found they needed some tweaking and some updates have happened which make things a little easier.
I’m using crosstool-ng from Homebrew on OS X 10.9.
Instructions
Install packages
These are the packages I needed from Homebrew.
1 2 3 4 5 6 7 8 9 |
|
Note that link --force
is not a particularly nice thing to do, and will (e.g.) prevent you from reinstalling crosstool-ng without uninstalling gettext first. But it appears to be necessary, as eglibc build fails without it (and I don’t understand if there’s an option that will let me specity gettext’s location to eglibc)
Make crosstools use GNU grep
1
|
|
Edit paths.sh
, changing the line about grep
to read:
1
|
|
(Is there a user-level config way to do this w/o poking around in the Homebrew cellar?)
Create disk images
Crosstools needs case-sensitive file systems to work on, we’ll create two images, one to compile in and one to host the binaries.
1 2 3 4 5 6 7 8 9 |
|
Set up crosstools-ng
Thanks to Kentzo there is a Raspberry Pi configuration already in crosstools-ng
in Homebrew, and there only need minor adjustments.
1 2 |
|
Now extract this repository onto the drive image. It contains a .config
file and a couple of patches.
1
|
|
Then inspect the configuration:
1
|
|
Check that all the paths under “Paths” point to somewhere logical (mounted on your disk images)
For extra speed, set “Paths::Build behavior::number of parallel jobs” to twice your number of cores. This also means you will need to also up the ulimit
before building. (If there are weird errors about no rules to make targets related to language localization, you probably forgot to do this.) So now do
1 2 |
|
Hopefully this will work.
Test the compiler
1 2 3 |
|
(press ctrl-d to finish)
1
|
|
Copy test
over to your RPi and try running it.
1 2 |
|
Compiling a Kernel
Well this is what I signed up for.
I wanted to build the kernel described here.
I’m cribbing from these notes.
1 2 |
|
Copy the existing config.
1 2 3 |
|
1
|
|
menuconfig
doersn’t work for me because of some ncurses
problem but there is make nconfig
1
|
|
1
|
|
Now it is complaining about lack of “elf.h” Where is it looking for elf.h?
1 2 3 4 |
|
… and some other advice from the internet, which didn’t work either. It’s not the ‘echo’ problem, as that’s been long fixed.
Giving up threshold reached
…. oh but adjusting Linux enough to compile in an OSX environment is going to be bad. gonna investigate just installing an Ubuntu VM under VirtualBox and compiling there
honestly a kernel compile on the Pi itself would have finished by now