u-boot-2015.07 的一些记录
简单记录,需要整理//////////////////// u-boot -> u-boot.bin -> u-boot.img/home/root_work/AM335X_v02.00.00.00/linux-devkit/sysroots/x86_64-arago-linux/usr/bin/arm-linux-gnueabihf-ld.bfd -pie --gc-sectio
简单记录,需要整理
u-boot -> u-boot.bin -> u-boot.img
/home/root_work/AM335X_v02.00.00.00/linux-devkit/sysroots/x86_64-arago-linux/usr/bin/arm-linux-gnueabihf-ld.bfd -pie --gc-sections -Bstatic -Ttext 0x80800000 -o u-boot -T u-boot.lds arch/arm/cpu/armv7/start.o --start-group arch/arm/cpu/built-in.o arch/arm/cpu/armv7/built-in.o arch/arm/lib/built-in.o board/ti/rsb4220/built-in.o common/built-in.o disk/built-in.o drivers/built-in.o drivers/dma/built-in.o drivers/gpio/built-in.o drivers/i2c/built-in.o drivers/mmc/built-in.o drivers/mtd/built-in.o drivers/mtd/nand/built-in.o drivers/mtd/onenand/built-in.o drivers/mtd/spi/built-in.o drivers/net/built-in.o drivers/net/phy/built-in.o drivers/pci/built-in.o drivers/power/built-in.o drivers/power/battery/built-in.o drivers/power/fuel_gauge/built-in.o drivers/power/mfd/built-in.o drivers/power/pmic/built-in.o drivers/power/regulator/built-in.o drivers/serial/built-in.o drivers/spi/built-in.o drivers/usb/dwc3/built-in.o drivers/usb/emul/built-in.o drivers/usb/eth/built-in.o drivers/usb/gadget/built-in.o drivers/usb/gadget/udc/built-in.o drivers/usb/host/built-in.o drivers/usb/musb-new/built-in.o drivers/usb/musb/built-in.o drivers/usb/phy/built-in.o drivers/usb/ulpi/built-in.o fs/built-in.o lib/built-in.o net/built-in.o test/built-in.o test/dm/built-in.o --end-group arch/arm/lib/eabi_compat.o -L /home/root_work/AM335X_v02.00.00.00/linux-devkit/sysroots/x86_64-arago-linux/usr/bin/../lib/gcc/arm-linux-gnueabihf/4.9.3 -lgcc -Map u-boot.map/home/root_work/AM335X_v02.00.00.00/linux-devkit/sysroots/x86_64-arago-linux/usr/bin/arm-linux-gnueabihf-objcopy -j .text -j .secure_text -j .rodata -j .hash -j .data -j .got -j .got.plt -j .u_boot_list -j .rel.dyn --gap-fill=0xff -O binary u-boot u-boot.bin
./tools/mkimage -A arm -T firmware -C none -O u-boot -a 0x80800000 -e 0 -n "U-Boot 2015.07-00114-gf5078ef-dirty for rsb4220 board" -d u-boot.bin u-boot.img
/u-boot-spl -> u-boot-spl.bin -> MLO & MLO.byteswap
(cd spl && /home/root_work/AM335X_v02.00.00.00/linux-devkit/sysroots/x86_64-arago-linux/usr/bin/arm-linux-gnueabihf-ld.bfd -T u-boot-spl.lds --gc-sections -Bstatic --gc-sections -Ttext 0x402F0400 arch/arm/cpu/armv7/start.o --start-group arch/arm/cpu/armv7/built-in.o arch/arm/cpu/built-in.o arch/arm/lib/built-in.o board/ti/rsb4220/built-in.o common/spl/built-in.o common/built-in.o disk/built-in.o drivers/i2c/built-in.o drivers/gpio/built-in.o drivers/mmc/built-in.o drivers/serial/built-in.o drivers/mtd/spi/built-in.o drivers/spi/built-in.o fs/built-in.o lib/built-in.o drivers/power/built-in.o drivers/power/pmic/built-in.o drivers/mtd/built-in.o drivers/mtd/nand/built-in.o drivers/usb/musb-new/built-in.o drivers/watchdog/built-in.o --end-group arch/arm/lib/eabi_compat.o -L /home/root_work/AM335X_v02.00.00.00/linux-devkit/sysroots/x86_64-arago-linux/usr/bin/../lib/gcc/arm-linux-gnueabihf/4.9.3 -lgcc -Map u-boot-spl.map -o u-boot-spl)
/home/root_work/AM335X_v02.00.00.00/linux-devkit/sysroots/x86_64-arago-linux/usr/bin/arm-linux-gnueabihf-objcopy -j .text -j .secure_text -j .rodata -j .hash -j .data -j .got -j .got.plt -j .u_boot_list -j .rel.dyn --gap-fill=0xff -O binary spl/u-boot-spl spl/u-boot-spl.bin
./tools/mkimage -T omapimage -a 0x402F0400 -d spl/u-boot-spl.bin MLO
./tools/mkimage -T omapimage -n byteswap -a 0x402F0400 -d spl/u-boot-spl.bin MLO.byteswap
####cp MLO.byteswap adv_boot.bin
MLO 在fat分区就可启动。
MLO.byteswap(adv_boot.bin) 烧写在SPI flash启动。
U-boot分为两个阶段,SPL和U-boot阶段,在编译生成SPL和U-boot的Makefile中,分别决定是否定义CONFIG_SPL_BUILD。
因为这涉及到后面lowlevel的初始化的问题。
对于SPL定义CONFIG_SPL_BUILD,则CONFIG_SKIP_LOWLEVEL_INIT不会被定义,在start.s中,会执行:
bl cpu_init_cp15
bl cpu_init_crit
对于U-boot程序,不定义CONFIG_SPL_BUILD,则CONFIG_SKIP_LOWLEVEL_INIT被定义,在start.s中则跳过两个lowlevel的初始化。这是因为SPL已经完成初始化工作,不需要再来一次。
对于SPL而言,定义了CONFIG_SPL_BUILD,则:
#ifdef CONFIG_SPL_BUILD
_undefined_instruction: .word _undefined_instruction
_software_interrupt: .word _software_interrupt
_prefetch_abort: .word _prefetch_abort
_data_abort: .word _data_abort
_not_used: .word _not_used
_irq: .word _irq
_fiq: .word _fiq
_pad: .word 0x12345678 /* now 16*4=64 */
用.word伪指令为中断向量预留一个字,实际上复位第一条指令是reset,其他的异常不会出现,因此不需要赋值。如果到u-boot阶段了就是#else的部分,这些中断向量都是用.global修饰,就不知道在哪里定义了。
++++++++++++++++++++++++++++++++++++++++++++
arch/arm/cpu/armv7/start.S
reset:
bl cpu_init_cp15
设置cp15
bl cpu_init_crit
b lowlevel_init @ go setup pll,mux,memory
arch/arm/cpu/armv7/lowlevel_init.S(lowlevel_init.S文件有两个,好像都连接了,内容不同,都是定义了一些函数)
bl s_init
arch/arm/cpu/armv7/am33xx/board.c
bl _main arch/arm/lib/crt0.S
//board_init_f arch/arm/lib/spl.c(不再这里,看文件27行)
board_init_f arch/arm/cpu/armv7/am33xx/board.c
board_early_init_f();
prcm_init();
set_mux_conf_regs();
sdram_init();
board_init_r() common/spl/spl.c +191
mem_malloc_init
timer_init();
spl_board_init(); arch/arm/cpu/armv7/omap-common/boot-common.c +117
preloader_console_init();
spl_spi/mmc/net/board_load_image(); #不同的加载函数
jump_to_image_no_args(&spl_image); #跳转到Uboot......
+++++++++++++++++++++++++++++++++++++++++++++
.globl ymj_led
34 lines gpio3_7 ///
ENTRY(ymj_led)
LDR R5,=0x44E109E4 @gpio3_7
MOV R4,#0x0000007
STR R4,[R5]
LDR R5,=0x44E000B4 @clk and enable gpio3_7
MOV R4,#0x2
STR R4,[R5]
LDR R5,=0x481AE134 @set outPUT
MOV R4,#0
STR R4,[R5]
MaiLoopp:
LDR R5,=0x481AE13C @set 0
MOV R4,#0x00000000
STR R4,[R5]
MOV R7,#0x08000000 @延时参数0x00080000 0x00800000
DELAYS_L1: SUBS R7,R7,#1 @ R7 = R7-1
BNE DELAYS_L1 @判断R7-1结果是否为0,若不为0则跳转
LDR R5,=0x481AE13C @set 1
MOV R4,#0x000000f0
STR R4,[R5]
MOV R7,#0x08000000 @延时参数
DELAYS_L2: SUBS R7,R7,#1 @ R7 = R7-1
BNE DELAYS_L2 @判断R7-1结果是否为0,若不为0则跳转
B MaiLoopp
ENDPROC(ymj_led)
///
只能在MMU没打开时使用。
在汇编中调用:
b ymj_led
在C语言中调用:
extern void ymj_led(void);
ymj_led();
void ymj_cled(void)
{
int ymjt=0;
volatile unsigned int *port_addr1 = ioremap(0x44E109E4,0x4);
volatile unsigned int *port_addr2 = ioremap(0x44E000B4,0x4);
volatile unsigned int *port_addr3 = ioremap(0x481AE134,0x4);
volatile unsigned int *port_addr = ioremap(0x481AE13C,0x4);
*port_addr1 = 0x7;
*port_addr2 = 0x2;
*port_addr3 = 0x0;
while (ymjt<100){
ymjt++;
*port_addr=0x0;
mdelay(10000);
*port_addr=0xf0;
mdelay(10000);
}
return ;
}
//
不同的启动方式
common/spl/spl.c
从SPI启动会执行到下面的函数,在SPI中加载uboot。需要修改
source/u-boot-2015.07+gitAUTOINC+d49aa5effa/drivers/mtd/spi/spi_spl_load.c
在Uboot将SD卡中的adv_boot写入SPI http://processors.wiki.ti.com/index.php/AM335x_U-Boot_User%27s_Guide#SPI
U-Boot# sf probe 0
U-Boot# sf erase 0 400000
U-Boot# mmc rescan
U-Boot# fatload mmc 0 ${loadaddr} adv_boot.bin
U-Boot# sf write ${loadaddr} 0 ${filesize}
UBoot命令查看2个分区内容是正确的
U-Boot# fatls mmc 0:1
3194336 uimage.bin
364376 u-boot.img
100549 mlo
U-Boot# ext4ls mmc 0:2
<DIR> 4096 .
<DIR> 4096 ..
<DIR> 16384 lost+found
<DIR> 4096 bin
<DIR> 4096 boot
uboot最终执行include/configs/am335x_rsb4220.h
211 #define CONFIG_BOOTCOMMAND \
212 "run findfdt; " \
213 "run mmcboot;" \
214 "setenv mmcdev 1; " \
215 "setenv bootpart 1:1; " \
216 "run mmcboot;" \
217 "run nandboot;"
更多推荐
所有评论(0)