1 Reply Latest reply on Oct 2, 2019 4:06 PM by JoSa_3786491

    Dual application combination project won't jump the second application

    JoSa_3786491

      Hello PSOC community,

      I've attached a bare bones dual application combination projects that I made. It represents the basic setting for my real project and demos the errors that I'm getting.

      The issue is when I try to jump into my second application it just jumps back to the first application. There isn't much code but I'll layout the two main.c that are causing the issue.

      This is main.c for the bootloader

      #include "project.h"
      
      int main(void)
      {
          CyGlobalIntEnable; /* Enable global interrupts. */
      
          /* Place your initialization/startup code here (e.g. MyInst_Start()) */
          uint32_t status = Bootloader_1_GetMetadata(Bootloader_1_GET_BTLDB_STATUS, Bootloader_1_MD_BTLDB_ACTIVE_1);
          if (status == 1u)
              Bootloader_1_Exit(Bootloader_1_EXIT_TO_BTLDB_2);
          
          Bootloader_1_Start();
          for(;;)
          {
              /* Place your application code here. */
          }
      }
      
      

      basically I check to see if it going to load the second application and the explicitly exit to the second application

       

      This is main.c for AppA the first application

      // App A
      
      #include "project.h"
      #define PRESSED (1u)
      #define WAITING (0u)
      
      volatile uint8_t button1_pressed = WAITING;
      
      CY_ISR(button1ISR)
      {
          button1_pressed = PRESSED;
      }
      int main(void)
      {
          CyGlobalIntEnable; /* Enable global interrupts. */
      
          /* Place your initialization/startup code here (e.g. MyInst_Start()) */
          isr_button1_StartEx(button1ISR);
          
          for(;;)
          {
              LED1_Write(0xffu);
              CyDelay(100);
              LED1_Write(0u);
              CyDelay(100);
              if (button1_pressed == PRESSED)
              {
                  CyDelay(3000);
                  Bootloadable_1_SetActiveApplication(Bootloadable_1_MD_BTLDB_ACTIVE_1);
                  Bootloadable_1_Load();
              }
          }
      }
      
      
      
      
      
      

      Here I wait for a button to be pressed, then Set the active application to AppB and exit to the bootloader.

      I've debugged to code and followed the Load actually loads the main.c bootloader code then exits back AppA instead of AppB.
      I'm not sure what I'm doing wrong. I'm using a PSOC 5LP. Attached is the Workspace that contains the three projects Bootloader, AppA, and AppB.

       

      Oh just for reference here is AppB's main.c

      // App B
      #include "project.h"
      
      #define PRESSED (1u)
      #define WAITING (0u)
      
      volatile uint8_t button1_pressed = WAITING;
      
      CY_ISR(button1ISR)
      {
          button1_pressed = PRESSED;
      }
      
      int main(void)
      {
          CyGlobalIntEnable; /* Enable global interrupts. */
      
          /* Place your initialization/startup code here (e.g. MyInst_Start()) */
          isr_button1_StartEx(button1ISR);
          
          for(;;)
          {
              LED1_Write(0xffu);
              CyDelay(1000);
              LED1_Write(0u);
              CyDelay(1000);
              if (button1_pressed == PRESSED)
              {
                  Bootloadable_1_SetActiveApplication(Bootloadable_1_MD_BTLDB_ACTIVE_0);
                  Bootloadable_1_Load();
              }
          }
      }
      
      
      
      
      
      
      

       

      Thanks for any help,

      -Morio