从nandflash启动uboot的基本原理.doc
从NANDFLASH启动UBOOT的基本原理CITEDFROMHTTP//HIBAIDUCOM/ZENGZHAONONG/BLOG/ITEM/4B901EE9B5EF343CB90E2D16HTML前4K的问题如果S3C2410被配置成从NANDFLASH启动配置由硬件工程师在电路板设置,S3C2410的NANDFLASH控制器有一个特殊的功能,在S3C2410上电后,NANDFLASH控制器会自动的把NANDFLASH上的前4K数据搬移到4K内部RAM中,并把0X00000000设置内部RAM的起始地址,CPU从内部RAM的0X00000000位置开始启动。这个过程不需要程序干涉。程序员需要完成的工作,是把最核心的启动程序放在NANDFLASH的前4K中。启动程序的安排由于NANDFLASH控制器从NANDFLASH中搬移到内部RAM的代码是有限的,所以在启动代码的前4K里,我们必须完成S3C2410的核心配置以及把启动代码UBOOT剩余部分搬到RAM中运行。UBOOT源码不支持从NANDFLASH启动,可是S3C2410支持从NANDFLASH启动,开发板SBC2410X加电后S3C2410将NANDFLASH的前4K保存有UBOOT的部分功能拷贝功能把NANDFLASH中的内容拷贝到SDRAM拷贝到SRAMS3C2410芯片内的SRAM。这就需要修改UBOOT源码,增加UBOOT的功能使UBOOT在得到执行权后能够将其自身拷贝到开发板上SDRAM中,以便处理器能够执行UBOOT。CDUBOOT116在BOARD/BKS2410加入NANDFLASH读函数,建立NAND_READC,加入如下内容COPYFROMVIVIVIBOARD/SBC2410X/NAND_READCINCLUDEDEFINE__REGBXVOLATILEUNSIGNEDCHARXDEFINE__REGIXVOLATILEUNSIGNEDINTXDEFINENF_BASE0X4E000000DEFINENFCONF__REGINF_BASE0X0DEFINENF__REGBNF_BASE0X4DEFINENFADDR__REGBNF_BASE0X8DEFINENFDATA__REGBNF_BASE0XCDEFINENFSTAT__REGBNF_BASE0X10DEFINEBUSY1INLINEVOIDWAIT_IDLEVOID{INTIWHILENFSTATI9NFADDRI17NFADDRI25WAIT_IDLEFORJ0JCOBJSSBC2410XOFLASHONAND_READOVICPU/ARM920T/STARTS从NANDFLASH中把数据拷贝到RAM,是由COPY_MYSELF程序段完成1在“LDRPC,_START_ARMBOOT“之前加入223行IFDEFCONFIG_S3C2410_NAND_BOOTBLCOPY_MYSELFJUMPTORAMLDRR1,ON_THE_RAMADDPC,R1,0NOPNOP1B1BINFINITELOOPON_THE_RAMENDIF2在“_START_ARMBOOTWORDSTART_ARMBOOT“之后加入IFDEFCONFIG_S3C2410_NAND_BOOTCOPY_MYSELFMOVR10,LRRESETNANDMOVR1,NAND_CTL_BASELDRR2,0XF830INITIALVALUESTRR2,R1,ONFCONFLDRR2,R1,ONFCONFBICR2,R2,0X800ENABLECHIPSTRR2,R1,ONFCONFMOVR2,0XFFRESETCOMMANDSTRBR2,R1,ONFMOVR3,0WAIT1ADDR3,R3,0X1CMPR3,0XABLT1B2LDRR2,R1,ONFSTATWAITREADYTSTR2,0X1BEQ2BLDRR2,R1,ONFCONFORRR2,R2,0X800DISABLECHIPSTRR2,R1,ONFCONFGETREADTOCALLCFUNCTIONSFORNAND_READLDRSP,DW_STACK_STARTSETUPSTACKPOINTERMOVFP,0NOPREVIOUSFRAME,SOFP0COPYVIVITORAMLDRR0,UBOOT_RAM_BASEMOVR1,0X0MOVR2,0X20000BLNAND_READ_LLTSTR0,0X0BEQOK_NAND_READIFDEFCONFIG_DEBUG_LLBAD_NAND_READLDRR0,STR_FAILLDRR1,SERBASEBLPRINTWORD1B1BINFINITELOOPENDIFOK_NAND_READIFDEFCONFIG_DEBUG_LLLDRR0,STR_OKLDRR1,SERBASEBLPRINTWORDENDIFVERIFYMOVR0,0LDRR1,UBOOT_RAM_BASEMOVR2,0X4004BYTES10244KBYTESGO_NEXTLDRR3,R0,4LDRR4,R1,4TEQR3,R4BNENOTMATCHSUBSR2,R2,4BEQDONE_NAND_READBNEGO_NEXTNOTMATCHIFDEFCONFIG_DEBUG_LLSUBR0,R0,4LDRR1,SERBASEBLPRINTHEXWORDLDRR0,STR_FAILLDRR1,SERBASEBLPRINTWORDENDIF1B1BDONE_NAND_READIFDEFCONFIG_DEBUG_LLLDRR0,STR_OKLDRR1,SERBASEBLPRINTWORDENDIFMOVPC,R10CLEARMEMORYR0STARTADDRESSR1LENGTHMEM_CLEARMOVR2,0MOVR3,R2MOVR4,R2MOVR5,R2MOVR6,R2MOVR7,R2MOVR8,R2MOVR9,R2CLEAR_LOOPSTMIAR0,{R2R9}SUBSR1,R1,84BNECLEAR_LOOPMOVPC,LRENDIFCONFIG_S3C2410_NAND_BOOT3在文件的最后加入ALIGN2DW_STACK_STARTWORDSTACK_BASESTACK_SIZE4VIINCLUDE/CONFIGS/SBC2410XH1将CONFIG_SERVERIP设置为主机IP这样以后在通过网络下载内核映像时,就不用就该IP地址了。这一项修改与NANDFLASH没有关系DEFINECONFIG_SERVERIP19216802402在文件末尾添加如下内容/NANDFLASHBOOT/DEFINECONFIG_S3C2410_NAND_BOOT1DEFINESTACK_BASE0X33F00000DEFINESTACK_SIZE0X8000DEFINEUBOOT_RAM_BASE0X33F80000/NANDFLASHCONTROLLER/DEFINENAND_CTL_BASE0X4E000000DEFINEBINT_CTLNB__REGINT_CTL_BASENB/OFFSET/DEFINE