Flash Erase not working in MPC5777M

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Flash Erase not working in MPC5777M

1,379 Views
vmedina
Contributor III

Hello, 

Flash erase is not working for me with the MPC5777M.

I am using an example from MPC5748G-Flash_RW-SSD_GHS614 that I found on the forums. None of the following steps fail with an error and pFlashCheckStatus is returning with C55_DONE. However, it does not erase anything. I am trying to erase memory sector 0x09640000.

This is my code:

#define C55_REG_BASE 0xFFFE0000
#define MAIN_ARRAY_BASE 0x00404000
#define UTEST_ARRAY_BASE 0x00400000

#define C55_PROGRAMMABLE_SIZE 0x80

SSD_CONFIG 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 */
C55_PROGRAMMABLE_SIZE,/* programmable size */
FALSE /* debug mode selection */
};

void func()

{

uint32_t returnCode = 0; /* Return code from each SSD function. */
uint32_t result = 0;
uint32_t lowBlockSelect, midBlockSelect, highBlockSelect;
CONTEXT_DATA CtxData;
N256K_BLOCK_SEL n256KBlockSelect;

// Flash Init
returnCode = pFlashInit(&ssdConfig);
if (C55_OK != returnCode)
{
return;
}

returnCode = pSetLock(&ssdConfig, C55_BLOCK_256K_FIRST, 0xFDFFFFFF);
if (C55_OK != returnCode)
{
return;
}

//erase the mid block
lowBlockSelect = 0x00000000;
midBlockSelect = 0x00000000;
highBlockSelect = 0x00000000;
n256KBlockSelect.first256KBlockSelect = 0x02000000;
n256KBlockSelect.second256KBlockSelect = 0x00000000;

returnCode = pFlashErase(&ssdConfig,
C55_ERASE_MAIN,
lowBlockSelect,
midBlockSelect,
highBlockSelect,
n256KBlockSelect);

if (C55_OK != returnCode)
{
return;
}
while(1)
{

returnCode = pFlashCheckStatus(&ssdConfig, C55_MODE_OP_ERASE,&result, &CtxData);
if(returnCode != C55_INPROGRESS)
{
break;
}
}

}

I have also done it in the following way after searching for information on the forums with similar results:

C55FMC.LOCK2.R = 0b11111101111111111111111111111111;
C55FMC.MCR.B.ERS = 1;
C55FMC.SEL2.R = 0b00000010000000000000000000000000;
*(unsigned int*)0x09640000 = 0xFFFFFFFF; //interlock write
C55FMC.MCR.B.EHV = 1;
while(C55FMC.MCR.B.DONE == 0);
C55FMC.MCR.B.EHV = 0;
C55FMC.MCR.B.ERS = 0;

Labels (1)
0 Kudos
6 Replies

978 Views
davidtosenovjan
NXP TechSupport
NXP TechSupport

Hi, I am afraid the address 0x09640000 is not specified within Flash memory map.

pastedImage_1.png

0 Kudos

978 Views
vmedina
Contributor III

Hello,

Perhaps that is not the MPC5777M? I have even tried 0x01640000 with no success.

I am writing for the MPC5777M.

This is the table i have:

pastedImage_1.png

0 Kudos

978 Views
davidtosenovjan
NXP TechSupport
NXP TechSupport

OK, this should be correct address. Mirror spaces cannot be used for flash programming (erasing).

Are you executing the code from RAM?

0 Kudos

978 Views
vmedina
Contributor III

Hello,

Yes, I am executing this code from RAM.

0 Kudos

978 Views
davidtosenovjan
NXP TechSupport
NXP TechSupport

Do you have enabled cache? If so, it is possible you have incoherent data between cache and target memory. In other words flash block is erased but you read data already pre-fetched in the cache.

So you can either disable cache before flash erasing/programming or invalidate cache after erasing/programming.

0 Kudos

978 Views
vmedina
Contributor III

That seems to be the issue.

I reference this post to address my problem:

https://community.nxp.com/thread/396056 

Thanks for your help.

0 Kudos