How-to: Compile a Beagle Bone Black kernel under OSX

First of all, we need a cross compiler.
Please see for the cross compilation toolchain installation. ( Thanks to KNut Welzels )

A fews things will also be usefull, so we install:

Elf.h is somewhat missing on OSX, so we need it.

Edit elf.h and add those lines:

Please see at the end of the post for a patch file.

We now have all the tools to compile a Kernel.

In order to avoid some git trouble, we need a case sensitive file system. If your system is not on that type of file system, you need to build and mount a drive image.

Open the disk utility -> new image.
Choose where you want the image to be placed, name it, select 4.6Gigs size, format MUST be case sensitive.
Click on create.

Disk image is mounted on /Volumes/ with the name you choose earlier.

In the terminal, navigate to your mounted image.

Next, it’s time to clone the kernel repo.

We need to tweak and change a few things.

First is the cross compiler.

You must insert the path to your compiler, ie for me it’s:

Second thing is to modify the Robert’s scripts to include the OSx recognition.
To do so, edit nano and nano tools/ to replace menu_config function or apply the patch at the end of the post.

Time to build !

You will need to disable raid6 drivers, no way to build under OSX and who needs raid6 drivers on a BBB anyway 😉
In the config menu, go to drivers, and disable raid drivers.

Everything should compile fine and you’ll see after a few minutes

Time to build sgx libraries !

First we need the Ti SDK, and the only way to have it on OSX is to copy it from linux, because the .bin won’t execute.
So copy SDK_BIN dir to ignore/.

We have some trouble with xargs on osx that won’t let you do a xargs -r.
No trouble, you already installed findutils, so you have gxargs

edit KERNEL/scripts/Makefile.modpost and change

Please see at the end of the post for a patch file.


Then launch ./
Modules should build fine.

Next, kernel needs to be compiled again using tools/

Everything went well, you should have

There’s still a little glitch, depmod is not on OSX. The modules’ tar will not contains anything but the modules themselves. Looks like you’ll have to run a depmod -a on the beaglebone before being able to load any module.

I need to add a few things to this recipe to be complete because some parts where failing when I followed it.
I’ll add them soon.

For now you can download this kernel patch to be launched against KERNEL directory and this elf.h for osx file to be copied into KERNEL/scripts/ directory.
This patch enables UIO_pruss driver in Kernel menuconfig and make raid6 compilation available.
But you still have to disable apparmor in the kernl config.


Thanks to Robert C Nelson for the repo and advices.

, , , , , , ,

This article was written by Cédric


Knut07/03/2015 at 05:32Reply

Hi Cédric,

nice tutorial, but I run into an error:
In file included from scripts/kconfig/nconf.gui.c:8:
scripts/kconfig/nconf.h:18:10: fatal error: ‘curses.h’ file not found

Did you have installed the ncurses libraries and header files from brew?

And why did you have installed findutils from port and not from brew? Are they differ?

Thanks Knut

Cédric07/03/2015 at 13:04Reply

Hi Knut,
Yes I installed ncurses from brew because I wanted to see if I could get menuconfig working, but I abandoned and went the nconfig route.

You can get findutils from brew or from port, I do not think they differ, they’re both gnu ports.

Thanks for the report, I’ll modify the post to include ncurses libs.