How to skip erase a flash page when debugger?

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

How to skip erase a flash page when debugger?

Jump to solution
809 Views
Snaku
Contributor III

Hi,

I try to skip erase a page of S12XDG128, the memory page which I want to skip is 0xFE8000. so I select the block 'FLASH_8000' by AEFSKIPERASING setting. The picture is my setting for skipping erase memory blocks, but the page at 0xFE8000 still be erased, what I missed?

3676_3676.pngNvmSelSetting.png

 

Thank you,

Snaku

Labels (1)
0 Kudos
1 Solution
520 Views
jorge_plascencia
NXP TechSupport
NXP TechSupport


Hi Lee, 

Solution 1:

Explanation of the command:

FLASH AEFSKIPERASING specifies non-volatile memory blocks to protect from mass erasing at application automated programming. Place this command in a Startup command file.

If no modules are specified, no blocks are erased.

**Note:

If you want to protect one module of EEPROM you need to set the command for all the available modules of EEPROM, because if one module is erased all the EEPROM modules are erased.

For example:

For a MC9S12XDP512 device with the following FLASH modules:

Block Module Name             Address Range Status

0 FLASH_4000 4000 -  7FFF Blank - Unselected

1 FLASH_C000 C000 -  FFFF Programmed - Unselected

2 ALL_PPAGES E08000 -FFBFFF        Programmed - Unselected

3 EEPROM_C00 C00 -   FFF Blank - Unselected

4 ALL_EPAGES FC0800 -FF0BFF Programmed - Unselected

5 EEPROM_800 800 -   BFF Blank - Unselected

6 FLASH_8000 8000 -  BFFF Programmed - Unselected

On the P&E_Multilink_CyclonePro_Preload.cmd you need to type:

FLASH AEFSKIPERASING 3-5

you will need to protect the entire memory page in order to get this solved.



Solution 2:

or this trick may work for you as well:

As you mention it is not possible to indicate smaller sections than the ones present in the FLASH memory map.

To accomplish what you want, maybe this workaround might help you:

1) Save FLASH memory section each time you program the MCU. You can achieve it by adding debugger command "save ..." into *_Preload.cmd command file. This .cmd file is usually located here:

{Project directory}\cmd\P&E_Multilink_CyclonePro_Preload.cmd

// Before load the commands written below will be executed

//SAVE Flash section

save 0x208000..0x20BFFF MyFlash.s19

2) In order to restore Flash content erased by Mass Erase command flash the "MyFlash.s19" file back to the MCU as soon as the application is loaded. This could be done by the sequence of debugger commands below placed into *_Postload.cmd command file. This cmd file is usually located here:

{Project directory}\cmd\P&E_Multilink_CyclonePro_Postload.cmd

// After load the commands written below will be executed

flash

flash select 4  //ALL PAGES block

flash arm

srec MyFlash.s19

flash disarm

flash unselect

reset

For reference on the debugger commands you can consult the document " Debugger_HC12.pdf" located on the CodeWarrior installation path:

{CW install path}\Help\PDF

Hope this helps.



Regards,


View solution in original post

0 Kudos
3 Replies
521 Views
jorge_plascencia
NXP TechSupport
NXP TechSupport


Hi Lee, 

Solution 1:

Explanation of the command:

FLASH AEFSKIPERASING specifies non-volatile memory blocks to protect from mass erasing at application automated programming. Place this command in a Startup command file.

If no modules are specified, no blocks are erased.

**Note:

If you want to protect one module of EEPROM you need to set the command for all the available modules of EEPROM, because if one module is erased all the EEPROM modules are erased.

For example:

For a MC9S12XDP512 device with the following FLASH modules:

Block Module Name             Address Range Status

0 FLASH_4000 4000 -  7FFF Blank - Unselected

1 FLASH_C000 C000 -  FFFF Programmed - Unselected

2 ALL_PPAGES E08000 -FFBFFF        Programmed - Unselected

3 EEPROM_C00 C00 -   FFF Blank - Unselected

4 ALL_EPAGES FC0800 -FF0BFF Programmed - Unselected

5 EEPROM_800 800 -   BFF Blank - Unselected

6 FLASH_8000 8000 -  BFFF Programmed - Unselected

On the P&E_Multilink_CyclonePro_Preload.cmd you need to type:

FLASH AEFSKIPERASING 3-5

you will need to protect the entire memory page in order to get this solved.



Solution 2:

or this trick may work for you as well:

As you mention it is not possible to indicate smaller sections than the ones present in the FLASH memory map.

To accomplish what you want, maybe this workaround might help you:

1) Save FLASH memory section each time you program the MCU. You can achieve it by adding debugger command "save ..." into *_Preload.cmd command file. This .cmd file is usually located here:

{Project directory}\cmd\P&E_Multilink_CyclonePro_Preload.cmd

// Before load the commands written below will be executed

//SAVE Flash section

save 0x208000..0x20BFFF MyFlash.s19

2) In order to restore Flash content erased by Mass Erase command flash the "MyFlash.s19" file back to the MCU as soon as the application is loaded. This could be done by the sequence of debugger commands below placed into *_Postload.cmd command file. This cmd file is usually located here:

{Project directory}\cmd\P&E_Multilink_CyclonePro_Postload.cmd

// After load the commands written below will be executed

flash

flash select 4  //ALL PAGES block

flash arm

srec MyFlash.s19

flash disarm

flash unselect

reset

For reference on the debugger commands you can consult the document " Debugger_HC12.pdf" located on the CodeWarrior installation path:

{CW install path}\Help\PDF

Hope this helps.



Regards,


0 Kudos
520 Views
Snaku
Contributor III

Hi Jorge,

I use the solution 2, i.e. save flash data before erase it, can solve my problem. :smileyhappy:

I also tried solution 1, but it doesn't work. I have a question is that you mention in solution 1 "if one module is erased all the EEPROM modules are erased", is it the same as flash ? if I need to write only one flash page, all flash page will be erase even I selected to skip erase 'FLASH_8000' ?

Thanks for your help and rapidly reply, :smileyhappy:

Snaku

0 Kudos
520 Views
jorge_plascencia
NXP TechSupport
NXP TechSupport

Hi Lee,

that is true.

Regards,

0 Kudos