Not Able to partition for MK40DX256VLQ10

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

Not Able to partition for MK40DX256VLQ10

815 Views
see
Contributor II

I am facing problem with partition before programing on MCU, a flash program is used to mass erase the mcu.

emulator used: PE universal multilink

below are my codes.

 

#define LONGWORD_COUNTER_ADDR 0x14000000

 

#define WORD_COUNTER_ADDR 0x14000004

 

#define BYTE_COUNTER_ADDR 0x14000006

 

      

 

 

#define EEPROM_16_16 0x39     // subsystem A = 16 bytes, subsystem B = 16 bytes #define DFLASH_SIZE_128 0x05

 

      

 

          /* Partition the memory to enable FlexMem mode *   

 

        if ( partition_flash( EEPROM_16_16, DFLASH_SIZE_128) )

 

           {

 

               /* Device has been partitioned for the first time, so this

 

                * means the counters have not been initialized yet. We'll

 

                * zero them out now.

 

                */

 

              //printf("\nVariables on FlexRAM are initialized to 0x11111111, 0x2222, and 0x33!\n");

 

*((uint32 *)(LONGWORD_COUNTER_ADDR)) = 0x11111111;

 

               /* Wait for the command to complete */

 

               while(!(FTFL_FCNFG & FTFL_FCNFG_EEERDY_MASK));

 

 

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

 

 

               /* Wait for the command to complete */

 

               while(!(FTFL_FCNFG & FTFL_FCNFG_EEERDY_MASK));

 

 

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

 

 

               /* Wait for the command to complete */

 

               while(!(FTFL_FCNFG & FTFL_FCNFG_EEERDY_MASK));    

 

           }

 

           else

 

           {

 

              //printf("\nDevice already partitioned\n");

 

              /* Change the value of BYTE variable to 0x88 */

 

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

 

              /* Wait for the command to complete */

 

              while(!(FTFL_FCNFG & FTFL_FCNFG_EEERDY_MASK));  

 

}

 

                                 

 

              /* Read the variables from FlexRAM */

 

 

int RAMFUNC  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 */

 

 

           /* clear RDCOLERR & ACCERR & FPVIOL flag in flash status register */

 

           FTFL_FSTAT = (0x40|0x20|0x10);

 

FTFL_FCCOB0 = 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;

 

}

 

 

 

At Linker file

 

 

 

/* Specify the memory areas */

 

MEMORY

 

{

 

m_interrupts       (rx) : ORIGIN = 0x00000000, LENGTH = 0x1E0      /* Loo: rx--> r: read  x : execute */

 

m_cfmprotrom       (rx) : ORIGIN = 0x00000400, LENGTH = 0x10

 

m_text             (rx) : ORIGIN = 0x00000800, LENGTH = 256K - 0x800

 

m_data         (rwx) : ORIGIN = 0x1FFF8000, LENGTH = 32K                  /*  Lower SRAM r: read, w:write, x: execute  */

 

m_data2        (rwx) : ORIGIN = 0x20000000, LENGTH = 32K                  /* Upper SRAM */

 

}

 

 

/* Define output sections */

 

SECTIONS

 

{

 

.data : AT(___ROM_AT) /*contents of .data is going to be placed in the flash address pointed by _ROM_AT*/

 

{

 

. = ALIGN(4);

 

_sdata = .;        /* create a global symbol at data start */

 

*(.data)           /* .data sections */

 

*(.data*)          /* .data* sections */

 

       *(.ramsection) /* here your ramsection will be located */

 

. = ALIGN(4);

 

*(.relocate_code)

 

       . = ALIGN(4);

 

_edata = .;        /* define a global symbol at data end */

 

 

 

} > m_data  /* The content of this .data is going to be placed in memory segment m_data or Lower RAM */

 

}

 

 

Tags (2)
0 Kudos
4 Replies

564 Views
see
Contributor II

additional information:

 

SIM_FCFG1 always show 0xff020e00 upon run debug

 

FTFL_FCNG = 0x02, FTFL_FSTAT = 0x80 and EEERDY bit never set

 

0 Kudos

564 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

I would recommend customer to download Kinetis Flash driver software from below link, which includes FlexNVM partition example demo (demo_normal).

C90TFS_FLASH_DRIVER(TFS Flash Driver Software for Kinetis and ColdFire+ Microcontrollers):

http://cache.freescale.com/files/32bit/software/C90TFS_FLASH_DRIVER.exe


Wish it help.

best regards,
Ma Hui

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

564 Views
see
Contributor II

I  manage to solve the problem by migrating the project from CW10.4 to CW 10.6. thanks

0 Kudos

564 Views
Wlodek_D_
Senior Contributor II

Hello,

Thank you for your post, however please consider moving it to the right community place (e.g. CodeWarrior Development Tools or Kinetis Microcontrollers ) to get it visible for active members.

For details please see general advice Where to post a Discussion?

Thank you for using Freescale Community. 

0 Kudos