3 Replies Latest reply on Sep 10, 2018 5:08 AM by sweeney_2578827

    Debug Dual Application Bootloader

    sweeney_2578827

      I have a combination bootloader application but I'm having trouble debugging the image in the upper section. There seems to be some issue with my firmware copying/flash writing code but it only happens when the upper image is running and writing to the lower image location (the first firmware copy to the upper location works fine). I don't know how to debug the upper image. I can trick the bootloader into booting the upper image but the debug symbols don't seem to align to the correct code if I do this.

        • 1. Re: Debug Dual Application Bootloader
          geon

          What is the flash consumption of the new first-combination application? Is there any overlap with the second application in flash?

           

          Please bootload the previous version of first-combinaton application to confirm the same. If it does not help, please share the project and steps to recreate the issue.

           

          Could you please elaborate what you meant by, debug symbols don't seem to align to the correct code if I do this.

          • 2. Re: Debug Dual Application Bootloader
            sweeney_2578827

            The flash consumption is around 40%, there is no overlap in the flash (there is an error check to prevent this from happening plus the second application runs fine). Unfortunately I cannot share the project but the issue isn't unique to the project it's just that I don't know the correct procedure to debug the second application in flash.

             

            PSoC creator creates a hex file that contains the bootloader, the first application in the lower section of flash and the second application in the upper section of flash. By default the lower application is active so if I debug the project from PSoC creator it debugs the first application in the lower part of the flash, is there a way to debug the application in the upper part of flash? My attempt thus far involved manually changing the bootloader so that the upper part of flash is the active project, this works fine and the application runs, but then the debugger does not know what line of code is running, if I try to pause the program the debugger does not know where it is and the call stack shows question marks.

            • 3. Re: Debug Dual Application Bootloader
              sweeney_2578827

              I finally got back to attempting this again and I semi-successfully got it working. You can select the debug target by right clicking on the project in the Workspace Explorer sidebar and going to "Build Settings > Debug > General > Debug Target" then select "Application Code and Data 2". However this only works if the bootloader boots Application 2 and for some reason this setting doesn't automatically change the metadata to reflect that. I was able to hack it by manually tweaking the bootloader to boot the second image instead of the first one. Here's what my new bootloader main looked like:

               

                  Bootloader_1_SetFlashByte((uint32) Bootloader_1_MD_BTLDB_ACTIVE_OFFSET(0),0);
                  Bootloader_1_SetFlashByte((uint32) Bootloader_1_MD_BTLDB_ACTIVE_OFFSET(1),1);
                      
                  Bootloader_1_Start();
              

               

              Obviously this is only a temporary solution for debugging, since it forces the second image to be the one that gets booted no matter what the metadata bits say, you can't actually update the firmware with that hack in there. There's probably a better way to set the metadata not at runtime but this was sufficient for me to debug so I didn't spend any longer looking into it.