手机版
你好,游客 登录 注册 搜索
背景:
阅读新闻

CentOS交叉编译Raspberry Pi 2 内核

[日期:2015-09-16] 来源:Linux社区  作者:lwh007 [字体: ]

交叉编译工具链在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

本文永久更新链接地址http://www.linuxidc.com/Linux/2015-09/123104.htm

linux
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款