# 编译linux内核 :
核心步骤其实只有下面几步 :
安装交叉编译工具链
sudo apt-get install ncurses-dev make gcc-arm-linux-gnueabi git
其中 ncurses is a library for ubild console menus. It is necessary for menuconfig
下载内核源代码并解压
配置config
cd linux_source_code
- 手动配置在源代码顶层目录生成 .config , 该文件随后make编内核会用到。
- 有些教程会让你直接从解压的源代码中去拷贝,比如cp linux_source_code/arch/arm/configs/xx_defconfig .config
- 如果不拷贝,直接 make menuconfig 手动配置 (其实这样也不会完全从头来,里面最基础的东西都有了) ,可以参考这个wiki来配置 : https://stdrc.cc/post/2020/09/12/minimal-linux-with-busybox/
- 但不论是直接拷贝,还是make menuconfig, 最终目的都是生成 .config
make menuconfig
编译
- 我机器上交叉编译工具链是 arm-linux-gnueabi- ,不是 arm64-xx,它只能编译32位的,所以ARCH不能选择
- ARCH=arm64 ,而要选择 ARCH=arm
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi-