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

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
YoIs_1298666
Level 5
Level 5
250 sign-ins 100 replies posted 100 sign-ins

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

0 Likes
1 Solution

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. */

    }

}

View solution in original post

7 Replies