Recently, I started to learn about the bare metal driver in the book Wei Dongshan. when running the code in the SDRAM, I found that it could not run correctly. the method I downloaded was to run the program through the D command of the supervivi provided by mini2440. Now, I think we have made many mistakes. Wei Dongshan's book emphasizes more than once that these bare metal programs should be downloaded to nandflash for running, but I downloaded them to the SDRAM through the D command of supervivi. Now, let's summarize the following:
1. These bare metal programs need to be downloaded to nandflash for running. When the CPU is started from nandflash, the CPU will use internal hardware to copy the 4 KB data starting with nandflash to the 4 kb internal RAM called "steppingston" (the starting address is 0 ), then jump to ram address 0 to start execution.
2. The D command of supervivi downloads the program to the memory starting address 0x3000000 of the sdram. At this time, it was actually started from nor flash. In this example, if you start from nor flash and download the program directly to SDRAM to run the program, run the code in SDRAM and copy the 4 kb code in steppingston to SDRAM, at this time, because something in steepingston is unknown, the code in the SDRAM will be overwritten, leading to program disorder.
3. the correct operation is to first start the program from nor flash, and then use the V command (download the program to the VIVI partition of nandflash, And the VIVI partition address is 0x0-0x50000) to download the program to nandflash, in fact, the V command First downloads the program to the SDRAM through dnw, and then executes the NAND write operation, copy the code starting with 0x30000000 to the address 0 of nandflash (this is what a friend on the Internet said ). In this way, the code is downloaded to nandflash. Then restart nandflash, so that stepingston is the code in nandflash, and this experiment will be able to run normally.