Flash driver example: Reading the flash memory

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Flash driver example: Reading the flash memory

ソリューションへジャンプ
1,635件の閲覧回数
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 解決策
1,010件の閲覧回数
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 返信
1,011件の閲覧回数
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 件の賞賛
返信