MK10FX512 Setting Partition Info for FLEXNVM

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

MK10FX512 Setting Partition Info for FLEXNVM

1,151 次查看
Ali2006
Contributor II

I"m having problems getting my MK10 to set the Partition information correclty . 

I've created code  that has worked perfectly on a MK70FX512 system and am porting this code to the MK10FX512 system.

I've modified the code slightly to add the EEERST bit to the partition information.  When running this code it actully completes the SetPartitionInfo command with  success = 1, but when it tries to Printf the message that it was sucessful the system prints out part of the message.. and then begins spitting out garbage.  If I put an incorrect value for EEESPLIT the

SetPartitionInfo command does fail with success = 0, and the printf failure message prints as expected. 

#define  EEESIZE_VALUE  0x03        //Size of EEPROM is 2K
#define  EEESPLIT_VALUE 0x00        //Read Only (Always read as a one)
#define  DEPART_VALUE   0x04        // 64K of Backup EEPROM bytes.
#define  EEERST_VALUE   1            //Flex Ram is Loaded with valid data after reset

//*****************This is the code I'm calling when I want to partition the device.  The triggerFCCOBinRAM has been setup appropriately and copied to RAM to run.    This exact code functions perfectly in an MK70FX512 system. 

     // Partition the memory now.
      if (SetPartitionInfo(EEERST_VALUE,EEESIZE_VALUE, EEESPLIT_VALUE, DEPART_VALUE, triggerFCCOBinRAM))
         printf("FlexNVM_Init() Device partitioning successful.\r\n");
      else
         printf("FlexNVM_Init() Device partitioning FAILED.\r\n");

//***********************This is the SetPartitionInfo Subrotine

// Set new partition information.
static boolean SetPartitionInfo(uint8 eeerst, uint8 eeesize, uint8 eeesplit, uint8 depart, TriggerFn_t triggerFn)
{

   // To set a new partition scheme, use the Program Partition command.
   boolean success = false;

   // First step of any command sequence is wait for ready, then clear faults.
   while (!(FTFE_FSTAT & FTFE_FSTAT_CCIF_MASK))
   {
      // Do nothing as long as the CCIF flag is clear.
   }

   // If flash protection violation is set, clear it by writing 1 to the bit
   if (FTFE_FSTAT & FTFE_FSTAT_FPVIOL_MASK)
      FTFE_FSTAT |= FTFE_FSTAT_FPVIOL_MASK;

   // If access error is set, clear it by writing 1 to the bit
   if (FTFE_FSTAT & FTFE_FSTAT_ACCERR_MASK)
      FTFE_FSTAT |= FTFE_FSTAT_ACCERR_MASK;

   // If read collision error is set, clear it by writing 1 to the bit
   if (FTFE_FSTAT & FTFE_FSTAT_RDCOLERR_MASK)
      FTFE_FSTAT |= FTFE_FSTAT_RDCOLERR_MASK;

   // Housekeeping done, set up command structure.
   FTFE_FCCOB0 = PROGRAM_PARTITION_CMD;
   FTFE_FCCOB1 = 0x00;        // Address 23-16 not used
   FTFE_FCCOB2 = 0x00;        // Address 15- 8 not used
   FTFE_FCCOB3 = 0x00;        // Address  7- 0 not used
   FTFE_FCCOB4 = ( ((eeerst & 0x01) << 6) | (eeesplit & 0x03) << 4) | (eeesize & 0x0f);
   FTFE_FCCOB5 = (depart & 0x0f);

   // Trigger the function and wait for it to complete.
   // Trigger/wait code must run from RAM.
   // Don't allow interrupts to run, they could access flash.
   Enter_Critical_Section();   //MACRO that turns off interrupts - Defination below
   triggerFn(&FTFE_FSTAT);
   Leave_Critical_Section();  //MACRO that restores interrupts.  - Defination below

   // Operation is successful if there are no errors.
   success = (!(FTFE_FSTAT & (FTFE_FSTAT_FPVIOL_MASK | FTFE_FSTAT_ACCERR_MASK | FTFE_FSTAT_RDCOLERR_MASK | FTFE_FSTAT_MGSTAT0_MASK)));

   return success;
}

#define Enter_Critical_Section()                                        \
{                                /* Begin local code block           */ \
   static unsigned char saveFAULTMASK;  /* Local storage for FAULTMASK      */ \
   asm(PUSH {R0,R1});            /* Save registers that will be used */ \
   asm(MRS R0, FAULTMASK);       /* Move FAULTMASK to temp regiser   */ \
   asm(CPSID f);                 /* Disable all interrupts but NMI   */ \
   asm(LDA R1, saveFAULTMASK);   /* Get address of local storage     */ \
   asm(STRB R0, [R1]);           /* Save original FAULTMASK value    */ \
   asm(POP {R0,R1});             /* Restore original register values */


#define Leave_Critical_Section()                                        \
    asm(PUSH {R0,R1});           /* Save registers that will be used */ \
    asm(LDA R1, saveFAULTMASK);  /* Get address of local storage     */ \
    asm(LDRB R0, [R1]);          /* Get original FAULTMASK value     */ \
    asm(MSR FAULTMASK,R0;);      /* Restore original FAULTMASK value */ \
    asm(POP {R0,R1});            /* Restore original register values */ \
}                                /* End local code block             */

标签 (1)
0 项奖励
回复
4 回复数

861 次查看
Ali2006
Contributor II

I'll take a look at the code.. I've downloaded it but didn't really see any

files specific to the Mk10FX512.  I am using Codewarrior not IAR.. so I can't use the demo project file you pointed me too.

Can you just point me to some specific code files..

Also. based on my findings, I'm just wondering  is it true then on the MK10FX512 that  since you can't set the EEESPLIT values.. and they are specified as being 11.. Does that mean that the FlexNVM is partitioned into two section each 1/2 the size of the memory?   Or is there just one FlexNVM section in this chip?

pastedImage_2.pngpastedImage_1.png

0 项奖励
回复

861 次查看
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi

Thank you for the patience.

In fact, the below description should be incorrect, the EESPLIT could be 0b00, 0b01 and 0b10.

pastedImage_1.png

So, the Flash command [Program Partition Command] EEPROM Data Set Size Code (FCCOB4) related value, please refer reference manual table Table 30-70. Valid EEPROM Data Set Size Codes:

pastedImage_2.png

The Kinetis document team will fix that document issue.

Sorry for that bring any inconvenience to you.


Wish it helps.

Have a great day,
Ma Hui
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 项奖励
回复

861 次查看
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi

The Flash Driver software also provide project based on CodeWarrior IDE.

Customer could refer the [demo_normal] of MK70FX512xxx12 product, the default path is:

C:\Program Files\Freescale\Standard_Software_Driver_v1.03\C90TFS\Demos\build\MK70FX512xxx12\CW10.4\demo_normal

I will check with Kinetis product team about the EEPROM Data Set Size Field [EEESPLIT] bits description.

I will post the comments, when there with any feedback.


Thank you for the attention.

Have a great day,
Ma Hui
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 项奖励
回复

861 次查看
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi

I would recommend customer to refer TFS Flash Driver software from here.

The project could be found from below folder:

..\Standard_Software_Driver_v1.03\C90TFS\Demos\build\MK53DX256Zxxx10\IAR\demo_normal


Wish it helps.

Have a great day,
Ma Hui
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 项奖励
回复