Writing to non-volatile flash on PSoC 6 M0+

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

cross mob
DaCh_1995281
Level 3
Level 3
First solution authored 10 sign-ins 10 questions asked

We are currently working on utilizing both cores of the PSoC 6 (we have only been using the M4 till now). We are planning on running everything on the M0+ aside from some functions that are more complex and take longer to run.

Currently everything is running on the M0+ and it skips over the more complex tasks so the M4 is just sleeping. There are 2 rows that we write to but only one of them seems to work when executed from the M0+.

Is there a reason why writing to a row of flash would cause the device to crash when executed on the M0+ instead of the M4?

Any help would be appreciated.

0 Likes
1 Solution
Rakshith
Moderator
Moderator
Moderator
250 likes received 1000 replies posted 750 replies posted

Hi @DaCh_1995281

Thank you for sharing additional details regarding your application. I modified the test project to write to SFlash on the CM0+ CPU and I was able to recreate the issue. 

The CY_FLASH_DRV_IPC_BUSY error is returned if there is another process writing to flash. Also, the CM4 CPU should be enabled and should be in Active mode. Please note that flash operations are not allowed in Deep Sleep and Hibernate mode.

Please try running a test project to confirm if flash writes to the address works in an empty project. Once that is confirmed you could try disabling BLE in your application and try writing to SFlash. 

Please let me know your observation.

Thanks and Regards,
Rakshith M B

View solution in original post

0 Likes
5 Replies
Rakshith
Moderator
Moderator
Moderator
250 likes received 1000 replies posted 750 replies posted

Hi @DaCh_1995281

Can you please let me know the target device MPN and if you are using PSoC Creator or ModusToolbox to develop your application? What is the flash row address that you are writing the data to? Also, is there any other functionality like BLE that could be running during flash writes?

Thanks and Regards,
Rakshith M B
0 Likes
lock attach
Attachments are accessible only for community members.

Hi Rakshith,

We are using the CY8C6347BZI-BLD53 with PSoC Creator. The row we are writing to is at address 0x16000A00. BLE is running at the same time, however another row at address 0x1600A200 seems to work fine when we write to it.

The project has an upgradable BLE stack over OTA based on CE220960. We modified the linker files a little to allocate more flash to both cores. The allocated space does not go past the section marked as unused in the sample project pdf file.

I have attached the modified bootloader linker file. I am using the CM0 for the BLE stack.

0 Likes
Rakshith
Moderator
Moderator
Moderator
250 likes received 1000 replies posted 750 replies posted

Hi @DaCh_1995281

0x16000A00 is within the user SFlash region so writing to this row should be possible. I tried writing to this row and it worked for me. Can you please share the code that you used to write into this row? You could also debug the project and check the error returned by the flash write API.

This Knowledge Based Article might help - Store Custom Data in SFlash for PSoC 6 MCU Device – KBA228374

Can you please confirm that the 0x1600A200 address is correct? How did you confirm that the write is successful? I believe this address is invalid as it is not within the SFlash region.

Rakshith_0-1628525794893.png

Thanks and Regards,
Rakshith M B
0 Likes

Hi Rakshith,

My mistake, the address of the working row is 0x16000C00.

Our project has proprietary content so I'm not able to share the whole thing.

I use this line to write to the flash:

sflashStatus = Cy_Flash_WriteRow(SFLASH_ADDR_CALIB_DATA, (uint32_t *)sFlash_CalibData);

where SFLASH_ADDR_CALIB_DATA is address 0x16000A00 and sFlashCalibData is an array of type uint8_t with a length of 512.

The error returned when writing to this row is CY_FLASH_DRV_IPC_BUSY.

The part that confuses me is that writing to this row seems to work fine when the project was entirely on the M4 aside from the BLE which was using a dual core configuration. Now that the majority of the project has been moved to the M0 and the BLE changed to an M0 configuration, writing to this row no longer works even though writing to a different row still works.

0 Likes
Rakshith
Moderator
Moderator
Moderator
250 likes received 1000 replies posted 750 replies posted

Hi @DaCh_1995281

Thank you for sharing additional details regarding your application. I modified the test project to write to SFlash on the CM0+ CPU and I was able to recreate the issue. 

The CY_FLASH_DRV_IPC_BUSY error is returned if there is another process writing to flash. Also, the CM4 CPU should be enabled and should be in Active mode. Please note that flash operations are not allowed in Deep Sleep and Hibernate mode.

Please try running a test project to confirm if flash writes to the address works in an empty project. Once that is confirmed you could try disabling BLE in your application and try writing to SFlash. 

Please let me know your observation.

Thanks and Regards,
Rakshith M B
0 Likes