Erase application from flash

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

Erase application from flash

Jump to solution
1,202 Views
ikarkala
Contributor III

I want to erase my application code present from 0x00A00000--0x00FFFFFF and since the code for erase was part of the same RWW partition , I tried to write in another partition x009C0000 and erase it but haven't been successful 
I tried erasing using the following commands

1. Write Enable

2.Sector Erase command

3. Address which has to be erased

using PUSH and POP via DSPIC which is connected to the flash memory 

Anything which I might have missed ? why isnt the erase successful 

 

0 Kudos
1 Solution
1,162 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

I'm not really sure what you are doing. Here I have simple piece of code for unlock, erase and program:

// step1. unlock all blocks (for simplicity)
C55FMC.LOCK0.R = 0;
C55FMC.LOCK1.R = 0;
C55FMC.LOCK2.R = 0;
C55FMC.LOCK3.R = 0;

// step2. erase the large block 31 (0x00FC0000 - 0x00FFFFFF)
C55FMC.MCR.B.ERS = 1;
C55FMC.SEL2.R = 0x80000000; // select the large block 7
*(unsigned int*)0x00FC0000 = 0xFFFFFFFF; //interlock write
C55FMC.MCR.B.EHV = 1;
while(C55FMC.MCR.B.DONE == 0);
C55FMC.MCR.B.EHV = 0;
C55FMC.MCR.B.ERS = 0;

// step3. program data
C55FMC.MCR.B.PGM = 1;
*(unsigned int*)0x00FC0000 = 0xAABBCCDD; //interlock write
*(unsigned int*)0x00FC0004 = 0x11223344;
C55FMC.MCR.B.EHV = 1;
while(C55FMC.MCR.B.DONE == 0);
C55FMC.MCR.B.EHV = 0;
C55FMC.MCR.B.PGM = 0;

Not sure why SPI is mentioned. You can use SPI only to get some command from outside world that someone wants to perform flash operations and your application can execute some code like the code above.

And again - make sure that data cache is disabled or invalidated to see the correct result.

Regards,

Lukas

View solution in original post

7 Replies
1,182 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi Indira,

what does it mean you "haven't been successful"? Was an exception triggered? Or which error code was returned? Also which SW do you use? Is that SDK RTM 3.0.3?
Or do you mean that no error code was returned and you just can't see erased flash in your debugger?
Could you make sure that the data cache is either disabled or invalidated after erase?
Could you make sure that the blocks are unlocked?
Could you try to disable all interrupts?

Regards,
Lukas

0 Kudos
1,174 Views
ikarkala
Contributor III

Sorry missed mentioning by havent been successful i mean the erase isnt happening 

0 Kudos
1,177 Views
ikarkala
Contributor III

Hi 

No error code is returned , I have written the code (it is not SDK RTM 3.0.3) and using Lauterbach Trace32 debugger , No interrupts occur as well. I have written some data to 0x9c00000 and i am trying to clear it using PUSH and POP commands of DSPIC . Do we need this area to be unblocked ? How do we unblock it ? Do you think the erase can be achieved using SPI ?

0 Kudos
1,163 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

I'm not really sure what you are doing. Here I have simple piece of code for unlock, erase and program:

// step1. unlock all blocks (for simplicity)
C55FMC.LOCK0.R = 0;
C55FMC.LOCK1.R = 0;
C55FMC.LOCK2.R = 0;
C55FMC.LOCK3.R = 0;

// step2. erase the large block 31 (0x00FC0000 - 0x00FFFFFF)
C55FMC.MCR.B.ERS = 1;
C55FMC.SEL2.R = 0x80000000; // select the large block 7
*(unsigned int*)0x00FC0000 = 0xFFFFFFFF; //interlock write
C55FMC.MCR.B.EHV = 1;
while(C55FMC.MCR.B.DONE == 0);
C55FMC.MCR.B.EHV = 0;
C55FMC.MCR.B.ERS = 0;

// step3. program data
C55FMC.MCR.B.PGM = 1;
*(unsigned int*)0x00FC0000 = 0xAABBCCDD; //interlock write
*(unsigned int*)0x00FC0004 = 0x11223344;
C55FMC.MCR.B.EHV = 1;
while(C55FMC.MCR.B.DONE == 0);
C55FMC.MCR.B.EHV = 0;
C55FMC.MCR.B.PGM = 0;

Not sure why SPI is mentioned. You can use SPI only to get some command from outside world that someone wants to perform flash operations and your application can execute some code like the code above.

And again - make sure that data cache is disabled or invalidated to see the correct result.

Regards,

Lukas

1,072 Views
ikarkala
Contributor III
Thank you for the prompt response . I got what i needed
0 Kudos
1,191 Views
davidtosenovjan
NXP TechSupport
NXP TechSupport

Could you specify used MCU, please?

0 Kudos
1,189 Views
ikarkala
Contributor III

MPC5777C

0 Kudos