1, the program is burned to write to Nandflash, set to Nandflash start, 6410 tablets have 8 K of memory, set to Nandflash start, is from the on-chip memory 0 address start, a power, Nandflash Front 8K content will be copied to the 6410 front of the memory 8k address, and then start from 0 address, if the burn to Nandflash above the program above 8k, do not do other processing will not be able to run.
So to initialize the DDR, the entire Nandflash inside the program is copied into the DDR.
So where do you copy the program to DDR? The link address that should be copied to it.
Before the makefile inside,-ttext 0, indicating that the program's link address is starting from 0, so when the program is less than 8K, copy to 6410 before 8k, starting from 0 address, so corresponding to the link address, to be able to run.
When the program is more than 8K, to copy to the DDR, then to modify the link address!
Look at the role of the link address:
A program is divided into:
Code snippet: A global variable with an initial value and an initial value nonzero, or a static variable, BSS segment: A global, static variable with an initial value of zero or no initial value
Note that there is no content in the binary file that does not hold the BSS section!!!!!!!!!!!! The program at the start of the Bss_start to the bss_end inside the variable zeroed.
When the link address is 0 o'clock,
A link address is used when accessing global variables!
When the link address is 0x50000000
Above the same set of programs, the link address is not the same, causing the program to access the global variables also use the same address!
When starting from the Nandflash, the Nandflash before the 8k copy to 6410 in the first 8K inside to go, at this time even if the program's link address is 0x50000000, (note: A program run time "should" be located in its link address.) ), because the previous program uses the location-independent code written, so no matter how much the link address, it can run anywhere, it is mainly using B, bl to jump, and do not access global variables and static variables.
When starting from the Nandflash, the Nandflash before the 8k copy to 6410 in the first 8K inside, when the program's link address is 0x50000000 time, then when the program copied to 6410 in the re-positioning, That is, the program itself will copy itself into the DDR link address 0x50000000, and then from 6410 in tune to the DDR link address run. This will be correct!!
Reposition: Copy the program to its link address.
1) When the program runs, "should" be located at its connection address
2) The hardware determines the start of the program from 0 to run, need to relocate, that is, a small piece of code before the program copied to its link address.
3) Why the previous snippet of code works, because they are written in position-independent code.
w-d-s-Link Address