How to Re-partition FlexNVM from FlexRAM to EEPROM

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

How to Re-partition FlexNVM from FlexRAM to EEPROM

832 Views
jcress
Contributor I

I have an MK60 that I need to change its FlexNVM partitioning from FlexRAM to EEPROM.

The Program Partition command (0x80) fails with FSTAT[ACCERR] because the EEPROM data size and FlexNVM partition code bytes are not initially 0xFFFF. What can I do to get them both to 0xFFFF? I tried bulk erase, but that did not work.

0 Kudos
5 Replies

815 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi jcress,

  If your chip is already partitioned, then you need to do the mass erase at first.

  About the mass erase, you can use the external debugger to finish it. I don't know what's the IDE you are using, the IDE also have the mass erase item when you download the code.

  You also can use the JLINK debugger with JLINK commander: unlock kinetis

   After you do the mass erase, I think you should can finish the partition.

   Please try it on your side.

Please note, when you do the partition, you need to disable the interrupt, and flash operation commander need to put in the RAM.

 

Wish it helps you!

If you still have questions about it, please kindly let me know!

Best Regards,

Kerry

-------------------------------------------------------------------------------

Note:

- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored

Please open a new thread and refer to the closed one, if you have a related question at a later point in time.

-----------------------------------------------------------------------------

0 Kudos

804 Views
jcress
Contributor I

Hi Kerry and thanks for the reply.

First the IDE I'm using is CodeWarrior 11.0.1.

You said to do a mass erase. Mass erase what? I've already tried mass erasing FTFE_PFLASH starting at address 0x00000000 and FTFE_DFLASH starting at address 0x14000000. This had no affect - I cannot re-partition to EEPROM.

Thanks,
Jim

0 Kudos

794 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi jcress,

 What's the debugger you are using with the CW?

  Mass erase, means erase all the kinetis flash memory, then you can do the FlexNVM partition again.

  In the CW, different debugger has the different the mass erase windows, so please tell me which debugger you are using at first?

  Normally, you can find it in the debug configuration in your CW,  the item will be erase all, you can check that item before you downlod the code, then download the code again, the first  time, you should can do the partition successfully.

 

Wish it helps you!

Best Regards,

Kerry

0 Kudos

772 Views
jcress
Contributor I

Mass erase did NOT work. I do not have a solution.

0 Kudos

766 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi jcress,

   What's the detail operation steps on your K60?

   Please also let me know your detail K60 partnumber.

   1. Do the mass erase

        You even can use the JLINK commander: unlock kinetis

        to finish the mass erase function.

  2. Do the partition checking like this code

    

int partition_flash(int eeprom_size, int dflash_size)
{
/* Test to make sure the device is not already partitioned. If it
* is already partitioned, then return with no action performed.
*/
if ((SIM_FCFG1 & SIM_FCFG1_DEPART(0xF)) != 0x00000F00)
{
printf("\nDevice is already partitioned.\n");
return 0;
}

/* Write the FCCOB registers */
FTFL_FCCOB0 = FTFL_FCCOB0_CCOBn(0x80); // Selects the PGMPART command
FTFL_FCCOB1 = 0x00;
FTFL_FCCOB2 = 0x00;
FTFL_FCCOB3 = 0x00;

/* FCCOB4 is written with the code for the subsystem sizes (eeprom_size define) */
FTFL_FCCOB4 = eeprom_size;

/* FFCOB5 is written with the code for the Dflash size (dflash_size define) */
FTFL_FCCOB5 = dflash_size;


/* All required FCCOBx registers are written, so launch the command */
FTFL_FSTAT = FTFL_FSTAT_CCIF_MASK;

/* Wait for the command to complete */
while(!(FTFL_FSTAT & FTFL_FSTAT_CCIF_MASK));

return 1;
}

 Please note, you need to give the correct eeprom_size and dflash_size for K60 chip.

Main code can like this:

