Saving to flash

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

cross mob
niprc_3742601
Level 4
Level 4
5 likes given First like received First like given

Hello,

I would like to be able to permanently store data to flash of my PSoC5 processor and being able to retrieve it after rebooting the processor.  I found sample project "Flash Example" that seems to be doing just that.

This is the code snippet how they store data to flash:

...

            CySetTemp();

            returnValue = CyWriteRowData(ARRAY_ID, ARRAY_ID_ROW_ADDR, rowPattern);

            /* Check if operration is successful */

            if (returnValue != CYRET_SUCCESS)

            {

                LED_Error_Write(LIGHT_ON);

                CyHalt(0x00u);

...

It writes data to the flash and then immediately reads it and matches to what was stored.  Everything works fine here.  But if I modify this code such that when it runs first time it ONLY writes the data and the second it ONLY reads the data then the stored data is lost.  So it looks like the stored data didn't survive the reboot OR reprogramming of the chip (I had to do it to comment out the code that writes data to flash).

Is there a way to burn something to flash so it stays there until explicitly erased?

Thanks!

Nikolay

0 Likes
1 Solution

Question: Can I protect a flash region from being cleared during chip programming?

Answer: If you program the device use PSOC Programmer or Creator(include a mini programmer), you cannot protect a flash region from being cleared during chip programming because device flash is erased all first before program, this process is preset and fixed in software tool.  Change the flash block protection level cannot prevent protected flash block be erased from external.

1.jpg

I think there are two ways to fix this issue:

(1) Store data in EEPROM of PSoC5LP, erase flash won't change EEPROM region.

(2) Design device program script use cli (command line),  custom you own programming steps instead of use ready-made programming tools. Post 6. Re: Saving to flash also mentioned this method("unless you implement a custom program step).  You can search "PSoC Programmer CLI User Guide.pdf" file on your PC to know how to do that.

If your design is a bootloader-bootlodable system, you can define a checksum-exclude region which won't be modified when bootlodable is upgrading by bootloader.

View solution in original post

0 Likes
10 Replies