前言:
为了再熟悉下代码,改改源码。其实搜索原来串口打印的关键字就可以找到,然后替换字符而已。
另外,就是将u-boot-spl调用的函数及u-boot调用的函数大致弄清楚了。lds的layout弄清楚了。
2020-09-23日已将定制后的bb black uboot源码及编译结果上传到我的gitee
问题1:u-boot-spl的主要makefile在哪里?
[移植uboot[2020.10.r4]--Apple的学习笔记]https://www.jianshu.com/p/5a420c27e78d)我里面提交到uboot-spl和uboot的调用哪个board_init_f及board_init_r我有点搞不清楚,之前是通过map文件反向搜索board_init_f中调用的函数来确认到底用了那个文件中的board_init_f。主要是我没找到uboot-spl的makefile。感觉区分不了。
所以,我今天就从顶层makefile来找spl的地图线索。通过搜索u-boot-spl的依赖关系,最后搜索到spl/u-boot-spl,里面有关键信息Makefile.spl all。如果要指定特定的Makefile,你可以使用make的“- f”和“--file”参数。所以打开Makefile.spl all后就得知结果。所以Makefile.spl文件是u-boot-spl的地图。
spl/u-boot-spl: tools prepare \
$(if $(CONFIG_OF_SEPARATE)$(CONFIG_OF_EMBED)$(CONFIG_SPL_OF_PLATDATA),dts/dt.dtb) \
$(if $(CONFIG_OF_SEPARATE)$(CONFIG_OF_EMBED)$(CONFIG_TPL_OF_PLATDATA),dts/dt.dtb)
$(Q)$(MAKE) obj=spl -f $(srctree)/scripts/Makefile.spl all
问题2:spl调用的board_init_r在哪里?
从Makefile.spl中可以看到。用的是common/spl.c里面的board_init_r。另外,其它共享文件中,其实是通过# ifdef CONFIG_SPL_BUILD来区分某几行属于spl,某几行属于uboot的。
比如如下代码中,#if ! defined(CONFIG_SPL_BUILD),说明board_init_f函数后,uboot调用了relocate_code。而spl调用了spl_relocate_stack_gd。
mov r0, #0
bl board_init_f
#if ! defined(CONFIG_SPL_BUILD)
/*
* Set up intermediate environment (new sp and gd) and call
* relocate_code(addr_moni). Trick here is that we'll return
* 'here' but relocated.
*/
ldr r0, [r9, #GD_START_ADDR_SP] /* sp = gd->start_addr_sp */
bic r0, r0, #7 /* 8-byte alignment for ABI compliance */
mov sp, r0
ldr r9, [r9, #GD_NEW_GD] /* r9 <- gd->new_gd */
adr lr, here
ldr r0, [r9, #GD_RELOC_OFF] /* r0 = gd->reloc_off */
add lr, lr, r0
#if defined(CONFIG_CPU_V7M)
orr lr, #1 /* As required by Thumb-only */
#endif
ldr r0, [r9, #GD_RELOCADDR] /* r0 = gd->relocaddr */
b relocate_code
here:
/*
* now relocate vectors
*/
bl relocate_vectors
/* Set up final (full) environment */
bl c_runtime_cpu_setup /* we still call old routine here */
#endif
#if !defined(CONFIG_SPL_BUILD) || CONFIG_IS_ENABLED(FRAMEWORK)
#if !defined(CONFIG_SPL_BUILD) || !defined(CONFIG_SPL_EARLY_BSS)
CLEAR_BSS
#endif
# ifdef CONFIG_SPL_BUILD
/* Use a DRAM stack for the rest of SPL, if requested */
bl spl_relocate_stack_gd
cmp r0, #0
movne sp, r0
movne r9, r0
# endif
问题3:ddr的size宏定义设置的是1G,但是输出是512M,我买了次货?
代码中定义的是1G的,但是确能识别出512M,分析了下get_ram_size函数里面的机制是先按1G写入,然后一个个读取,若一致,则说明内存大小存在。通过此方法确认大小。后来查了下我的订购信息,原版用的是美光系列内存,我是中国版用的是金士顿ddr3内存,确实是512M,所以我将宏定义改成了512<<20了。
问题4:在哪里设置环境参数默认值?
env_default.h中的default_environment数组可以看到,需要在menuconfig中设置即可。
简单定制效果
字符串哪里看的不顺眼就在源码中修改哪里,哈哈~
之前我不改源码,只改配置,如下
U-Boot SPL 2020.10-rc4 (Sep 20 2020 - 20:37:17 +0800)
Trying to boot from MMC1
Loading Environment from FAT... OK
U-Boot 2020.10-rc4 (Sep 20 2020 - 20:37:17 +0800)
CPU : AM335X-GP rev 2.1
Model: TI AM335x BeagleBone Black
DRAM: 512 MiB
MMC: OMAP SD/MMC: 0, OMAP SD/MMC: 1
Loading Environment from FAT... OK
Net: eth2: ethernet@4a100000, eth3: usb_ether
Press SPACE to abort autoboot in 2 seconds
switch to partitions #0, OK
mmc0 is current device
6020864 bytes read in 399 ms (14.4 MiB/s)
34782 bytes read in 5 ms (6.6 MiB/s)
## Flattened Device Tree blob at 88000000
Booting using the fdt blob at 0x88000000
Loading Device Tree to 8fff4000, end 8ffff7dd ... OK
Starting kernel ...
现在简单修改源码,由于删除了uenv.txt,导致警告crc bad,所以我将此句改成了Apple,Good job!
简单定制后,如下
U-Boot SPL 2020.10-rc4 (Sep 21 2020 - 21:17:39 +0800)
Trying to boot from MMC1
Loading Environment from FAT... Apple,Good job!
Loading Environment from MMC... Apple,Good job!
U-Boot 2020.10-rc4 (Sep 21 2020 - 21:17:39 +0800)
CPU : AM335X-GP rev 2.1
Model: TI AM335x BeagleBone Black
Apple's DRAM: 512 MiB
Apple's MMC: OMAP SD/MMC: 0, OMAP SD/MMC: 1
Loading Environment from FAT... Apple,Good job!
Loading Environment from MMC... Apple,Good job!
not set. Validating first E-fuse MAC
Apple's Net: eth2: ethernet@4a100000, eth3: usb_ether
Press SPACE to abort autoboot in 2 seconds
Apple:switch to partitions #0, OK
mmc0 is current device
6020864 bytes read in 399 ms (14.4 MiB/s)
48713 bytes read in 6 ms (7.7 MiB/s)
## Flattened Device Tree blob at 88000000
Booting using the fdt blob at 0x88000000
Loading Device Tree to 8fff1000, end 8ffffe48 ... OK
Starting kernel ...
9月22日追加遗留问题
今天修改了dts中的Model name,然后把In:Out:通过关闭静默配置项打印出来,无法通过配置的方法删除
U-Boot SPL 2020.10-rc4 (Sep 22 2020 - 21:30:07 +0800)
Trying to boot from MMC1
Loading Environment from FAT... Apple,Good job!
Loading Environment from MMC... Apple,Good job!
U-Boot 2020.10-rc4 (Sep 22 2020 - 21:30:07 +0800)
CPU : AM335X-GP rev 2.1
Model: APPLE's TI AM335x BeagleBone Black
Apple's DRAM: 512 MiB
Apple's MMC: OMAP SD/MMC: 0, OMAP SD/MMC: 1
Loading Environment from FAT... Apple,Good job!
Loading Environment from MMC... Apple,Good job!
In: serial@44e09000
Out: serial@44e09000
Err: serial@44e09000
not set. Validating first E-fuse MAC
Apple's Net: eth2: ethernet@4a100000, eth3: usb_ether
Press SPACE to abort autoboot in 2 seconds
Apple:switch to partitions #0, OK
mmc0 is current device
6020864 bytes read in 399 ms (14.4 MiB/s)
48721 bytes read in 7 ms (6.6 MiB/s)
## Flattened Device Tree blob at 88000000
Booting using the fdt blob at 0x88000000
Loading Device Tree to 8fff1000, end 8ffffe50 ... OK
Starting kernel ...
[ 0.000000] Booting Linux on physical CPU 0x0
[ 0.000000] Linux version 4.19.59 (root@applecaiHP) (gcc version 8.4.0 (Buildroot 2020.05.2)) #1 SMP Sun Sep 6 17:05:07 CST 2020
[ 0.000000] CPU: ARMv7 Processor [413fc082] revision 2 (ARMv7), cr=10c5387d
[ 0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
[ 0.000000] OF: fdt: Machine model: APPLE's TI AM335x BeagleBone Black
[ 0.000000] Memory policy: Data cache writeback
[ 0.000000] cma: Reserved 16 MiB at 0x9e800000
[ 0.000000] CPU: All CPU(s) started in SVC mode.
[ 0.000000] AM335X ES2.1 (sgx neon)
9月23日解决22日的问题
1.
2.CONFIG_ENV_IS_IN_MMC改为FALSE。就不会出现
Loading Environment from MMC... Apple,Good job!
修改后效果如下
U-Boot SPL 2020.10-rc4 (Sep 23 2020 - 20:47:42 +0800)
Trying to boot from MMC1
Loading Environment from FAT... Apple,Good job!
U-Boot 2020.10-rc4 (Sep 23 2020 - 20:47:42 +0800)
CPU : AM335X-GP rev 2.1
Model: APPLE's TI AM335x BeagleBone Black
Apple's DRAM: 512 MiB
Apple's MMC: OMAP SD/MMC: 0, OMAP SD/MMC: 1
Loading Environment from FAT... Apple,Good job!
In: serial@44e09000
Out: serial@44e09000
Err: serial@44e09000
Apple's Net: eth2: ethernet@4a100000, eth3: usb_ether
Press SPACE to abort autoboot in 2 seconds
Apple:switch to partitions #0, OK
mmc0 is current device
6020864 bytes read in 397 ms (14.5 MiB/s)
48721 bytes read in 7 ms (6.6 MiB/s)
## Flattened Device Tree blob at 88000000
Booting using the fdt blob at 0x88000000
Loading Device Tree to 8fff1000, end 8ffffe50 ... OK
Starting kernel ...
[ 0.000000] Booting Linux on physical CPU 0x0
[ 0.000000] Linux version 4.19.59 (root@applecaiHP) (gcc version 8.4.0 (Buildroot 2020.05.2)) #1 SMP Sun Sep 6 17:05:07 CST 2020
[ 0.000000] CPU: ARMv7 Processor [413fc082] revision 2 (ARMv7), cr=10c5387d
[ 0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
[ 0.000000] OF: fdt: Machine model: APPLE's TI AM335x BeagleBone Black
uboot网络功能也正常,可以ping通
U-Boot 2020.10-rc4 (Sep 23 2020 - 20:47:42 +0800)
CPU : AM335X-GP rev 2.1
Model: APPLE's TI AM335x BeagleBone Black
Apple's DRAM: 512 MiB
Apple's MMC: OMAP SD/MMC: 0, OMAP SD/MMC: 1
Loading Environment from FAT... Apple,Good job!
In: serial@44e09000
Out: serial@44e09000
Err: serial@44e09000
Apple's Net: eth2: ethernet@4a100000, eth3: usb_ether
Press SPACE to abort autoboot in 2 seconds
=> printenv ipaddr
ipaddr=192.168.0.2
=> ping 192.168.0.111
link up on port 0, speed 100, full duplex
Using ethernet@4a100000 device
host 192.168.0.111 is alive
=>
至此,本轮的uboot定制完结了。