移植 u-boot-2020.07 到 iTOP-4412(一)地址无关码点灯

一、u-boot 源码

官网:http://www.denx.de/wiki/U-Boot/WebHome
ftp下载地址:ftp://ftp.denx.de/pub/u-boot/

我下载了这两个文件:
u-boot-2020.07

首先参考该博文进行下载文件的验证:

"验证获取钥匙号"
xhr@ubuntu:~/iTop4412/uboot-2020-07$ gpg --verify u-boot-2020.07.tar.bz2.sig u-boot-2020.07.tar.bz2
gpg: Signature made Tue 07 Jul 2020 03:23:40 AM CST
gpg:                using RSA key E872DB409C1A687EFBE8633687F9F635D31D7652
gpg:                issuer "trini@konsulko.com"
gpg: Can't check signature: No public key
"获取钥匙"
xhr@ubuntu:~/iTop4412/uboot-2020-07$ gpg --recv-keys E872DB409C1A687EFBE8633687F9F635D31D7652
gpg: key 87F9F635D31D7652: new key but contains no user ID - skipped
gpg: Total number processed: 1
gpg:           w/o user IDs: 1
"再次验证"
xhr@ubuntu:~/iTop4412/uboot-2020-07$ gpg --verify --verbose u-boot-2020.07.tar.bz2.sig u-boot-2020.07.tar.bz2
gpg: Signature made Tue 07 Jul 2020 03:23:40 AM CST
gpg:                using RSA key E872DB409C1A687EFBE8633687F9F635D31D7652
gpg:                issuer "trini@konsulko.com"
gpg: Can\'t check signature: No public key
"OK,没有成功,放弃"

OK,没有成功,放弃。
以后有时间在参考。

解压:tar -jxvf u-boot-2020.07.tar.bz2

二、交叉编译器

想要编译最新的 u-boot ,需要使用最新的编译器,可以在这几个网站找找。

最后我是下载了这个:

gcc-arm-none-eabi-9-2020-q2-update-x86_64-linux.tar.bz2

解压:tar -jxvf gcc-arm-none-eabi-9-2020-q2-update-x86_64-linux.tar.bz2

解压后把 ~/gcc-arm-none-eabi-9-2020-q2-update/bin/ 目录添加到环境变量中,就可以使用编译器了。

三、修改 u-boot

1. 创建开发板的各种文件

首先在 u-boot 中已经存在且类似开发板的板级文件的基础上进行修改。

这里使用 origen,因为该开发板的代码支持 spl,且芯片类似 Exynos-4412。

然后把复制出来的这些文件里的 origen 都改为 xhr4412。

cp -a board/samsung/origen/ board/samsung/xhr4412
cp include/configs/origen.h include/configs/xhr4412.h
cp configs/origen_defconfig configs/xhr4412_defconfig
cp arch/arm/dts/exynos4210-origen.dts arch/arm/dts/xhr4412.dts

vim arch/arm/dts/Makefile
vim arch/arm/mach-exynos/Kconfig

config TARGET_XHR4412
        bool "Exynos4412 xhr4412 board"
        select SUPPORT_SPL

vim arch/arm/include/asm/mach-types.h

由于 SPL 要改几个特殊的:

"1. 需要支持SPL"
vim arch/arm/include/asm/spl.h

#if defined(CONFIG_ARCH_OMAP2PLUS) \
	|| defined(CONFIG_EXYNOS4) || defined(CONFIG_EXYNOS5) \
	|| defined(CONFIG_EXYNOS4210) || defined(CONFIG_ARCH_K3) \
	|| defined(CONFIG_EXYNOS4412)

"2. 编译"
vim arch/arm/mach-exynos/Makefile

obj-$(CONFIG_EXYNOS4412)+= dmc_init_exynos4.o clock_init_exynos4.o

"3. 不知道是啥"
vim scripts/config_whitelist.txt
// line 492
CONFIG_EXYNOS4412

"4. 照着 CONFIG_ORIGEN 添加 CONFIG_XHR4412"
arch/arm/mach-exynos/dmc_init_exynos4.c:178:#ifdef CONFIG_ORIGEN
arch/arm/mach-exynos/exynos4_setup.h:436:#ifdef CONFIG_ORIGEN
arch/arm/mach-exynos/exynos4_setup.h:558:#ifdef CONFIG_ORIGEN
// 上面三个改成 #if defined(CONFIG_ORIGEN) || defined(CONFIG_XHR4412)
scripts/config_whitelist.txt:1226:CONFIG_ORIGEN
  • vim arch/arm/dts/Makefile

