S12XE D-flash really to be erased to run Partition D-flash command?

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

S12XE D-flash really to be erased to run Partition D-flash command?

Jump to solution
1,266 Views
mroczeks
Contributor IV

Hi,

 

I am designing migration process for S12XE based application. 

The old one is storing data directly into D-Flash. 

The new one is to be using EEEPROM.

 

We have a CAN bootloader to update firmware.

 

Freescale application notes AN3490 and AN3743 together with reference manual say D-Flash is required to be fully erased before performing Partition D-Flash command.

 

As there is only 4k RAM it may be difficult to backup all D-Flash data (> 4k) for the time of partitioning process (and to risky due to volatile nature of RAM). Copying that data into P-Flash is not a best option for us neither...

 

So I did some tests and found no problems partitioning non-erased D-Flash with Partition D-Flash command.

New application was uploaded into S12XE in place of the old one and did partitioning on its first run.

No error flags had been set, the process seemed to be succesfull, old data was left unchanged.

All D-Flash data is stored outside EEE NVM region of D-Flash so it is safe in this aspect.

 

I was not able to find explanaitions why D-Flash is to be in fully erased state before Partitioning...

The EEEPROM seems to be a very elegant solution overally and I would really make sure I am safe partitioning D-Flash without erasing it first. I can erase EEE NVM region if it is required but it would be great to leave the rest of D-Flash part untouched.

 

Any comments?

Why D-Flash to be erased before partitioning?

Am I safe othervise?

 

Regards,

Szymon

Labels (1)
0 Kudos
1 Solution
635 Views
mroczeks
Contributor IV

OK, solved it.

Had to resolve Processor Expert issue (read below) and lack of clarity of reference manual and both AN3490 and AN3743 application notes, arrgh!

 

Indeed D-Flash has to be fully erased before performing Partition D-Flash command (Flash Module Command 0x20).

I erase each sector of D-Flash with Erase D-Flash Sector (0x12) command to meet this requirement.

Otherwise procedure will not complete succesfully. Here's what AN3490 page 15 says "If the D-flash block is  not fully erased it will generate an ACCERR flag.

 

One of the problems was that I generated EEE code with "help" of Processor Expert.

What PE did it generated a Full Partition D-Flash command (Flash Module Command 0x0F):

 

  if(!IsPartitioned) {                 /* Need to be partitioned ? */    FSTAT = 48U;                       /* Clear error flags */    FCCOBIX = 0U;                      /* Clear index register */    FCCOBHI = 15U;                     /* Partition D-Flash command */    FCCOBIX++;                         /* Index the DFPART info */    FCCOB = 22U;                       /* Write DFPART */    FCCOBIX++;                         /* Index the DFPART info */    FCCOB = 1U;                        /* Write ERPART */    FSTAT = 128U;                      /* Clear flag command complete */    if (FSTAT_ACCERR) {                /* Is access error detected ? */      return ERR_NOTAVAIL;             /* If yes then error */    }    while (!FSTAT_CCIF) {              /* Wait to command complete */    }  }

The line FCCOBHI = 15U; /* Partition D-Flash command */ is Full Partition D-Flash (0x0F == 15). 

If you perform Full Partition D-Flash command from application level it will only work in special modes (reference manual page 927). 

Here's what AN3490 page 15 says "5.1 Full Partition D-Flash. This is not an application level command. It is only available in special modes and should be run during initial device programming."

Therefore this command is not apropriate for application level usage, i.e. when you want to use it with a bootloader.

 

If you try to use it from an application level anyway you will not be able to use EEE until you do hardware reset with programming interface (i.e. PE Micro USB Multilink under Hiwave). Switching off and on power supply won't help at all. Reseting programmatically neither.

 

Moreover you will not get error code returned from PE's Partition function. The way Processor Expert created Partition function code is not allowing to detect the problem easily. This is really misleading because it leaves you with EEE not working and no error returned from Partition function:

    FSTAT = 128U;                      /* Clear flag command complete */    if (FSTAT_ACCERR) {                /* Is access error detected ? */      return ERR_NOTAVAIL;             /* If yes then error */    }    while (!FSTAT_CCIF) {              /* Wait to command complete */    }

It checks for error flag ACCERR right after engaging the command execution. It should in fact first wait for FSTAT_CCIF flag and then check for ACCERR flag. When I corrected this code I was then able to see that there's ACCERR flag being set and something is not OK.

 

Then (and many hours already lost fighting) I decided to have a closer look at rest of PE's code. I discovered it is using Full Partition D-Flash (0x0F) command instead Partition D-Flash command (0x20). After reading all those application notes and reference manual several times I was so sure it is to be using Partition D-Flash command (0x20).

Here's what AN3490 page 15 says: "5.2 Partition D-Flash. This is an application-level command that can execute in normal modes.  It is intended to allow serial bootloaders and applications to configure the EEE once."

 

