交叉編譯工具鏈在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.htm
Raspberry Pi 樹莓派上安裝Weston http://www.linuxidc.com/Linux/2013-06/86685.htm
用於Raspberry Pi 的Linux 操作系統已經可用 http://www.linuxidc.com/Linux/2012-03/56058.htm
Raspberry Pi(樹莓派)試用小記 http://www.linuxidc.com/Linux/2013-10/91008.htm
Raspberry Pi(樹莓派)的安裝、配置IP及軟件源等入門 http://www.linuxidc.com/Linux/2013-10/91009.htm