what can let DFlash's Patition Miss for MC9S12XET256

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

what can let DFlash's Patition Miss for MC9S12XET256

Jump to solution
2,804 Views
alexzhu
Contributor II

    Hello,I meet a quetion about DFlash of MC9S12XET256,I use it by the follow steps:

Step1: I use the full patition  d-flash commnd 0xf in case that with BDM, and set DFPART is 0x0,ERPART is 0x10;

Step2: I use Enable EEE commnd 0x13 and write to buffer ram,it's ok, after that I remove BDM(BKGD not connect);

step3: In the  case  that without BDM,I use Query cmd test the patition, and visible EEE IFR (MMCCTL1's Bit5 set),result is normal,use ok;

step4: after step3,I run my board for a short time, and  one day I find  i can not use the eeprom,i use the query cmd,

the result(use query )is  DFPART is 0xFFFF,ERPART is 0xFFFF,I read the EEEIR and  the result is  0x120004 is 0x00,

0x120005 is 0x00, 0x120006 is 0x10, 0x120007 is 0x10FF, i am sure during  step4 without BDM.

 

My  question are :

1:what can make the partition's parameters become zero in case that without bdm?

2:In case that  no patition how can  i repatition by no bdm?

thanks for  reply my quetion!

Labels (1)
0 Kudos
1 Solution
2,196 Views
RadekS
NXP Employee
NXP Employee

Hi alex,

I could simply help you in case of partition command unexpected interrupt simulations.

I already created example code some time ago. Please look at attachment.

You could simply play with Start_interval() parameter and try simulate similar issue as in your case.

In root of project you could find examples of OK and NOK memory contents.

For recovery, please unsecure MCU and load code again, after that you could execute partition command once again.


I hope it helps you.

Have a great day,
RadekS

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

12 Replies
2,196 Views
kef2
Senior Contributor IV

ERPART 0x10 is too big. Buffer RAM size is 2kB and ERPART specifies how much data you, up to 2kB, you are going to store in emulated EEPROM. Max ERPART figure is 2kB / 256 = 8. Perhaps wrong ERPART caused your problem.

It is not necessary to use BDM-only full partition command (0xF). Alternatively from normal mode you can 1) issue EEPROM query command (0x15) to determine if EEPROM is partitioned, and 2) in case 0x15 command returned 0xFFFF (in FCCOBIDX=2, FCCOB == 0xFFFF), issue normal mode partition command (0x20). And finally 3) Issue enable emulation command (0x13).

void SetupEeprom(void)
{
   FSTAT = FSTAT_ACCERR_MASK | FSTAT_FPVIOL_MASK;
   FCCOBIX = 0;
   FCCOB   = 0x1500;  // EEPROM QUERY
   FSTAT &= FSTAT_CCIF_MASK;  
   while(!(FSTAT & FSTAT_CCIF_MASK))
   {
   }

   FCCOBIX = 2;
   if(FCCOB == 0xFFFF)
   {
      FSTAT = FSTAT_ACCERR_MASK | FSTAT_FPVIOL_MASK;
      FCCOBIX = 0;
      FCCOB   = 0x2000; //0x0F00; // partition
      FCCOBIX++;
      FCCOB   = 0; //DFPART
      FCCOBIX++;
      FCCOB   = 8; //ERPART
      FSTAT &= FSTAT_CCIF_MASK;  
      while(!(FSTAT & FSTAT_CCIF_MASK))
      {
      }
   }

   FSTAT = FSTAT_ACCERR_MASK | FSTAT_FPVIOL_MASK;
   FCCOBIX = 0;
   FCCOB   = 0x1300; // enable emulation
   FSTAT &= FSTAT_CCIF_MASK;  
   while(!(FSTAT & FSTAT_CCIF_MASK))
   {
   }
}

0 Kudos
2,196 Views
alexzhu
Contributor II

That's great!Thank for replying me!But a pity is that i check it out and think it's not the solution to my problem. In normal mode(i check the MODE Register value is 0x80),i follow your method that use the patition command -0x20,after invoking these codes ,i check register's messages,the results are: 1)FCCOBIX=0,->FCCOB=0x2000;2)FCCOBIX=1,->FCCOB=0; 3)FCCOBIX=2,->FCCOB=8, FSTAT=0x83.

But,when i set  register-MMCCTL1-bit5 and read the address 0x120004 and 0x120005,the values still are 0x00, not change,so i think it's failure to execute the patition command, of course,i still can't use the eepom.

I think that the globle address 0x120000~0x120007 must be erased state before execute patition command,is it? How can i execute the patiton command successful in the normal mode?

I wish that you can continue to help me.

0 Kudos
2,196 Views
kef2
Senior Contributor IV

My routine shows how one could avoid partitioning in BDM mode (special single chip mode) and partition in normal mode. Once partitioning is done (like in your case), EEPROM query returns non-0xFFFF value, normal mode partition command (0x20) can not be used. Once partitioned in any mode (normal or special), you need to go to BDM mode and erase all DFLASH before commands 0xF or 0x20 can be used again.

