移植u-boot到mini2440--从norflash启动
??前面提到了用 openjtag 加载 u-boot,这只是检验下u-boot是否能运行。如果想要真正能用就需要从flash里面启动(无论是nor 还是nand),这里先选择nor flash。 ??在前文用arm-linux-gdb 加载u-boot的时候,定义了一个宏CONFIG_SKIP_LOWLEVEL_INIT,这个宏跳过了处理器相关的包括存储器控制器初始化代码,而且用了一个脚本 s3c2440_gdb.init 来替代。 cpu_init_crit:
/* * flush v4 I/D caches */
mov r0,#0
mcr p15,0,r0,c7,0 /* flush v3/v4 cache */
mcr p15,c8,0 /* flush v4 TLB */
/* * disable MMU stuff and caches */
mrc p15,c1,c0,0
bic r0,#0x00002300 @ clear bits 13,9:8 (--V- --RS)
bic r0,#0x00000087 @ clear bits 7,2:0 (B--- -CAM)
orr r0,#0x00000002 @ set bit 2 (A) Align
orr r0,#0x00001000 @ set bit 12 (I) I-Cache
mcr p15,0
/* * before relocating,we have to setup RAM timing * because memory timing is board-dependend,you will * find a lowlevel_init.S in your board directory. */
mov ip,lr
bl lowlevel_init
mov lr,ip
mov pc,lr
??这里跳转到 lowlevel_init ,这个函数在 board/samsung/mini2440/lowlevel_init.S ,定义。 .globl lowlevel_init
lowlevel_init:
/* memory control configuration */
/* make r0 relative the current location so that it */
/* reads SMRDATA out of FLASH rather than memory ! */
ldr r0,=SMRDATA
ldr r1,=CONFIG_SYS_TEXT_BASE
sub r0,r1
ldr r1,=BWSCON /* Bus Width Status Controller */
add r2,#13*4
0:
ldr r3,[r0],#4
str r3,[r1],#4
cmp r2,r0
bne 0b
/* everything is fine now */
mov pc,lr
.ltorg
/* the literal pools origin */
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
关于这里涉及到的知识点可以参考我以前博文: mini2440 裸机编程 - 内存控制 配置 #define DEBUG
/*#define CONFIG_SKIP_LOWLEVEL_INIT */
#define CONFIG_SYS_TEXT_BASE 0x0 /*0x33F80000 */
??然后编译,用 openjtag 把二进制文件烧写到norflash上 ,运行。 ??当开发板从 norflash 启动的时候 norflash 映射到 nGCS0 片选空间,基地址为0x0。上面配置把链接基地址设置为0x0。 ??从norflash启动之后,u-boot代码会把自身代码拷贝到 高地址处 DRAM 来运行,运行过程中几乎就不再涉及到norflash了。 ??从 norflash 里面启动和用 openjtag 加载启动内存分配几乎是一样的。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |