1 2 Previous Next 20 Replies Latest reply on Dec 14, 2016 11:28 PM by JoMe_264151




      I would like to use the SFlash of the PRoc 4 BLE to save some information and parameters about my device. I need to save information and parameters in this location because I would like to keep them after a bootstraploader ota.


      I found the User_SFlash_Write project in Cypress website but I cannot use it because there is a bug... I read in this document project that the BLE address is saved in the ROW0 in first 6 bytes. If I use the debug and go in the address 0x0FFFF200 of the Flash, all bytes are 0x00. why?


      I know there a function "CyBle_GetDeviceAddress(&localAddr)" to obtain the address but I would like to do by myself.
      I wrote this code to read the ROW0 of the SFlash:


      #define ROW0    0x0FFFF200
      uint8 * ptrSFlash;
      static uint8 memSFlash[128];


      ptrSFlash = (uint8 *)ROW0;


      for(i=0;i<128;i++) {
        memSFlash[i] = 0xFF;

      for(i=0;i<128;i++) {
        memSFlash[i] = *ptrSFlash++;


      I received all 0x00, so I decided to read the first row of the Flash (@0x00000000), but It doesn't work because the result isn't the same than I can read in the Flash in Debug state and I don't understand why....


      Is there any mistake in my code or my understanding about SFlash?



        • 1. Re: SFlash

          There is a difference between ordinary flash and the supervisor flash SFlash. While you can read the former using standard pointer access, the latter needs some special access to have it protected.


          Take care:


          Programming flash by using the appropiate APIs may cause malfunctions of the BLE-subsystem because the internal clocks are changed during programming.





          • 2. Re: SFlash

            OK, I understand but why I cannot read the standard Flash with my code?


            How I can proceed to read and write the SFlash?

            • 3. Re: SFlash

              Can you post your complete project, so that we all can have a look at all of your settings? To do so, use
              Creator->File->Create Workspace Bundle (minimal)
              and attach the resulting file.


              It will save us a lot of time (Creating a new project with the right chip, setting the hardware...) And tell us which board you use, CY8CKIT-042 BLE??





              • 4. Re: SFlash

                Accessing SFlash examples here.





                • 5. Re: SFlash

                  I use the CYBLE-022001-00 module.

                  • 6. Re: SFlash

                    Your program works flawlessly. You read the memory starting at location 0x00 into your memSFlash array.





                    • 7. Re: SFlash

                      I am not sure, because when I read memSFlash in the "locals variables" values are not same than in Memory... Did you try my program?



                      • 8. Re: SFlash

                        Yes, I tried exactly your program. Remember that starting at 0x00 the interrupt table resides which might be changed during run.


                        What is the reason you want to read flash memory? and why didn't you start reading the top-memory which is used only when you get with your code near the limit.





                        • 9. Re: SFlash

                          I would like to use the SFlash memory but I had some problem it is why I first tried to read the "standard" Flash...


                          Now, it is ok and I can read and write the SFlash.


                          In the project documentation "User SFlash Write" it indicates that the first 6 bytes of the ROW0 are reserved for BLE address. I can write at this address (0x0FFFF200 to 0x0FFFF205) and read it but it isn't the BLE address.


                          If I use the function CYBLE_API_RESULT_T CyBle_SetDeviceAddress(CYBLE_GAP_BD_ADDR_T* bdAddr), I can set a new address but I cannot read it through a pointer, I need to use the function CYBLE_API_RESULT_T CyBle_GetDeviceAddress(CYBLE_GAP_BD_ADDR_T* bdAddr)


                          I don't really understand why I cannot do this and why I cannot see the BLE address. This information about BLE address is it true?



                          • 10. Re: SFlash

                            How do you understand the word "reserved"? I understand it as "Hands OFF!!!"





                            • 11. Re: SFlash

                              I understand "reserved" like you, but we can change this address with the function CyBle_SetDeviceAddress(). :-)


                              But my question is still the same why it is not possible to read the BLE address through a pointer? Anyway, I will use the function but it is a shadow area.


                              Bob, thanks for your help and your advice, I really appreciated.



                              • 12. Re: SFlash

                                Probably I have a different view than you, Greg. PSoCs are for me nothing new I want to experience with. I presume that every API, every component runs as described in the datasheet or other manuals. As the time has shown there have been very few real issues with any of them. I have no time to explore any "secrets", PSoCs are complex enough, did you already have a view into the HDL "Verilog" to construct your own hardware?


                                Reading from flash is something very simple and it just works as on any other ARM processor, nothing special for PSoCs.





                                • 13. Re: SFlash

                                  CyBle_SetDeviceAddress() does not write the address to supervisory flash.


                                  Some BLE operations do write to flash such as Store Bonding Data but these dont write to supervisory flash, they write to a Const value which is somewhere in regular flash, determined by the compiler. I am not sure if SetDeviceAddress writes to regular flash, but I suspect it doesnt write to flash at all and only sets up the address within the stack. It definitely does not write to Sflash.


                                  Incidentally the SflashWrite example project I had problems with as it messes up the clocks and doesnt return clocks exactly back as it found them. I had to add part of the reset setup of clocks to the end of the supplied API call.

                                  • 14. Re: SFlash



                                    I can't get the simple Sample project " User_SFlash_Write" to work on the CY8CKIT-042-BLE kit, using the CYBLE-222014 module.


                                    Reading the SFlash Rows seems to be ok, but the function WriteUserSFlashRow doesn't return, so that I don't get the UART status results.


                                    Does someone have any idea?



                                    1 2 Previous Next