Cross-compiled raspberry pi 2 kernel in CentOS, centosraspberry
Cross-compilation toolchain in centos 6.6 x64 requires glibc-2.14 support (x86 is not needed), so first install the glibc-2.14
Install the relevant compilation tools before installation. Here I will install the entire group directly.
yum groupinstall "Development tools" -y
Download the glibc-2.14 source code, compile, install
wget http://ftp.gnu.org/gnu/glibc/glibc-2.14.tar.xzmkdir /usr/local/glibc-2.14tar xvf glibc-2.14.tar.xzcd glibc-2.14mkdir buildcd build../configure --prefix=/usr/local/glibc-2.14/make && make install
Set temporary environment variables
export LD_LIBRARY_PATH=/usr/local/glibc-2.14/lib:$LD_LIBRARY_PATH
Obtain the cross-compilation toolchain, kernel, and firmware (this method is used in this article)
wget https://github.com/raspberrypi/tools/archive/master.tar.gz -O tools-master.tar.gzwget https://github.com/raspberrypi/linux/archive/rpi-4.1.y.tar.gz -O linux-rpi-4.1.y.tar.gzwget https://github.com/raspberrypi/firmware/archive/master.tar.gz -O firmware-master.tar.gz
You can also use git to clone related repositories:
git initgit clone --depth 1 git://github.com/raspberrypi/linux.git
git clone --depth 1 git://github.com/raspberrypi/tools.git
git clone git://github.com/raspberrypi/firmware.git
Install the tool chain and add it to the environment variable:
tar xvf tools-master.tar.gz -C /optvim /etc/profileexport PATH=$PATH:/opt/tools-master/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin. /etc/profilemv linux-rpi-4.1.y linuxcd linux
Ensure that the compilation directory is clean (if extracted from the tar.gz file, it can be omitted)
make mrproper
Generate the default Kernel configuration file
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- bcm2709_defconfig
To change the configuration, run the following command:
# CentOS 6.6x64 run yum install ncurses-develmake ARCH = arm CROSS_COMPILE = arm-linux-gnueabihf-menuconfig
Set Environment Variables
KERNEL=kernel7
Start Compilation
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- zImage modules dtbs
After compilation, remove the Raspberry Pi SD card and put it on CentOS.
mkdir /mnt/fat32mkdir /mnt/ext4mount /dev/sdb1 /mnt/fat32mount /dev/sdb2 /mnt/ext4
Installation Module
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_MOD_PATH=/mnt/ext4 modules_install
Copy the kernel and drive to the SD card
# Back up the original KERNEL cp/mnt/fat32/$ KERNEL. img/mnt/fat32/$ KERNEL-backup.imgscripts/mkknlimg arch/arm/boot/zImage mnt/fat32/$ KERNEL. imgcp arch/arm/boot/dts /*. dtb/mnt/fat32/cp arch/arm/boot/dts/overlays /*. dtb */mnt/fat32/overlays/cp arch/arm/boot/dts/overlays/README/mnt/fat32/overlays/
Update firmware
Tar xvf firmware-master.tar.gzcd firmware-master # Replace the relevant file cp boot /*. dat/mnt/fat32/cp boot /*. elf/mnt/fat32/cp boot/bcm2709-rpi-2-b.dtb/mnt/fat32/
Update vc Library
cp -rv hardfp/opt/vc /mnt/ext4/opt/vc
After that, uninstall the SD card.
umount /dev/sdb1umount /dev/sdb2
Plug the SD card into raspberry pi 2 and power in. OK!
References:
Https://github.com/raspberrypi/documentation/blob/master/linux/kernel/building.md
Http://elinux.org/Raspberry_Pi_Kernel_Compilation