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

PSoC™ 5, 3 & 1 Forum Discussions

JoSa_3786491
Level 3
Level 3
First like received First like given

Hello PSOC community,

I've attached a bare bones dual application combination projects that I made. It represents the basic setting for my real project and demos the errors that I'm getting.

The issue is when I try to jump into my second application it just jumps back to the first application. There isn't much code but I'll layout the two main.c that are causing the issue.

This is main.c for the bootloader

#include "project.h"

int main(void)

{

    CyGlobalIntEnable; /* Enable global interrupts. */

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

    uint32_t status = Bootloader_1_GetMetadata(Bootloader_1_GET_BTLDB_STATUS, Bootloader_1_MD_BTLDB_ACTIVE_1);

    if (status == 1u)

        Bootloader_1_Exit(Bootloader_1_EXIT_TO_BTLDB_2);

   

    Bootloader_1_Start();

    for(;;)

    {

        /* Place your application code here. */

    }

}

basically I check to see if it going to load the second application and the explicitly exit to the second application

This is main.c for AppA the first application

// App A

#include "project.h"

#define PRESSED (1u)

#define WAITING (0u)

volatile uint8_t button1_pressed = WAITING;

CY_ISR(button1ISR)

{

    button1_pressed = PRESSED;

}

int main(void)

{

    CyGlobalIntEnable; /* Enable global interrupts. */

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

    isr_button1_StartEx(button1ISR);

   

    for(;;)

    {

        LED1_Write(0xffu);

        CyDelay(100);

        LED1_Write(0u);

        CyDelay(100);

        if (button1_pressed == PRESSED)

        {

            CyDelay(3000);

            Bootloadable_1_SetActiveApplication(Bootloadable_1_MD_BTLDB_ACTIVE_1);

            Bootloadable_1_Load();

        }

    }

}

Here I wait for a button to be pressed, then Set the active application to AppB and exit to the bootloader.

I've debugged to code and followed the Load actually loads the main.c bootloader code then exits back AppA instead of AppB.
I'm not sure what I'm doing wrong. I'm using a PSOC 5LP. Attached is the Workspace that contains the three projects Bootloader, AppA, and AppB.

Oh just for reference here is AppB's main.c

// App B

#include "project.h"

#define PRESSED (1u)

#define WAITING (0u)

volatile uint8_t button1_pressed = WAITING;

CY_ISR(button1ISR)

{

    button1_pressed = PRESSED;

}

int main(void)

{

    CyGlobalIntEnable; /* Enable global interrupts. */

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

    isr_button1_StartEx(button1ISR);

   

    for(;;)

    {

        LED1_Write(0xffu);

        CyDelay(1000);

        LED1_Write(0u);

        CyDelay(1000);

        if (button1_pressed == PRESSED)

        {

            Bootloadable_1_SetActiveApplication(Bootloadable_1_MD_BTLDB_ACTIVE_0);

            Bootloadable_1_Load();

        }

    }

}

Thanks for any help,

-Morio

0 Likes
1 Solution
JoSa_3786491
Level 3
Level 3
First like received First like given

The fix for this is to merge the AppA and AppB .elf files with cyelftool.exe -M, then use psoc programmer to upload the code to the chip.

Here is the full command.

"C:\Program Files (x86)\Cypress\PSoC Creator\4.2\PSoC Creator\bin\cyelftool.exe" -M AppA.cydsn\CortexM3\ARM_GCC_541\Debug\AppA_1.elf AppB.cydsn\CortexM3\ARM_GCC_541\Debug\AppB_2.elf DualBoot.hex --flash_size 131072 --flash_row_size 256

Further information is here https://community.cypress.com/docs/DOC-15385

I'm still having issues Bootloadable_1_SetActiveApplication, it is returning 0x09 or CYRET_CANCELED instead of 0x00 or CYRET_SUCCESS

View solution in original post

0 Likes
1 Reply
JoSa_3786491
Level 3
Level 3
First like received First like given

The fix for this is to merge the AppA and AppB .elf files with cyelftool.exe -M, then use psoc programmer to upload the code to the chip.

Here is the full command.

"C:\Program Files (x86)\Cypress\PSoC Creator\4.2\PSoC Creator\bin\cyelftool.exe" -M AppA.cydsn\CortexM3\ARM_GCC_541\Debug\AppA_1.elf AppB.cydsn\CortexM3\ARM_GCC_541\Debug\AppB_2.elf DualBoot.hex --flash_size 131072 --flash_row_size 256

Further information is here https://community.cypress.com/docs/DOC-15385

I'm still having issues Bootloadable_1_SetActiveApplication, it is returning 0x09 or CYRET_CANCELED instead of 0x00 or CYRET_SUCCESS

0 Likes