Welcome 微信登录

首页 / 操作系统 / Linux / CentOS交叉编译Raspberry Pi 2 内核

交叉编译工具链在CentOS 6.6 x64需要glibc-2.14支持(x86不需要),所以先安装glibc-2.14安装前把编译需要的相关工具安装下,我这里直接安装整个组yum groupinstall "Development tools" -y下载glibc-2.14源码,编译,安装wget http://ftp.gnu.org/gnu/glibc/glibc-2.14.tar.xz
mkdir /usr/local/glibc-2.14
tar xvf glibc-2.14.tar.xz
cd glibc-2.14
mkdir build
cd build
../configure --prefix=/usr/local/glibc-2.14/
make && make install设置临时环境变量export LD_LIBRARY_PATH=/usr/local/glibc-2.14/lib:$LD_LIBRARY_PATH获取交叉编译工具链,内核,固件(本文使用此方式获取)wget https://github.com/raspberrypi/tools/archive/master.tar.gz -O tools-master.tar.gz
wget https://github.com/raspberrypi/linux/archive/rpi-4.1.y.tar.gz -O linux-rpi-4.1.y.tar.gz
wget https://github.com/raspberrypi/firmware/archive/master.tar.gz -O firmware-master.tar.gz也可以使用git克隆相关仓库:git init
git 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安装工具链,并添加到环境变量中:tar xvf tools-master.tar.gz -C /opt
vim /etc/profile
export PATH=$PATH:/opt/tools-master/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin
. /etc/profile
mv linux-rpi-4.1.y linux
cd linux保证编译目录的干净的(从tar.gz文件解压的话实际上可以省略)make mrproper生成内核默认配置文件make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- bcm2709_defconfig如想更改配置,运行这下:#CentOS 6.6 x64 需要执行 yum install ncurses-devel
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig设置环境变量KERNEL=kernel7开始编译make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- zImage modules dtbs编译结束后,把树莓派的SD卡取下来,挂在到CentOS上mkdir /mnt/fat32
mkdir /mnt/ext4
mount /dev/sdb1 /mnt/fat32
mount /dev/sdb2 /mnt/ext4安装模块make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_MOD_PATH=/mnt/ext4 modules_install复制内核及驱动到SD卡上#先备份原来的内核
cp /mnt/fat32/$KERNEL.img /mnt/fat32/$KERNEL-backup.img
scripts/mkknlimg arch/arm/boot/zImage mnt/fat32/$KERNEL.img
cp 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/更新固件tar xvf firmware-master.tar.gz
cd firmware-master
#替换相关文件
cp boot/*.dat /mnt/fat32/
cp boot/*.elf /mnt/fat32/
cp boot/bcm2709-rpi-2-b.dtb /mnt/fat32/更新vc库cp -rv hardfp/opt/vc /mnt/ext4/opt/vc 完成后,卸载SD卡umount /dev/sdb1
umount /dev/sdb2把SD卡插上raspberry pi 2,插上电源,OK!在(Raspberry Pi)树莓派上安装NodeJS  http://www.linuxidc.com/Linux/2015-01/111714.htmRaspberry Pi 树莓派上安装Weston http://www.linuxidc.com/Linux/2013-06/86685.htm用于Raspberry Pi 的Linux 操作系统已经可用 http://www.linuxidc.com/Linux/2012-03/56058.htmRaspberry Pi(树莓派)试用小记 http://www.linuxidc.com/Linux/2013-10/91008.htmRaspberry Pi(树莓派)的安装、配置IP及软件源等入门 http://www.linuxidc.com/Linux/2013-10/91009.htm本文永久更新链接地址