int main (void)
{
char ch;
uint32 temp=0;
#ifdef KEIL
start();
#endif
printf("\nRunning the hello_world project in K2050MHz family\n");

SCB_SHCSR|=SCB_SHCSR_BUSFAULTENA_MASK|SCB_SHCSR_MEMFAULTENA_MASK|SCB_SHCSR_USGFAULTENA_MASK;
printf("\nRunning FlexMem demo!!\n");
/* Partition the memory to enable FlexMem mode */
if ( partition_flash( 0X33, 0X03) )//0X03
{
/* Device has been partitioned for the first time, so this
* means the counters have not been initialized yet. We'll
* zero them out now.
*/
*((uint32 *)(LONGWORD_COUNTER_ADDR)) = 0x0;

/* Wait for the command to complete */
while(!(FTFL_FCNFG & FTFL_FCNFG_EEERDY_MASK));

*((uint16 *)(WORD_COUNTER_ADDR)) = 0x0;

/* Wait for the command to complete */
while(!(FTFL_FCNFG & FTFL_FCNFG_EEERDY_MASK));

*((uint8 *)(BYTE_COUNTER_ADDR)) = 0x0;

/* Wait for the command to complete */
while(!(FTFL_FCNFG & FTFL_FCNFG_EEERDY_MASK));
}


//Write eeprom
*((uint32 *)(LONGWORD_COUNTER_ADDR)) = 0x0;

/* Wait for the command to complete */
while(!(FTFL_FCNFG & FTFL_FCNFG_EEERDY_MASK));

*((uint16 *)(WORD_COUNTER_ADDR)) = 0x0;

/* Wait for the command to complete */
while(!(FTFL_FCNFG & FTFL_FCNFG_EEERDY_MASK));

*((uint8 *)(BYTE_COUNTER_ADDR)) = 0x0;

/* Wait for the command to complete */
while(!(FTFL_FCNFG & FTFL_FCNFG_EEERDY_MASK));
printf("\nlongword counter = 0x%08X", *(uint32 *)(LONGWORD_COUNTER_ADDR));
printf("\nword counter = 0x%04X", *(uint16 *)(WORD_COUNTER_ADDR));
printf("\nbyte counter = 0x%02X", *(uint8 *)(BYTE_COUNTER_ADDR));
////////////////////////
/* Make sure the EEE is ready. If not wait for the command to complete */
while(!(FTFL_FCNFG & FTFL_FCNFG_EEERDY_MASK));

temp = *((uint32 *)(LONGWORD_COUNTER_ADDR));
*((uint32 *)(LONGWORD_COUNTER_ADDR)) = (uint32) temp + 1;

/* Make sure the EEE is ready. If not wait for the command to complete */
while(!(FTFL_FCNFG & FTFL_FCNFG_EEERDY_MASK));

temp = *((uint16 *)(WORD_COUNTER_ADDR));
*((uint16 *)(WORD_COUNTER_ADDR)) = (uint16) temp + 1;

/* Make sure the EEE is ready. If not wait for the command to complete */
while(!(FTFL_FCNFG & FTFL_FCNFG_EEERDY_MASK));

temp = *((uint8 *)(BYTE_COUNTER_ADDR));
*((uint8 *)(BYTE_COUNTER_ADDR)) = (uint8) temp + 1;

/* Make sure the EEE is ready. If not wait for the command to complete */
while(!(FTFL_FCNFG & FTFL_FCNFG_EEERDY_MASK));

/* Display the initial counter values */
printf("\nlongword counter = 0x%08X", *(uint32 *)(LONGWORD_COUNTER_ADDR));
printf("\nword counter = 0x%04X", *(uint16 *)(WORD_COUNTER_ADDR));
printf("\nbyte counter = 0x%02X", *(uint8 *)(BYTE_COUNTER_ADDR));

printf("\nRunning FlexMem demo!!end\n");
while(1)
{
ch = getchar();
putchar(ch);
}
}

 

Although the code which I give you is the K20, but your K60 also can refer to it, just need to give the correct configuration.

 

Please try it again.

If you still have questions about it, please kindly let me know.

Best Regards,

Kerry

 

0 Kudos