This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

RL78 L13 R5F10WMG PFDL Problems

I am trying to use the user memory on the RL78 - R5F10WMG. I am using IAM Embedded Workbench 1.40.5 due to the fact that my company has a license for this version. I downloaded the latest PFDL library, and I believe I modified the linker file correctly, however I must be doing something wrong as the processor appears to lock up when PFDL_Execute(); is called when attempting to either read or write to the flash memory. I have used this library on other parts such as the G10, G12 and G13 and never have had a problem. Thanks in advance!

Parents
  • The R5F10WMG is subject to the so-called "Self-RAM" restrictions - see document R20UT2944 RL78 Family Self RAM list of Flash Self Programming Library:

    Do you block the start of RAM from allocation to the application?

  • No, I did not, this could be the issue, thank you! To be honest I'm not very knowledgeable when it comes to linker files, how would I go about doing this?

  • Edit the linker config-file according to the requirement:

    For the PFDL the restricted RAM is smaller:

    Here are the linker files for v1.40.6, original and modified for PFDL, I assume v1.40.5 is the same.

    lnkr5f10wmg-Orig.xcl.txt
    //-------------------------------------------------------------------------
    //      XLINK command file template for RL78 microcontroller R5F10WMG.
    //
    //      This file can be used to link object files from the RL78
    //      Assembler, ARL78, and the C/C++ compiler ICCRL78.
    //
    //          This file is generated from the device file:
    //          DR5F10WMG.DVF
    //          Copyright(C) 2012 Renesas
    //          Format version V3.00, File version E1.00d
    //-------------------------------------------------------------------------
    
    //-------------------------------------------------------------------------
    //      The following segments are defined in this template link file:
    //
    //      INTVEC      -- Interrupt vectors.
    //      CLTVEC      -- Calltable vectors.
    //      RCODE       -- Code used by C/C++ startup and run-time library.
    //      CODE        -- Code used by __near_func, __interrupt and __callt functions.
    //      XCODE       -- Code used by __far_func functions.
    //      NEAR_CONST_ -- Constants used by __near const.
    //      FAR_CONST   -- Constants used by __far const.
    //      SADDR_x     -- Variables used by __saddr.
    //      NEAR_x      -- Variables used by __near.
    //      FAR_x       -- Variables used by __far.
    //      NEAR_HEAP   -- The heap used by near data model.
    //      FAR_HEAP    -- The heap used by far data model.
    //      SWITCH      -- Switch tables used by near code model.
    //      FSWITCH     -- Switch tables used by far model.
    //      DIFUNCT     -- Dynamic initialization vector used by C++
    //
    //      Where _x could be one of:
    //
    //      _Z      -- Initialized data (initvalue = 0 or without init value).
    //      _I      -- Initialized data (initvalue != 0).
    //      _ID     -- The initial values of _I.
    //      _N      -- Uninitialized data, used by __no_init.
    //-------------------------------------------------------------------------
    
    //-------------------------------------------------------------------------
    //      Define CPU
    //-------------------------------------------------------------------------
    
    -cRL78
    
    //-------------------------------------------------------------------------
    //      Size of the stack.
    //      Remove comment and modify number if used from command line.
    //-------------------------------------------------------------------------
    
    //-D_CSTACK_SIZE=80
    
    //-------------------------------------------------------------------------
    //      Size of the heaps.
    //      Remove comment and modify number if used from command line.
    //-------------------------------------------------------------------------
    
    //-D_NEAR_HEAP_SIZE=400
    //-D_FAR_HEAP_SIZE=4000
    
    //-------------------------------------------------------------------------
    //      Near constant location.
    //      0 -> 0xF0000-0xFFFFF mirrored in rom area 0x00000 - 0x0FFFF
    //      1 -> 0xF0000-0xFFFFF mirrored in rom area 0x10000 - 0x1FFFF
    //      2 -> Writeable constants
    //      Remove comments and modify number if used from command line.
    //-------------------------------------------------------------------------
    
    //-D_NEAR_CONST_LOCATION=0
    //-D_NEAR_CONST_LOCATION_START=02000
    //-D_NEAR_CONST_LOCATION_END=0DEFF
    
    //-------------------------------------------------------------------------
    //      Define the format functions used by printf/scanf.
    //      Default is auto formatting.
    //      Remove appropriate comment(s) to get desired formatting
    //      if used from command line.
    //-------------------------------------------------------------------------
    
    //-e_PrintfTiny=_Printf
    //-e_PrintfSmall=_Printf
    //-e_PrintfLarge=_Printf
    //-e_PrintfFull=_Printf
    
    //-e_ScanfSmall=_Scanf
    //-e_ScanfLarge=_Scanf
    //-e_ScanfFull=_Scanf
    
    //-------------------------------------------------------------------------
    //      Define replacement of the default library math functions.
    //      Choose either of: 
    //      1) smaller and faster versions
    //      2) more accurate versions 
    //      Remove appropriate comment(s) from either
    //      1) or 2), but not both, if used from command line.
    //-------------------------------------------------------------------------
    
    //-------------------------------------------------------------------------
    // 1) Smaller and faster versions
    //-------------------------------------------------------------------------
    //-e__iar_sin_small=sin
    //-e__iar_cos_small=cos
    //-e__iar_tan_small=tan
    //-e__iar_log_small=log
    //-e__iar_log10_small=log10
    //-e__iar_exp_small=exp
    //-e__iar_pow_small=pow
    //-e__iar_Sin_small=__iar_Sin
    //-e__iar_sin_smallf=sinf
    //-e__iar_cos_smallf=cosf
    //-e__iar_tan_smallf=tanf
    //-e__iar_log_smallf=logf
    //-e__iar_log10_smallf=log10f
    //-e__iar_exp_smallf=expf
    //-e__iar_pow_smallf=powf
    //-e__iar_Sin_smallf=__iar_Sinf
    //-e__iar_sin_smalll=sinl
    //-e__iar_cos_smalll=cosl
    //-e__iar_tan_smalll=tanl
    //-e__iar_log_smalll=logl
    //-e__iar_log10_smalll=log10l
    //-e__iar_exp_smalll=expl
    //-e__iar_pow_smalll=powl
    //-e__iar_Sin_smalll=__iar_Sinl
    
    //-------------------------------------------------------------------------
    // 2) More accurate versions
    //-------------------------------------------------------------------------
    //-e__iar_sin_accurate=sin
    //-e__iar_cos_accurate=cos
    //-e__iar_tan_accurate=tan
    //-e__iar_pow_accurate=pow
    //-e__iar_Sin_accurate=__iar_Sin
    //-e__iar_Pow_accurate=__iar_Pow
    //-e__iar_sin_accuratef=sinf
    //-e__iar_cos_accuratef=cosf
    //-e__iar_tan_accuratef=tanf
    //-e__iar_pow_accuratef=powf
    //-e__iar_Sin_accuratef=__iar_Sinf
    //-e__iar_Pow_accuratef=__iar_Powf
    //-e__iar_sin_accuratel=sinl
    //-e__iar_cos_accuratel=cosl
    //-e__iar_tan_accuratel=tanl
    //-e__iar_pow_accuratel=powl
    //-e__iar_Sin_accuratel=__iar_Sinl
    //-e__iar_Pow_accuratel=__iar_Powl
    
    //-------------------------------------------------------------------------
    //      Define if row buffering should be used by terminal output.
    //      Default is no buffering.
    //      Remove comment to get buffered terminal output if used from command line.
    //-------------------------------------------------------------------------
    
    //-e__write_buffered=__write
    
    //-------------------------------------------------------------------------
    //      Allocate the read only segments that are mapped to ROM.
    //-------------------------------------------------------------------------
    //-------------------------------------------------------------------------
    //      Interrupt vector segment.
    //-------------------------------------------------------------------------
    -Z(CODE)INTVEC=00000-0007F
    
    //-------------------------------------------------------------------------
    //      CALLT vector segment.
    //-------------------------------------------------------------------------
    -Z(CODE)CLTVEC=00080-000BD
    
    //-------------------------------------------------------------------------
    //      OPTION BYTES segment.
    //-------------------------------------------------------------------------
    -Z(CODE)OPTBYTE=000C0-000C3
    
    //-------------------------------------------------------------------------
    //      SECURITY_ID segment.
    //-------------------------------------------------------------------------
    -Z(CODE)SECUID=000C4-000CD
    
    //-------------------------------------------------------------------------
    //      Reserved ROM areas for OCD Firmware: 000CE-000D7
    //                                           1FC00-1FFFF
    //-------------------------------------------------------------------------
    
    //-------------------------------------------------------------------------
    //      Near constant segments.
    //-------------------------------------------------------------------------
    --segment_mirror @NEAR_CONST=NEAR_CONST_ID
    -Z(CONST)NEAR_CONST_ID=_NEAR_CONST_LOCATION_START-_NEAR_CONST_LOCATION_END
    -Z(DATA)NEAR_CONST=(_NEAR_CONST_LOCATION_START+F0000)-(_NEAR_CONST_LOCATION_END+F0000)
    
    //-------------------------------------------------------------------------
    //      Startup, Runtime-library, Near, Interrupt 
    //      and CALLT functions code segment and near switch.
    //-------------------------------------------------------------------------
    -Z(CODE)RCODE,CODE=000D8-0FFFF
    
    -Z(CONST)SWITCH=000D8-0FBFF
    
    //-------------------------------------------------------------------------
    //      Near data initializer segments. 
    //-------------------------------------------------------------------------
    -Z(CONST)NEAR_ID=[000D8-0FBFF]/10000
    -Z(CONST)SADDR_ID=[000D8-0FBFF]/10000
    -Z(CONST)DIFUNCT=[000D8-0FBFF]/10000
    
    //-------------------------------------------------------------------------                                                     
    //      Huge data segments.                                                      
    //-------------------------------------------------------------------------                                                     
    -Z(CONST)HUGE_ID=0DF00-1FBFF                 
    -Z(DATA)HUGE_I=FDF00-FFE1F                          
                                                            
    //-------------------------------------------------------------------------
    //      Far constant segments and far switch.
    //-------------------------------------------------------------------------
    -Z(CONST)FAR_ID=[0DF00-1FBFF]/10000
    -Z(DATA)FAR_I=[FDF00-FFE1F]/10000
    
    -P(CONST)FAR_CONST,FSWITCH=[000D8-1FBFF]/10000
    
    //-------------------------------------------------------------------------
    //      Far functions code segment.
    //-------------------------------------------------------------------------
    -P(CODE)XCODE=[000D8-1FBFF]/10000
    
    //-------------------------------------------------------------------------
    //      Allocate the read/write segments that are mapped to RAM.
    //-------------------------------------------------------------------------
    //-------------------------------------------------------------------------
    //      EEPROM segment.
    //      Note: This segment will not be automatically created
    //            and it will not be initialised by CSTARTUP!
    //-------------------------------------------------------------------------
    -Z(DATA)EEPROM=F1000-F1FFF
    
    //-------------------------------------------------------------------------
    //      Short address data and workseg segments.
    //-------------------------------------------------------------------------
    -Z(DATA)WRKSEG=FFE20-FFEDF
    -Z(DATA)SADDR_I,SADDR_Z,SADDR_N=FFE20-FFEDF
    
    //-------------------------------------------------------------------------
    //      Near data segments.
    //-------------------------------------------------------------------------
    -Z(DATA)NEAR_I,NEAR_Z,NEAR_N=FDF00-FFE1F
    
    //-------------------------------------------------------------------------
    //      Stack segment.
    //-------------------------------------------------------------------------
    -Z(DATA)CSTACK+_CSTACK_SIZE=FDF00-FFE1F
    
    //-------------------------------------------------------------------------
    //      Heap segments.
    //-------------------------------------------------------------------------
    -Z(DATA)NEAR_HEAP+_NEAR_HEAP_SIZE=FDF00-FFE1F
    -Z(DATA)FAR_HEAP+_FAR_HEAP_SIZE=[FDF00-FFE1F]/10000
    
    //-------------------------------------------------------------------------                                                     
    //      Huge data segments.                                                      
    //-------------------------------------------------------------------------                                                     
    -Z(DATA)HUGE_Z=FDF00-FFE1F
    -P(DATA)HUGE_N=FDF00-FFE1F
                                                            
    //-------------------------------------------------------------------------
    //      Far data segments.
    //-------------------------------------------------------------------------
    -Z(DATA)FAR_Z=[FDF00-FFE1F]/10000
    -P(DATA)FAR_N=[FDF00-FFE1F]/10000
    
    //-------------------------------------------------------------------------
    //      Select the output file format if used from command line.
    //      Remove comment to select the file format if used from command line.
    //-------------------------------------------------------------------------
    //-Fdebug
    
    //-------------------------------------------------------------------------
    //      End of File
    //-------------------------------------------------------------------------
    

    lnkr5f10wmg-PFDL.xcl.txt
    //-------------------------------------------------------------------------
    //      XLINK command file template for RL78 microcontroller R5F10WMG.
    //
    //      This file can be used to link object files from the RL78
    //      Assembler, ARL78, and the C/C++ compiler ICCRL78.
    //
    //          This file is generated from the device file:
    //          DR5F10WMG.DVF
    //          Copyright(C) 2012 Renesas
    //          Format version V3.00, File version E1.00d
    //-------------------------------------------------------------------------
    
    //-------------------------------------------------------------------------
    //      The following segments are defined in this template link file:
    //
    //      INTVEC      -- Interrupt vectors.
    //      CLTVEC      -- Calltable vectors.
    //      RCODE       -- Code used by C/C++ startup and run-time library.
    //      CODE        -- Code used by __near_func, __interrupt and __callt functions.
    //      XCODE       -- Code used by __far_func functions.
    //      NEAR_CONST_ -- Constants used by __near const.
    //      FAR_CONST   -- Constants used by __far const.
    //      SADDR_x     -- Variables used by __saddr.
    //      NEAR_x      -- Variables used by __near.
    //      FAR_x       -- Variables used by __far.
    //      NEAR_HEAP   -- The heap used by near data model.
    //      FAR_HEAP    -- The heap used by far data model.
    //      SWITCH      -- Switch tables used by near code model.
    //      FSWITCH     -- Switch tables used by far model.
    //      DIFUNCT     -- Dynamic initialization vector used by C++
    //
    //      Where _x could be one of:
    //
    //      _Z      -- Initialized data (initvalue = 0 or without init value).
    //      _I      -- Initialized data (initvalue != 0).
    //      _ID     -- The initial values of _I.
    //      _N      -- Uninitialized data, used by __no_init.
    //-------------------------------------------------------------------------
    
    //-------------------------------------------------------------------------
    //      Define CPU
    //-------------------------------------------------------------------------
    
    -cRL78
    
    //-------------------------------------------------------------------------
    //      Size of the stack.
    //      Remove comment and modify number if used from command line.
    //-------------------------------------------------------------------------
    
    //-D_CSTACK_SIZE=80
    
    //-------------------------------------------------------------------------
    //      Size of the heaps.
    //      Remove comment and modify number if used from command line.
    //-------------------------------------------------------------------------
    
    //-D_NEAR_HEAP_SIZE=400
    //-D_FAR_HEAP_SIZE=4000
    
    //-------------------------------------------------------------------------
    //      Near constant location.
    //      0 -> 0xF0000-0xFFFFF mirrored in rom area 0x00000 - 0x0FFFF
    //      1 -> 0xF0000-0xFFFFF mirrored in rom area 0x10000 - 0x1FFFF
    //      2 -> Writeable constants
    //      Remove comments and modify number if used from command line.
    //-------------------------------------------------------------------------
    
    //-D_NEAR_CONST_LOCATION=0
    //-D_NEAR_CONST_LOCATION_START=02000
    //-D_NEAR_CONST_LOCATION_END=0DEFF
    
    //-------------------------------------------------------------------------
    //      Define the format functions used by printf/scanf.
    //      Default is auto formatting.
    //      Remove appropriate comment(s) to get desired formatting
    //      if used from command line.
    //-------------------------------------------------------------------------
    
    //-e_PrintfTiny=_Printf
    //-e_PrintfSmall=_Printf
    //-e_PrintfLarge=_Printf
    //-e_PrintfFull=_Printf
    
    //-e_ScanfSmall=_Scanf
    //-e_ScanfLarge=_Scanf
    //-e_ScanfFull=_Scanf
    
    //-------------------------------------------------------------------------
    //      Define replacement of the default library math functions.
    //      Choose either of: 
    //      1) smaller and faster versions
    //      2) more accurate versions 
    //      Remove appropriate comment(s) from either
    //      1) or 2), but not both, if used from command line.
    //-------------------------------------------------------------------------
    
    //-------------------------------------------------------------------------
    // 1) Smaller and faster versions
    //-------------------------------------------------------------------------
    //-e__iar_sin_small=sin
    //-e__iar_cos_small=cos
    //-e__iar_tan_small=tan
    //-e__iar_log_small=log
    //-e__iar_log10_small=log10
    //-e__iar_exp_small=exp
    //-e__iar_pow_small=pow
    //-e__iar_Sin_small=__iar_Sin
    //-e__iar_sin_smallf=sinf
    //-e__iar_cos_smallf=cosf
    //-e__iar_tan_smallf=tanf
    //-e__iar_log_smallf=logf
    //-e__iar_log10_smallf=log10f
    //-e__iar_exp_smallf=expf
    //-e__iar_pow_smallf=powf
    //-e__iar_Sin_smallf=__iar_Sinf
    //-e__iar_sin_smalll=sinl
    //-e__iar_cos_smalll=cosl
    //-e__iar_tan_smalll=tanl
    //-e__iar_log_smalll=logl
    //-e__iar_log10_smalll=log10l
    //-e__iar_exp_smalll=expl
    //-e__iar_pow_smalll=powl
    //-e__iar_Sin_smalll=__iar_Sinl
    
    //-------------------------------------------------------------------------
    // 2) More accurate versions
    //-------------------------------------------------------------------------
    //-e__iar_sin_accurate=sin
    //-e__iar_cos_accurate=cos
    //-e__iar_tan_accurate=tan
    //-e__iar_pow_accurate=pow
    //-e__iar_Sin_accurate=__iar_Sin
    //-e__iar_Pow_accurate=__iar_Pow
    //-e__iar_sin_accuratef=sinf
    //-e__iar_cos_accuratef=cosf
    //-e__iar_tan_accuratef=tanf
    //-e__iar_pow_accuratef=powf
    //-e__iar_Sin_accuratef=__iar_Sinf
    //-e__iar_Pow_accuratef=__iar_Powf
    //-e__iar_sin_accuratel=sinl
    //-e__iar_cos_accuratel=cosl
    //-e__iar_tan_accuratel=tanl
    //-e__iar_pow_accuratel=powl
    //-e__iar_Sin_accuratel=__iar_Sinl
    //-e__iar_Pow_accuratel=__iar_Powl
    
    //-------------------------------------------------------------------------
    //      Define if row buffering should be used by terminal output.
    //      Default is no buffering.
    //      Remove comment to get buffered terminal output if used from command line.
    //-------------------------------------------------------------------------
    
    //-e__write_buffered=__write
    
    //-------------------------------------------------------------------------
    //      Allocate the read only segments that are mapped to ROM.
    //-------------------------------------------------------------------------
    //-------------------------------------------------------------------------
    //      Interrupt vector segment.
    //-------------------------------------------------------------------------
    -Z(CODE)INTVEC=00000-0007F
    
    //-------------------------------------------------------------------------
    //      CALLT vector segment.
    //-------------------------------------------------------------------------
    -Z(CODE)CLTVEC=00080-000BD
    
    //-------------------------------------------------------------------------
    //      OPTION BYTES segment.
    //-------------------------------------------------------------------------
    -Z(CODE)OPTBYTE=000C0-000C3
    
    //-------------------------------------------------------------------------
    //      SECURITY_ID segment.
    //-------------------------------------------------------------------------
    -Z(CODE)SECUID=000C4-000CD
    
    //-------------------------------------------------------------------------
    //      Reserved ROM areas for OCD Firmware: 000CE-000D7
    //                                           1FC00-1FFFF
    //-------------------------------------------------------------------------
    
    //-------------------------------------------------------------------------
    //      Near constant segments.
    //-------------------------------------------------------------------------
    --segment_mirror @NEAR_CONST=NEAR_CONST_ID
    -Z(CONST)NEAR_CONST_ID=_NEAR_CONST_LOCATION_START-_NEAR_CONST_LOCATION_END
    -Z(DATA)NEAR_CONST=(_NEAR_CONST_LOCATION_START+F0000)-(_NEAR_CONST_LOCATION_END+F0000)
    
    //-------------------------------------------------------------------------
    //      Startup, Runtime-library, Near, Interrupt 
    //      and CALLT functions code segment and near switch.
    //-------------------------------------------------------------------------
    -Z(CODE)RCODE,CODE=000D8-0FFFF
    
    -Z(CONST)SWITCH=000D8-0FBFF
    
    //-------------------------------------------------------------------------
    //      Near data initializer segments. 
    //-------------------------------------------------------------------------
    -Z(CONST)NEAR_ID=[000D8-0FBFF]/10000
    -Z(CONST)SADDR_ID=[000D8-0FBFF]/10000
    -Z(CONST)DIFUNCT=[000D8-0FBFF]/10000
    
    //-------------------------------------------------------------------------                                                     
    //      Huge data segments.                                                      
    //-------------------------------------------------------------------------                                                     
    -Z(CONST)HUGE_ID=0DF00-1FBFF                 
    -Z(DATA)HUGE_I=FDF88-FFE1F                          
                                                            
    //-------------------------------------------------------------------------
    //      Far constant segments and far switch.
    //-------------------------------------------------------------------------
    -Z(CONST)FAR_ID=[0DF00-1FBFF]/10000
    -Z(DATA)FAR_I=[FDF88-FFE1F]/10000
    
    -P(CONST)FAR_CONST,FSWITCH=[000D8-1FBFF]/10000
    
    //-------------------------------------------------------------------------
    //      Far functions code segment.
    //-------------------------------------------------------------------------
    -P(CODE)XCODE=[000D8-1FBFF]/10000
    
    //-------------------------------------------------------------------------
    //      Allocate the read/write segments that are mapped to RAM.
    //-------------------------------------------------------------------------
    //-------------------------------------------------------------------------
    //      EEPROM segment.
    //      Note: This segment will not be automatically created
    //            and it will not be initialised by CSTARTUP!
    //-------------------------------------------------------------------------
    -Z(DATA)EEPROM=F1000-F1FFF
    
    //-------------------------------------------------------------------------
    //      Short address data and workseg segments.
    //-------------------------------------------------------------------------
    -Z(DATA)WRKSEG=FFE20-FFEDF
    -Z(DATA)SADDR_I,SADDR_Z,SADDR_N=FFE20-FFEDF
    
    //-------------------------------------------------------------------------
    //      Near data segments.
    //-------------------------------------------------------------------------
    -Z(DATA)NEAR_I,NEAR_Z,NEAR_N=FDF88-FFE1F
    
    //-------------------------------------------------------------------------
    //      Stack segment.
    //-------------------------------------------------------------------------
    -Z(DATA)CSTACK+_CSTACK_SIZE=FDF88-FFE1F
    
    //-------------------------------------------------------------------------
    //      Heap segments.
    //-------------------------------------------------------------------------
    -Z(DATA)NEAR_HEAP+_NEAR_HEAP_SIZE=FDF88-FFE1F
    -Z(DATA)FAR_HEAP+_FAR_HEAP_SIZE=[FDF88-FFE1F]/10000
    
    //-------------------------------------------------------------------------                                                     
    //      Huge data segments.                                                      
    //-------------------------------------------------------------------------                                                     
    -Z(DATA)HUGE_Z=FDF88-FFE1F
    -P(DATA)HUGE_N=FDF88-FFE1F
                                                            
    //-------------------------------------------------------------------------
    //      Far data segments.
    //-------------------------------------------------------------------------
    -Z(DATA)FAR_Z=[FDF88-FFE1F]/10000
    -P(DATA)FAR_N=[FDF88-FFE1F]/10000
    
    //-------------------------------------------------------------------------
    //      Select the output file format if used from command line.
    //      Remove comment to select the file format if used from command line.
    //-------------------------------------------------------------------------
    //-Fdebug
    
    //-------------------------------------------------------------------------
    //      End of File
    //-------------------------------------------------------------------------
    

  • Thank you for the help! Also I had to add the following line to the new linker:

    -Z(CODE)PFDL_COD=[01000-01FFE]/10000

    I updated the linker file and now it appears that the execute function no longer causes a lockup/reset when doing a read command however when I attempt to write the chip locks up.

  • Timing is much more critical for write / erase operations than a read, check your descriptor values for valid info.  Also double-check your request data being passed to the lib.

    I have never used the T04/Pico lib type, have always needed to have EEL which is not supported by this lib.  Your 128KB L13 device should have adequate resources to support T02/Tiny FDL and also corresponding EEL if needed.

    Using the v1 IAR tools for RL78 you are a bit limited, as newer (v2, v3, v4) have pretty significant improvements with code generation and optimization, and support for the newer on-chip debuggers E2 & E2-Lite.  v1 maintains backward compatibility with 78K tools but for any non-migrating application I would recommend the latest and greatest.

  • Alright, we may switch over to IAR 4.10.1. I see the linker file format is different, I'm assuming I couldn't use the modified linker file that you provided me the other day?

  • Yes, the linker file format changed with v2, as the linker changed.

    Same type of file edits - have to modify the RAM start address to skip the Self-RAM and add the section for the FDL code.

  • The issue appears to have been resolved. I modified the linker for for IAR 4.10.5 and all is well. Thank you for all of the help!

  • I seem to have spoken too soon. It appeared to be working for a while but I am seeing some eratic behavior. Can you double check the changes I made to the linker?

    Original:

    //-------------------------------------------------------------------------
    //      ILINK command file template for RL78 microcontroller R5F10WMG.
    //
    //      This file can be used to link object files from the RL78
    //      Assembler, IASMRL78, and the C/C++ compiler ICCRL78.
    //
    //          This file is generated from the device file:
    //          DR5F10WMG.DVF
    //          Copyright(C) 2013 Renesas
    //
    //          Core type: s2
    //
    //          Format version 3.00, File version 1.01 
    //-------------------------------------------------------------------------
    
    
    define exported symbol __link_file_version_2 = 1;
    
    initialize by copy with simple ranges, packing = auto { rw, R_DATA, R_BSS, R_DATAF, R_BSSF, R_SDATA, R_SBSS };
    do not initialize   { section *.noinit };
    
    define memory mem with size = 1M;
    
    
    // Set the symbol __RESERVE_OCD_ROM to 1 to reserve the OCD area for debugging.
    // IDE: Symbol can be defined within the project settings here:
    //      "Project"-->"Options..."->"Linker"-->"Config"-->"Configuration file symbol definitions"
    //      Symbol definition: __RESERVE_OCD_ROM=1
    // Command line: --config_def __RESERVE_OCD_ROM=1
    
    if (isdefinedsymbol(__RESERVE_OCD_ROM))
    {
      if (__RESERVE_OCD_ROM == 1)
      {
        reserve region "OCD ROM area" = mem:[from 0x1FE00 size 0x0200];
      }
    }
    
    define region ROM_near = mem:[from 0x000D8 to 0x0FFFF];
    define region ROM_far  = mem:[from 0x000D8 to 0x0FFFF] | mem:[from 0x10000 to 0x1FFFF];
    define region ROM_huge = mem:[from 0x000D8 to 0x1FFFF];
    define region SADDR    = mem:[from 0xFFE20 to 0xFFEDF];
    define region RAM_near = mem:[from 0xFDF00 to 0xFFE1F];
    define region RAM_far  = mem:[from 0xFDF00 to 0xFFE1F];
    define region RAM_huge = mem:[from 0xFDF00 to 0xFFE1F];
    define region VECTOR   = mem:[from 0x00000 to 0x0007F];
    define region CALLT    = mem:[from 0x00080 to 0x000BF];
    define region EEPROM   = mem:[from 0xF1000 to 0xF1FFF];
    
    define block NEAR_HEAP  with alignment = 2, size = _NEAR_HEAP_SIZE {  };
    define block FAR_HEAP   with alignment = 2, size = _FAR_HEAP_SIZE {  };
    define block HUGE_HEAP  with alignment = 2, size = _HUGE_HEAP_SIZE {  };
    define block CSTACK     with alignment = 2, size = _STACK_SIZE { rw section CSTACK };
    define block INIT_ARRAY with alignment = 2, fixed order { ro section .preinit_array,
                                                              ro section .init_array };
    define block INIT_ARRAY_TLS with alignment = 2, fixed order { ro section .preinit_array_tls,
                                                                  ro section .init_array_tls };
    
    
    
    define block OPT_BYTE with size = 4  { R_OPT_BYTE,
                                           ro section .option_byte,
                                           ro section OPTBYTE };
    define block SECUR_ID with size = 10 { R_SECUR_ID,
                                           ro section .security_id,
                                           ro section SECUID };
    
    
    place at address mem:0x00000       { ro section .reset };
    place at address mem:0x00004       { ro section .intvec };
    place at address mem:0x000C0       { block OPT_BYTE };
    place at address mem:0x000C4       { block SECUR_ID };
    if ( _NEAR_CONST_LOCATION_SIZE > 0 )
    {
      "MIRROR": place in [from _NEAR_CONST_LOCATION_START size _NEAR_CONST_LOCATION_SIZE] with mirroring to (_NEAR_CONST_LOCATION_START | 0xF0000) { ro R_CONST,
                                                                                                                                                        ro section .const,
                                                                                                                                                        ro section .switch };
    }
    
    "CALLT":place in CALLT             { R_CALLT0, ro section .callt0 };
    
    "ROMNEAR":place in ROM_near        { R_TEXT, ro section .text};
    
    "ROMFAR":place in ROM_far          { block INIT_ARRAY,
                                         block INIT_ARRAY_TLS,
                                         R_TEXTF_UNIT64KP,
                                         ro section .textf_unit64kp,
                                         ro section .constf,
                                         ro section .switchf,
                                         ro };
    
    "ROMHUGE":place in ROM_huge        { ro section .consth,
                                         R_TEXTF,
                                         ro section .textf };
    
    "RAMNEAR":place in RAM_near        { block NEAR_HEAP,
                                         block CSTACK,
                                         zi section .iar.dynexit,
                                         R_DATA,
                                         rw section .data,
                                         R_BSS,
                                         rw section .bss*,
                                         rw };
    
    "RAMFAR":place in RAM_far          { block FAR_HEAP,
                                         R_DATAF,
                                         rw section .dataf,
                                         rw section .data_unit64kp,
                                         rw section .bss_unit64kp,
                                         R_BSSF,
                                         rw section .bssf* };
    
    "RAMHUGE":place in RAM_huge        { block HUGE_HEAP,
                                         rw section .hdata,
                                         rw section .hbss* };
    
    "SADDRMEM":place in SADDR          { rw section .sdata,
                                         R_SDATA,
                                         rw section .sbss*,
                                         R_SBSS,
                                         rw section .wrkseg };
    
    

    Modified:

    //-------------------------------------------------------------------------
    //      ILINK command file template for RL78 microcontroller R5F10WMG.
    //
    //      This file can be used to link object files from the RL78
    //      Assembler, IASMRL78, and the C/C++ compiler ICCRL78.
    //
    //          This file is generated from the device file:
    //          DR5F10WMG.DVF
    //          Copyright(C) 2013 Renesas
    //
    //          Core type: s2
    //
    //          Format version 3.00, File version 1.01 
    //-------------------------------------------------------------------------
    
    
    define exported symbol __link_file_version_2 = 1;
    
    initialize by copy with simple ranges, packing = auto { rw, R_DATA, R_BSS, R_DATAF, R_BSSF, R_SDATA, R_SBSS };
    do not initialize   { section *.noinit };
    
    define memory mem with size = 1M;
    
    
    // Set the symbol __RESERVE_OCD_ROM to 1 to reserve the OCD area for debugging.
    // IDE: Symbol can be defined within the project settings here:
    //      "Project"-->"Options..."->"Linker"-->"Config"-->"Configuration file symbol definitions"
    //      Symbol definition: __RESERVE_OCD_ROM=1
    // Command line: --config_def __RESERVE_OCD_ROM=1
    
    if (isdefinedsymbol(__RESERVE_OCD_ROM))
    {
      if (__RESERVE_OCD_ROM == 1)
      {
        reserve region "OCD ROM area" = mem:[from 0x1FE00 size 0x0200];
      }
    }
    
    define region ROM_near = mem:[from 0x000D8 to 0x0FFFF];
    define region ROM_far  = mem:[from 0x000D8 to 0x0FFFF] | mem:[from 0x10000 to 0x1FFFF];
    define region ROM_huge = mem:[from 0x000D8 to 0x1FFFF];
    define region SADDR    = mem:[from 0xFFE20 to 0xFFEDF];
    define region RAM_near = mem:[from 0xFDF88 to 0xFFE1F];
    define region RAM_far  = mem:[from 0xFDF88 to 0xFFE1F];
    define region RAM_huge = mem:[from 0xFDF88 to 0xFFE1F];
    define region VECTOR   = mem:[from 0x00000 to 0x0007F];
    define region CALLT    = mem:[from 0x00080 to 0x000BF];
    define region EEPROM   = mem:[from 0xF1000 to 0xF1FFF];
    
    define block NEAR_HEAP  with alignment = 2, size = _NEAR_HEAP_SIZE {  };
    define block FAR_HEAP   with alignment = 2, size = _FAR_HEAP_SIZE {  };
    define block HUGE_HEAP  with alignment = 2, size = _HUGE_HEAP_SIZE {  };
    define block CSTACK     with alignment = 2, size = _STACK_SIZE { rw section CSTACK };
    define block INIT_ARRAY with alignment = 2, fixed order { ro section .preinit_array,
                                                              ro section .init_array };
    define block INIT_ARRAY_TLS with alignment = 2, fixed order { ro section .preinit_array_tls,
                                                                  ro section .init_array_tls };
    
    
    
    define block OPT_BYTE with size = 4  { R_OPT_BYTE,
                                           ro section .option_byte,
                                           ro section OPTBYTE };
    define block SECUR_ID with size = 10 { R_SECUR_ID,
                                           ro section .security_id,
                                           ro section SECUID };
    
    
    place at address mem:0x00000       { ro section .reset };
    place at address mem:0x00004       { ro section .intvec };
    place at address mem:0x000C0       { block OPT_BYTE };
    place at address mem:0x000C4       { block SECUR_ID };
    if ( _NEAR_CONST_LOCATION_SIZE > 0 )
    {
      "MIRROR": place in [from _NEAR_CONST_LOCATION_START size _NEAR_CONST_LOCATION_SIZE] with mirroring to (_NEAR_CONST_LOCATION_START | 0xF0000) { ro R_CONST,
                                                                                                                                                        ro section .const,
                                                                                                                                                        ro section .switch };
    }
    
    "CALLT":place in CALLT             { R_CALLT0, ro section .callt0 };
    
    "ROMNEAR":place in ROM_near        { R_TEXT, ro section .text};
    
    "ROMFAR":place in ROM_far          { block INIT_ARRAY,
                                         block INIT_ARRAY_TLS,
                                         R_TEXTF_UNIT64KP,
                                         ro section .textf_unit64kp,
                                         ro section PFDL_COD,
                                         ro section .constf,
                                         ro section .switchf,
                                         ro };
    
    "ROMHUGE":place in ROM_huge        { ro section .consth,
                                         R_TEXTF,
                                         ro section .textf };
    
    "RAMNEAR":place in RAM_near        { block NEAR_HEAP,
                                         block CSTACK,
                                         zi section .iar.dynexit,
                                         R_DATA,
                                         rw section .data,
                                         R_BSS,
                                         rw section .bss*,
                                         rw };
    
    "RAMFAR":place in RAM_far          { block FAR_HEAP,
                                         R_DATAF,
                                         rw section .dataf,
                                         rw section .data_unit64kp,
                                         rw section .bss_unit64kp,
                                         R_BSSF,
                                         rw section .bssf* };
    
    "RAMHUGE":place in RAM_huge        { block HUGE_HEAP,
                                         rw section .hdata,
                                         rw section .hbss* };
    
    "SADDRMEM":place in SADDR          { rw section .sdata,
                                         R_SDATA,
                                         rw section .sbss*,
                                         R_SBSS,
                                         rw section .wrkseg };
    
    

  • The changes look fine.  What do you mean by erratic behavior?

Reply Children
  • On 3 different ICs now I get behavior that looks great at first but after some time, I start getting resets when I try to write to memory. I've run the code in a debugger and do not see that flash memory is being written more often than expected and thus do not think I am wearing the flash memory out.

  • Nevermind, I figured it out! It had to do with the voltage in the circuit decaying slowly when power was removed, and the chip would try to write to flash without enough power causing corruption. It was intermittent but managed to track it down and add mitigations. Thank you for all the help!