uboot单独编译测试
????????使用yocto编译链环境,设置编译链环境命令:. ./environment-setup-aarch64-poky-linux,编译链工具:aarch64-poky-linux-gcc
????????使用NXP官方的uboot源码,git路径:git://source.codeaurora.org/external/imx/uboot-imx.git,分支:imx_v2018.03_4.14.78_1.0.0_ga
????????配置imx8qxp平台配置:make imx8qxp_mek_defconfig,文件路径:configs/imx8qxp_mek_defconfig,
????????设置ARCH="arm",编译命令:make,编译完成后文件:u-boot.bin
-rw-rw-r-- 1 wangyb wangyb 631K 1月 7 16:26 u-boot.bin
? ? ? ? 编译完成后还需imx-mkimage制作boot:
《i.MX_Linux_User's_Guide.pdf》
4.5.13 How to build imx-boot image by using imx-mkimage
For i.MX 8QuadXPlus, to build imx-boot image by using imx-mkimage, perform the following steps:
1. Copy u-boot.bin from u-boot/u-boot.bin to imx-mkimage/iMX8QX/.
2. Copy scfw_tcm.bin from SCFW porting kit to imx-mkimage/iMX8QX/.
3. Copy bl31.bin from ARM Trusted Firmware (imx-atf) to imx-mkimage/iMX8QX/.
4. Copy the SECO firmware container image (ahab-container.img) to imx-mkimage/iMX8QX/.
5. Run make SOC=iMX8QX flash to generate flash.bin.
????????下载imx-mkimage源码:git clone https://source.codeaurora.org/external/imx/imx-mkimage -b imx_4.14.98_2.3.0
.
├── COPYING
├── iMX8dv
├── iMX8DXL
├── iMX8M
├── iMX8QM
├── iMX8QX
├── Makefile
├── mkimage_imx8
├── README
├── scripts
└── src
? ? ? ? 拷贝yocot编译环境现成的文件scfw_tcm.bin、bl31.bin、mx8qxb0-ahab-container.img到imx-mkimage/iMX8QX目录下,否则需要下载源码进行编译。
? ? ? ? 拷贝前面编译出来的uboot文件u-boot.bin到imx-mkimage/iMX8QX/?目录下
? ? ? ? 进行编译制作:make SOC=iMX8QX flash
include misc.mak
include m4.mak
include android.mak
include test.mak
include autobuild.mak
include rev_a.mak
include alias.mak
./../mkimage_imx8 -soc QX -rev B0 -append mx8qxb0-ahab-container.img -c -scfw scfw_tcm.bin -ap u-boot-atf.bin a35 0x80000000 -out flash.bin
SOC: QX
REVISION: B0
New Container: 0
SCFW: scfw_tcm.bin
AP: u-boot-atf.bin core: a35 addr: 0x80000000
Output: flash.bin
CONTAINER FUSE VERSION: 0x00
CONTAINER SW VERSION: 0x0000
ivt_offset: 1024
rev: 2
Platform: i.MX8QXP B0
ivt_offset: 1024
container image offset (aligned):d000
flags: 0x10
Hash of the images = sha384
记录了1+0 的读入
记录了1+0 的写出
160768 bytes (161 kB, 157 KiB) copied, 0.000643625 s, 250 MB/s
记录了313+1 的读入
记录了313+1 的写出
160512 bytes (161 kB, 157 KiB) copied, 0.000662578 s, 242 MB/s
SCFW file_offset = 0xd000 size = 0x27400
Hash of the images = sha384
记录了1+0 的读入
记录了1+0 的写出
777216 bytes (777 kB, 759 KiB) copied, 0.000579057 s, 1.3 GB/s
记录了1517+1 的读入
记录了1517+1 的写出
777046 bytes (777 kB, 759 KiB) copied, 0.00209588 s, 371 MB/s
AP file_offset = 0x34400 size = 0xbdc00
CST: CONTAINER 0 offset: 0x400
CST: CONTAINER 0: Signature Block: offset is at 0x590
DONE.
Note: Please copy image to offset: IVT_OFFSET + IMAGE_OFFSET
? ? ? ? 编译出的flash.bin默认从emmc启动,需要从SD卡启动需要修改配置。
U-Boot 2018.03 (Jan 07 2022 - 16:26:07 +0800)
CPU: Freescale i.MX8QXP revC A35 at 1200 MHz at 27C
Model: Freescale i.MX8QXP MEK
Board: iMX8QXP MEK
Boot: MMC0
DRAM: 3 GiB
setup_typec lookup gpio@1a_7 failed ret = 3
MMC: FSL_SDHC: 0, FSL_SDHC: 1
Loading Environment from MMC... *** Warning - bad CRC, using defaul t environment
使用openwrt编译链编译
? ? ? ? 设置编译链环境变量:export PATH="/home/wangyb/sda3/openwrt/openwrt-4-glibc-test/staging_dir/toolchain-aarch64_cortex-a35+neon_gcc-8.3.0_musl/bin:PATH"
? ? ? ? 编译工具链:aarch64-openwrt-linux-gcc
? ? ? ? 编译:make imx8qxp_mek_defconfig,make
? ? ? ? 编译问题1:
make CC=aarch64-openwrt-linux-gcc LD=aarch64-openwrt-linux-ld AS=aarch64-openwrt-linux-as
CC examples/standalone/hello_world.o
aarch64-openwrt-linux-gcc: warning: environment variable 'STAGING_DIR' not defined
LD examples/standalone/hello_world
OBJCOPY examples/standalone/hello_world.srec
OBJCOPY examples/standalone/hello_world.bin
objcopy: Unable to recognise the format of the input file `examples/standalone/hello_world'
examples/standalone/Makefile:71: recipe for target 'examples/standalone/hello_world.bin' failed
make[2]: *** [examples/standalone/hello_world.bin] Error 1
scripts/Makefile.build:425: recipe for target 'examples/standalone' failed
make[1]: *** [examples/standalone] Error 2
Makefile:1331: recipe for target 'examples' failed
aarch64-openwrt-linux-gcc: warning: environment variable 'STAGING_DIR' not defined
? ? ? ? 设置STAGING_DIR目录:export STAGING_DIR="/home/wangyb/sda3/openwrt/openwrt-4-glibc-test/staging_dir",设置ARCH=arm,make ARCH=arm CROSS_COMPILE=aarch64-openwrt-linux-,编译成功。
? ? ? ? 拷贝u-boot.bin到imx-mkimage/iMX8QX制作
????????烧写emmc启动测试:
U-Boot 2018.03-4.14.98-2.3.2+g672f25d (Oct 08 2021 - 06:54:30 +0000)【yocto编译】
U-Boot 2018.03 (Feb 21 2022 - 11:21:49 +0800)【openwrt编译链编译】
加入openwrt集成编译
? ? ? ? OpenWrt发布版默认没有加入boot的编译,Boot Loaders ?---> 选项是空的,需要自己配置。
? ? ? ? 虽然在package/boot/目录下有很多平台的boot,但没有可配置项
[wangyb@wangyb-VirtualBox:openwrt-4-glibc-test]$ ls package/boot/
apex fconfig kexec-tools tfa-layerscape uboot-envtools uboot-imx8 uboot-layerscape uboot-omap uboot-tegra
arm-trusted-firmware-sunxi grub2 kobs-ng uboot-ar71xx uboot-fritz4040 uboot-kirkwood uboot-mvebu uboot-oxnas uboot-zynq
at91bootstrap imx-bootlets rbcfg uboot-at91 uboot-imx6 uboot-lantiq uboot-mxs uboot-sunxi
? ? ? ? 增加uboot-imx8目录:
package/boot/uboot-imx8/
├── files
│?? └── imx-mkimage
│?? ├── COPYING
│?? ├── iMX8dv
│?? ├── iMX8DXL
│?? ├── iMX8M
│?? ├── iMX8QM
│?? ├── iMX8QX
│?? ├── Makefile
│?? ├── mm-back
│?? ├── README
│?? ├── scripts
│?? └── src
├── Makefile
└── patches
[wangyb@wangyb-VirtualBox:openwrt-4-glibc-test]$ cat package/boot/uboot-imx8/Makefile
#
# Copyright (C) 2006-2014 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=uboot-imx8
PKG_DISTNAME:=u-boot-imx8
PKG_VERSION:=2018.03
PKG_RELEASE:=3.1
PKG_SOURCE_PROTO:=git
PKG_SOURCE:=$(PKG_DISTNAME)-$(PKG_VERSION).tar.xz
PKG_SOURCE_SUBDIR:=$(PKG_DISTNAME)-$(PKG_VERSION)
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_DISTNAME)-$(PKG_VERSION)
PKG_MIRROR_HASH:=f6ec08e605aa79e263d5738781ff241e617cd727537060c58723c91421afe574
PKG_BUILD_DEPENDS:=fstools
PKG_LICENSE:=GPL-2.0 GPL-2.0+
PKG_LICENSE_FILES:=Licenses/README
PKG_FLAGS:=nonshared
PKG_BUILD_PARALLEL:=1
include $(INCLUDE_DIR)/package.mk
define Package/uboot-imx8
SECTION:=utils
CATEGORY:=Boot Loaders
TITLE:=imx8 U-Boot bootloader
URL:=http://www.denx.de/wiki/U-Boot
endef
define Package/uboot-imx8/description
This package includes IMX8QXP U-Boot bootloader.
endef
define Build/Configure
$(CP) -rf ./files/imx-mkimage $(PKG_BUILD_DIR)/
$(MAKE) -C $(PKG_BUILD_DIR) imx8qxp_mek_defconfig
endef
define Build/Compile
$(call Build/Compile/Default,ARCH=arm)
$(CP) $(PKG_BUILD_DIR)/u-boot.bin $(PKG_BUILD_DIR)/imx-mkimage/iMX8QX
# $(MAKE) -C $(PKG_BUILD_DIR)/imx-mkimage
$(MAKE) -C $(PKG_BUILD_DIR)/imx-mkimage SOC=iMX8QX flash
endef
define Package/uboot-imx8/preinst
endef
define Package/uboot-imx8/install
$(INSTALL_DIR) $(STAGING_DIR_IMAGE)
endef
$(eval $(call BuildPackage,uboot-imx8))
? ? ? ? 配置项:
????????Boot Loaders ?--->
????????????????<*> uboot-imx8........................................ imx8 U-Boot bootloader
? ? ? ? 编译问题1:
trip OBJCOPY=aarch64-openwrt-linux-musl-objcopy OBJDUMP=aarch64-openwrt-linux-musl-objdump SIZE=aarch64-openwrt-linux-musl-size CROSS="aarch64-openwrt-linux-musl-" ARCH="aarch64" ;
make[3]: Entering directory '/home/wangyb/sda3/openwrt/openwrt-4-glibc-test/build_dir/target-aarch64_cortex-a35+neon_musl/u-boot-imx8-2018.03'
scripts/kconfig/conf --silentoldconfig Kconfig
ln: failed to create symbolic link 'arch/aarch64/include/asm/arch': No such file or directory
scripts/Makefile.autoconf:136: recipe for target 'create_symlink' failed
? ? ? ? 修改为arm架构:define Build/Compile ? ? $(call Build/Compile/Default,ARCH=arm)
? ? ? ? 编译问题2:
make -C /home/wangyb/sda3/openwrt/openwrt-4-glibc-test/build_dir/target-aarch64_cortex-a35+neon_musl/u-boot-imx8-2018.03/imx-mkimage
make[3]: Entering directory '/home/wangyb/sda3/openwrt/openwrt-4-glibc-test/build_dir/target-aarch64_cortex-a35+neon_musl/u-boot-imx8-2018.03/imx-mkimage'
Compiling mkimage_imx8
gcc src/imx8qm.c src/imx8qx.c src/imx8qxb0.c src/mkimage_imx8.c -o /home/wangyb/sda3/openwrt/openwrt-4-glibc-test/package/boot/uboot-imx8/mkimage_imx8 -I src
include misc.mak
include m4.mak
include android.mak
include test.mak
include autobuild.mak
include rev_a.mak
include alias.mak
make[4]: *** No rule to make target '../mkimage_imx8', needed by 'flash'. Stop.
Makefile:39: recipe for target '/home/wangyb/sda3/openwrt/openwrt-4-glibc-test/package/boot/uboot-imx8/mkimage_imx8' failed
? ? ? ? 删除绝对路径?
$(MKIMG): src/build_info.h $(SRCS)
@echo "Compiling mkimage_imx8"
- $(CC) $(CFLAGS) $(SRCS) -o $(MKIMG) -I src【路径问题】
+ $(CC) $(CFLAGS) $(SRCS) -o mkimage_imx8 -I src
? ? ? ? 编译完成后启动:
U-Boot 2018.03 (Nov 14 2021 - 20:36:15 +0000)
? ? ? ? 时间戳没有更新,不知为何,修改open的时间源更新脚本也无改善。
[wangyb@wangyb-VirtualBox:openwrt-4-glibc-test]$ git diff scripts/
diff --git a/scripts/get_source_date_epoch.sh b/scripts/get_source_date_epoch.sh
index 84ba445..5facb30 100755
--- a/scripts/get_source_date_epoch.sh
+++ b/scripts/get_source_date_epoch.sh
@@ -3,6 +3,10 @@ export LANG=C
export LC_ALL=C
[ -n "$TOPDIR" ] && cd $TOPDIR
+try_date_now(){
+ SOURCE_DATE_EPOCH="$(date +%s)"
+}
+
try_version() {
[ -f version.date ] || return 1
SOURCE_DATE_EPOCH="$(cat version.date)"
@@ -26,5 +30,5 @@ try_mtime() {
[ -n "$SOURCE_DATE_EPOCH" ]
}
-try_version || try_git || try_hg || try_mtime || SOURCE_DATE_EPOCH=""
+try_date_now | try_version || try_git || try_hg || try_mtime || SOURCE_DATE_EPOCH=""
echo "$SOURCE_DATE_EPOCH"
|