RL78 Flash Self Programming Considerations

In RL78 series MCUs, a special RAM area is allocated by flash self programming library.  This RAM area is called self-RAM.  User not aware of this, may see unexpected behaviors when using the RL78 series Flash Self-Programming Library to erase and program RL78 MCUs in field.  

An example for Self-RAM

Taking e2 studio and the CC-RL compiler as an example.

In the default configuration, the user RAM area is allocated at the beginning address of the RAM region (for example, this starts at address 0xFEF00 for R5F100LEA). However, when using the Flash Self-Programming Library, it is necessary to reserve the address range from 0xFEF00 to 0xFF2FF as the Self RAM area. Therefore, the user RAM area must be allocated outside of this range. For the R5F100LEA, the starting address of the user RAM must be modified from 0xFEF00 to 0xFF300.

Users can set the reserved Self RAM area in the following two ways.

Method 1: Manual Method
First, navigate to Project Properties → C/C++ Build → Settings → Linker → Sections and uncheck Layout sections automatically. Then, manually edit the section to change the starting address of the RAM from 0xFEF00 to 0xFF300.

Method 2: Automatic Method
First, navigate to Project Properties → C/C++ Build → Settings → Linker → Sections and check Layout sections automatically.

Then, in Project Properties → C/C++ Build → Settings → Linker → Device → RAM Area Without Section, select Self RAM Area from the dropdown menu.

More Details on Self-RAM

The relevant application documentation for the RL78 series Flash Self-Programming Library includes descriptions of self-RAM.  For example, the section 9.4 "Defining the Internal RAM Area" in the RL78 Family Flash Self-Programming Library Type01 Package Ver.4.00 Release Note provides detailed information about self-RAM allocation and its usage. 

RL78 Family Flash Self-Programming Library Type01 Package Ver.4.00