Make bootloader wait for command when pushing a button

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

cross mob
jofo_817731
Level 1
Level 1

Hi,

   

I want to be able to hold a button down when powering up the board to tell the Bootloader to wait forever for a command. If the button is not pressed while power-on, it should directly launch the application. 

   

Is there a simple way to do this?  

   

This is for emergencies, if for some reason the downloaded image messes up the communication with the host. Then there is no way to get back to the bootloader to download a new image. Is there another way (apart from entering a timeout of a few seconds)?

Regards,
Jostein

0 Likes
5 Replies
jofo_817731
Level 1
Level 1

Before you reply.... yes an alternative is to have a dual bootloader. I am still interested in the answer to whether we can hold a button to stay in the bootloader.

   

Cheers,
Jostein

0 Likes
AnkitaS_51
Employee
Employee
100 likes received 50 likes received 25 likes received

void Bootloadable_Load (void )---
Schedules the Bootloader/Launcher to be launched and then performs a software reset to launch it.
Returns:
This method will never return. It will load a new application and reset the device.

   

You can call this API on a switch press,thus this API will immediately call the bootloader and the bootloader will wait for a new application forever.

0 Likes
Anonymous
Not applicable

I have the same need, and he answer above doesn't solve it. There should be a way in the Bootloader to cause it to "Wait for Command" if it senses a button pressed on powerup. I finally got it with

   
if(SW1_Read()==0u) Bootloader_HostLink(Bootloader_WAIT_FOR_COMMAND_FOREVER);
   

But but you have to bodge the Bootloader.c and Bootloader.h files to make it non-static and exposed in the header. I remember the 4200 sticks working this way out of the box.

0 Likes
legu_1300611
Level 1
Level 1
10 sign-ins First like given 5 sign-ins

You can call Bootloader_SET_RUN_TYPE(Bootloader_START_BTLDR)

   

    if(Pin_bl_Read() == 0){
        //BLFLAG_FOREVER = 1;
        Bootloader_SET_RUN_TYPE(Bootloader_START_BTLDR);
    }

   

    
    /* This API does the entire bootload operation. After a succesful bootload operation, this API transfers
       program control to the new application via a software reset */
    Bootloader_Start();

Anonymous
Not applicable

Thanks, I have verified that it works without altering the generated code. An ominous note in the V1.50 Datasheet says that the command CYBTDLR_SET_RUN_TYPE(x) is deprecated, and should not be used for new designs. Does that mean that Bootloader_SET_RUN_TYPE() is also deprecated? Hopefully they'll add something new before they eliminate it.

0 Likes