系列文章目录
- Exynos4412 Linux Kernel 5.15移植过程记录(一)——解决编译内核出现mpc.h: gmp.h: No such file or director问题
- Exynos4412 移植Linux Kernel 5.15过程记录(二)——解决U-Boot卡在Starting kernel的问题,DM9000网卡驱动(设备树)
- Exynos4412 移植Linux Kernel 5.4过程记录(三)——根文件系统构建与SD卡挂载fs
Exynos4412 Linux Kernel 5.15移植过程记录
- 系列文章目录
- 一、Linux Kernel编译的准备工作
- 1、Linux Kernel下载与解压
- 2、修改内核顶层目录下的Makefile
- 3、导入默认配置
- 4、配置内核
- 5、解决LEX scripts/kconfig/lexer.lex.c /bin/sh: 1: flex: not found的问题
- 6、解决fatal error: openssl/bio.h: No such file or director
- 7、解决error: gmp.h: No such file or director问题
- 8、解决error: mpc.h: No such file or director
- 9、解决multiple (or no) load addresses错误
- 10、配置tftp服务器,
- 11、烧写内核
- 二、为Exynos4412移植内核
项目 | 说明 |
---|---|
操作系统 | Ubuntu 18.04 |
Linux内核版本 | Linux Kernel stable: 5.15.14 |
Image Name | Linux-5.15.14-FriendlyARM |
硬件 | CBT4412(类似:tiny4412) |
U-Boot | u-boot-2022.01-rc4 |
gcc | arm-linux-gnueabihf-gcc 10.3.1 20210621 |
一、Linux Kernel编译的准备工作
1、Linux Kernel下载与解压
下载地址:https://www.kernel.org/
目前,最新版本是5.16。我下载的是linux-5.15.14.tar.xz。
解压到~目录下。
tar vxf linux-5.15.14.tar.xz
2、修改内核顶层目录下的Makefile
cd ~/linux-5.15.14/
gedit Makefile
修改:
ARCH ?= $(SUBARCH)
CROSS_COMPILE ?= $(CONFIG_CROSS_COMPILE:"%"=%)
为:
ARCH ?= arm
CROSS_COMPILE ?= arm-linux-gnueabihf-
3、导入默认配置
make exynos_defconfig
4、配置内核
make menuconfig
配置System Type —>
Samsung Exynos —>Samsung Exynos 4412
5、解决LEX scripts/kconfig/lexer.lex.c /bin/sh: 1: flex: not found的问题
解决方法:
$ sudo apt-get install flex
6、解决fatal error: openssl/bio.h: No such file or director
解决方法:
$ sudo apt-get install libssl-dev
7、解决error: gmp.h: No such file or director问题
编译内核
make uImage
报错:error: gmp.h 没有这个文件或目录
通过360搜索,找到解决方案如下:
sudo apt-get install libgmp3-dev
8、解决error: mpc.h: No such file or director
编译内核,报错fatal error: gmp.h: 没有那个文件或目录。解决方法:
sudo apt-get install libmpc-dev
9、解决multiple (or no) load addresses错误
make uImage编译内核,报错multiple (or no) load addresses。表明没有定义宏LOADADDR。具体分析可参见博文Linux内核移植 part3:Exynos4412内核编译1
编辑arch/arm/boot/Makefile,直接添加
LOADADDR := 0x40008000
由于找不到mkimage工具,复制在uboot根目录tools目录的mkimage,放到/usr/local/bin即可。
sudo cp ~/u-boot-2022.01-rc4-cbt4412/tools/mkimage /usr/local/bin
准备就绪,make uImage编译内核,显示如下信息:
$ make uImage
Kernel: arch/arm/boot/Image is ready
Kernel: arch/arm/boot/zImage is ready
UIMAGE arch/arm/boot/uImage
Image Name: Linux-5.15.14-FriendlyARM
Created: Sat Jan 15 20:11:36 2022
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 6795088 Bytes = 6635.83 KiB = 6.48 MiB
Load Address: 40008000
Entry Point: 40008000
Kernel: arch/arm/boot/uImage is ready
10、配置tftp服务器,
配置tftp服务器具体步骤参见另一篇博文ubuntu18.04上配置tftp服务器2
把arch/arm/boot目录下的uImage复制到/CBT-SuperIOT/tftpboot/。
cp arch/arm/boot/uImage /CBT-SuperIOT/tftpboot/
11、烧写内核
安装串口助手CuteCom。
sudo apt-get install cutecom
打开/dev/ttyUSB0。如果遇到无权限打开串口的情况,通过chmod指令修改/dev目录下的ttyS0或ttyUSB0等串口的读写权限即可。
sudo chmod 666 ttyUSB0
在CuteCom终端中,输入指令
tftp 40008000 uImage;bootm 40008000;
在CuteCom终端中显示。
[20:14:46:125] ## Booting kernel from Legacy Image at 40008000 ...␍␊
[20:14:46:145] Image Name: Linux-5.15.14-FriendlyARM␍␊
[20:14:46:145] Image Type: ARM Linux Kernel Image (uncompressed)␍␊
[20:14:46:145] Data Size: 6795088 Bytes = 6.5 MiB␍␊
[20:14:46:145] Load Address: 40008000␍␊
[20:14:46:161] Entry Point: 40008000␍␊
[20:14:46:161] Verifying Checksum ... OK␍␊
[20:14:47:026] Loading Kernel Image␍␊
[20:14:47:128] FDT and ATAGS support not compiled in␍␊
以上是开发板通过串口打印出的信息,在“OK”之前的内容是64Bytes打印出的内容,之后的是Linux内核自解压程序输出的内容。在打印出“Loading Kernel Image”后,内核遇到错误停止运行。而接下来,即在内核移植之前,有必要去了解Linux内核源代码构造框架——Kbuild机制,这是进行内核代码增删改的基础。
二、为Exynos4412移植内核
请参见第二篇博文《Exynos4412 Linux Kernel移植过程记录(二)——解决U-Boot启动内核,卡在Starting kernel的问题》。