How to flash a dual image bootloader project?

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

cross mob
JEv_295166
Level 3
Level 3
First like received

I'm building a bootloader project that has 2 applications. The idea is to switch between application #1 and #2 at boot time.

   

The bootloader will be tasked with checking for new CYACD images and flashing those if present. 

   

My understanding is that upon completion of any bootloader operations I can call Bootloader_Exit() to reboot into the selected application.

   

Where I am getting slightly confused is how to flash the device in the first place.

   

Does one take the .hex files generated by PSOC Creator and use the bootloader host to write all 3?

   

If this is the case, am I right in thinking that each application needs to have the correct image placement manually specified? If so does this override the 'applications are allocated an equal amount of flash space'  note in the datasheet?

   

Or is it necessary to assemble a single contiguous image containing the bootloader and the 2 applications?

   

Any help much appreciated.

   

TAIA

   

Jerry.

0 Likes
2 Replies
AnkitaS_51
Employee
Employee
100 likes received 50 likes received 25 likes received
0 Likes
lock attach
Attachments are accessible only for community members.
JEv_295166
Level 3
Level 3
First like received

Hello Anks.

   

Thank you.

   

My problem seems then to rest with the .hex files.

   

I flash any of the hex files using PSOC programmer, then 'debug without programming'. After this initial step, Bootloader_ValidateBootloadable() fails and starts the bootloader process.

   

Once the bootloader has updated both images, all works as expected. But this is not what I want at this stage of development. 

   

All this using PSOC Creator 4.0 Update 1. Here is the minimal relevant code. A minimal example project is attached.

   
 //----------------------------------------------------------------------------- int main() {     volatile cystatus status = CYRET_SUCCESS;     volatile uint8_t sw_status = 0;     uint8_t master_app_id = 0;     uint8_t slave_app_id = 1;          // Global Interrupt Enable     CyGlobalIntEnable;           // utility to flash LED      Flash(4,100);      // validate image 1     status = Bootloader_ValidateBootloadable(master_app_id);     if (status != CYRET_SUCCESS)     {         Flash(1,1000);         Bootloader_Start();     } // validate image 2     status = Bootloader_ValidateBootloadable(slave_app_id);     if (status != CYRET_SUCCESS)     {         Flash(2,1000);         Bootloader_Start();     } // if switch pressed we boot into image 1     sw_status = SW1_Read();     if (sw_status == 0)     {         Flash(1,1000);         //         Bootloader_SetFlashByte((uint32) Bootloader_MD_BTLDB_ACTIVE_OFFSET(master_app_id),0x01u);                     Bootloader_SetFlashByte((uint32) Bootloader_MD_BTLDB_ACTIVE_OFFSET(slave_app_id),0x00u);         Bootloader_Exit(Bootloader_MD_BTLDB_ACTIVE_0);     }     else     {         Flash(2,1000);         Bootloader_SetFlashByte((uint32) Bootloader_MD_BTLDB_ACTIVE_OFFSET(master_app_id),0x00u);                     Bootloader_SetFlashByte((uint32) Bootloader_MD_BTLDB_ACTIVE_OFFSET(slave_app_id),0x01u);                     Bootloader_Exit(Bootloader_MD_BTLDB_ACTIVE_1);       } }  
0 Likes