Pieter-Jan5000
Posts: 40
Joined: Tue Jun 12, 2012 7:20 pm
Contact: Website

Trouble cross compiling linux kernel on osX

Wed Nov 05, 2014 7:53 pm

Hello,

I can't cross compile the linux kernel on osX and I don't understand why. Following the steps on the eLinux website I get the following error:

Code: Select all

scripts/sortextable.c:244:7: error: use of undeclared identifier 'EM_S390'
I first installed the arm-none-eabi toolchain with following instructions:

http://blog.y3xz.com/blog/2012/10/07/se ... n-mac-os-x

This is the script I used to compile (edited a little bit from the eLinux):

Code: Select all

#!/bin/bash
# sudo port install arm-none-eabi-gcc
# sudo port install arm-none-eabi-binutils
brew install libelf
sudo ln -s /usr/local/Cellar/libelf /usr/include/libelf
sudo curl http://opensource.apple.com/source/dtrace/dtrace-48/sys/elftypes.h?txt -o  /usr/include/elftypes.h
sudo curl http://opensource.apple.com/source/dtrace/dtrace-48/sys/elf.h?txt -o /usr/include/elf.h
#code to append to elf.h
echo "
#define R_386_NONE 0
#define R_386_32 1
#define R_386_PC32 2
#define R_ARM_NONE 0
#define R_ARM_PC24 1
#define R_ARM_ABS32 2
#define R_MIPS_NONE 0
#define R_MIPS_16 1
#define R_MIPS_32 2
#define R_MIPS_REL32 3
#define R_MIPS_26 4
#define R_MIPS_HI16 5
#define R_MIPS_LO16 6" > elf-append.h
sudo -s 'cat elf-append.h >> /usr/include/elf.h'

#Make a case sensitive 3 GB disk image, raspberrypi-kernel, and attach it:
hdiutil create -size 10g -type SPARSEBUNDLE -nospotlight -volname raspberrypi-kernel -fs "Case-sensitive Journaled HFS+" -attach ./raspberrypi-kernel.dmg
cp raspberrypi.config /Volumes/raspberrypi-kernel/
mkdir /Volumes/raspberrypi-kernel/src
cd /Volumes/raspberrypi-kernel/src

git init
git clone --depth 1 git://github.com/raspberrypi/linux.git

cpu=$(sysctl hw.ncpu | awk '{print $2}')
cpup1=$((cpu+1))

cd /Volumes/raspberrypi-kernel/src/linux/
export CCPREFIX=~/arm-cs-tools/bin/arm-none-eabi-
make mrproper
cp /Volumes/raspberrypi-kernel/raspberrypi.config .config
#Answer yes to all config options
yes "" | make ARCH=arm CROSS_COMPILE=${CCPREFIX} oldconfig
make ARCH=arm CROSS_COMPILE=${CCPREFIX} -j2
#make ARCH=arm CROSS_COMPILE=${CCPREFIX} modules -j$cpup1
The problem seems related to Elf, but everything seems installed correctly ...
http://www.pieter-jan.com/

Pieter-Jan5000
Posts: 40
Joined: Tue Jun 12, 2012 7:20 pm
Contact: Website

Re: Trouble cross compiling linux kernel on osX

Wed Nov 05, 2014 8:48 pm

Ok, quick update:

Adding the following line to the build script's includes already got me further:

Code: Select all

#define EM_S390   22      /* IBM S/390 */
I found that in 2012 the dependency for this EM_S390 macro was added to scripts/sortextable.c
http://www.pieter-jan.com/

riklaunim
Posts: 265
Joined: Tue Apr 22, 2014 7:34 pm

Re: Trouble cross compiling linux kernel on osX

Wed Nov 05, 2014 10:46 pm

Wouldn't it be better to run a Linux OS in vitual machine that would cross-compile to ARM?

Pieter-Jan5000
Posts: 40
Joined: Tue Jun 12, 2012 7:20 pm
Contact: Website

Re: Trouble cross compiling linux kernel on osX

Thu Nov 06, 2014 6:08 am

Well it worked by adding the define. Everything compiled now.

I used to use VM's and stuff to do this but I think they are suboptimal solutions. OSX is what I use to develop stuff at home, so that's what I want to use all the way through ;). It's a pretty great UNIX system as well ...
Last edited by Pieter-Jan5000 on Thu Nov 06, 2014 7:26 am, edited 1 time in total.
http://www.pieter-jan.com/

Return to “General discussion”