参考:Linux 4.19.88 移植到imx280_buildroot280-CSDN博客
1.编译elftosb工具
$ cd imx280_zlg $ TopDir=`pwd`
修改imx280_zlg文件夹中的Makefile文件:
OUT_DIR := $(CURDIR)/OUT
$(shell [ -d ${OUT_DIR} ] || mkdir -p ${OUT_DIR})
_cross_compile=$(shell cd cross_compile/bin/;pwd)
_out_dir=$(shell cd $OUT_DIR;pwd)
CC=${_cross_compile}/arm-none-eabi-
.PHONY: bootloader kernel tools bootstream
all: bootloader kernel
@echo -e "\t\033[32m build success . \033[0m"
bootloader:
${MAKE} -C bootloader/u-boot-2017.09/ ARCH=arm CROSS_COMPILE=${CC} O=${OUT_DIR}/uboot mx28evk_defconfig
${MAKE} -C bootloader/u-boot-2017.09/ ARCH=arm CROSS_COMPILE=${CC} O=${OUT_DIR}/uboot u-boot.sb -j8
cp bootloader/u-boot-2017.09/bootstream/uboot_ivt.bd ${OUT_DIR}/uboot/
cd ${OUT_DIR}/uboot; rm u-boot.sb;../tools/elftosb -f imx28 -c uboot_ivt.bd -o uboot.sb
cd ${OUT_DIR}/uboot; ./tools/mxsboot sd uboot.sb uboot.sd
# dd if= ${OUT_DIR}/uboot/uboot.sd of=/def/sdf1
#$(OUT_DIR)/tools/elftosb -f imx28 -c ${OUT_DIR}/uboot/uboot_ivt.bd -o ${OUT_DIR}/uboot/boot.sb
kernel:
make -C kernel/linux-4.19.88/ ARCH=arm CROSS_COMPILE=${CC} O=${OUT_DIR}/kernel mxs_defconfig
make -C kernel/linux-4.19.88/ ARCH=arm CROSS_COMPILE=${CC} O=${OUT_DIR}/kernel -j8
tools:
mkdir $(OUT_DIR)/tools
make -C elftosb/ O=$(OUT_DIR)/tools/
rm $(OUT_DIR)/tools/*.o
make -C imxtools/sbtools/ O=$(OUT_DIR)/tools/
rm $(OUT_DIR)/tools/*.o
make -C imxtools/uuc/ O=$(OUT_DIR)/tools/
rm $(OUT_DIR)/tools/*.o
strip $(OUT_DIR)/tools/*
clean:
rm OUT/ -rf
指定编译结果的输出位置
export OUT_DIR=${TopDir}'/out'
指定默认编译器使用当前系统x86-x64的gnu gcc编译器编译
export CC=gcc
删除源码中:
dengxm2024@PC-202105142413:~/imx280_zlg$ rm -r -f elftosb/
下载源码:
cd ~
git clone https://github.com/eewiki/elftosb
复制源码到~/imx280_zlg
dengxm2024@PC-202105142413:~/imx280_zlg$ cp -r ../elftosb/
修改elftosb的makefile.rules.
“CC ?= gcc”修改为“CC := gcc”
${OBJ_FILES_COMMON} \
EncoreBootImageReader.o \
sbtool.o
OBJ_FILES_KEYGEN = \
${OBJ_FILES_COMMON} \
keygen.o
LIBS ?= -lstdc++ -lm
ifeq ("${UNAMES}", "Linux")
EXEC_FILE_ELFTOSB2 = elftosb
EXEC_FILE_SBTOOL = sbtool
EXEC_FILE_KEYGEN = keygen
else
ifeq ("${UNAMES}", "CYGWIN_NT-5.1")
EXEC_FILE_ELFTOSB2 = elftosb.exe
EXEC_FILE_SBTOOL = sbtool.exe
EXEC_FILE_KEYGEN = keygen.exe
endif # ifeq ("${UNAMES}", "CYGWIN_NT-5.1")
endif # ifeq ("${UNAMES}", "Linux")
#*******************************************************************************
# Targets
all: elftosb sbtool keygen
# Uncomment the next line to print out the environment variables.
all: exec_always
exec_always:
@echo "SRC_DIR = ${SRC_DIR}"
@echo "OBJ_FILES = ${OBJ_FILES_ELFTOSB2}"
@echo "LIBS = ${LIBS}"
@echo "EXEC_FILE = ${EXEC_FILE}"
@echo "BUILD_DIR = ${BUILD_DIR}"
clean:
rm -f ${OBJ_FILES_ELFTOSB2} ${OBJ_FILES_SBTOOL} ${OBJ_FILES_KEYGEN} \
${EXEC_FILE_ELFTOSB2} ${EXEC_FILE_SBTOOL} ${EXEC_FILE_KEYGEN}
elftosb: ${OBJ_FILES_ELFTOSB2}
${CC} ${OBJ_FILES_ELFTOSB2} ${LIBS} -o ${EXEC_FILE_ELFTOSB2}
cp ${EXEC_FILE_ELFTOSB2} ${OUT_DIR}/tools/${EXEC_FILE_ELFTOSB2}
sbtool: ${OBJ_FILES_SBTOOL}
${CC} ${OBJ_FILES_SBTOOL} ${LIBS} -o ${EXEC_FILE_SBTOOL}
keygen: ${OBJ_FILES_KEYGEN}
${CC} ${OBJ_FILES_KEYGEN} ${LIBS} -o ${EXEC_FILE_KEYGEN}
cp ${EXEC_FILE_KEYGEN} ${OUT_DIR}/tools/${EXEC_FILE_KEYGEN}
#ifeq ("${UNAMES}", "Linux")
#ifeq ("${UNAMES}", "Linux")
# Use default rules for creating all the .o files from the .c files. Only
# for linux
.SUFFIXES : .c .cpp
.c.o :
${CC} ${CFLAGS} -c $<
.cpp.o :
${CC} ${CFLAGS} -c $<
#endif
#*******************************************************************************
# Automatic dependency generation
%.d: %.c
@set -e; \
$(CC) -MM $(CFLAGS) $< | \
sed 's/\($*\)\.o[ :]*/\1.o $@ : /g' > $@; \
[ -s $@ ] || rm -f $@
%.d: %.cpp
@set -e; \
$(CC) -MM $(CFLAGS) $< | \
sed 's/\($*\)\.o[ :]*/\1.o $@ : /g' > $@; \
[ -s $@ ] || rm -f $@
#*******************************************************************************
修改添加
elftosb: ${OBJ_FILES_ELFTOSB2}
${CC} ${OBJ_FILES_ELFTOSB2} ${LIBS} -o ${EXEC_FILE_ELFTOSB2}
cp ${EXEC_FILE_ELFTOSB2} ${OUT_DIR}/tools/${EXEC_FILE_ELFTOSB2}
sbtool: ${OBJ_FILES_SBTOOL}
${CC} ${OBJ_FILES_SBTOOL} ${LIBS} -o ${EXEC_FILE_SBTOOL}
keygen: ${OBJ_FILES_KEYGEN}
${CC} ${OBJ_FILES_KEYGEN} ${LIBS} -o ${EXEC_FILE_KEYGEN}
cp ${EXEC_FILE_KEYGEN} ${OUT_DIR}/tools/${EXEC_FILE_KEYGEN}
编译:
make tools
2.编译uboot
修改Makefile:
dengxm2024@PC-202105142413:~/imx280_zlg$ nano Makefile
修改编译器定义为:
CC=${_cross_compile}/arm-none-eabi-
编译uboot
make bootloader
出现错误:
编译uboot出现下面错误 HOSTCC tools/pbl_crc32.o ../tools/mxsimage.c:18:10: fatal error: openssl/evp.h: No such file or directory 18 | #include <openssl/evp.h> | ^~~~~~~~~~~~~~~ compilation terminated.
编译器未能找到 OpenSSL 的头文件 evp.h
。这通常意味着你的主机系统上没有安装 OpenSSL 开发库,或者编译环境没有正确配置来查找 OpenSSL 的头文件。
安装SSL库
sudo apt-get install libssl-dev
3.编译内核:
make kernel
出现错误:
HOSTCC scripts/kconfig/conf.o YACC scripts/kconfig/zconf.tab.c /bin/sh: 1: bison: not found make[3]: *** [scripts/Makefile.lib:196: scripts/kconfig/zconf.tab.c] Error 127 make[2]: *** [/home/dengxm2024/imx280_zlg/kernel/linux-4.19.88/Makefile:534: mxs_defconfig] Error 2 make[2]: Leaving directory '/home/dengxm2024/imx280_zlg/OUT/kernel' make[1]: *** [Makefile:146: sub-make] Error 2 make[1]: Leaving directory '/home/dengxm2024/imx280_zlg/kernel/linux-4.19.88' make: *** [Makefile:23: kernel] Error 2
bison
(一个通用的 LL*(1) 文法解析器生成器)
下载安装依赖库:
sudo apt-get install bison
出现错误:
LEX scripts/kconfig/zconf.lex.c
/bin/sh: 1: flex: not found
flex
,一个用来生成词法分析器的工具,安装:
sudo apt-get install flex
出现错误:
修改dtc代码
您可以手动修改dtc
代码以避免多重定义问题。通常的方法是在dtc-lexer.l
和dtc-parser.y
文件中使用extern
关键字来声明yylloc
变量。具体步骤如下:
在scripts/dtc/dtc-lexer.l文件中,找到yylloc的声明(通常在文件的顶部)添加“extern” 并将其修改为:
extern YYLTYPE yylloc;
继续编译。
编译成功。
4.下载buildroot源码
tar -zxvf /mnt/d/imx280a_exe_folder/buildroot-2019.11.3.tar.gz -C ./
make freescale_imx28evk_defconfig
make menuconfig
错误:
dengxm2024@PC-202105142413:~/buildroot-2018.11.4$ make menuconfig
mkdir -p /home/dengxm2024/buildroot-2018.11.4/output/build/buildroot-config/lxdialog
PKG_CONFIG_PATH="" make CC="/usr/bin/gcc" HOSTCC="/usr/bin/gcc" \
obj=/home/dengxm2024/buildroot-2018.11.4/output/build/buildroot-config -C support/kconfig -f Makefile.br mconf
make[1]: Entering directory '/home/dengxm2024/buildroot-2018.11.4/support/kconfig'
*** Unable to find the ncurses libraries or the
*** required header files.
*** 'make menuconfig' requires the ncurses libraries.
***
*** Install ncurses (ncurses-devel or libncurses-dev
*** depending on your distribution) and try again.
***
make[1]: *** [Makefile:253: /home/dengxm2024/buildroot-2018.11.4/output/build/buildroot-config/dochecklxdialog] Error 1
make[1]: Leaving directory '/home/dengxm2024/buildroot-2018.11.4/support/kconfig'
make: *** [Makefile:901: /home/dengxm2024/buildroot-2018.11.4/output/build/buildroot-config/mconf] Error 2
根据提示安装依赖库:
sudo apt install libncurses-dev
2021.2------>4.19.152 custom------->5.4.42
2019.08.3 ------>4.19.65 custom------4.17.8
2019.11 last 4.19.75 custom---- 5.3.8
编译"host-m4-1.4.18出错:
删除文件夹内的补丁
rm ~/buildroot-2019.11.3/package/m4/00*
修改"m4.mk"
################################################################################
#
# m4
#
################################################################################
M4_VERSION = 1.4.19
M4_SOURCE = m4-$(M4_VERSION).tar.xz
M4_SITE = $(BR2_GNU_MIRROR)/m4
M4_LICENSE = GPL-3.0+
M4_LICENSE_FILES = COPYING
$(eval $(host-autotools-package))
修改m4.hash
# Locally calculated after checking pgp signature
sha256 63aede5c6d33b6d9b13511cd0be2cac046f2e70fd0a07aa9573a04a82783af96 m4-1.4.19.tar.xz
# License files, locally calculated
sha256 3972dc9744f6499f0f9b2dbf76696f2ae7ad8af9b23dde66d6af86c9dfb36986 COPYING
再次编译。
package/fakeroot/1.20.2编译错误。
更新为host-fakeroot-1.25.3。
未完待续......