คอมไพล์เคอร์เนล
จาก Morange Wiki
เนื้อหา
[ซ่อน]Cross compiling from OSX
การติดตั้งจาก Macports
ในการติดตั้ง ต้องลง Xcode และ command line tools จาก Apple Developer Connection และติดตั้ง Macport เสียก่อน macports จากนั้น ติดตั้ง gcc คอมไพเลอร์จาก port
port install arm-none-eabi-gcc port install arm-none-eabi-binutils
ถ้าพลบว่า elf.h หายไป
sudo port install libelf && sudo ln -s /opt/local/include/libelf /usr/include/libelf
จาก opensource.apple.com, download and copy elf.h and elftypes.h to /usr/include
เตรียม config สำหรับ kernel โดยดึงมาจากเครื่อง raspberrypi ที่เปิดอยู่โดยใช้คำสั่ง
zcat /proc/config.gz > raspberrypi.config
script สำหรับการตั้งค่า
sudo port install arm-none-eabi-gcc sudo port install arm-none-eabi-binutils sudo port install libelf && sudo ln -s /opt/local/include/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 3gb 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 #get source, either 1. from zip (faster), or 2. from git #1. from zip curl https://codeload.github.com/raspberrypi/linux/zip/rpi-3.6.y -o ./rpi-3.6.y.zip unzip rpi-3.6.y.zip #2. from git (disabled) #git init #git fetch git://github.com/raspberrypi/linux.git rpi-3.6.y:refs/remotes/origin/rpi-3.6.y #git checkout rpi-3.6.y cd /Volumes/raspberrypi-kernel/src/linux-rpi-3.6.y/ export CCPREFIX=/opt/local/bin/arm-none-eabi- make mrproper
git clone git://aufs.git.sourceforge.net/gitroot/aufs/aufs3-standalone.git cd aufs3-standalone git checkout origin/aufs3.6 cp -rp *.patch ../ cp -rp fs ../ cp -rp Documentation/ ../ cp -rp include/ ../ cd .. patch -p1 < aufs3-kbuild.patch patch -p1 < aufs3-base.patch patch -p1 < aufs3-mm_map.patch patch -p1 < aufs3-standalone.patch
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} -j6 make ARCH=arm CROSS_COMPILE=${CCPREFIX} -j6 modules make ARCH=arm CROSS_COMPILE=${CCPREFIX} -j6 zImage export MODULES_TEMP=~/modules make ARCH=arm CROSS_COMPILE=${CCPREFIX} INSTALL_MOD_PATH=${MODULES_TEMP} modules_install
จากนั้น copy file จาก ~/module และ zImage จาก arch/arm/boot/zImage เพื่อใช้ในการ boot
Cross compiling from Debian x64
แก้เป็น jessie
apt-get install libc6 make ncurse-dev git git clone git://github.com/raspberrypi/tools.git --depth 1 curl https://codeload.github.com/raspberrypi/linux/zip/rpi-3.12.y -o ./rpi-3.12.y.zip unzip rpi-3.12.y.zip git clone git://aufs.git.sourceforge.net/gitroot/aufs/aufs3-standalone.git cd aufs3-standalone git checkout origin/aufs3.6 cp -rp *.patch ../ cp -rp fs ../ cp -rp Documentation/ ../ cp -rp include/ ../ cd ..
export ${CCPREFIX}=/root/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-gcc cp raspberrypi.config .config #answer yes to all config options #yes "" | make ARCH=arm CROSS_COMPILE=${CCPREFIX} oldconfig make ARCH=arm CROSS_COMPILE=${CCPREFIX} -j6 make ARCH=arm CROSS_COMPILE=${CCPREFIX} -j6 modules make ARCH=arm CROSS_COMPILE=${CCPREFIX} -j6 zImage export MODULES_TEMP=~/modules make ARCH=arm CROSS_COMPILE=${CCPREFIX} INSTALL_MOD_PATH=${MODULES_TEMP} modules_install
แหล่งที่มา
- [ http://elinux.org/RPi_Kernel_Compilation#Cross_compiling_from_OSX RPi_Kernel_Compilation]
- [ http://rpitc.blogspot.com/p/kernel-rebuild.html HowTo rebuild Kernel for Raspberri-Pi to add aufs support]