Return ERR_FAILED when calling Cpu_SetFlexNVMPartition() using KDS, PE and K10

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

Return ERR_FAILED when calling Cpu_SetFlexNVMPartition() using KDS, PE and K10

2,227 Views
matherinewang
Contributor III

I am using PE with KDS 3.0.0 with MK10DX128VLF5 processor and i am trying to get the FlexNVM to work but having problem with the partition.

i've setup the memory organization as per the attached screenshot.

pastedImage_0.png

when i call the Cpu_SetFlexNVMPartition(), it returned ERR_FAILED, because FSTAT register value is 0xa0. why failed? Thank you.

Labels (1)
0 Kudos
7 Replies

1,197 Views
arthurjonathan
Contributor I

Hello,

I'm using MK20DX256VLL7 controller. I am trying to use FlexNVM as mentioned above. But I  am not able to partition using the Cpu_SetFlexNVMPartition() method. Everytime it fails. 

My EEPROM Data Set Size is 512 bytes, D Flash 24 KB and EEPROM Backup size is 8KB. So I am passing FTFL_PDD_Cmd_ProgramPartition_Init(FTFL_BASE_PTR, 0x30 | FTFL_PDD_EEPROM_DATA_SIZE_512_B, FTFL_PDD_EEPROM_BACKUP_SIZE_8_KB) into my code (0x35) instead of (0x25) as mentioned by MarekNeuzil‌.

Can anyone please suggest what am i missing?

Thanks in advance!

0 Kudos

1,197 Views
marek_neuzil
NXP Employee
NXP Employee

Hello,

I don't know the details of your application but the issue can be caused by existing partition code that is programmed on your device. The partition code can be erased by the Erase All Blocks Command only, see the detailed description in the Program Partition Code chapter in the MK10DX128 reference manual. You can also configure the debugger to execute this erase operation. For example the PEMicro debugger provides "Mass Erase on connect" options or you can use the J-link Commander to execute the mass erase operation and programming of the device.

You can also use the following code (main.c program module) to check the state of your device in your application. The code use the Cpu_GetFlexNVMPartitionCode() method to check the current state of the device (partition code in data flash IFR).

/* User includes (#include below this line is not maintained by Processor Expert) */

#include "FTFL_PDD.h"

/*lint -save  -e970 Disable MISRA rule (6.3) checking. */

int main(void)

/*lint -restore Enable MISRA rule (6.3) checking. */

{

  /* Write your local variable definition here */

  uint16_t PartitionCode;

  /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/

  PE_low_level_init();

  /*** End of Processor Expert internal initialization.                    ***/

  PartitionCode = Cpu_GetFlexNVMPartitionCode();

  switch (PartitionCode) {

    case FLEX_NVM_NOT_PARTITIONED:

      printf("FlexNVM has not been partitioned yet.\n");

      printf("SetFlashNVMPartition() method will be called.\n");

      if (Cpu_SetFlexNVMPartition() != ERR_OK) {

        printf("ERROR: SetFlexNVMPartition() failed.\n");

      } else {

        printf("SetFlexNVMPartition() done\n");

        while(!FTFL_PDD_GetEEEReady(FTFL_BASE_PTR));

        PartitionCode = Cpu_GetFlexNVMPartitionCode();

      }

    break;

    case FLEX_NVM_REQUESTED_PARTITION_CODE:

      printf("FlexNVM has been already partitioned. Current partition settings:\n");

      printf("  EEPROM Data Set Size  0x%02x\r\n", (PartitionCode >> 8) & 0x3F);

      printf("  FlexNVM Partition Code 0x%02x\r\n", PartitionCode & 0x0F);

      while(!FTFL_PDD_GetEEEReady(FTFL_BASE_PTR));

    break;

    default:

      printf("FlexNVM has been already partitioned but different partition settings has been detected. Current partition settings:\n");

      printf("    EEPROM Data Set Size  0x%02x\r\n", (PartitionCode >> 8) & 0x3F);

      printf("    FlexNVM Partition Code 0x%02x\r\n", PartitionCode & 0x0F);

      printf("  Expected partition settings:\n");

      printf("    EEPROM Data Set Size  0x%02x\r\n", (FLEX_NVM_REQUESTED_PARTITION_CODE >> 8) & 0x3F);

      printf("    FlexNVM Partition Code 0x%02x\r\n", FLEX_NVM_REQUESTED_PARTITION_CODE & 0x0F);

  }

  if (PartitionCode == FLEX_NVM_REQUESTED_PARTITION_CODE) {

    *((uint32_t *)0x14000000) += 1;

    printf("Number of MCU resets form last Mass erase:%d\n",*((uint32_t *)0x14000000));

  }

Best Regards,

Marek Neuzil

0 Kudos

1,197 Views
matherinewang
Contributor III
Hi,

i use J-Flash erase the flash first, and then run the application just the same thing as you showed. but still got "SetFlexNVMPartition() failed."

the same reason as previous: when i call the Cpu_SetFlexNVMPartition(), it returned ERR_FAILED, because FSTAT register value is 0xa0.

Best Regards,

matherine

0 Kudos

1,197 Views
marek_neuzil
NXP Employee
NXP Employee

Hello,

What value is returned by the Cpu_GetFlexNVMPartitionCode() method? You must receive FLEX_NVM_NOT_PARTITIONED otherwise the partitioning is not possible.

Please, make sure that the mass erase operation is processed (and the debugger or any tool does not process partitioning). If you just erase flash the previous partitioning is not impacted.

Best Regards,

Marek Neuzil

0 Kudos

1,197 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Marek,

I use the TWR0K20D72M(  k20dx256vll7 ) board, on KDS 3.0 +PE,

use the code you provide , configure the EEPROM size to 1K, the

EEPROM backup size to 16k, the other place as default .

pastedImage_0.png

While when i run the function of

pastedImage_1.png

the register of FTFL_FSTAT->ACCERR is 1:Access error detected .

And when i run the function of    PartitionCode = Cpu_GetFlexNVMPartitionCode(); it return FLEX_NVM_NOT_PARTITIONED .

I use the PE debug mode , and select the "Mass erase on connect":

pastedImage_2.png

Could you help me , this is link to another customer's question : Problem creating prtition for EEPROM in Kinetis MK10DX256VLL7 

Thank you very much !

Alice

0 Kudos

1,197 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello

0 Kudos

1,197 Views
matherinewang
Contributor III

Hi,

First, the function of "SetFlexNVMPartition" have been enabled.

Secondly, i call this function the same as Marek Neuzil's reply. when call the Cpu_SetFlexNVMPartition(), it returned ERR_FAILED.

0 Kudos