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
ODOUV.1
ST Employee

Hello,

I would say you maybe inverted IrqIsrEnable and IrqIsrDisable, and you forgot componentsInit ?

Best Regards,

-Olivier

AVM
Associate III

Hi Olivier,

In the beginning, componentsInit() is called in main().

Also I have tried this with IrqIsrEnable() and then IrqIsrDisable(), but no success.

Warm Regards,

AM

ODOUV.1
ST Employee

Hello,

on SPC58xGxx, it seems that flash sector 0x00FF0000 is in Low select block 9:

0693W00000JNYJTQA5.png 

would you please try using 0x200 instead of 0x100 for LOWBLOCKSELECT ?

Best regards,

-Olivier

Hello,

on SPC58xGxx, it seems that flash sector 0x00FF0000 is in Low select block 9:

0693W00000JNYJTQA5.png 

would you please try using 0x200 instead of 0x100 for LOWBLOCKSELECT ?

Best regards,

-Olivier

AVM
Associate III

Hi Olivier,

I corrected the value,

#define LOWBLOCKSELECT 0x00000200U

So, now with this corrected value, I am able to erase the block 0xFF0000 only when I keep breakpoint at line8 in below code. But when I run it without breakpoint at line8 and put it on line14, line19, execution goes to unhandled exception.

/* Unlock the requested block for Erase operation */
nLargeBlockSelect.firstLargeBlockSelect = 0;
nLargeBlockSelect.secondLargeBlockSelect = 0;
SetLock(&FLSHM_ssdConfig, C55_BLOCK_LOW, UNLOCK_ALL_BLOCKS);
 
/* 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 done */
FLSHM_CmdStat = FLSHM_SUCCESS;
}
else
{
/* Erase failed */
FLSHM_CmdStat = FLSHM_ERASEFAILED;
}

ODOUV.1
ST Employee

Hello,

1) question:

How and where is declared/defined FLSHM_eraseCtxData ?

2) few remarks:

It should be safer to check the returned value from SetLock at line 4.

It should be safer to check opResult value at line 14 instead of always returning SUCCESS.

It should be safer to use default 0x80 instead of 256 for programmable size in FLSHM_ssdConfig.

Best Regards,

-Olivier

AVM
Associate III

Hi Olivier,

Ans:1) It is defined as global CONTEXT_DATA FLSHM_eraseCtxData;

Should this CONTEXT_DATA argument be same for both in case of erase and program calls?

For your remark point 2, I will check with those points as well and let you know the results.

Warm Regards,

AM

programmable size 256 should be OK, but did you forget to call FlashInit before the SetLock ?

BRs,

-Olivier

AVM
Associate III

Hi Olivier,

FlashInit is called just after componentsInit with mentioned FLSHM_ssdConfig structure.

Warm Regards,

AM