8.5.1 Outline

When a variable is declared globally or static within a program, the variable is allocated to the data-attribute section in RAM if the variable has a initial value, or to the bss-attribute section if it does not have a initial value. When the variable has a initial value, that initial value is also stored in RAM. In addition, program code may be stored in the internal RAM area to speed up applications.

In the case of an embedded system, if a debug tool such as an in-circuit emulator is used, executable modules can be downloaded and executed just as they are in the allocation image. However, if the program is actually written to the target system's ROM area before being executed, the initial value information that has been allocated to the data-attribute section and the program code that has been allocated to a RAM area must be deployed in RAM prior to execution. In other words, data that is residing in RAM must be deployed in ROM, and this means that data must be copied from ROM to RAM before the corresponding application is executed.

"ROMization" refers to the packing of the initial values of variables in data-attribute sections and program code to be allocated to the RAM into a single section of ROM. Allocating this section to the ROM and calling the copy function provided by the CC-RH make it easy to deploy the initial values and program code to the RAM.

The following figure shows an outline of the operation flow in creating objects for ROMization.

Figure 8.3

Creation of Object for ROMization

 

When ROMization objects are created as shown in the "Figure 8.3 Creation of Object for ROMization", execution of the _INITSCT_RH copies the data to be allocated to RAM from the packed ROM section.

 

The function used to copy from the ROM area to the RAM area is as follows.

 

This function is stored in the library "libc.lib".

 

If the object files resolved for relocation include symbol information and debug information, the CC-RH creates a ROMization object module file without deleting them. Therefore, the debugger can debug the source even with a ROMization object module file.