In fact, the difference between nand flash and nor flash has nothing to say, one that in arm9 in the start-up mode here: Since nor have their own separate address and data lines can be directly run the program; but the nand address data public, when you start cpu It will take before 4KB data to run sram, so for larger than 4KB program, we must consider how to complete implementation of the program? After the program is about to 4KB 4KB in sdram by copying to continue to run in the front; used a chip cypres usb3014, although nuclear arm9, he's had sram 512kb projects, and using a package through real-time operation of thread x systems, generally 512kb enough, add a spi_flash on it; turn the subject back! Look at the code below:
.s
.text . Global _start _start: LDR SP, = 4096 @ disposed stack bl disable_watch_dog @ off DOG WATCH BL @ initialization memsetup the SDRAM BL @ initialization nand_init the Flash NAND @ in the NAND Flash 4096 1024-byte address codes (start compiling main.c obtained) to the SDRAM @nand_read_ll function takes three parameters: LDR r0 of, = 0x30000000 @ . 1 target address =. 0x30000000 , which is the starting SDRAM address MOV R1, # 4096 @2 . Source address = 4096 , the time of connection, main.c code exists at the beginning of 4096 NAND Flash address MOV R2, # 2048 @ . 3 . Copy length = 2048 (bytes), for main.c this experiment, which is enough bl nand_read @ call C functions nand_read, different models of similar LDR SP, = 0x34000000 @ set the stack LDR LR, = halt_loop @ set the return address; one is used to save the subroutine return address; the second is when an exception occurs, LR when the value stored in the value equal to the exception of the PC 4 minus (or minus 2), can be returned in a variety of modes according to an abnormal value LR to the corresponding position before the error occurrence continue. pc LDR, = main @b bl instruction and instruction can jump back and forth range of 32M, the method used herein to jump pc assignment halt_loop: B halt_loop
.lds (linker script)
{A SECTIONS firtst 0x00000000 : {head.o init.o nand.o} // Run these three documents address is 0, the resulting image file is also offset address 0 SECOND 0x30000000 : the AT ( 4096 ) {main.o } // run the file address is 0x30000000, the generated image file is also offset address 4096 }