How can I store non-volatile data used in app?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
HyCh_2920631
Level 1
Level 1

What APIs should I use to store non-volatile data?

I am using cyw43907 and the manual says it supports External Flash Memory.

I wonder if I should use wiced_sflash_write to store the data, or whether I can save it using wiced_dct_write.

0 Likes
1 Solution

You can use wiced_dct_write() to store data during runtime in DCT section of flash. The string_var in the example is modified during runtime. The dct_read_write_app_dct_t struct in the example is user defined. Similarly you can have your own struct or you can simply store other data types in DCT dynamically. Using API to directly write to SFlash is not recommended because the SFlash has a well defined memory layout and if you write data into a dedicated section (such as bootloader), you may risk corrupting that section.

View solution in original post

5 Replies
GauravS_31
Moderator
Moderator
Moderator
10 questions asked 250 solutions authored 250 sign-ins

You can use DCT app section so that the data persists across power cycles. Please refer to snip.dct_read_write to check how the App section is modified.

0 Likes

Yes, I saw the snip.dct_read_write project.

But the example seems to have to use dct predefined(like my_app_dct_t structure), right?

What I want to do is dynamically save and store data in flash.

Can I use sflash_read/write API?

0 Likes

You can use wiced_dct_write() to store data during runtime in DCT section of flash. The string_var in the example is modified during runtime. The dct_read_write_app_dct_t struct in the example is user defined. Similarly you can have your own struct or you can simply store other data types in DCT dynamically. Using API to directly write to SFlash is not recommended because the SFlash has a well defined memory layout and if you write data into a dedicated section (such as bootloader), you may risk corrupting that section.

Oh, I see. Thank you for answer

If so, which API should I use if I want to delete all the data in the flash's DCT_APP_SECTION?

There is only read/write in the dct API.

0 Likes

You can set the value of each member of the structure to 0 and write this in DCT. This should be done between wiced_dct_read_lock() and wiced_dct_read_unlock().

0 Likes