How to use K60 internal NOR flash memory as data memory?

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

How to use K60 internal NOR flash memory as data memory?

1,849 Views
lisa_tx
Contributor III

Hello,

I use twrk60f120m tower board as development board currently. My product PCB board will use MK60FX512 processor. My PCB board doesn't have any external memory. My application needs to store some data to non-volatile memory. Whenever PCB is powered up, the application program will copy this data from non-volatile memory to RAM. This data can be updated by user through network or serial port. It doesn't need to be in file system. So ROM is not good for this purpose, while internal NOR flash memory is good. My application doesn't need entire internal NOR flash memory space. I think the top of internal NOR flash memory maybe configured as RW data segment. How to modify LCF file to do this?

Thank you!

Lisa

Labels (1)
0 Kudos
6 Replies

1,076 Views
mjbcswitzerland
Specialist V

Lisa

If you use API calls from code to read and write flash you don't need to modify any LCF settings. In fact the LCF settings won't have any effect on the operation that the application performs.

See the following for an implementation of the functions that you need: http://www.utasker.com/docs/uTasker/uTaskerFileSystem_3.PDF

Regards

Mark

1,076 Views
lisa_tx
Contributor III

Hi Mark,

Thank you!

I know that my code will not use entire internal NOR flash memory. I could just access the top of internal NOR flash memory without modifying LCF. But, to prevent the program data exceed data space without realizing it, I could reduce program data size and leave the top of internal NOR flash memory undefined. That way I will make sure the program size will not exceed the boundary, otherwise it will give me an error when I build the code.

0 Kudos

1,076 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi Lisa,

For you will using MK60FX512 chip in your design, MK60FX512 chip with FlexNVM memory, which could provides eeprom function during the application. You can storage the product parameter into EEPROM memory.

More detailed info, you could check with MK60FX512 reference manual chapter Flash memory module:

http://cache.freescale.com/files/microcontrollers/doc/ref_manual/K60P144M150SF3RM.pdf

About MK60FX512 eeprom operation related code, customer could check Kinetis Flash driver software below:

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

Wish it helps.

Best regards,

Ma Hui

0 Kudos

1,076 Views
lisa_tx
Contributor III

Hi Ma Hui,

Thank you for help!

I have to use a processor without FlexNVM for quite long time. For now, I need to divide internal NOR flash to program space and data space. I only need two 4 KB data space. They should not be in same sector. EEPROM seems not an option for me since my application will change data space content at run time. For now I have to limit my program and data space to be within 512 KB NOR flash. There is a post in another thread mentioned that FLASHX_FILE_BLOCK may need to be modified. The post is at: Re: Which flash regions can I access with flashx?

The current MQX FLASHX_FILE_BLOCK is defined as (I use TWRK60F120M demo, I will move to our PCB which has a K60 with 512 KB internal NOR flash):

const FLASHX_FILE_BLOCK _bsp_flashx_file_blocks[] = {

    { "bank0", BSP_INTERNAL_FLASH_BASE                                    , BSP_INTERNAL_FLASH_BASE + 1 * (BSP_INTERNAL_FLASH_SIZE / 4) - 1 },

    { "bank1", BSP_INTERNAL_FLASH_BASE + 1 * (BSP_INTERNAL_FLASH_SIZE / 4), BSP_INTERNAL_FLASH_BASE + 2 * (BSP_INTERNAL_FLASH_SIZE / 4) - 1 },

    { "bank2", BSP_INTERNAL_FLASH_BASE + 2 * (BSP_INTERNAL_FLASH_SIZE / 4), BSP_INTERNAL_FLASH_BASE + 3 * (BSP_INTERNAL_FLASH_SIZE / 4) - 1 },

    { "bank3", BSP_INTERNAL_FLASH_BASE + 3 * (BSP_INTERNAL_FLASH_SIZE / 4), BSP_INTERNAL_FLASH_BASE + 4 * (BSP_INTERNAL_FLASH_SIZE / 4) - 1 },

    { ""     , (uint_32) __FLASHX_START_ADDR, (uint_32) __FLASHX_END_ADDR },

    { NULL   ,                             0,                           0 }

};

