On S7G2, boot swap code that runs normally on S5D9 causes a problem

Hi Everyone,

 

I try boot swapping on SK-S7G2, but the code that runs normally on PK-S5D9 cause a problem.

Though function startupAreaSelect() returns SSP_SUCCESS, BTFLG seems to be unstable.

Memory dump at address 0x40120064 is 0x7fffffff at one time or 0xffffffff at another time.

Value read by cpu is so.

 

 

After power on reset, value at address 0x40120064 returns to 0xffffffff.

 

Here is a snipet of the code.

--------------------------------------------

void SwapBootFlag2(bool boot_default)
{
ssp_err_t err_ssp;
flash_startup_area_swap_t start_up_block;

/* Get current BTFLG */
if ( boot_default )
{
start_up_block = FLASH_STARTUP_AREA_BLOCK1;
}
else
{
start_up_block = FLASH_STARTUP_AREA_BLOCK0;
}

/* Swap BTFLG */
err_ssp = g_flash0.p_api->open(g_flash0.p_ctrl, g_flash0.p_cfg);
APP_ERR_TRAP( SSP_SUCCESS != err_ssp);

err_ssp = g_flash0.p_api->startupAreaSelect( g_flash0.p_ctrl, start_up_block, false );
APP_ERR_TRAP( SSP_SUCCESS != err_ssp);

err_ssp = g_flash0.p_api->close(g_flash0.p_ctrl);
APP_ERR_TRAP( SSP_SUCCESS != err_ssp);
} /* End of function SwapBootFlag2() */

 

void wait_boot_swap(bool boot_default)

{
if(boot_default)
{
while(IS_BTFLG_DEFAULT)
{
__NOP();
}
}
else
{
while(!IS_BTFLG_DEFAULT)
{
__NOP();
}
}
}

void flwrite_swap_boot(bool boot_default)
{
relocate_vector_table();
__set_PRIMASK(1U);
SwapBootFlag2(boot_default);
wait_boot_swap(boot_default);
NVIC_SystemReset();
}

--------------------------------------------

Data of Block0 are shadowed to block1 in advance.

Is there any important notice at using S7G2?

 

board: SK-S7G2

SSP: ver. 1.7.0

e2studio: ver 7.5.1

  • Good day, tenballs!

    Is this the same issue as you've encountered before? I hope you could wait for our experts to notice your concern. Thank you for waiting.

    Best regards,

    Sai
    RenesasRulz Forum Moderator
    https://renesasrulz.com/
    https://academy.renesas.com/
    en-us.knowledgebase.renesas.com/

  • In reply to Sai:

    Hi Sai,

    >Is this the same issue as you've encountered before? I hope you could wait for our experts to notice your concern. Thank you for waiting.
    No.
    I 'am still in process of trial and error.
    You mean the question I made in the following thread, don't you?
    With Karol's advice Boot swapping on S5D9 work properly.
    So I wonder why I can't make it on S7G2 in the same way.


    (2206) Boot swap function causes unexpected program behavior - Synergy - Forum - Renesas Synergy Platform - RenesasRulz
    renesasrulz.com/.../boot-swap-function-causes-unexpected-program-behavior

     

    P.S.

    I might find a answer.

    I'll report about this.

  • In reply to tenballs:

    I edited  jlink file to remove AWS register from flash cache list and tried.

    ---------------------------------

    [FLASH]

    CacheExcludeSize = 0x04

    CacheExcludeAddr = 0x40120064

    ---------------------------------

    As a result,  BTFLG had been changed stably until reconnect by e2studio.

     

    Next I tried memoy dump by jlink.exe after swap.

    That tells BTFLG is zero.

     

    But BTFLG returns to default again when I reconnect by e2studio.

     

    So I conclude it is caused by e2studio.

    Does e2studio have any settings about this?

    Or does it rewrite flash configuration area of S7G2 flash?

     

    Any help would be greatly appreciated.

  • In reply to tenballs:

    Have tried removing the ID code from the image you download? The BTFLG and the ID Code are in the same area of configuration flash memory.
  • In reply to Jeremy:

    >Have tried removing the ID code from the image you download? The BTFLG and the ID Code are in the same area of configuration flash memory.
    You are right.
    I tried deleting the ID Code section in s7g2.ld.
    Even if I reconnected by e2stdio, BTFLG did't change.
    Thank you for the useful advice.

    By the way,I think Renesas should add this phenomenon to technical update or update SSP.
    Whenever a user make a new project, the ID Code section is included in the autogenerated linker script even if "ID code Mode" is "Unlocked(Ignore ID)".