1 2 Previous Next 27 Replies Latest reply on Aug 4, 2020 3:51 AM by JaOr_4642046

    Psoc 4 BLE: ERROR, Region Ram overflowed with stack

    JaOr_4642046

      Hi all,

       

      I am trying to implement a bootloader which connecting with a external memory by SPI, for that I use (as reference) the document " Psoc 4 BLE - OTA Firmware Upgrade using Serial NOR flash".  As it is shown in the screenshot at the moment I start the SPI the message is "ERROR: Ram overflowed with stack"

       

       

      Any idea about it?

      the result is

       

      when in dis-comment this line :  ( I put this line (EMI_SPIM_Start()) to easy shown the behaviour)

       

       

       

      The TopDesign is :

       

       

      Thanks very much in advance for your help, I hope some of you have any idea about it.

       

      Regards.

        • 1. Re: Psoc 4 BLE: ERROR, Region Ram overflowed with stack
          SudheeshK_26

          Hello,

           

          To get a better understanding about this issue, could you please share your bootloader project with us? Are you using any of our code examples or writing your own bootloader project?

           

          An example for SPI based external memory bootloader project is available at: PSoC-4-BLE/100_Projects_in_100_Days/Project051_NOR_Flash_Bootloader at master · cypresssemiconductorco/PSoC-4-BLE · GitH… .

           

          Thanks and Regards,

          Sudheesh

          • 2. Re: Psoc 4 BLE: ERROR, Region Ram overflowed with stack
            JaOr_4642046

            Hi Sudheesh

             

             

            Many thanks for your answer.

             

             

            I have used exactly the example code which you have indicate. to get a roughly idea about SPI and external memory in boot-loader.

             

            The weird thing to me is just with add the line  "EMI_SPIM_Start();" it give to me de message even I did not use this module.

             

            Anyway, I attached the Bootloader project. I hope it could give you an idea of why this happen and  you can guide me about it.

             

            Thank you very much.

             

            Have a nice day.

             

            Regards

            • 3. Re: Psoc 4 BLE: ERROR, Region Ram overflowed with stack
              JaOr_4642046

              Hi

               

              I forgot to mention I have been playing around with Stack Size and Heap Size but without positive results

               

              Regards

              • 4. Re: Psoc 4 BLE: ERROR, Region Ram overflowed with stack
                JaOr_4642046

                Hi Sudheesh,

                I realised I have this configuration on the BLE component (image below)

                 

                On the example which you have

                : PSoC-4-BLE/100_Projects_in_100_Days/Project051_NOR_Flash_Bootloader at master · cypresssemiconductorco/PSoC-4-BLE · GitH… .

                The BLE configuration is:

                when I swap this blocks ( BLE from your example by  "CyBle" of my project) the overflowed error is gone (of course appear others), but I can´t leave it like that, since my project is communicate with the external device by the configuration "HID over GATT" and in this sense it is already works.

                 

                I tried to remove services like "bootloader", but If I remove "bootloader" service, I lose API which I need on the code.

                 

                 

                 

                Honestly, I am not sure which way I need to follow to sorted this issue.

                 

                I appreciate any suggest

                 

                Regards

                • 5. Re: Psoc 4 BLE: ERROR, Region Ram overflowed with stack
                  SudheeshK_26

                  Hello,

                   

                  I am able to build your project without any errors (Call to function EMI_SPIM_Start(); function is not commented). Are there any other steps to be followed to recreate this failure?

                   

                  The error you observe "ERROR: region RAM overflowed with stack" happens when more memory is allocated for stack and heap in .cydwr file -> System tab. As per your previous response, I understand that you tried different stack and heap size for your project. Did you try reducing the stack and heap size from default value?

                   

                  In the bootloader project, it is not required initialize the SPI block separately. The function Bootloader_Start(); will automatically initialize it. Could you please clarify why you are calling the function "EMI_SPIM_Start();" form main?

                   

                  Thanks and Regards,

                  Sudheesh

                  • 6. Re: Psoc 4 BLE: ERROR, Region Ram overflowed with stack
                    JaOr_4642046

                    Hi Sudheesh,

                     

                    Before anything, I wish to say that appreciate your help about it a lot.

                     

                    I am able to build your project without any errors (Call to function EMI_SPIM_Start(); function is not commented). Are there any other steps to be followed to recreate this failure?

                    I attach the folder again , I not sure, may be the previous folder, which I uploaded, it could be have modifications ( my tries) and I didn't realize before send you (in this case sorry).

                    This "new" folder is cleans, the only steps I follow are:

                              1º) In the "original" project (my develop project)  TopSesing.cysch has implemented the blocks  "Cyble" and "Bootloader", (and everything is working OK).

                              2º) I add "EMI_SPIM" and "EMI_SPIM_SlaveSelect" pin (from the Cypress example mentioned, with the same configuration)

                              3º) I clean an build the project.

                              4º) I add   " EMI_SPIM_Start();" in line 104 of "main.c" (just to check if it give me the overflowed message )

                     

                    and the failure appear.

                     

                    The error you observe "ERROR: region RAM overflowed with stack" happens when more memory is allocated for stack and heap in .cydwr file -> System tab. As per your previous response, I understand that you tried different stack and heap size for your project. Did you try reducing the stack and heap size from default value?

                     

                     

                    Since the failure is because of small memory size, I just increased it, honestly, I did not try to reduce it. it is no sense to me but I will try it and let see,  if this is the problem and anything change, I will post here to everyone.

                     

                    (note: in the above image,  A) they was the original values)  the values modifications did not fix the issue.

                     

                     

                    In the bootloader project, it is not required initialize the SPI block separately. The function Bootloader_Start(); will automatically initialize it. Could you please clarify why you are calling the function "EMI_SPIM_Start();" form main?

                    I am Sorry, I don't exactly understand your question.

                     

                    I just try to follow the PSoC-4-BLE/100_Projects_in_100_Days/Project051_NOR_Flash_Bootloader/BLE_External_Memory_Bootloader01/ example.

                    In this example from:

                                   main().c ->Bootloader_Start(),

                                   go to

                                   Bootloader.c->Bootloader_Start() ->Bootloader_HostLink() ->CyBtldrCommStart()

                                   go to

                                   CustomInterafce.c -> EMI_Start();

                                   go to

                                   ExternalMemoryInterface.c -> EMI_SPIM_Start();

                     

                    In my case, when I tried to do something similar to this, was when it also shown me the failure,  so by simplicity I captured the picture with the call functions "...START()"  in the main().c  ( previous check that if I call the function from main() the failure was the same )

                     

                    I hope it can help and I have explained myself properly.

                     

                    Thanks and Regards,

                    • 7. Re: Psoc 4 BLE: ERROR, Region Ram overflowed with stack
                      SudheeshK_26

                      Hello

                       

                      As per my understanding, your requirements are as below. Please correct me, if I am wrong.

                      1. Need to use "Human Interface Device", "Device Information", Battery Service", "Scan parameters" and bootloader services in your application.

                      2. User external memory (SPI) bootloader to update application over the air.

                       

                      To implement the above requirements, you should use the external memory bootloader example project from Cypress without any changes and implement the required BLE services in the bootloadable project. Please refer our example projects available at: https://github.com/cypresssemiconductorco/PSoC-4-BLE/tree/master/100_Projects_in_100_Days/Project051_NOR_Flash_Bootloader. As you can see in this example projects, BLE component in bootloader project has only 2 services "Generic Access" and Generic Attribute". Other services "Device Information", "Bootloader" and "Heart Rate" are implemented in Bootloadable project.

                       

                      Were you able to test the bootloader and bootloadable projects available from above link successfully? Please check if you can perform bootloading operation to update application. If it is working without any issues, then you can modify the bootloadable project as per your requirements. It is not recommended to modify the bootloader project.

                       

                      Thanks and Regards,

                      Sudheesh

                      • 8. Re: Psoc 4 BLE: ERROR, Region Ram overflowed with stack
                        JaOr_4642046

                        Hello,

                         

                        As always thanks for your help.

                         

                        Yes, you are right, I got an interface BLE using  "human Interface Device" and so in my application, and I need to use a external memory (SPI) boot-loader to update application over the air, But from the own Boot-loader.

                         

                        I am quite new using Cypress components so some of concepts, at the moment, escape to my knowledge. So I don´t know if it possible to do or not what I am going to explain.

                        **********************************************************************************************

                        From the example project which you referenced, I can see two parts:

                        1) boot-loadable: we have (among others):

                                  a) BLE: this one have services, which are used to communicate with the Host (e.g mobile ) when the application is running in a normal working stage (internal memory) as mechanism to exchange information each other.

                                  b) SPI: This SPI master is used, in this normal working stage, to send the data received from host to the external flash memory.

                         

                        on the other hand we got

                        2) boot-loader: we have (among others):

                                  a) BLE:  it has just two mandatory services.

                                  b) SPI:  it is in charge of going to external flash memory and charge the image, which previously was received from host,  to the internal flash.

                         

                        *************************************************************************************************

                        If I do not wrong in the above short summary.  I got some questions:

                         

                                  a ) On 2.a) ¿what exactly is the functionality doing this BLE with this two services on boot-loader?, could I modify this one with another services? ( y presume yes),What kind of implications does it have respect to the BLE block in boot-loadable area?

                         

                                  b)  As I mentioned above, I wondering if it possible to get the BLE connection between host (= mobile) and  Server (= device) when the boot-loader started, then send  the data received from host to the external flash and if everything are OK, charge this data to the internal flash, all of this process implemented  from  Boot-loader not from boot-loadable.

                         

                        In summary, I can´t use the boot-loadable for communicate with the flash, for load and unload, and I wonder if I could do that from Boot-loader.

                         

                        Thank you very much.

                        • 9. Re: Psoc 4 BLE: ERROR, Region Ram overflowed with stack
                          SudheeshK_26

                          Hello,

                           

                          As I mentioned in my previous response, it is not recommended modify the external memory bootloader project to add additional functionalities. Bootloader project uses functions in BLE component related to data encryption and decryption. That is why BLE component is present in bootloader project.

                           

                          Is it necessary to use an external SPI memory for bootloading in your application? If not, you can try to use fixed stack OTA bootloader or upgradable stack OTA bootloader in your application. Both of these will support programming bootloader first and later sending application from host. Please find more details about them from our application note: https://www.cypress.com/file/198301/download .

                           

                          Thanks and Regards,

                          Sudheesh

                          • 10. Re: Psoc 4 BLE: ERROR, Region Ram overflowed with stack
                            JaOr_4642046

                            Hello Sudheesh,

                             

                            Sadly I need to use the external SPI memory.  The Psoc 4 BLE we are using is at 96% of its capacity and also we want to be sure that the upgrade it OK  before delete the old internal memory application.

                             

                            The problem is that we are using 2 UART  for serial communication with other MCU and with the outside, and apparently this is the maximum number of serial blocks which are allowed at Psoc 4 BLE. that  is one of the reason I was wondering if was possible to add the SPI just in the boot-loader project?

                             

                            *********************************

                             

                            On the other hand, I am trying to do your suggest, I downloaded the "PSoC 4 BLE - OTA Firmware Upgrade using Serial NOR Flash ", I have upgraded the Psoc 4 BLE with this app and change the pins to match with my, I don´t use the UART so I disabled it. But although the projects seem OK, when I try to upgrade the new "boot-loadable" this is the result.

                             

                             

                            could you orientate me about why could happen this disconnect?

                             

                            Also I attach the log, in case it can help.

                             

                            PS: On the device I am using :  CYBLE-212020-01  and Flash: S25FL064LABMF1013

                             

                            Many Thanks.

                            • 11. Re: Psoc 4 BLE: ERROR, Region Ram overflowed with stack
                              SudheeshK_26

                              Hello,

                               

                              Can you please set the ECO capacitance trim values as explained in following knowledge base article and test again?

                              KBA: ECO Capacitance Trim Values for EZ-BLE™ Modules - KBA218990

                               

                              Is it possible for you to enable UART? If yes, please give us the UART log also.

                               

                              Thanks and Regards,

                              Sudheesh

                              • 12. Re: Psoc 4 BLE: ERROR, Region Ram overflowed with stack
                                JaOr_4642046

                                Hello Sudheesh

                                 

                                 

                                A)

                                I was stuck all this weekend. So I am now a bit more happy thanks to this suggest, it is doesn't works completely but we have take one step forward (Thanks)

                                 

                                As you can see below, I added the command at line "72" on the "main().c" file of the Cypress examples. ( I could not found the plase which suggest in :

                                ECO Capacitance Trim Values for EZ-BLE™ Modules - KBA218990 )

                                => "For setting ECO capacitance trim value in firmware, add the following code in the CYBLE_EVT_STACK_ON event:"

                                 

                                 

                                 

                                 

                                Below you can see the result.

                                 

                                 

                                 

                                As you can see, the error is now in the transfer Firmware image. Which is a bit peculiar since the image which I send through OTA (at the moment) is exactly the same image which I programming with the programmer.

                                 

                                Any idea?

                                 

                                I tried a second time and the result was the same, this time it sent some data through OTA, I attach the message

                                 

                                 

                                 

                                I attach the log too.

                                 

                                 

                                 

                                 

                                *****************************************************************************************************************************************************

                                *****************************************************************************************************************************************************

                                B)

                                In regard to the uart:

                                 

                                 

                                I tried too to run this. since I am working with our own PCB, I have tried to connect the UART to my PC using the "Sdata" pin connector of the programmer ( ping 24 of BLE chip). As I slow below.

                                With this configuration I have tried to see the data using Putty at 115200 but the result is just rubbish ( I changed the baud rate with the same result). But I am not sure if this is the correct way to visualize the UART messages using the programmer (which, on the other hand, is the only access I have from my pc to the PCB)

                                 

                                 

                                 

                                 

                                 

                                If I doing something wrong I am more than happy to read you suggest about it and sent to you the UART log.

                                 

                                 

                                Thank you very much.

                                 

                                Regards.

                                • 13. Re: Psoc 4 BLE: ERROR, Region Ram overflowed with stack
                                  JaOr_4642046

                                  Hello,

                                   

                                  I found the issue mentioned above post (I leave it here in case it can help to another people) . The issue came from a external signal which was affecting to the SPI bus therefore this produced a Checksum error.

                                   

                                  Now the example, PSoC-4-BLE/100_Projects_in_100_Days/Project051_NOR_Flash_Bootloader at master · cypresssemiconductorco/PSoC-4-BLE · GitH…   is working. The Dongle send the image to the external memory.

                                   

                                  Thanks.

                                   

                                  ***********************************************************************************************************

                                  ***********************************************************************************************************

                                   

                                  Now cypress´  example is working properly, I am still wondering:

                                   

                                  from this example, it is possible to run the functionality  which collecting image and send it to external memory but in the boot-loader project?

                                  I will try to explain myself with the next images.

                                   

                                   

                                  1) I got the Boot-loadable running until SW2 is press. In this moment, the stack pointer jump to 2)

                                  in 2) ( which is programming in boot-loader) I am trying to do exactly as the original example do, send image from dongle to external flash memory. and when this transfer have finish, 3) run the boot-loader (as original example) .

                                  Is it possible to do that in the boot-loader project? I mean,  is it possible to call a function from boot-loadable to boot-loader previous reset the system and after execute this image transfer (Dongle to external flash)  reset the system and launch the boot-loader (external flash to internal flash) ?

                                   

                                   

                                  Thank you very much and Regards.

                                  • 14. Re: Psoc 4 BLE: ERROR, Region Ram overflowed with stack
                                    SudheeshK_26

                                    Hello,

                                     

                                    As I mentioned in my previous responses, it is not recommended to modify the bootloader project. Adding BLE stack will take more than 30% of the internal flash, but you are already using 96% of the flash.

                                     

                                    Another way is to use an unconfigured SCB block and configure it as UART during normal operation and as SPI master during bootloading. But, the UART pins and SPI pins need to be shared. As per my understanding, you are already using 2 SCB blocks in your application for UART communication. If you can use this method, then you can configure one of the SCB blocks as unconfigured and configure it as UART or SPI master during run time. You can refer PSoC creator SCB component datasheet for more information about configuring SCB block during runtime.

                                     

                                    Please see the attached project. I modified our bootloader and bootloadable projects to implement this method. Changes made to the example projects are as below.

                                    1. Configured SCB block "EMI_SPIM" as "Unconfigured SCB".
                                    2. Unconfigured SCB blocks need an input clock. So, added clock component "EMI_SPIM_CLK" and set it to HFCLK (32MHz).
                                    3. Added additional source files to configure SCB block as UART and SPI master. (spi_config.c, spi_config.h, uart_config.c, uart_config.h). They are present under the folder "SCB_Config".
                                    4. This project will configure "EMI_SPIM" SCB block as UART from main(). Please see the function "config_SCB_UART()".
                                    5. When the bootloader service is activated, it will reconfigure "EMI_SPIM" block as SPI master. See function config_SCB_SPI().
                                    6. After configuring as SPI master, code will try to read device ID from flash device. This is just for debugging purpose. Reading correct device ID will confirm that the SPI block got reconfigured as SPI master. Device ID for S25FL064L device is "0x01, 0x60 and 0x17". It is mentioned in the datasheet of flash device.
                                    7. Now, you can try to bootload from CySmart application.

                                     

                                    I did not change the name of the SCB block (EMI_SPIM) to avoid updating the API names in the file "ExternalMemoryInterface.c" file. If it is working at your side, you can modify the names as per your application. Please test the attached project and let me know the result.

                                     

                                    Thanks and Regards,

                                    Sudheesh

                                    1 2 Previous Next