Skip to main content

IAR Embedded Workbench for RL78 5.20

Reserving resources when debugging

In this section:

When an OCD emulator is debugging an application, some resources cannot be used by the application and must be reserved. Any modification of these areas is prohibited.

All ROM areas used by the monitor program must be reserved by your application. Any modification of these areas is prohibited. These areas must be excluded from the usable address space in the linker configuration file.

Device-specific linker configuration files to be used as templates are included in the $TOOLKIT_DIR$\config\ directory.

If unused ROM addresses are filled, you must use ielftool to exclude the resources required by the debug monitor program.

These ROM areas must be reserved:

  • The reset vector. Will be overwritten by the monitor program during debugging.

  • The IRQ vector at address 0x0002,0x0003. Used by the monitor program.

  • The OCD option byte area address at 0x00C3. Used for configuring the OCD interface.

  • The User option byte area address at 0x00C00x00C2. Used for device configuration such as watchdog, voltage detection, on-chip oscillator, etc.

  • The Security ID area at 0x00C40x00CD. Contains the authentication code.

  • Monitor area 1 at 0x00CE0x00D7. Used by the monitor program.

  • Monitor area 2, 256 or 512 bytes at the end of the internal ROM. Used by the monitor program. If the pseudo RRM feature is not used in 2-wire mode, this area is only 88 bytes.

An additional 6 bytes of the stack area must be reserved.

The TOOL0 pin must be reserved.

The Option byte area of the RL78 flash memory holds the User option byte and On-chip debug option byte. During power-up and reset of an application, the Option byte area is automatically referenced by the device, so you must make sure that it is correctly configured. Refer to the hardware user manual for your device.

The Security ID allows an authentication check before the debug session is started. C-SPY can be configured to behave in a certain way, if an incorrect security ID is entered. The Security ID of an erased device is filled with 0xFF (this means that 0xFF is reserved, and that you cannot use it as an ID code).

Define the Security ID and option bytes using one of two methods:

  • In specific constant sections

  • By absolute memory allocation.

Examples
  1. Using specific constant sections:

    #pragma constseg=.option_byte
    __root const unsigned char optbyte[4] = {v0,v1,v2,v3}; 
    #pragma constseg=.security_id
    __root const unsigned char secu_ID[10]= {s0,s1,s2,s3,s4,s5,s6,
    	                        
                    s7,s8,s9}; 
    #pragma constseg=default 
  2. Using absolute memory allocation:

    __root const unsigned char optbyte[4] @ 0x00C0 = {v0,v1,v2,v3};
    __root const unsigned char secu_ID[10] @ 0x00C4 = {s0,s1,s2,s3,s4,s5,s6,s7,s8,s9};
  3. In assembler language:

    ORG 0x00C0
    ; Option bytes
    DB 0x00,0xFE,0xFF,0x85
    
    ORG 0x00C4
    ; Security ID
    DB 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF
    END

The 10 bytes s0s9 or 16 bytes s0s15 make up the ID Code that you are defining. By default, all values are 0xFF. See Hardware Setup.

You can change the section names .option_byte and .security_id. New names must be defined in the linker configuration file.

The device-specific values v0–v2 are described in the device documentation. The value v3 configures the OCD interface. For more information, refer to the User’s Manual for your emulator, available from the Renesas website www.renesas.eu/e1.

The addresses 0x02, 0x03, the area between 0x00CE0x00D7, and the last 256 or 512 bytes of the internal ROM must be reserved for the debug monitor program. If this area is rewritten by the flash self-programming, on-chip debugging can no longer be performed. Make sure to reserve these areas in your linker configuration file.

Device-specific linker configuration file templates reserving all necessary areas are included with the product. The templates are located in the $TOOLKIT_DIR$\config\ directory. The naming convention is transparent; the template for a device is named lnkdevicename.icf.

On-chip debugging requires another 6 bytes of stack. Therefore, the stack size of the application must be increased. In the IAR Embedded Workbench IDE, choose Project>Options and open the Stack/Heap page in the General Options category. If you are debugging from the command line, the stack size is defined in the linker configuration file:

//--------------------------------------------------------------- 
// Size of the stack.
//--------------------------------------------------------------- 
--config_def _STACK_SIZE=128

There are a number of important things you need to know when debugging with an OCD emulator. Refer to the User’s Manual for your emulator, available from the Renesas website www.renesas.eu/e1.