树莓派3b+ 交叉编译 及升级 kernel
安装 gcc pkg 等工具
sudo apt-get install build-essential git
官方介绍
https://www.raspberrypi.org/documentation/linux/kernel/building.md
https://www.raspberrypi.org/documentation/linux/kernel/configuring.md
https://www.raspberrypi.org/documentation/linux/kernel/patching.md
配置环境变量 添加交叉工具链
git clone https://github.com/raspberrypi/tools.git
/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin
arm-linux-gnueabihf-gcc --version
下载内核源码
git clone --depth=1 --branch rpi-4.14.y https://github.com/raspberrypi/linux
cd linux
KERNEL=kernel7
#make bcm2709_defconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- bcm2709_defconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- zImage modules dtbs -j4
如果在树莓派上也可以编译就是时间久
使用 新内核,在 ubuntu 插入SD 卡查看 , 16G sandisk class 10
lsblk
sdb 8:16 1 14.9G 0 disk
├─sdb2 8:18 1 14.8G 0 part /media/dev/rootfs
└─sdb1 8:17 1 43.2M 0 part /media/dev/boot
cat /proc/mounts
/dev/sdb2 /media/dev/rootfs ext4 rw,
/dev/sdb1 /media/dev/boot vfat rw,
自动挂载好了
with sdb1 being the FAT (boot) partition, and sdb2 being the ext4 filesystem (root) partition.
先安装模块
sudo make ARCH=arm CROSS_COMPILE=/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf- INSTALL_MOD_PATH=/media/dev/rootfs modules_install
使用新内核替换原文件
sudo cp /media/dev/boot/$KERNEL.img /media/dev/boot/$KERNEL-backup.img
sudo cp arch/arm/boot/zImage /media/dev/boot/$KERNEL.img
sudo cp arch/arm/boot/dts/*.dtb /media/dev/boot/
sudo cp arch/arm/boot/dts/overlays/*.dtb* /media/dev/boot/overlays/
sudo cp arch/arm/boot/dts/overlays/README /media/dev/boot/overlays/
插SD卡,上电,启动正常