学习Mainline之Kernel编译
记录: 学习 Mainline 之 Kernel 编译
获取Kernel源码
git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git --depth=1
配置
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- sunxi_defconfig
关于sunxi_defconfig:
大姐姐 [26.04.17 22:13]
Linux 内核没有 per-board 的 defconfig 用
sunxi_defconfig 就行
针对Banana Pi M2+的Patch
mkdir M2P_Patch
cd M2P_Patch
wget https://github.com/linux-sunxi/linux-sunxi/commit/a0b1910e857897ae6c420fa0ece52c87d7cff373.patch
wget https://github.com/linux-sunxi/linux-sunxi/commit/d699c1d0860aa8b3031d56ec861e6c2f2e37df95.patch
wget https://github.com/linux-sunxi/linux-sunxi/commit/864ebdf0bd4166e64c21e95b72d770eaa33122aa.patch
wget https://github.com/linux-sunxi/linux-sunxi/commit/3ecc25e12f0e210d56fcca110a8144e50db05905.patch
wget https://github.com/linux-sunxi/linux-sunxi/commit/da89e1d5cbafe9fac6325867e609cc4d2b681e84.patch
git am M2P_Patch/a0b1910e857897ae6c420fa0ece52c87d7cff373.patch
git am M2P_Patch/d699c1d0860aa8b3031d56ec861e6c2f2e37df95.patch
git am M2P_Patch/864ebdf0bd4166e64c21e95b72d770eaa33122aa.patch
git am M2P_Patch/3ecc25e12f0e210d56fcca110a8144e50db05905.patch
git am M2P_Patch/da89e1d5cbafe9fac6325867e609cc4d2b681e84.patch
注意da89e1d5cbafe9fac6325867e609cc4d2b681e84.patch
文件内的sunxi-h3-h5.dtsi
需要改成sun8i-h3.dtsi
才能被打进源码
编译zImage
ARCH=arm CROSS_COMPILE=<编译器的位置> make zImage dtbs
编译成功后会在linux/arch/arm/boot/
目录下生成我们需要的zImage
文件,留以备用!
编译Kernel Module的配置
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig
启用可加载模块支持
[*] Enable loadable module support --->
打开Kernel Debug
Kernel hacking --->
[*] Kernel debugging
开启内核低级调试
[*] Kernel low-level debugging functions (read help!) Kernel low-level
debugging port (Kernel low-level debugging messages via sunXi UART0)
---> [*] Early printk
开启 USB OTG Mass Storage
Device Drivers --->
USB.....
编译和安装Kernel Module
make ARCH=arm CROSS_COMPILE=<交叉编译链位置> INSTALL_MOD_PATH=<Kernel Module安装位置> modules modules_install
参考
标签: 无标签