cancel
Showing results for 
Search instead for 
Did you mean: 

Flash Erase for SPC58NG84E7 is not working

AVM
Associate III

Hello,

I am working on the bootloader, trying to flash only 256 bytes. So, before flashing, erasing the block 0xFF0000. There is already some data in this block. But erase is not happenin, even if FlashErase() returns 0 and FlashCheckStatus() also gives opResult=0. Also when I check memory, it still shows the same data and not erased.

Following below steps to get flash block erased-

#define LOWBLOCKSELECT 0x00000100U

#define MIDBLOCKSELECT 0x00000000U

#define HIGHBLOCKSELECT 0x00000000U

/* Unlock the requested block for Erase operation */
nLargeBlockSelect.firstLargeBlockSelect = 0;
nLargeBlockSelect.secondLargeBlockSelect = 0;
SetLock(&FLSHM_ssdConfig, C55_BLOCK_LOW, UNLOCK_ALL_BLOCKS);
 
irqIsrDisable();
 
/* Erase the requested block */
Return_Val = FlashErase(&FLSHM_ssdConfig, C55_ERASE_MAIN, LOWBLOCKSELECT, MIDBLOCKSELECT, HIGHBLOCKSELECT, nLargeBlockSelect);
if(Return_Val == C55_OK)
{
while(C55_INPROGRESS == FlashCheckStatus(&FLSHM_ssdConfig, 
C55_MODE_OP_ERASE, &opResult, &FLSHM_eraseCtxData))
{}
/* Erase is in progress */
}
else
{
/* Erase failed */
}
 
irqIsrEnable();

Configuration for flash is as follows -

SSD_CONFIG FLSHM_ssdConfig = {
C55_REG_BASE, /* C55 control register base */
MAIN_ARRAY_BASE, /* base of main array */
{ 0, 0, 0 }, /* blocks info of low address space */
{ 0, 0, 0 }, /* blocks info of mid address space */
{ 0, 0, 0 }, /* blocks info of high address space */
0, /* number of blocks in 256K address space */
UTEST_ARRAY_BASE, /* base of UTEST array */
TRUE, /* interface flag indicate main or alternate interface */
256U,/* programmable size */
FALSE /* debug mode selection */
};

0693W00000JNFt8QAH.png 

What could be the issue here?

Regards,

AM

23 REPLIES 23

OK

-Olivier

AVM
Associate III

Hi Olivier,

Updated the remarks from point 2,

a)checked the returned value from SetLock

b)checked opResult value

But, same behaviour.

The execution is not halting at any of both ErrorTrap() and gets stuck in unhandled exception.

/* Unlock the requested block for Erase operation */
nLargeBlockSelect.firstLargeBlockSelect = 0;
nLargeBlockSelect.secondLargeBlockSelect = 0;
Return_Val = SetLock(&FLSHM_ssdConfig, C55_BLOCK_LOW, UNLOCK_ALL_BLOCKS);
if (C55_OK != Return_Val)
{
  ErrorTrap(Return_Val);
}
 
/* Erase the requested block */
Return_Val = FlashErase(&FLSHM_ssdConfig, C55_ERASE_MAIN, LOWBLOCKSELECT, MIDBLOCKSELECT, HIGHBLOCKSELECT, nLargeBlockSelect);
if(Return_Val == C55_OK)
{
  while(C55_INPROGRESS == FlashCheckStatus(&FLSHM_ssdConfig, 
  C55_MODE_OP_ERASE, &opResult, &FLSHM_eraseCtxData))
  {}
  if(opResult == C55_OK)
  {
    /* Erase is in progress */
    FLSHM_CmdStat = FLSHM_SUCCESS;
  }
  else
  {
    /* Erase failed */
    FLSHM_CmdStat = FLSHM_ERASEFAILED;
    ErrorTrap(opResult);
  }
}
else
{
/* Erase failed */
FLSHM_CmdStat = FLSHM_ERASEFAILED;
}

Warm Regards,

AM

ODOUV.1
ST Employee

Would you please show me your BOOT configuration in SPC58xGxx RLA Platform->runtime_settings ?

as example:

0693W00000JNhthQAD.pngBRs,

-Olivier

AVM
Associate III

Hi Olivier,

Here's the Platform RLA configuration (I dont have watchdog option in this)-

0693W00000JNiPWQA1.pngWatchdog is in clock RLA -

0693W00000JNiRrQAL.png 

Warm Regards,

AM

ODOUV.1
ST Employee

Could you try this Load in RAM configuration ? (in runtime settings)0693W00000JNilIQAT.png 

BRs,

-Olivier

AVM
Associate III

Hi Olivier,

Great! This is erasing the flash successfully, even writing to flash is also working.

Could you tell me the reason for this?

Warm Regards,

AM

ODOUV.1
ST Employee

I am not 100% sure, I will check with Flash expert,

but I think you cannot erase a flash sector near to the one you are executing your own program.

0xFC_0000 and 0xFF_0000 are may be too closed from each other.

Load your program in RAM and executing from RAM, there is no more conflict

BRs,

-Olivier

AVM
Associate III

Hi Olivier,

Sure, please check with the expert and let me know the reason for this.

'0xFC_0000 and 0xFF_0000 are may be too closed from each other.' - If so, I will check this scenario for different flash block then.

Also, loading the program in RAM should certainly have some limitations I suspect. Am I right?

Warm Regards,

AM

Sure I will provide confirmation as soon as I have all the information.

For load in RAM the program must fulfill into limited RAM size..

BRs,

-Olivier

AVM
Associate III

Hi Olivier,

I tried flash erase for large blocks address space as -

nLargeBlockSelect.firstLargeBlockSelect = 0x01; //0x0100_0000 

nLargeBlockSelect.firstLargeBlockSelect = 0x02; // 0x0104_0000

nLargeBlockSelect.firstLargeBlockSelect = 0x10; //0x010C_0000

But, seen the same result. Flash erase doesn't happen and control gets stuck in unhandled exception.

Warm Regards,

AM