Read / Write the internal flash memory

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

Read / Write the internal flash memory

2,652 Views
dongshengwang
Contributor I

I am using FRDM-K64F for my project. I need to write / read the internal flash memory to store some parameters at runtime. My development environment is KDS_1.1.1 and MQX_KSDK_1.0.0. I tried the demo project in C:\Freescale\MQX_KSDK_1.0.0\demos\flash_demo. It displayed the following information: No D_Flash (FlexNVM) and Enhanced EEPROM (EEE) on this device. In this situation, can I read / write the internal flash memory?  I need to config the flash? Are there better solution to read / write the internal flash memory? Thank you!

Labels (1)
0 Kudos
2 Replies

957 Views
terry_lv
NXP Employee
NXP Employee

Hi,

     The internal flash can be read like memory access directly, but need a driver and write sequency for write.

For example:

Firstly, define a place in flash to store the data:

/* put the data to the flash */

#pragma location = 0x0001f800

const XXX_configs saved_configs;/* this variable is stored in flash */

Then this parameter can be read directly from flash address 0x0001f800.

Please note that it is better to align the address to flash sector (normally 2K or 4K).

Secondly, use flash write driver to write your parameters to saved_configs.

...

FlashEraseSector(&saved_configs, ...);

FlashProgram(&saved_configs, ...);

...

You can refer to flash_demo under demo for reference.

Thanks!

Best regards

Terry

0 Kudos

957 Views
mjbcswitzerland
Specialist V

Hi

You can use the internal data flash for storing parameters in - FlexNVM is not necessary.

You can see the parameter system from the uTasker project as reference: http://www.utasker.com/docs/uTasker/uTaskerFileSystem_3.PDF,[chapters 7 and 8] which is used on the FRDM-K64F.

Regards

Mark

0 Kudos