For more information about realboard, visit the official website of huizhi technology.Www.hugacy.com
Download a 2440 ucosii version from the Internet, and run it on the realboard simulator. Suddenly, it's a zombie. I immediately followed it step by step with the debugger, and finally found the culprit.Code:
BL readnandid
MoV R6, #0
LDR r0, = 0xec73
CMP R5, R0
Beq % F1
LDR r0, = 0xec75
CMP R5, R0
Beq % F1
MoV R6, #1
1
BL readnandstatus
MoV R8, #0
LDR R9, =__ entry
2
ANDS r0, R8, # 0x1f
BNE % F3
MoV r0, R8
BL checkbadblk
CMP r0, #0; // a non-0 value is returned. Is there an error in the whole simulated NAND Flash?
Addne R8, R8, #32
BNE % F4
3
MoV r0, R8
MoV R1, R9
BL readnandpage
Add R9, R9, #512.
Add R8, R8, #1
4
CMP R8, #5120; copy to SDRAM
BCC % B2
Go to checkbadblk and see the figure below:
checkbadblk
mov R7, LR
mov R5, # nfconf
Bic r0, R0, # 0x1f; ADDR & = ~ 0x1f;
LDR R1, [R5, #4]; nfchipen ()
Bic R1, R1, #0x02
STR R1, [R5, #4]
mov R1, #0x50; wrnfcmd (readcmd2)
strb R1, [R5, #8]; nfcmd
mov R1, #6
strb R1, [R5, # 0x0c]; wrnfaddr (6)
strb r0, [R5, # 0x0c]; wrnfaddr (ADDR)
mov R1, R0, LSR #8; wrnfaddr (ADDR> 8)
strb R1, [R5, # 0x0c]
CMP R6, #0; if (nandaddr)
movne r0, R0, LSR #16; wrnfaddr (ADDR> 16)
strneb r0, [R5, # 0x0c]
BL waitnandbusy; waitnfbusy ()
Ldrb r0, [R5, #0x10]; rdnfdat (); // The read value is not the default OOB value 0xff, which is odd.Strange, isn't it?What happened to readcmd2?
Sub r0, R0, # 0xff
MoV R1, #0; wrnfcmd (read1_0)
Strb R1, [R5, #8]
LDR R1, [R5, #4]; nfchipds ()
ORR R1, R1, #0x02
STR R1, [R5, #4]
MoV PC, r7
Then I went further to waitnandbusy, and the old fox finally appeared.
Waitnandbusy
MoV r0, #0x70; wrnfcmd (querycmd );
MoV R1, # nfconf
Strb r0, [R1, #8]; nfcmd
1; while (! (Rdnfdat () & 0x40 ));
Ldrb r0, [R1, #0x10]; nfdata
Tst r0, #0x40
Beq % B1
MoV r0, #0; wrnfcmd (read1_0 );
Strb r0, [R1, #8]; // annoying. the OOB status is overwritten here.
MoV PC, LR
After the accident was handled, I searched the internet and fainted. Someone had previously solved the problem on the 2440 board, but I met it on the realboard.
Strneb r0, [R5, # 0xc]
; BL waitnandbusy; waitnfbusy ()
; Do not use waitnandbusy, after waitnandbusy will read Part!
MoV r0, #100