系列的往期已经介绍了工具链环境建立以及内核压缩文件的获取,话不多说,现在进行解压编译。
前期工作
- 解压
- 修改Makefile
wu@ubuntu:~/linux-upstream-linux-cortexm-2.5.1$ vi Makefile
wu@ubuntu:~/linux-upstream-linux-cortexm-2.5.1$ make distclean
- 菜单配置
wu@ubuntu:~/linux-upstream-linux-cortexm-2.5.1$ make menuconfig
前面我在makefile里手动添加了工具链不知道下面这个是不是画蛇添足
不断纠错
错误1
配置好menuconfig后执行make,发现错误如下
解决方法:
wu@ubuntu:~/linux-upstream-linux-cortexm-2.5.1$ vi .config
错误2
fs/binfmt_elf_fdpic.c: In function 'maydump':
fs/binfmt_elf_fdpic.c:1259:2: error: implicit declaration of function 'vma_is_dax' [-Werror=implicit-function-declaration]
fs/binfmt_elf_fdpic.c: In function 'elf_fdpic_dump_segments':
fs/binfmt_elf_fdpic.c:1545:17: warning: unused variable 'addr' [-Wunused-variable]
cc1: some warnings being treated as errors
scripts/Makefile.build:258: recipe for target 'fs/binfmt_elf_fdpic.o' failed
make[1]: *** [fs/binfmt_elf_fdpic.o] Error 1
Makefile:953: recipe for target 'fs' failed
make: *** [fs] Error 2
解决方法:在binfmt_elf_fdpic.c里添加#include <linux/dax.h>
wu@ubuntu:~/linux-upstream-linux-cortexm-2.5.1/fs$ vi binfmt_elf_fdpic.c
错误3
drivers/usb/dwc2/platform.c: In function 'dwc2_driver_probe':
drivers/usb/dwc2/platform.c:611:2: error: implicit declaration of function 'of_usb_get_dr_mode' [-Werror=implicit-function-declaration]
drivers/usb/dwc2/platform.c:627:2: error: 'phy' undeclared (first use in this function)
drivers/usb/dwc2/platform.c:627:2: note: each undeclared identifier is reported only once for each function it appears in
drivers/usb/dwc2/platform.c:642:2: error: 'struct dwc2_hsotg' has no member named 'init_mutex'
drivers/usb/dwc2/platform.c: In function 'dwc2_suspend':
drivers/usb/dwc2/platform.c:734:3: error: implicit declaration of function 's3c_hsotg_suspend' [-Werror=implicit-function-declaration]
drivers/usb/dwc2/platform.c: At top level:
drivers/usb/dwc2/platform.c:398:12: warning: 'dwc2_lowlevel_hw_init' defined but not used [-Wunused-function]
cc1: some warnings being treated as errors
scripts/Makefile.build:258: recipe for target 'drivers/usb/dwc2/platform.o' failed
make[3]: *** [drivers/usb/dwc2/platform.o] Error 1
scripts/Makefile.build:407: recipe for target 'drivers/usb/dwc2' failed
make[2]: *** [drivers/usb/dwc2] Error 2
scripts/Makefile.build:407: recipe for target 'drivers/usb' failed
make[1]: *** [drivers/usb] Error 2
Makefile:953: recipe for target 'drivers' failed
make: *** [drivers] Error 2
解决方法:
wu@ubuntu:~/linux-upstream-linux-cortexm-2.5.1/drivers/usb/dwc2$ vi platform.c
wu@ubuntu:~/linux-upstream-linux-cortexm-2.5.1$ vi drivers/usb/dwc2/core.h
wu@ubuntu:~/linux-upstream-linux-cortexm-2.5.1$ vi drivers/usb/dwc2/platform.c
错误4
drivers/iio/light/noa1305.c:164:1: error: 'noa1305_id' undeclared here (not in a function)
drivers/iio/light/noa1305.c:164:1: error: '__mod_i2c__noa1305_id_device_table' aliased to undefined symbol 'noa1305_id'
scripts/Makefile.build:264: recipe for target 'drivers/iio/light/noa1305.o' failed
make[3]: *** [drivers/iio/light/noa1305.o] Error 1
scripts/Makefile.build:407: recipe for target 'drivers/iio/light' failed
make[2]: *** [drivers/iio/light] Error 2
scripts/Makefile.build:407: recipe for target 'drivers/iio' failed
make[1]: *** [drivers/iio] Error 2
Makefile:952: recipe for target 'drivers' failed
make: *** [drivers] Error 2
解决方法:
wu@ubuntu:~/linux-upstream-linux-cortexm-2.5.1$ vi drivers/iio/light/noa1305.c
错误5
drivers/usb/dwc2/platform.c: In function 'dwc2_driver_probe':
drivers/usb/dwc2/platform.c:611:2: warning: passing argument 1 of 'usb_get_dr_mode' from incompatible pointer type [enabled by default]
In file included from include/linux/usb/of.h:11:0,
from drivers/usb/dwc2/platform.c:50:
include/linux/usb/otg.h:129:25: note: expected 'struct device *' but argument is of type 'struct device_node *'
drivers/usb/dwc2/platform.c:627:2: error: 'phy' undeclared (first use in this function)
drivers/usb/dwc2/platform.c:627:2: note: each undeclared identifier is reported only once for each function it appears in
drivers/usb/dwc2/platform.c: At top level:
drivers/usb/dwc2/platform.c:398:12: warning: 'dwc2_lowlevel_hw_init' defined but not used [-Wunused-function]
scripts/Makefile.build:258: recipe for target 'drivers/usb/dwc2/platform.o' failed
make[3]: *** [drivers/usb/dwc2/platform.o] Error 1
scripts/Makefile.build:407: recipe for target 'drivers/usb/dwc2' failed
make[2]: *** [drivers/usb/dwc2] Error 2
scripts/Makefile.build:407: recipe for target 'drivers/usb' failed
make[1]: *** [drivers/usb] Error 2
Makefile:952: recipe for target 'drivers' failed
make: *** [drivers] Error 2
解决方法:
wu@ubuntu:~/linux-upstream-linux-cortexm-2.5.1$ vi drivers/usb/dwc2/platform.c
这时候执行make应该就不会报错了
uImage
wu@ubuntu:~/linux-upstream-linux-cortexm-2.5.1$ make uImage
Linux只能生成zImage而生成不了uImage。uImage不关linux内核的事,linux内核只管生成zImage即可,然后uboot中的mkimage工具再去由zImage加工生成uImage来给uboot启动。
解决方法:
首先在uboot的/tools目录下寻找mkimage文件,把其copy到系统/usr/local/bin目录下,这样就 完成制作工具。然后在内核目录下运行make uImage
(如果你还没编译uboot,这里往后的无法进行)
wu@ubuntu:/usr/local/bin$ sudo cp ~/u-boot-fsl-linux-cortexm-2.5.0/tools/mkimage .
[sudo] password for wu:
wu@ubuntu:/usr/local/bin$ ls
mkimage
wu@ubuntu:/usr/local/bin$ cd ~/u-boot-fsl-linux-cortexm-2.5.0/
wu@ubuntu:~/u-boot-fsl-linux-cortexm-2.5.0$ cd ..
wu@ubuntu:~$ cd linux-upstream-linux-cortexm-2.5.1/
wu@ubuntu:~/linux-upstream-linux-cortexm-2.5.1$ make uImage
CHK include/config/kernel.release
CHK include/generated/uapi/linux/version.h
CHK include/generated/utsrelease.h
make[1]: 'include/generated/mach-types.h' is up to date.
CHK include/generated/bounds.h
CHK include/generated/timeconst.h
CHK include/generated/asm-offsets.h
CALL scripts/checksyscalls.sh
CHK include/generated/compile.h
Kernel: arch/arm/boot/Image is ready
Kernel: arch/arm/boot/Image is ready
Kernel: arch/arm/boot/zImage is ready
Kernel: arch/arm/boot/Image is ready
Kernel: arch/arm/boot/zImage is ready
UIMAGE arch/arm/boot/uImage
Image Name: Linux-4.5.0
Created: Fri Jul 23 07:59:53 2021
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 4119560 Bytes = 4023.01 KiB = 3.93 MiB
Load Address: 00808000
Entry Point: 00808001
Image arch/arm/boot/uImage is ready
wu@ubuntu:~/linux-upstream-linux-cortexm-2.5.1$ cd arch/arm/boot/
wu@ubuntu:~/linux-upstream-linux-cortexm-2.5.1/arch/arm/boot$ ls
bootp compressed dts Image install.sh Makefile uImage zImage
wu@ubuntu:~/linux-upstream-linux-cortexm-2.5.1/arch/arm/boot$
uboot编译相关文章欢迎前往专栏查阅