7 Replies Latest reply on Oct 9, 2017 11:43 PM by user_483038750

    how to jump to Bootloadable application program in case of using Bootloader

    user_483038750

      Hello,

       

      I am trying the Bootloader and the Bootloadable programs of "USB HID Bootloader".

      If the SW_2 is pushed, the Bootloader is executed and the Bootloadable application is programmed by using the Bootloader Host.

      If it is not pushed, the Bootloadable application is executed directly.

      Please see main.c of the Bootloader below. It can run well.

      I wonder if this is correct. Please tell me if there is something that I should bring.

       

      int main()

      {

          /* Indicates that the bootloader is running. */

          PWM_Start();

          PWM_TriggerCommand(PWM_MASK,PWM_CMD_START);

       

       

          if(Pin_SW_Read()== 0){

              /* Enters the bootloader to wait for the application update. */

              Bootloader_SET_RUN_TYPE(Bootloader_START_BTLDR);

              Bootloader_Start();

          }

          else{

              Bootloader_SET_RUN_TYPE(Bootloader_START_APP);

              Bootloader_Start();

          }

          /* Bootloader_Start() never returns. */

          for (;;)

          {

          }

      }

      無題1.png

      Best regards,

      Yocchi

        • 1. Re: how to jump to Bootloadable application program in case of using Bootloader
          ntan

          Maybe you are looking for this API function.

           

          void Bootloader_Exit (uint8 appId)

          Schedules the specified application and performs a software reset to launch a specified application.

          If the specified application is not valid, the Bootloader (the result of the ValidateBootloadable() function execution returns other than CYRET_SUCCESS, the Bootloader application is launched.

           

          Parameters:

          appId

          The application to be started:

          □ Bootloader_EXIT_TO_BTLDR - The Bootloader application will be started on a software reset.

          □ Bootloader_EXIT_TO_BTLDB;

          □ Bootloader_EXIT_TO_BTLDB_1 - Bootloadable application # 1 will be started on a software reset.

          □ Bootloader_EXIT_TO_BTLDB_2 - Bootloadable application # 2 will be started on a software reset. Available only if the "Dual-application" option is enabled in the component customizer.

           

          These descriptions come from the "Bootloader and Bootloadable component datasheet v1.5"

           

          Regards,

          Noriaki

          • 2. Re: how to jump to Bootloadable application program in case of using Bootloader
            geon

            Hello Yocchi-San,

             

            Inorder to directly execute the the Bootloadable application, schedule Bootloadable and perform software reset. It is recommended to validate the application before scheduling the application.

             

            When SW_2 is pushed, use Bootloader_Start(). It will validate the application, run communication subroutine, wait for bootloading, schedule the Bootloadable and reset the device.

            • 3. Re: how to jump to Bootloadable application program in case of using Bootloader
              user_483038750

              Hello geon,

               

              Please tell me the example code concretely.

               

              Best regards,

              Yocchi

              • 4. Re: how to jump to Bootloadable application program in case of using Bootloader
                geon

                Hello Yocchi-San,

                 

                Please make use of appended code and attached workspace.

                 

                #include <project.h>

                #define Bootloader_activeApp      (Bootloader_MD_BTLDB_ACTIVE_0)

                 

                int main()

                {

                    /* Place your initialization/startup code here (e.g. MyInst_Start()) */

                    CyGlobalIntEnable;

                 

                    if(Pin_Read()==0)

                    {

                        /* Turn on blue LED */

                        Bootloader_Status_Blue_Write(0u);

                        CyDelay(500);

                      

                        /* Start bootloader communication. This will wait for bootloading as configured by Wait for command*/

                        Bootloader_Start();

                    }

                    else

                    {

                        /* Turn on red LED */

                        Bootloader_Status_Green_Write(0u);

                        CyDelay(500);

                        

                      

                        /* Validate and schedule bootloadable. Perform software reset*/

                        if(CYRET_SUCCESS == Bootloader_ValidateBootloadable(Bootloader_activeApp))

                            {

                                Bootloader_SET_RUN_TYPE(Bootloader_SCHEDULE_BTLDB);

                                CySoftwareReset();

                            }

                                      

                      

                    }

                  

                    for(;;)

                    {

                        /* Place your application code here. */

                    }

                }

                1 of 1 people found this helpful
                • 5. Re: how to jump to Bootloadable application program in case of using Bootloader
                  user_483038750

                  Hello geon,

                   

                  Thank you for your support.

                  In conclusion, I simplified the code that you sent me.

                  It can run well. Is this right?

                   

                  int main()

                  {

                      /* Indicates that the bootloader is running. */

                      PWM_Start();

                      PWM_TriggerCommand(PWM_MASK,PWM_CMD_START);

                   

                   

                      if(Pin_SW_Read()== 0){

                          /* Schedules the Bootloader for the application update. */

                          Bootloader_SET_RUN_TYPE(Bootloader_SCHEDULE_BTLDR);

                          CySoftwareReset();

                      }

                      else{

                          Bootloader_Start();

                      }

                   

                   

                      for (;;)

                      {

                      }

                  }

                   

                  Best regards,

                  Yocchi

                  • 6. Re: how to jump to Bootloadable application program in case of using Bootloader
                    geon

                    Hello Yocchi-San,

                     

                    Yes. As we discussed it is always recommended to validate the bootlodable application before scheduling.

                    1 of 1 people found this helpful
                    • 7. Re: how to jump to Bootloadable application program in case of using Bootloader
                      user_483038750

                      Hello geon,

                       

                      I really appreciate your help.

                       

                      Best regards,

                      Yocchi