仿造 origen 添加一行,其实把其他的删了应该也可以把(猜的,没试过)。

dtb-$(CONFIG_EXYNOS4) += exynos4210-origen.dtb \
        exynos4210-smdkv310.dtb \
        exynos4210-universal_c210.dtb \
        exynos4210-trats.dtb \
        exynos4412-trats2.dtb \
        exynos4412-odroid.dtb \
        exynos4412-xhr4412.dtb

修改完后执行

  • make xhr4412_defconfig
  • make menuconfig
  • make

make menuconfig 然后将我们修改的选项等选上。
在这里插入图片描述

make 出现以下错误:

  CFGCHK  u-boot.cfg
comm: file 2 is not in sorted order
make[1]: *** [/home/xhr/iTop4412/uboot-2020-07/xhr-uboot-origen-2020.07/Makefile:1129: all] Error 1
make[1]: Leaving directory '/home/xhr/iTop4412/uboot-2020-07/xhr-uboot-origen-2020.07/out'
make: *** [Makefile:167: sub-make] Error 2

好像是因为修改了 whitelist 的原因,所以把 Makefile 这几行检查注释掉

quiet_cmd_cfgcheck = CFGCHK  $2
cmd_cfgcheck = $(srctree)/scripts/check-config.sh $2 \
		$(srctree)/scripts/config_whitelist.txt $(srctree)

顺便添加编译所需的参数到 Makefile 前面几行:

export ARCH=arm
export CROSS_COMPILE=/home/xhr/iTop4412/crossCompiler/gcc-arm-none-eabi-9-2020-q2-update/bin/arm-none-eabi-
export KBUILD_OUTPUT=out

除了上面的修改,还有一些修改没有描述,可以一边编译一边解决。

总之经过一些努力,最后编译成功。

2. 点灯 code

前面虽然编译成功,但是并没有什么用因为这实际上是别人的板子,我们肯定需要对我们自己的板子进行修改。

初始化 DRAM、uart、重定位等都是后话,目前肯定是点灯,看我们的 u-boot 是否有执行到。

通过看代码、反汇编等方法,确定 u-boot 开始执行的地方为

  • arch/arm/lib/vectors.S

在 “b reset” 前加上这几句(是否有实际用处不清楚,只是讯为提供的 u-boot.bin 在开头有这几个)

	# for xhr4412
	.word 0x2000
	.word 0x0
	.word 0x0
	.word 0x0
	# end - for xhr4412
	b	reset

最后在 arch/arm/cpu/armv7/start.S 的 reset 标签后添加电灯代码:

reset:
	/*
	 * My LED test
	 */
#if 1
	mov r1, #1
	mov r0, #0x11000000
	add r0, r0, #0x100
	str r1, [r0]
	add r0, r0, #0x4
	str r1, [r0]
#else
	ldr r0, =0x11000100
	ldr r1, =1
	str r1, [r0]
	ldr r0, =0x11000104
	ldr r1, =1
	ldr r1, [r0]
#endif
xhr_loop:
	b xhr_loop

请注意,这里点灯用的是地址无关的汇编。(使用地址有关的方法点灯还没有成功,因为不清楚讯为提供的 bl2.bin 将代码重定位到哪里了)

3. 制作 tf 卡启动

仿造讯为提供的脚本,写一个将 bl1 bl2 u-boot 等 bin 文件连接起来的脚本。

再使用已有脚本,制作 tf 卡。

这些我都已经重新仿写,只需要调用脚本即可。

"1. 制作 u-boot-spl-xhr4412.bin"
./build_uboot.sh
"2. 将 bin 刷写到 tf 卡"
./mkuboot.sh /dev/sdb

四、说明

本移植想要全部移植,不过 Exynos-4412 有些麻烦,bl1 等没有源码,并不清楚具体实现,bl2 如何制作也是不清不楚的,所以是否还能有下篇也不能肯定。

如果能研究出如何制作 bl1 能够识别的 bl2 可能还能有后文。

源码下载:
uboot-2020.07-xhr4412.tar.bz2

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值