/*************************************************
*
*Nand basic functions:
*************************************************
*/ //读取Nand的ID号,返回值在r5中
ReadNandID:
mov r7,#NFCONF
ldr r0,[r7,#0] //NFChipEn();
bic r0,r0,#0x800
str r0,[r7,#0]
mov r0,#0x90 //WrNFCmd(RdIDCMD);
strb r0,[r7,#4]
mov r4,#0 //WrNFAddr(0);
strb r4,[r7,#8]
y1: //while(NFIsBusy());
ldr r0,[r7,#0x10]
tst r0,#1
beq y1
ldrb r0,[r7,#0xc] //id = RdNFDat()<<8;
mov r0,r0,lsl #8
ldrb r1,[r7,#0xc] //id |= RdNFDat();
orr r5,r1,r0
ldr r0,[r7,#0] //NFChipDs();
orr r0,r0,#0x800
str r0,[r7,#0]
mov pc,lr
//读取Nand状态,返回值在r1,此处没有用到返回值。
ReadNandStatus:
mov r7,#NFCONF
ldr r0,[r7,#0] //NFChipEn();
bic r0,r0,#0x800
str r0,[r7,#0]
mov r0,#0x70 //WrNFCmd(QUERYCMD);
strb r0,[r7,#4]
ldrb r1,[r7,#0xc] //r1 = RdNFDat();
ldr r0,[r7,#0] //NFChipDs();
orr r0,r0,#0x800
str r0,[r7,#0]
mov pc,lr
//等待Nand内部操作完毕
WaitNandBusy:
mov r0,#0x70 //WrNFCmd(QUERYCMD);
mov r1,#NFCONF
strb r0,[r1,#4]
z1: //while(!(RdNFDat()&0x40));
ldrb r0,[r1,#0xc]
tst r0,#0x40
beq z1
mov r0,#0 //WrNFCmd(READCMD0);
strb r0,[r1,#4]
mov pc,lr
//检查坏block:
CheckBadBlk:
mov r7, lr
mov r5, #NFCONF
bic r0, r0, #0x1f //addr &= ~0x1f;
ldr r1,[r5,#0] //NFChipEn()
bic r1,r1,#0x800
str r1,[r5,#0]
mov r1,#0x50 //WrNFCmd(READCMD2)
strb r1,[r5,#4]
mov r1, #6
strb r1,[r5,#8] //WrNFAddr(6)
strb r0,[r5,#8] //WrNFAddr(addr)
mov r1,r0,lsr #8 //WrNFAddr(addr>>8)
strb r1,[r5,#8]
cmp r6,#0 //if(NandAddr)
movne r0,r0,lsr #16 //WrNFAddr(addr>>16)
strneb r0,[r5,#8]
bl WaitNandBusy //WaitNFBusy()
ldrb r0, [r5,#0xc] //RdNFDat()
sub r0, r0, #0xff
mov r1,#0 //WrNFCmd(READCMD0)
strb r1,[r5,#4]
ldr r1,[r5,#0] //NFChipDs()
orr r1,r1,#0x800
str r1,[r5,#0]
mov pc, r7
ReadNandPage:
mov r7,lr
mov r4,r1
mov r5,#NFCONF
ldr r1,[r5,#0] //NFChipEn()
bic r1,r1,#0x800
str r1,[r5,#0]
mov r1,#0 //WrNFCmd(READCMD0)
strb r1,[r5,#4]
strb r1,[r5,#8] //WrNFAddr(0)
strb r0,[r5,#8] //WrNFAddr(addr)
mov r1,r0,lsr #8 //WrNFAddr(addr>>8)
strb r1,[r5,#8]
cmp r6,#0 //if(NandAddr)
movne r0,r0,lsr #16 //WrNFAddr(addr>>16)
strneb r0,[r5,#8]
ldr r0,[r5,#0] //InitEcc()
orr r0,r0,#0x1000
str r0,[r5,#0]
bl WaitNandBusy //WaitNFBusy()
mov r0,#0 //for(i=0; i<512; i++)
r1:
ldrb r1,[r5,#0xc] //buf[i] = RdNFDat()
strb r1,[r4,r0]
add r0,r0,#1
bic r0,r0,#0x10000
cmp r0,#0x200
bcc r1
ldr r0,[r5,#0] //NFChipDs()
orr r0,r0,#0x800
str r0,[r5,#0]
mov pc,r7
关于nand命令,我尝试打开CFG_CMD_NAND选项,并定义
#define CFG_MAX_NAND_DEVICE 1
#define MAX_NAND_CHIPS 1
#define CFG_NAND_BASE 0x4e000000
添加boar_nand_init()定义(空实现)。但是连接时出现问题,原因是u-boot使用的是软浮点,而我的交叉编译arm-linux-gcc是硬件浮点。
看过一些解决方法,比较麻烦,还没有解决这个问题,希望好心的高手指点。不过我比较纳闷,u-boot在nand部分哪里会用到浮点运算呢? |