uboot:https://ftp.denx.de/pub/u-boot/
nxp-uboot:https://github.com/nxp-imx/uboot-imx
1、顶层Makefile

文件加入编译的两种方式:以xxx/xxx.c文件为例
1、使用menuconfig:
先编辑.c所在目录下的Kconfig,加入配置项xxx
再编辑.c所在目录下的Makefile,添加obj-$(CONFIG_xxx) = xxx.o
2、不使用menuconfig:
直接编辑.c所在目录下的Makefile,添加obj-y = xxx.o
说明:$(libs-y)依赖每个文件夹下的xxx-in.o,而每个文件夹下的xxx-in.o又依赖当前文件夹的所有.o文件。
2、Kbuild框架
<1>在scripts文件夹下,有一个Kbuild.include文件中定义了如下几个关键的变量:
181: build := -f $(srctree)/scripts/Makefile.build obj
187: modbuiltin := -f $(srctree)/scripts/Makefile.modbuiltin obj
193: dtbinst := -f $(srctree)/scripts/Makefile.dtbinst obj
199: clean := -f $(srctree)/scripts/Makefile.clean obj
205 hdr-inst := -f $(srctree)/scripts/Makefile.headersinst obj
217: echo-cmd = $(if $($(quiet)cmd_$(1)),\
echo ' $(call escsq,$($(quiet)cmd_$(1)))$(echo-why)';)
.....
<2>在顶层Makefile文件的391-393行有如下:
# We need some generic definitions (do not try to remake the file).
scripts/Kbuild.include: ;
include scripts/Kbuild.include # 包含<1>中定义的变量
<3>在顶层Makefile文件的1232-1234行有如下:
%.imx: $(IMX_DEPS) %.bin
$(Q)$(MAKE) $(build)=arch/arm/mach-imx $@ # <1>中定义的build被使用
$(BOARD_SIZE_CHECK)
<4>在顶层Makefile文件的1255-1259行有如下:(make dtbs命令)
PHONY += dtbs
dtbs: dts/dt.dtb
@:
dts/dt.dtb: u-boot
$(Q)$(MAKE) $(build)=dts dtbs
展开得:
@ make -f $(srctree)/scripts/Makefile.build obj=dts dtbs
其中:obj=dts是一个传入的变量, dtbs是要构建的目标
2、u-boot.map文件
反汇编:arm-linux-gnueabihf-objdump -D -m arm u-boot > u-boot.dis
./scripts/dtc/dtc -I dtb -O dts -o ./itop.dts ./arch/arm/dts/imx6ull-14x14-itop.dtb
./scripts/dtc/dtc -I dtb -O dts -o ./evk.dts ./arch/arm/dts/imx6ull-14x14-evk.dtb
注意:如何确定哪个.c文件的哪个函数被编译?
通过函数名在u-boot.map、u-boot.dis这两个文件中搜索。先在u-boot.dis找到函数的链接地址,以此链接地址在u-boot.map中搜索,即可确定是哪个.c文件下的函数被编译。
save_boot_params_ret:
/* disable interrupts (FIQ and IRQ), also set the cpu to SVC32 mode, except if in HYP mode already */
/* 禁用中断(FIQ 和 IRQ),同时将处理器设置为 SVC32 模式,除非已经处于 HYP 模式。 */
mrs r0, cpsr @ 将当前程序状态寄存器(CPSR)的值加载到寄存器r0中
and r1, r0, #0x1f @ 使用掩码操作提取r0的低5位,即当前的处理器模式
teq r1, #0x1a @ 测试是否当前处理器模式为HYP模式(Hypervisor mode)
bicne r0, r0, #0x1f @ 如果不在HYP模式,清除 CPSR 中的所有模式位
orrne r0, r0, #0x13 @ 如果不在HYP模式,设置 CPSR 的模式为SVC模式
orr r0, r0, #0xc0 @ 禁用FIQ和IRQ中断,将 CPSR 的FIQ和IRQ位设置为 1
msr cpsr,r0 @ 将修改后的 CPSR 的值写回 CPSR 寄存器,完成设置
/* Set V=0 in CP15 SCTLR register - for VBAR to point to vector */
/* 将 CP15 的 SCTLR 寄存器中将 V 位设置为0,以便将 VBAR 指向向量表 */
mrc p15, 0, r0, c1, c0, 0 @ 读取 CP15 SCTLR 寄存器里面的值
bic r0, #CR_V @ 将 CP15 SCTLR 寄存器中的 V 位清零
mcr p15, 0, r0, c1, c0, 0 @ 写回修改后的值到 CP15 SCTLR 寄存器
/* Set vector address in CP15 VBAR register */
/* 在 CP15 的 VBAR 寄存器中设置向量表的地址 */
ldr r0, =_start

最低0.47元/天 解锁文章
1059