Have no idea why PE is using Full Partition D-Flash command and why it checks for error flags before waiting for command to complete. 

 

Removed PE's code and wrote my own which is doing Partition D-Flash command (0x20) and checks for errors after waiting for command complete flag. Works OK :smileyhappy:

View solution in original post

0 Kudos
5 Replies
636 Views
mroczeks
Contributor IV

OK, solved it.

Had to resolve Processor Expert issue (read below) and lack of clarity of reference manual and both AN3490 and AN3743 application notes, arrgh!

 

Indeed D-Flash has to be fully erased before performing Partition D-Flash command (Flash Module Command 0x20).

I erase each sector of D-Flash with Erase D-Flash Sector (0x12) command to meet this requirement.

Otherwise procedure will not complete succesfully. Here's what AN3490 page 15 says "If the D-flash block is  not fully erased it will generate an ACCERR flag.

 

One of the problems was that I generated EEE code with "help" of Processor Expert.

What PE did it generated a Full Partition D-Flash command (Flash Module Command 0x0F):

 

  if(!IsPartitioned) {                 /* Need to be partitioned ? */    FSTAT = 48U;                       /* Clear error flags */    FCCOBIX = 0U;                      /* Clear index register */    FCCOBHI = 15U;                     /* Partition D-Flash command */    FCCOBIX++;                         /* Index the DFPART info */    FCCOB = 22U;                       /* Write DFPART */    FCCOBIX++;                         /* Index the DFPART info */    FCCOB = 1U;                        /* Write ERPART */    FSTAT = 128U;                      /* Clear flag command complete */    if (FSTAT_ACCERR) {                /* Is access error detected ? */      return ERR_NOTAVAIL;             /* If yes then error */    }    while (!FSTAT_CCIF) {              /* Wait to command complete */    }  }

The line FCCOBHI = 15U; /* Partition D-Flash command */ is Full Partition D-Flash (0x0F == 15). 

If you perform Full Partition D-Flash command from application level it will only work in special modes (reference manual page 927). 

Here's what AN3490 page 15 says "5.1 Full Partition D-Flash. This is not an application level command. It is only available in special modes and should be run during initial device programming."

Therefore this command is not apropriate for application level usage, i.e. when you want to use it with a bootloader.

 

If you try to use it from an application level anyway you will not be able to use EEE until you do hardware reset with programming interface (i.e. PE Micro USB Multilink under Hiwave). Switching off and on power supply won't help at all. Reseting programmatically neither.

 

Moreover you will not get error code returned from PE's Partition function. The way Processor Expert created Partition function code is not allowing to detect the problem easily. This is really misleading because it leaves you with EEE not working and no error returned from Partition function:

    FSTAT = 128U;                      /* Clear flag command complete */    if (FSTAT_ACCERR) {                /* Is access error detected ? */      return ERR_NOTAVAIL;             /* If yes then error */    }    while (!FSTAT_CCIF) {              /* Wait to command complete */    }

It checks for error flag ACCERR right after engaging the command execution. It should in fact first wait for FSTAT_CCIF flag and then check for ACCERR flag. When I corrected this code I was then able to see that there's ACCERR flag being set and something is not OK.

 

Then (and many hours already lost fighting) I decided to have a closer look at rest of PE's code. I discovered it is using Full Partition D-Flash (0x0F) command instead Partition D-Flash command (0x20). After reading all those application notes and reference manual several times I was so sure it is to be using Partition D-Flash command (0x20).

Here's what AN3490 page 15 says: "5.2 Partition D-Flash. This is an application-level command that can execute in normal modes.  It is intended to allow serial bootloaders and applications to configure the EEE once."

 

Have no idea why PE is using Full Partition D-Flash command and why it checks for error flags before waiting for command to complete. 

 

Removed PE's code and wrote my own which is doing Partition D-Flash command (0x20) and checks for errors after waiting for command complete flag. Works OK :smileyhappy:

0 Kudos
635 Views
mroczeks
Contributor IV

OK, I got in touch with the support and the Processor Expert team agreed this issue.

The problem will be fixed in next version of PE. 

No one responded to this topic.

Has no one before reported faced simillar problems?

Seems like nobody's been using PE's emulated eeprom code... ?

Strange, the EEE is a really nice feature on S12XE...

0 Kudos
635 Views
kef
Specialist I

EEE's nice, but you aren't forced to use PE, are you?

0 Kudos
635 Views
mroczeks
Contributor IV

No, and that's what I thought :smileywink:

0 Kudos
635 Views
ProcessorExpert
Senior Contributor III

Hello,

 

we will improve the "Partition" method of the IntEEPROM component by the following way for next release of PEx for HCS12 family:

 

1 - we will improve the order of code that handles error evaluation. 

2 - we will add new property to select partition command that will be used (0x0F or 0x20) in the method

3 - we will improve the documentaiton of the Partiotion method

 

best regards
Vojtech Filip
Processor Expert Support Team

0 Kudos