Loading

Kernel、busybox编译

一、编译kernel源码

1、指定硬件体系架构吗,如果需要指定编译arm内核,则指定ARCH=arm且需要安装交叉编译器。

#export ARCH=x86

2、配置board config,此处配置为x86_64_defconfig

#make x86_64_defconfig

在这一步的编中可能会报错,报错信息如下。

fatal error: curses.h: 没有那个文件或目录
compilation terminated.
make【1】: *** 【scripts/Makefile.host:118:scripts/kconfig/mconf.o】 错误 1
make: *** 【Makefile:553:menuconfig】 错误 2

针对上述报错信息,需要将源更新为清华源,执行.

sudo apt-get install libncurse5-dev

3、配置menuconfig

make menuconfig

4、配置内核
执行成功第三步中的命令后,会弹出一个配置框。对该菜单进行微调,需要内核支持ramdisk驱动,所以需要选中如下配置:

General setup  --->
       ----> [*] Initial RAM filesystem and RAM disk (initramfs/initrd) support
Device Drivers  --->
       [*] Block devices  --->
               <*>   RAM block device support
               (65536) Default RAM disk size (kbytes) 

5、编译内核

make

二、编译busybox源码

1、配置busybox源码,将busy配置为静态编译,这样busybox在运行的时候就不需要额外的动态链接库了。

#make menuconfig

Busybox setting --->
    Build Options --->
        [*] Build BusBox as a static binary (no share libs)

2、编译和安装

#make && make install

编译后的内核文件位于: ./_install 中

学习自: https://www.bilibili.com/read/cv11271232

posted @ 2021-09-02 22:50  鱼儿叁  阅读(215)  评论(0编辑  收藏  举报