Issue encountered using the FSL_BlankCheck() function

Hello all,

I just started to work on the RL78/G13 micro. For the moment, i'm reading the user guides, and all the documentations I can find about it. In the same time, I installed IAR and applilet, then generated some firsts files (.c and .h) and started to test the first code executions.
There is a piece of my code:

##############################################################################
#define CODE_FLASH_MEMORY_ADDR 0x10CE /* CODE FLASH MEMORY Start Address */
#define CODE_FLASH_MEMORY_SIZE 0x3EF31 /* CODE FLASH MEMORY Size */

int main( void )
{
 
  /*====================================================================*/
  /*                            Declaration                             */
  /*====================================================================*/   
  volatile fsl_u08  my_fsl_init_status_u08;                 // get fsl_init status
  volatile fsl_u08  my_fsl_blankCheck_status_u08;    // get fsl_blank_check status
 
  fsl_descriptor_t  fsl_descr;                                       // define fsl descriptor type

  fsl_descr.fsl_flash_voltage_u08     = 0x00;         // set the flash voltage mode --> full speed mode (see 25.6 docs-emea.rs-online.com/.../0900766b8144b40f.pdf)
  fsl_descr.fsl_frequency_u08               = 0x14;    // CPU freq (MHz)
  fsl_descr.fsl_auto_status_check_u08 = 0x01;   // set the status mode to internal status check
 
  /************************** Test Variables ****************************/
  fsl_u16 myBlankBlock = 0x0000;
 
  /*====================================================================*/
  /*                                Code                                */
  /*====================================================================*/
 
  my_fsl_init_status_u08 = FSL_Init((__far fsl_descriptor_t*)&fsl_descr);  //Init
 
  if(my_fsl_init_status_u08 != FSL_OK)
  {
    //MyErrorHandler();
  }
 
  FSL_Open();
  FSL_PrepareFunctions();


  my_fsl_blankCheck_status_u08 = FSL_BlankCheck(myBlankBlock);
  if(my_fsl_blankCheck_status_u08 != FSL_OK)
  {
.......
  }
}
################################################################################

I encountered an issue using the FSL_BlankCheck() function. I probably made something wrong, but I don't see my issue.
So tell me if i'm wrong, but I tried to check if the block located at the address "CODE_FLASH_MEMORY_ADDR (= 0x10CE)" is blanked or not.

When I run this code on IAR, it seems that the program doesn't work correctly, as I can't go ahead the command line " my_fsl_blankCheck_status_u08 = FSL_BlankCheck(myBlankBlockAddr);"

Do you know what is wrong with my code ?

Thank you in advance,
Antoine

  • Hi Antoine,

    How's this issue? Were you able to solve this already?

    JB
    RenesasRulz Forum Moderator

    https://renesasrulz.com/
    https://academy.renesas.com/
    https://en-us.knowledgebase.renesas.com/

  • In reply to JB:

    Hi JB,

    In fact, i'm trying another way to reach my dreams !! :D
    I downloaded a sample project provided by Renesas to implement a bootloader on a RL78 using the UART connection.

    So for the moment, i'm trying to adapt this code as the sample project uses the UART1 when the custom board I have here is rooted on the UART2. When it will be ok, I'll be able to test again the bootloader. :D
  • In reply to JB:

    Hello JB,
    After long hours working on the UART, it's finally working.
    So now, i used the sample project provided by Renesas to execute a Flash self programming.

    To realize that, I first sent a START command (0x02) so that the the initialization of the flash memory self programming is done. After that, the R_MAIN_SelfInitialize() functions returned an OK code (FSL_OK).

    Now, the Write Address is set to 0x1000 (Cluster 1 Address), and the function R_MAIN_WriteExecute(WriteAddr) is launched. I sent a short trame via the UART : 0x0006 (len), 0x03 (Write Command), 0x54('T'), 0x45('E'), 0x53('S'), 0x54('T'), 0x43 (CheckSum).

    And now, the loop is started in which we:
    1. initialize the WriteBlock variable to (WriteAddr / BLOCK_SIZE )
    2. Run the FSL_BlankCheck(WriteBlock ) function

    The BlankCheck function returns 0x1B which means "the specified block is not in the blank state". So to fix that issue, the function FSL_Erase(WriteBlock) is launched so that the write block becomes as expected.

    And now, the program seems to be blocked in the FSL_Erase function ... It never goes at the next step of the flash reprogramming
    **EDIT (14/10/2019)**:

    Sometimes, the program goes after the FSL_Erase function, and then the FSL_Write function is launched, but we have the same behaviour than the one we had before on the FSL_Erase function. I checked in the memory, and the bytes are correctly erased and written (after the fsl_write).
    So in fact, on 5 runs on the FSL_Erase function, the program continues 1 time out of 5, and same on the FSL_Write. So if I want to continue after the FSL_Write, I have to run about 25 times the program. Seems to be complicated to debug ...
    Any ideas ???

    *******

    Do you have any idea why ?

    For your information, i used the sample linked file "fsl_sample_linker_file_SCI.xcl".
    If I use the "fsl_sample_linker_file_SCU.xcl", then when running the BlankCheck function, nothing happens, and i'm back to the halt() function into the main routine.

    Thank you in advance

    Antoine

  • In reply to Anto185:

    Hello All,

    For your information, I found the issue (which was really simple to find in my side).
    In fact, the program on which I'm working is a program developed by another developper some motnhs ago.
    The aim of it was to provide the basics librairies (UART, I2C, ... possibilities). And so, he implemented interruptions which are using a part of the memory inside the 0x1000-0x1FFF. So after I erased this block, the interruption doesn't know anymore where to go, and the program is completely broken ...
    After disabling all the interruptions, I don't have any issue anymore.

    Thank you for your help, hoping this topic will be usefull for other devs.

    Antoine