AnsweredAssumed Answered

Attempt to partition results in reset

Question asked by Hab Collector on Feb 10, 2014
Latest reply on Mar 22, 2018 by SUDARSHAN KUMAR

Greetings everyone,

 

I am stuck - On a partitioning problem that continually resets.

 

TARGET HARDWARE: MK12DX256VLF5

TOOL: IAR (J-Link Debugger)

 

I use the following code which I got directly from Freescale:

 

main()

{

...

  printf("  Checking For *NV Memory Partition...\r\n");

  if (partition_flash(EEPROM_128_128, DFLASH_SIZE_0)) // passed values are 0x36 and 0x08

    printf("  **New Flex Memory Partition\r\n");

  else

    printf("  >>Device Already Partitioned\r\n");

...

}

 

bool_t partition_flash(uint8_t EEProm_size, uint8_t 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(0x0F)) != 0x00000F00)
    return(FALSE);

  /* 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) == 0x00);
  return(TRUE);
}

 

If the device is blank and I run the partition code it resets (Core Lockup Event) at the execute partiton command (bold line) every time.  If I set a break point at that line (bold line) then run it resets, but if I set a break point (at the bold line) then step one line it works.  the registers before the execution of the command look (I think) as they should...

 

FTFL_FSTAT: 0x80

FTFL_FCNFG: 0x02

FTFL_FSEC: 0xFE

FTFL_FOPT: 0xFF

FTFL_FCCOB0: 0x80

FTFL_FCCOB1: 0x00

FTFL_FCCOB2: 0x00

FTFL_FCCOB3: 0x00

FTFL_FCCOB4: 0x36

FTFL_FCCOB5: 0x08

FTFL_FCCOB6: 0x00

FTFL_FCCOB7: 0x00

FTFL_FCCOB8: 0x00

FTFL_FCCOB9: 0x00

FTFL_FCCOBA: 0x00

FTFL_FCCOBB: 0x00

FTFL_FPROT0: 0xFF

FTFL_FPROT1: 0xFF

FTFL_FPROT2: 0xFF

FTFL_FPROT3: 0xFF

FTFL_FEPROT: 0xFF

FTFL_FDPROT: 0xFF

 

I have also insered delays before the command execution (upto 1s) thinking it was timing related with no change of result.  Thinking it was unique to the J-Link debugger I loaded the code to the target and there it also resets. 

 

Any help on this would be great...

 

Thanks,

Hab

Outcomes