Edward

0 Kudos
2,196 Views
alexzhu
Contributor II

Good afternoon! is it  mean that  i must go to BDM mode if i want to  recover the EEPROM(once fault)  function? I worry about that  the same phenomenon(eeprom fault) would occur again.So i want there is a another way can recover EEPROM in normal mode.  because of i am not sure that the wrong ERPART cased my problem, because my other boards are normal and they run the same application code.

0 Kudos
2,196 Views
kef2
Senior Contributor IV

I think by now you should worry about invalid ERPART value of 0x10. Perhaps with right ERPART value of <=8 you won't ever see this problem again?

And yes, you can't recover failed EEE without BDM mode. Using DFLASH directly without EEE layer could be another choice for you.

Regards

Edward

0 Kudos
2,196 Views
RadekS
NXP Employee
NXP Employee

Hi Edward,

S12XET256 have 32kB D-Flash and 4kB buffer RAM, ERPART=16 and DFPART=0 should be OK.

Alex,

Few notes:

  1. You have to enable EEPROM (command 0x13 - Enable EEPROM Emulation) after every MCU reset.
  2. Yes, Flash IFR must be erased prior partitioning. Flash IFR could be erased only by mass erase command. As simplest way for erase flash IFR, please use unsecure command file - In Code Warior debugger menu ->MultilinkCyclonePro->Unsecure…
  3. You have to set FCLKDIV prior executing first flash command. So, after reset, you have to set FCLKDIV and execute Enable EEPROM Emulation command for activate storing into D-Flash.
  4. Prior we shut down MCU or disable EEE, we could wait for finish all pending EEEPROM tasks. We could use command like: while((ETAG > 0) || (FSTAT_MGBUSY == 1)); //we can wait for EEE to finish
  5. We have to avoid situation where (full) partition command is interrupted e.g by MCU reset. In that case, part of D-Flash may stay unformatted and EEEPROM will stop work after some time.

So, we should check whether (full) partition command was finished without interruption by some followed action (write flag to P-Flash, signalize to final test environment,…). Other option is check last sector header at address 0x107F00. For example:

if(*(unsigned int *far)0x107F00 == 0xFFFF) err = FORMAT_ERROR;

Unfortunately testing DFPART/ERPART is not enough since these values are written before D-Flash format.

In attachment you could find simple S12XE EEEPROM description and two simple example codes.


I hope it helps you.

Have a great day,
RadekS

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
2,196 Views
alexzhu
Contributor II

Hi Radek ,

Thank you very much!

Perhapes as you  indicate that  patition command is interrupted and cause the problem ,though eeprom normal at beginning,but exist risk of breakdown. I also think that the most  possibility of my problem is caused by unexpected mcu reset.once i make  a few test that during pending  eeprom datas force turn off the power,I can not see the same phenomenon,even i analyze maybe defect with my hardware ,In fact,no have external signals in FTM,so i do'nt know how to analyze it.

My purpose is that avoid the same problem occur again, prior ,i plan to find a method to repatition DFLASH and recover the eeprom, by sure the eeprom become error. but the application -level command(0x20) must be in the case that use the erase all bocks command(0x08 and available in special modes).

Of course,i should make lots of effors to improve my codes and try to see whether occur the same problem using the improved codes.

Alex.

0 Kudos
2,197 Views
RadekS
NXP Employee
NXP Employee

Hi alex,

I could simply help you in case of partition command unexpected interrupt simulations.

I already created example code some time ago. Please look at attachment.

You could simply play with Start_interval() parameter and try simulate similar issue as in your case.

In root of project you could find examples of OK and NOK memory contents.

For recovery, please unsecure MCU and load code again, after that you could execute partition command once again.


I hope it helps you.

Have a great day,
RadekS

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

2,196 Views
alexzhu
Contributor II

Hi Radek,

Sorry! Due to we are not belong to the same time zone,so i could not replay you fast. In fact,you have answered my question .I also need some time to check  it out. so i will follow your suggestion that avoid patition be interrupted,and i will follow Edward's suggestion that make the ERPART small,I plan to use DFLASH directly and back up my important parameters to PFLASH.

Thank you(and Edward) very much!

Have a great day!

Alex

0 Kudos
2,196 Views
RadekS
NXP Employee
NXP Employee

Hi alex,

According your colleague’s thread (https://community.freescale.com/thread/380574), re-partitioning didn’t help. So, problem will be probably somewhere else.


I hope it helps you.

Have a great day,
RadekS

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
2,196 Views
kef2
Senior Contributor IV

Sorry, those multipart datasheets are sometimes misleading, I was looking into S12XD128 chapter. But still ERPART should be kept as small as possible, matching required minimum of EEE size.

Regards,

Edward

0 Kudos
2,196 Views
RadekS
NXP Employee
NXP Employee

Ed, no more coffee for today.

S12XD128 chapter in S12XE datasheet. ;-)

Anyway, your cooperation is really appreciated. Thank you very much.

Radek

0 Kudos