in debugger, how to erase dflash in 9S12XE

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

in debugger, how to erase dflash in 9S12XE

Jump to solution
3,203 Views
rlw
Contributor I

I am running Code Warrior V5 for 9S12 with a P&E USB BDM Multilink.

 

I have no problem erasing and programming PFLASH (program flash), but I have not been able to erase or program DFLASH (data flash).

 

Here is what I did and the responses I got:

 

in>flash init autoid
FP: FLASH parameters loaded for MC9S12XEQ384_V3(NVMIF2 rev 1,1,1,1,1) from C:\Freescale\CodeWarrior_for_S12X_V5_0\prog\FPP\mcu02DB.fpp

      MCU clock speed: 4017000 Hz
Block Module Name      Address Range   Status
   0  PFLASH            4000 -  7FFF   Blank - Unselected
   1  PFLASH            C000 -  FFFF   Blank - Unselected
   2  PFLASH          E08000 -E7BFFF   Blank - Unselected
   3  PFLASH          F08000 -FFBFFF   Blank - Unselected
   4  DFLASH             800 -1F0BFF   Programmed - Unselected

in>flash erase 4
Vppon command file is disabled.
Vppoff command file is disabled.

in>flash

      MCU clock speed: 4017000 Hz
Block Module Name      Address Range   Status
   0  PFLASH            4000 -  7FFF   Blank - Unselected
   1  PFLASH            C000 -  FFFF   Blank - Unselected
   2  PFLASH          E08000 -E7BFFF   Blank - Unselected
   3  PFLASH          F08000 -FFBFFF   Blank - Unselected
   4  DFLASH             800 -1F0BFF   Programmed - Unselected

in>

 

I also tried using "flash select 4" before erasing, but the result was no different.

Labels (1)
Tags (1)
0 Kudos
Reply
1 Solution
1,753 Views
kef
Specialist I

S12XE doesn't have dedicated commands to erase only D-FLASH. Erase All Blocks and Unsecure command (0xB) contrary to reference manual don't erase D-FLASH. Now, since partitioning commands are missing in debugger, the only solution I see is issuing partitioning commands from user code.

To fully erase and repartition D-FLASH, one may need to execute Full Partition D-Flash  command. This command works only in special modes. So code may need to check if operating in special single chip mode under debugger control:

 

if ((MODE & 0xE0) == 0) // is it special

{

      FSTAT = FSTAT_ACCERR_MASK | FSTAT_FPVIOL_MASK;
      FCCOBIX = 0;
      FCCOB   = 0x0F00; // full partition d-flash
      FCCOBIX++;
      FCCOB   = xxx; //DFPART
      FCCOBIX++;
      FCCOB   = yyy; //ERPART
      FSTAT &= FSTAT_CCIF_MASK;  
      while(!(FSTAT & FSTAT_CCIF_MASK))
      {
      }
}

 

View solution in original post

0 Kudos
Reply
4 Replies
1,753 Views
kef
Specialist I

Is D-FLASH partitioned? I'm using emulated EEPROM (EEE) and I noticed that debugger doesn't erase it. Moreover, data in EEE survives chip securing and unsecurig. I didn't try if it is the same with D-partition or in case D-flash is never partitioned. Maskset is 5M48H.

 

Debugger unsecure command is working well. What's weird is that unsecure cmd file is using command 8 - Erase All Blocks. S12XE RM states that "The Erase All Blocks operation will erase the entire P-Flash and D-Flash memory space including the EEE nonvolatile information register." It looks like it is not true. After this command D-FLASH is still partitioned and contents of EEE is unchanged. EEPROM Emulation Query command returns unchanged partitioning parameters.

 

Are you trying to load some constants along with code to D-FLASH? If so, then what addresses are you using? D-FLASH on S12XEP100, while not partitioned, is from 0x100000'G to 0x107FFF'G . This corresponds to EEPROM segments EEPROM_00 to EEPROM_1F in default prm file.

0 Kudos
Reply
1,753 Views
rlw
Contributor I

The dflash is partioned. I want to completely erase dflash so it can be repartitioned.

 

In the debugger, I have tried every variation of the erase command I could think of, but any but "flash erase" and "flash erase 4" (or whatever number) were rejected.

 

Not can I find any other commands that seem useful for this purpose.

 

What am I missing?

 

0 Kudos
Reply
1,754 Views
kef
Specialist I

S12XE doesn't have dedicated commands to erase only D-FLASH. Erase All Blocks and Unsecure command (0xB) contrary to reference manual don't erase D-FLASH. Now, since partitioning commands are missing in debugger, the only solution I see is issuing partitioning commands from user code.

To fully erase and repartition D-FLASH, one may need to execute Full Partition D-Flash  command. This command works only in special modes. So code may need to check if operating in special single chip mode under debugger control:

 

if ((MODE & 0xE0) == 0) // is it special

{

      FSTAT = FSTAT_ACCERR_MASK | FSTAT_FPVIOL_MASK;
      FCCOBIX = 0;
      FCCOB   = 0x0F00; // full partition d-flash
      FCCOBIX++;
      FCCOB   = xxx; //DFPART
      FCCOBIX++;
      FCCOB   = yyy; //ERPART
      FSTAT &= FSTAT_CCIF_MASK;  
      while(!(FSTAT & FSTAT_CCIF_MASK))
      {
      }
}

 

0 Kudos
Reply
1,753 Views
rlw
Contributor I

Thanks.

 

0 Kudos
Reply