Supervisory Flash Write

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

cross mob
Anonymous
Not applicable

Is the function CyBle_StoreAppData() a future-planned function? Or is it already implemented? I'm looking at the code in BLE_StackHostMain.h, but I don't see the connected definition.

   

It seems to be getting used by the underlying cypress stack, so I'm assuming it is stored in a binary file.

   

Can I/Should I use it to write application data I want to store to the supervisory flash on the chip? I found the supervisory flash example here: http://www.cypress.com/blog/100-projects-100-days/project-029-supervisory-flash-psoc-4-ble

   

​But...I'm not sure if/what it does. I don't want to overwrite BLE bonding data, and I don't want to overflow bast the 512 bytes of flash into program flash or something. 

0 Likes
1 Solution
Anonymous
Not applicable

That is correct; the CyBle_StoreAppData() method will not work for SFLASH. Writing to the SFLASH area requires specific register operations instead. The simplest reference for that is actually the 100 Days project that you linked to in your original post. The PDF for that project (also on the GitHub repo) describes at a high level how it works, and you can find the specific code that does the writing in the WriteUserSFlash.c file:

   

https://github.com/cypresssemiconductorco/PSoC-4-BLE/blob/master/100_Projects_in_100_Days/Day029_BLE...

View solution in original post

0 Likes
8 Replies
Anonymous
Not applicable

That function is already implemented, and it can be used to store data in non-SFLASH areas on the device. You just need to supply a flash-stored constant location as the destination pointer. Check out the following discussion forum topic:

   

http://www.cypress.com/forum/psoc-4-ble/how-store-byte-array-flash-memory

   

Note that this function as described in the linked topic will write data to the normal (overwritable) flash area on the device. This is not the same as supervisory flash, which persists across SWD re-flash cycles.

0 Likes
Anonymous
Not applicable

Ah, no need to write my own then. Thanks!

   

I'm assuming I can't use the Cyble_AppStoreData() function to write to the supervisory flash location then?

   

Ideally, I'm looking to write debug values into the sFlash for debugging devices from the field if/when they come back with issues. Since the regular flash will be set to unreadable for code protection, that would make it hard to read the flash once it is programmed I'm assuming.

   

Thanks for the link to the other topic post :), it was very helpful for understanding what is going on.

0 Likes
Anonymous
Not applicable

That is correct; the CyBle_StoreAppData() method will not work for SFLASH. Writing to the SFLASH area requires specific register operations instead. The simplest reference for that is actually the 100 Days project that you linked to in your original post. The PDF for that project (also on the GitHub repo) describes at a high level how it works, and you can find the specific code that does the writing in the WriteUserSFlash.c file:

   

https://github.com/cypresssemiconductorco/PSoC-4-BLE/blob/master/100_Projects_in_100_Days/Day029_BLE...

0 Likes
Anonymous
Not applicable

I'm having trouble getting the example SFlash code working; Is there a reason for the write and read functions using uint8 and uint32 pointers respectively? Is it merely a matter of preference/use that the two pointers are different sizes (besides the write function requiring uint32 to write obviously)?

   

Is there a reason to the syntax WriteUserSFlashRow(rowIndex, &data[0]); instead of WriteUserSFlashRow(rowIndex, data);?

   

Is it allowable to read the SFlash data as uint32() values instead of uint8 values?

0 Likes
Anonymous
Not applicable

Hi,

   

In our recent versions of the creator, we have our own functions to write to the SFlash. The project in the 100 days list uses a custom function as it is an old project.

   

Please use this project in the PSoC Creator example project for your reference for using the SFlash:

   

C:\Program Files (x86)\Cypress\PSoC Creator\4.0\PSoC Creator\examples\sampleprojects\SFlash_Example

   

Regards,

   

- Madhu Sudhan

Anonymous
Not applicable

Thanks Madhu; It indeed looks newer than the 100 days project 🙂

0 Likes
Anonymous
Not applicable

Hi, I have tried out the new SFlash example. I am unable to get the LED error light to blink. I have also followed the project description to comment out the code "returnValue = CySysSFlashWriteUserRow(CY_TEST_SFLASH_ROW, rowPattern)" but to no avail. Did I do something wrong?

0 Likes
Anonymous
Not applicable

Did you correctly match up the pins for the LEDs to the pins for your specific device/module you are using?

   

If the SFlash data was already written (on a previous program run for example), then the data written to SFlash will still be in SFlash, and thus there will be no changes between what is stored in the SFlash and what you are looking for in the code.

   

Try changing the data pattern instead of commenting out the line to see if it writes a new data line to the SFlash;

   

Also, if you have a debugger, you can break on the comparison when reading back the SFlash to see what it returns.

0 Likes