FL2440的U-boot-2010.09移植(六)NAND FLash启动支持
FL2440的U-boot-2010.09移植(六)NAND FLash启动支持
从NAND Flash启动的原理很简单,就是利用S3C2440内部4K大小的SRAM,存储在NAND Flash中的代码不能被执行,而S3C2440在从NAND Flash启动把NAND Flash的前4k代码复制到SRAM中运行,U-boot支持从NAND Flash启动的方法就是利用这前4K代码完成SDRAM的初始化(SDRAM有64M),然后还要完成从U-boot代码从NAND Flash中复制到SDRAM中,然后再跳转到SDRAM中去运行完整的U-boot。为了便于系统启动的方便,可以在start.S文件中添加代码以识别系统是从NAND Flash启动还是从NOR Flash启动,从S3C2440芯片手册中可以看到
到OM[1:0]都为0时,说明是从NAND Flash启动,01和10都是从NOR Flash启动,OM[1:0]就是寄存器BWSCON的第2位~第1位(DW0)
一、添加NOR Flash启动和NAND Flash启动的识别
修改arch/arm/cpu/arm920t/start.S,首先将217行附近修改为:
- #ifndef CONFIG_SKIP_LOWLEVEL_INIT
- bl cpu_init_crit
- #endif
- #define BWSCON 0x48000000
- ldr r0, =BWSCON
- ldr r0, [r0]
- ands r0, r0, #0x6
- tst r0, #0x0
- bne norflash_boot /*OM[1:0] != 0, 跳转到NOR FLASH 启动处*/
- /*判断uboot是从nand flash启动还是从 nor flash启动*/
在220行附近将:
- #ifndef CONFIG_SKIP_RELOCATE_UBOOT
- relocate:
修改为
- norflash_boot:
- #ifndef CONFIG_SKIP_RELOCATE_UBOOT
- relocate:
二、添加NAND Flash的U-boot代码从NAND FLash到SDRAM搬移的代码
在前面修改的 bne norflash_boot ,227行后添加
- /*****************************nand boot**************************/
- nandflash_boot:
- #define LENGTH_UBOOT 0x40000
- #define NAND_CTL_BASE 0x4e000000
- #define oNFCONF 0x00
- #define oNFCONT 0x04
- #define oNFCMD 0x08
- #define oNFSTAT 0x20
- @reset NAND
- mov r1,#NAND_CTL_BASE
- ldr r2,=((7<<12)|(7<<8)|(7<<4))
- str r2,[r1,#oNFCONF]
- ldr r2,[r1,#oNFCONF]
- ldr r2,=((1<<4)|(1<<1)|(1<<0)) @Active low CE control
- str r2,[r1,#oNFCONT]
- ldr r2,[r1,#oNFCONT]
- @ get read to call C functions
- ldr sp,DW_STACK_START @setup stack point
- mov fp,#0 @no previous frame, so fp = 0
- @copy Uboot to ram
- ldr r0, =TEXT_BASE
- mov r1,#0x0
- mov r2,#LENGTH_UBOOT
- bl nand_read_ll
- tst r0,#0x0
- beq ok_nand_read
- bad_nand_read:
- loop2:
- b loop2 @infinite loop
- ok_nand_read:
- @verify
- mov r0,#0
- ldr r1,=TEXT_BASE
- mov r2,#0x400 @ compare 4k code from sram to sdram
- go_next:
- ldr r3, [r0], #4
- ldr r4, [r1], #4
- teq r3, r4
- bne notmatch
- subs r2,r2,#4
- tst r2,#0x0 @do not forget the instruction if have not this command the uboot can't break the loop
- beq stack_setup
- bne go_next
- notmatch:
- loop3:
- b loop3 @infinite loop
- /*****************************nand boot**************************/
上面这部分代码首先初始化了NAND Flash寄存器,然后进行了一个函数调用(这个函数中完成了代码搬移)后面则是对复制出来的数据进行一个简单的校验。在327行附近添加为:
- _start_armboot: .word start_armboot
- #define STACK_BASE 0x33f00000
- #define STACK_SIZE 0x10000
- .align 2
- DW_STACK_START: .word STACK_BASE+STACK_SIZE-4
添加函数的栈调用空间
相关阅读:
U-Boot源代码下载地址
FL2440的U-boot-2010.09移植(一)
FL2440的U-boot-2010.09移植(二)
FL2440的U-boot-2010.09移植(三)DM9000网卡及开发板相关配置
FL2440的U-boot-2010.09移植(四) 添加NOR FLash启动支持
FL2440的U-boot-2010.09移植(五)uboot架构中NAND FLash驱动修改
FL2440的U-boot-2010.09移植(六)NAND FLash启动支持
FL2440的U-boot-2010.09移植(七)LCD的支持
针对FL2440开发板的u-boot-2010.09版本补丁
|
评论暂时关闭