Device does not run the program on power up, when .Srecord file is successfully flashed using RFP tool

Hi Team,

I generate .srecord file using e2studio and debug through e2studio it works.

But when I download the same .srecord file using Renesas Flash programmer, device does not run the program on power up.

Do I need to do any thing else?

I am able to successfully flash the board by using RFP tool, but the program does not run on the board on power up, not only this none of the programs run with power uo by RFP.

Am I doing anything wrong kindly help.

  • Hello Tiger,

    do you use SK-S7G2 board? Could you post logs from the RFP, showing the programming results? What are the symptoms, which confirms that the application is not running properly? Could you also try with the Blinky project?

    After programming the MCU with the RFP, the J1 jumper (in case of SK-S7G2 board) should be set in position 1-2 again, and the MCU should be restarted.

    Best regards,
    anper

  • In reply to anper:

    Tiger,

    You can not use semi-hosting for stand alone programs - the program will hang and not run. make sure that any debug printf are sent to a real device such as USB CDC or uart.

    -Gary
  • Hello Tiger,

    Adding to what Gary suggested, following things will not work or will work differently when debugger is disconnected:
    * printf() but also time()
    * IWDT/WDT operation (by default they're disabled when debugger is connected)
    * Any DWT feature (i.e. Cycle Counter register - DWT->CYCCNT) will be disable by default when debugger is disconnected
    * Any feature that loads data/code directly into RAM without explicitly initializing the section or using flash section to initialize it (i.e. .noinit section)

    Regards
  • In reply to anper:

    Hi Anper/Gary/Karol,

    Thanks for your immediate reply.

    I have commented all the printf statements, it did not work still.

    Then I have taken out this function initialise_monitor_handles();

    Now it started working.

    Can you please explain.

    Can you please explain the following in detail.

    * Any feature that loads data/code directly into RAM without explicitly initializing the section or using flash section to initialize it (i.e. .noinit section)

  • In reply to Tiger:

    Hi Anper/Gary/Karol,

    I shared same build to the client. He flashed it . It worked once. After that it never worked again on power up. Not sure what can be the problem. But for me it works all the time. May be because e2studio is involved for me.

    Then I gave blinky project to the client, he flashed through RFP it works on mulitple power resets. But this program does not work. What can be the problem? Any thing to do with the LCD program?

    Please help. This is really urgent. Nothing works at client side, even such simple programs also. Very strange problems.
  • In reply to Tiger:

    Hi Tiger,

    if the application works correctly (after commenting out printf() and initialise_monitor_handles()), it means that the cause of the problem was using semihosting in stand alone operation (as garyj and Karol suggested).

    If the application does not work on the client side, while the Blinky works fine and while the application is working fine on your side, please try to verify any possible differences between your and the client's configuration, for example:

    • is the client's hardware the same as yours?
    • does the client use correct configuration in the RFP? (could they provide screenshots for verification?)
    • does the client use the same S-record file as you are?

    Some of the above points seems quite obvious, however it's worth double checking all possible causes.

    It is convenient to use a macro to easily enable or disable semihosting by changing only one code line. It can be done the following way:

    /*******************************************************************************
    * Place this code at the beginning of the <thread_name>_entry.c file, below the
    * "include files" section.
    */
    #include <stdio.h>

    #define SEMIHOSTING // this macro allows to easily enable or disable semihosting - simply uncomment or comment this line

    #ifdef SEMIHOSTING
    #ifdef __GNUC__
    extern void initialise_monitor_handles (void);
    #endif
    #endif

    /*******************************************************************************
    * Place this code at the beginnig of the <thread_name>_entry() function.
    */
    #ifdef SEMIHOSTING
    #ifdef __GNUC__
    if ((CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk) == CoreDebug_DHCSR_C_DEBUGEN_Msk)
    {
       initialise_monitor_handles();
    }
    #endif
    #endif

    /*******************************************************************************
    * Place this code each time you want to print a message.
    */
    #ifdef SEMIHOSTING
    if ((CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk) == CoreDebug_DHCSR_C_DEBUGEN_Msk)
    {
       /* Print notification in the Renesas Debug Virtual Console */
       printf("Some text\n");
    }
    #endif

    /******************************************************************************/

    Useful information on using semihosting can be found in the following documentation:

    Best regards,
    anper

  • In reply to anper:

    Hi Anper,

    Thanks for your immediate reply.

    I take remote(team viewer) and flash the firmware, so I am pretty sure I am flashing correct firmware.

    Also flashing shows success. So connections are correct. Clients hardware same as mine, same dev board.

    Only doubt I have is program with out LCD screen works fine perfectly.

    program with LCD screen does not work, so something to do with LCD screen program.

    Are there any other project settings related to printf and semi hosting still alive so it does not work?

    Is it insufficient power it is not allowing LCD screen to function properly? But again it is powered by USB, so power should not be a problem.

    I am clueless and schoked and do not know how to proceed now?

    And the fact is it worked once and after that it never works.

    Strange issues are stopping the progress?

    Any thing you can suggest to attack the problem? Any thoughts will help me to progress.
  • In reply to Tiger:

    Hi Anper,

    In the linker configuration do I need to take out this option? Is this the culprit in not running the firmware?

    --specs=rdimon.specs
  • In reply to Tiger:

    Hi Tiger,

    do you use the printf() function anywhere else in your application, for example to write data to communications driver? If so, then you could experience an application suspension, when running without a debugger connected. To solve this issue, you would have to change --specs=rdimon.specs to --specs=nosys.specs in the:

    e2 studio > Project > Properties > C/C++ Build > Settings > Cross ARM Linker > Miscellaneous > Other linker flags

    I did not experience similar issue associated with the LCD.

    Best regards,
    anper

  • In reply to anper:

    Hi Anper,

    Thanks for your immediate reply.

    I will try this and get back to you as soon as possible.
  • In reply to garyj:

    Hello garyj.

    I had the same problem and I solved it after commenting "printf" and "initialise_monitor_handles()".

    However, the problem came back again when I used "srand((uint8_t)time(NULL));" at the begginning of my program. What happened? Does it has to do with "semi hosting"?

    Regards
  • In reply to AlfonsoV:

    Hello Alfonso,

    It is possible that time() is trying to perform semihosted request via the debugger back to the host PC to try and get the time.

    However, I assume that if your are using srand() that you are also using rand() to generate a random number?

    Have you considered using the TRNG (true random number generator) that is available on all Synergy devices?
    This will provide you with a true random number.

    To use, simply add the TRNG Driver via the configuration

    Driver > Crypto > TRNG Driver on r_sce_trng

    With the driver added, it's usage is very simple as shown in the code example below.
    This may provide you with a simple solution to the issue you are seeing.

    Regards,
    Richard




    #include "hal_data.h"

    #define TRNG_NUMBERS_TO_READ 1 /* Specify how many random number to read at one time? */

    uint32_t g_trng_result[TRNG_NUMBERS_TO_READ]; /* create storage for the true random number generator */


    void hal_entry(void)
    {
    /* TODO: add your own code here */
    ssp_err_t ssp_err;

    /* open the SCE (TRNG is part of the SCE) */
    ssp_err = g_sce.p_api->open(g_sce.p_ctrl, g_sce.p_cfg);
    if(SSP_SUCCESS != ssp_err)
    {
    __BKPT(0); /* If open is unsuccessful, hit breakpoint */
    }

    /* Open the TRNG */
    ssp_err = g_sce_trng.p_api->open(g_sce_trng.p_ctrl, g_sce_trng.p_cfg);
    if(SSP_SUCCESS != ssp_err)
    {
    __BKPT(0); /* If open is unsuccessful, hit breakpoint */
    }

    /* For this example, read random numbers once a second */
    while(1)
    {
    /* With the TRNG open, read numbers as required */
    ssp_err = g_sce_trng.p_api->read(g_sce_trng.p_ctrl, &g_trng_result[0], TRNG_NUMBERS_TO_READ);
    if(SSP_SUCCESS != ssp_err)
    {
    __BKPT(0); /* If readis unsuccessful, hit breakpoint */
    }

    /* delay 1 second */
    R_BSP_SoftwareDelay(1, BSP_DELAY_UNITS_SECONDS);
    }
    }
  • In reply to AlfonsoV:

    Hi Alfonso,

    As Richard suggested, time() does access the debugger in the same way printf() does. There's no way to retrieve time on your Synergy device otherwise, unless you're using RTC. You can use (uninitialized) Standby RAM as your seed for rand():
    * ((uint32_t *) 0x200fe000);

    Regards