in debugger, how to erase dflash in 9S12XE

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

in debugger, how to erase dflash in 9S12XE

跳至解决方案
3,206 次查看
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.

标签 (1)
标记 (1)
0 项奖励
回复
1 解答
1,756 次查看
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 项奖励
回复
4 回复数
1,756 次查看
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 项奖励
回复
1,756 次查看
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 项奖励
回复
1,757 次查看
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 项奖励
回复
1,756 次查看
rlw
Contributor I

Thanks.

 

0 项奖励
回复