Erase application from flash

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Erase application from flash

跳至解决方案
5,139 次查看
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 项奖励
回复
1 解答
5,099 次查看
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

在原帖中查看解决方案

7 回复数
5,119 次查看
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 项奖励
回复
5,111 次查看
ikarkala
Contributor III

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

0 项奖励
回复
5,114 次查看
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 项奖励
回复
5,100 次查看
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

5,009 次查看
ikarkala
Contributor III
Thank you for the prompt response . I got what i needed
0 项奖励
回复
5,128 次查看
davidtosenovjan
NXP TechSupport
NXP TechSupport

Could you specify used MCU, please?

0 项奖励
回复
5,126 次查看
ikarkala
Contributor III

MPC5777C

0 项奖励
回复