Flash driver example: Reading the flash memory

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

Flash driver example: Reading the flash memory

跳至解决方案
1,452 次查看
gauravbanyal
Contributor IV

Hello,

 

I am using FRDM-KL03Z board and experimenting with the SDK 2.0 example \frdmkl03z\driver_examples\flash\pflash.

The example ends at flash write and verification. I would like to read the data written to the flash. I have tried using the function "FLASH_ReadResource" but I always get an error response "kStatus_FLASH_InvalidArgument" from the function "flash_check_resource_range". Moreover there is no mention of "FLASH_ReadResource" in the SDK API documentation.

 

Please let me know how to read out the array written to the flash in this example.

 

An early response will be much help.

标签 (1)
标记 (2)
0 项奖励
回复
1 解答
827 次查看
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello Gaurav Banyal,

The FLASH_ReadResource API is for a special flash memory region called Flash IFR. In particular for the KL03 this region includes a 64 bytes Program Once Field. You can find details about Program Once Field in the Reference Manual.

There is no dedicated API for reading flash as you can simply do it with a pointer or any C code method. Following the logic of the example you could read the written data in a separate buffer like below:

// Extra variables to read data
uint32_t read_buffer[BUFFER_LEN];
uint32_t *flash_ptr;

//...Example code

flash_ptr = (uint32_t*)destAdrss;

for (i = 0; i < BUFFER_LEN;  i++)
{   
   read_buffer[i] = *flash_ptr++;
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

I hope this helps to clarify.

Best Regards!,
Jorge Gonzalez

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

在原帖中查看解决方案

0 项奖励
回复
1 回复
828 次查看
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello Gaurav Banyal,

The FLASH_ReadResource API is for a special flash memory region called Flash IFR. In particular for the KL03 this region includes a 64 bytes Program Once Field. You can find details about Program Once Field in the Reference Manual.

There is no dedicated API for reading flash as you can simply do it with a pointer or any C code method. Following the logic of the example you could read the written data in a separate buffer like below:

// Extra variables to read data
uint32_t read_buffer[BUFFER_LEN];
uint32_t *flash_ptr;

//...Example code

flash_ptr = (uint32_t*)destAdrss;

for (i = 0; i < BUFFER_LEN;  i++)
{   
   read_buffer[i] = *flash_ptr++;
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

I hope this helps to clarify.

Best Regards!,
Jorge Gonzalez

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

0 项奖励
回复