I don't need bank2 and bank3, I can keep current bank0, but divide bank1 into bank1a, bank1b and bank1c. The bank1a will start at same address as before, but it will end its boundary 0x2000 earlier. bank1b and bank1c will occupy the last 0x2000 space, each of them has 0x1000 space:

const FLASHX_FILE_BLOCK _bsp_flashx_file_blocks[] = {

    { "bank0", BSP_INTERNAL_FLASH_BASE                                    , BSP_INTERNAL_FLASH_BASE + 1 * (BSP_INTERNAL_FLASH_SIZE / 4) - 1 },

    { "bank1a", BSP_INTERNAL_FLASH_BASE + 1 * (BSP_INTERNAL_FLASH_SIZE / 4), BSP_INTERNAL_FLASH_BASE + 2 * (BSP_INTERNAL_FLASH_SIZE / 4) -  0x2000 - 1 },

    { "bank1b", BSP_INTERNAL_FLASH_BASE + 2 * (BSP_INTERNAL_FLASH_SIZE / 4) - 0x2000, BSP_INTERNAL_FLASH_BASE + 2 * (BSP_INTERNAL_FLASH_SIZE / 4) - 0x1000 - 1 },

    { "bank1c", BSP_INTERNAL_FLASH_BASE + 2 * (BSP_INTERNAL_FLASH_SIZE / 4) - 0x1000, BSP_INTERNAL_FLASH_BASE + 2 * (BSP_INTERNAL_FLASH_SIZE / 4) - 1 },

    { "bank2", BSP_INTERNAL_FLASH_BASE + 2 * (BSP_INTERNAL_FLASH_SIZE / 4), BSP_INTERNAL_FLASH_BASE + 3 * (BSP_INTERNAL_FLASH_SIZE / 4) - 1 },

    { "bank3", BSP_INTERNAL_FLASH_BASE + 3 * (BSP_INTERNAL_FLASH_SIZE / 4), BSP_INTERNAL_FLASH_BASE + 4 * (BSP_INTERNAL_FLASH_SIZE / 4) - 1 },

    { ""     , (uint_32) __FLASHX_START_ADDR, (uint_32) __FLASHX_END_ADDR },

    { NULL   ,                             0,                           0 }

};

Do you think above definition will work?

I have also studied flash_demo.c. I believe the following #define is generated when the project is created:

#if (BSP_M51EMDEMO || BSP_TWRMCF51MM || BSP_TWRMCF51JE)

    #if !BSPCFG_ENABLE_FLASHX2

    #error This application requires BSPCFG_ENABLE_FLASHX1 defined non-zero in user_config.h. Please recompile BSP with this option.

    #endif

    #define         FLASH_NAME "flashx2:bank1"

#elif BSP_M54455EVB

    #if !BSPCFG_ENABLE_FLASHX0

    #error This application requires BSPCFG_ENABLE_FLASHX0 defined non-zero in user_config.h. Please recompile BSP with this option.

    #endif

    #define         FLASH_NAME "flashx0:bank0"

#else

    #if !BSPCFG_ENABLE_FLASHX

    #error This application requires BSPCFG_ENABLE_FLASHX defined non-zero in user_config.h. Please recompile BSP with this option.

    #endif

    #define         FLASH_NAME "flashx:bank0"

#endif

How to create a project with above #define? Could I do my own #define?

Thank you!

Lisa

0 Kudos

1,076 Views
lisa_tx
Contributor III

OK, I think that I have figured out how to do it. I don't need to modify init_flashx.c. I only need to reduce program space in LCF file and leave data space undefined. I can use default bank definition in init_flashx.c file. I can set address to the sector of flash memory bank to access (read or write). Thanks!

0 Kudos

1,076 Views
mjbcswitzerland
Specialist V

Lisa

Yes, that is a good strategy.

regards

Mark

0 Kudos