一、首先进行内存的初始化(vi arch/arm/cpu/arm920t/start.S)
将前面的注释去掉:
#ifndef CONFIG_SKIP_LOWLEVEL_INIT
? ? bl ?cpu_init_crit
#endif
沿着cpu_init_crit走到最后,将(vi board/samsung/shanl2440/lowlevel_init.S):
SMRDATA:
? ? .word (0+(B1_BWSCON<<4)+(B2_BWSCON<<8)+(B3_BWSCON<<12)+(B4_BWSCON<<16)+(B5_BWSCON<<20)+(B6_BWSCON<<24)+(B7_BWSCON<<28))
? ? .word ((B0_Tacs<<13)+(B0_Tcos<<11)+(B0_Tacc<<8)+(B0_Tcoh<<6)+(B0_Tah<<4)+(B0_Tacp<<2)+(B0_PMC))
? ? .word ((B1_Tacs<<13)+(B1_Tcos<<11)+(B1_Tacc<<8)+(B1_Tcoh<<6)+(B1_Tah<<4)+(B1_Tacp<<2)+(B1_PMC))
? ? .word ((B2_Tacs<<13)+(B2_Tcos<<11)+(B2_Tacc<<8)+(B2_Tcoh<<6)+(B2_Tah<<4)+(B2_Tacp<<2)+(B2_PMC))
? ? .word ((B3_Tacs<<13)+(B3_Tcos<<11)+(B3_Tacc<<8)+(B3_Tcoh<<6)+(B3_Tah<<4)+(B3_Tacp<<2)+(B3_PMC))
? ? .word ((B4_Tacs<<13)+(B4_Tcos<<11)+(B4_Tacc<<8)+(B4_Tcoh<<6)+(B4_Tah<<4)+(B4_Tacp<<2)+(B4_PMC))
? ? .word ((B5_Tacs<<13)+(B5_Tcos<<11)+(B5_Tacc<<8)+(B5_Tcoh<<6)+(B5_Tah<<4)+(B5_Tacp<<2)+(B5_PMC))
? ? .word ((B6_MT<<15)+(B6_Trcd<<2)+(B6_SCAN))
? ? .word ((B7_MT<<15)+(B7_Trcd<<2)+(B7_SCAN))
? ? .word ((REFEN<<23)+(TREFMD<<22)+(Trp<<20)+(Trc<<18)+(Tchr<<16)+REFCNT)
? ? .word 0x32
? ? .word 0x30
? ? .word 0x30
修改为:
SMRDATA:
? ? .long 0x22011110 ? ? //BWSCON ?
? ? .long 0x00000700 ? ? //BANKCON0
? ? .long 0x00000700 ? ? //BANKCON1
? ? .long 0x00000700 ? ? //BANKCON2
? ? .long 0x00000700 ? ? //BANKCON3
? ? .long 0x00000700 ? ? //BANKCON4
? ? .long 0x00000700 ? ? //BANKCON5
? ? .long 0x00018005 ? ? //BANKCON6
? ? .long 0x00018005 ? ? //BANKCON7
? ? .long 0x008C04F4 ? ? // REFRESH
? ? .long 0x000000B1 ? ? //BANKSIZE
? ? .long 0x00000030 ? ? //MRSRB6 ?
? ? .long 0x00000030 ? ? //MRSRB7
二、设置栈,对nandflash进行初始化,重定位代码,跳转SDRAM中执行(vi arch/arm/cpu/arm920t/start.S)
将:
/* Set stackpointer in internal RAM to call board_init_f */
call_board_init_f:
? ? ldr sp,=(CONFIG_SYS_INIT_SP_ADDR)
? ? bic sp,sp,#7 /* 8-byte alignment for ABI compliance */
? ? ldr r0,=0x00000000
? ? bl ?board_init_f
修改为:
? ? ldr sp,#7 /* 8-byte alignment for ABI compliance */
? ? bl nand_init_ll
? ? mov r0,#0
// ?ldr r1,=_start
? ? ldr r1,_TEXT_BASE
? ? ldr r2,_bss_start_ofs
? ? bl copy_code_to_sdram
? ? bl clear_bss
? ? ldr pc,=call_board_init_f
/* Set stackpointer in internal RAM to call board_init_f */
call_board_init_f:
? ? ldr r0,=0x00000000
? ? bl ?board_init_f
? ? ldr r1,_TEXT_BASE
? ? bl ?board_init_r
对于nand_init_ll?copy_code_to_sdram的实现在init.c中实现(init.c下载),将init.c拷贝到u-boot-2012.04.01_test1/board/samsung/shanl2440中,修改Makefile
修改如下:
COBJS ? := smdk2410.o init.o
修改board_init_f 提供返回值供board_init_r使用,并且关闭里面的重定位代码:
修改(vi arch/arm/lib/board.c?):
void board_init_f(ulong bootflag)
为:
unsigned int board_init_f(ulong bootflag)
在该函数底部加入返回值并注释重定位代码:
// ?relocate_code(addr_sp,id,addr);
? ? return (unsigned int)id;
在里面也修改下该函数的类型
shanl@shanl-Aspire-4740:~/Boot/u-boot-2012.04.01_test1$ vi include/common.h +276
三、去除-pie选项
u-boot-2012.04.01_test1$ vi arch/arm/config.mk +75
# needed for relocation
ifndef CONFIG_NAND_SPL
#LDFLAGS_u-boot += -pie
endif
四、在链接脚本中加入编译的文件
u-boot-2012.04.01_test1$ vi arch/arm/cpu/u-boot.lds
加入:
.text :
{
? ? __image_copy_start = .;
? ? CPUDIR/start.o (.text)
? ?
board/samsung/shanl2440/libshanl2440.o (.text)
? ? *(.text)
}
五、重新编译:烧写到开发板中:

郁闷:
tq开发板tftp烧写有可能不成功,需要使用它原始的uboot做一下檫写操作,才可以,浪费了很多时间。。。。。添加代码链接如下:
uboot_nandboot