Copy initial values to "data attribute" areas which are areas with initial values and clear "bss attribute" areas which are areas without initial values to 0. This processing is not required when there is no area that needs to be initialized before program execution.
First, instruct generation of initial value data with the -rom option of the optimizing linker, and define the RAM area section to where data is to be copied. For details, see "8.4 ROMization".
The defined RAM area section is written to the startup routine as follows.
Next, in the startup routine, write a code to initialize the bss attribute areas.
When initializing sections .bss and .sbss to 0, the code will be as follows.
Then, in the startup routine, write a code to copy data attribute areas to the RAM area section.
When copying sections .data and .sdata to .dataR and .sdataR, respectively, the code will be as follows. Note that the copy routine does not support a section that exceeds the 64-Kbyte boundary.
Write a program for zero-initializing the RAM area section and copying sections in the C language, and this program can be called from the startup routine.
A C language example of a function for initializing the RAM area section is given below.