Skip to main content

IAR Embedded Workbench for RH850 3.20.x

System initialization

In this section:

It is likely that you need to adapt the system initialization. For example, your application might need to initialize memory-mapped special function registers (SFRs), or omit the default initialization of data sections performed by the system startup code.

You can do this by implementing your own version of the routine __low_level_init, which is called from the cstartup file before the data sections are initialized. Modifying the cstartup file directly should be avoided.

The code for handling system startup is located in the source files cstartup and low_level_init.c, located in the rh850\src\lib directory. For the name of the cstartup file, see System startup and termination.

Note that normally, you do not need to customize cexit.s.

Note

Regardless of whether you implement your own version of __low_level_init or the file cstartup, you do not have to rebuild the library.

For information about how this works for multicore devices, see Adapting the system initialization for multiple cores.

Customizing __low_level_init

Two skeleton low-level initialization files are supplied with the product—a C source file, low_level_init.c and an alternative assembler source file, low_level_init.s. The latter is part of the prebuilt runtime environment. The only limitation using the C source version is that static initialized variables cannot be used within the file, as variable initialization has not been performed at this point.

The value returned by __low_level_init determines whether or not data sections should be initialized by the system startup code. If the function returns 0, the data sections will not be initialized.

The __low_level_init function has an integer input parameter that identifies the calling core. The permitted range is 1–7.

Modifying the cstartup file

As noted earlier, you should not modify the cstartup file if implementing your own version of __low_level_init is enough for your needs. However, if you do need to modify the cstartup file, we recommend that you follow the general procedure for creating a modified copy of the file and adding it to your project, see Overriding library modules.

Note

You must make sure that the linker uses the start label used in your version of cstartup.s. For information about how to change the start label used by the linker, see ‑‑entry.