编译linux内核

1.下载内核
https://www.kernel.org/
2.上传服务器,解压
tar -xvf linux-4.9.310
3.编辑Makefile,设置交叉编译工具链
#ARCH ?= $(SUBARCH)
ARCH ?= arm
#CROSS_COMPILE ?= $(CONFIG_CROSS_COMPILE:“%”=%)
CROSS_COMPILE ?= arm-linux-gnueabihf-
4.编译默认配置,配置在arch/arm/configs/目录下
make exynos_defconfig
5.设置菜单配置
make menuconfig
5.1执行命令报错 scripts/kconfig/lxdialog/dialog.h:38:20: fatal error: curses.h
这是没有安装用户界面显示的库
在 Debian/Ubuntu 环境下安装 ncurses 库
sudo apt-get install libncurses5-dev libncursesw5-dev
在 CentOS/RHEL 环境下安装 ncurses 库
sudo yum install ncurses-devel
6.编译内核
make uImage
6.1 出现如下报错
This is incompatible with uImages
Specify LOADADDR on the commandline to build an uImage
arch/arm/boot/Makefile:79: recipe for target ‘arch/arm/boot/uImage’ failed
重新执行命令:LOADADDR=0x40000000 make uImage

6.2出现如下报错
	"mkimage" command not found - U-Boot images will not be built

arch/arm/boot/Makefile:79: recipe for target ‘arch/arm/boot/uImage’ failed
执行命令:sudo apt-get install uboot-mkimage
但却提示”现在没有可用的软件包 uboot-mkimage,过时了,用u-boot-tools替代
执行命令:sudo apt-get install u-boot-tools

重新执行编译命令:LOADADDR=0x40000000 make uImage
6.3出现如下错误
xxx: fatal error: Python.h: No such file or directory 
是python版本与操作系统版本不一致(python32位,操作系统64位)
执行如下命令,查看python版本
python -V
apt-get install python3-dev  (我这是python3,python版本号-dev)
重新执行编译命令:LOADADDR=0x40000000 make uImage

7.编译成功,如下

Image Name:   Linux-4.9.310
Created:      Sat Apr 16 18:46:18 2022
Image Type:   ARM Linux Kernel Image (uncompressed)
Data Size:    4640656 Bytes = 4531.89 KiB = 4.43 MiB
Load Address: 40000000
Entry Point:  40000000
  Kernel: arch/arm/boot/uImage is ready

8.编译设备树
make dtbs

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值