- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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 (;;)
{
}
}
Best regards,
Yocchi
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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. */
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello geon,
Please tell me the example code concretely.
Best regards,
Yocchi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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. */
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Yocchi-San,
Yes. As we discussed it is always recommended to validate the bootlodable application before scheduling.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello geon,
I really appreciate your help.
Best regards,
Yocchi