BLE OTA Bootloader and Cy_BLE_RegisterAppHostCallback

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

cross mob
RuHe_1008296
Level 3
Level 3
5 replies posted 5 questions asked First reply posted

Hey

I have a BLE project using rtos and PSoC 6. By following the example in CE222604 i was able to create a application having the BLE running in dual core mode, using the Cy_BLE_RegisterAppHostCallback, to make the M0+ notify the M4 when it needs to call Cy_BLE_ProcessEvents().  This works like a charm.

Now I wanted to include the ability to do OTA firmware update for the system. So i took the example CE220960 that shows how to make a bootloadable project with a upgradable stack. This also almost works   I am able to program with only the stack application an everything seems fine. I can upload the main application and it starts as expected. But the device does never start advertising. Also I can see that my host callback never gets called. This I suspect is the problem.  So i tried to hardcode a call to Cy_BLE_ProcessEvents() in the main loop, and now it works. So i did a little digging. 

The function Cy_BLE_RegisterAppHostCallback saves the callback to a variable, and i do not think this is the same as the stack application is trying to call in the IPC call.

The stack project calls Cy_BLE_IPC_HostRegisterClientCallbacks, and have the function

static void Cy_BLE_IPC_HostMsgRecvCallBack(uint32_t *msgPtr)

{

    if(msgPtr != NULL)

    {

        /* Call the BLE Stack IPC handler */

        Cy_BLE_IPC_HostMsgRecvStackHandle(msgPtr);

    }

    /* Call the application IPC notification handler */

    if(Cy_BLE_HostRegisteredCallback != NULL)

    {

        Cy_BLE_HostRegisteredCallback();

    }

}

When the main application project is building it seems like it is creating its own version of the Cy_BLE_HostRegisteredCallback, so when the IPC callback is called it is not directed to the Cy_BLE_HostRegisteredCallback of my main application.

How do I make it so Cy_BLE_HostRegisteredCallback is part of the stack, and is updated properly using the Cy_BLE_RegisterAppHostCallback function?

0 Likes
1 Solution

I have configured the two ble componet to be dual core, and i have followed the appendix A in CE220960 on how to configure the stack and application for dual core mode.

I have found a solution for my problem though. The solution i ended up using until such a time that the true error is located is:

1. In the stack application i create a function called BLE_BUG_FIX_RegisterAppHostCallback all it is doing is calling a function:

void BLE_BUG_FIX_RegisterAppHostCallback(cy_ble_app_notify_callback_t callback)

{

    Cy_BLE_RegisterAppHostCallback(callback);

}

2. I add the function to the symole file, and in the bootload_cm4.ld so the function is not removed by the complier and so the profile application can call it.

3. In the profile application i can now call the BLE_BUG_FIX_RegisterAppHostCallback  instead of the Cy_BLE_RegisterAppHostCallback, and that is it.

When i use this method my callback is correctly triggered, and this enables me to process the BLE event on demand from the M0 core. This fixes my issues.

View solution in original post

0 Likes
2 Replies
ShipingW_81
Moderator
Moderator
Moderator
500 replies posted 250 solutions authored 250 replies posted

I guess this issue should be nothing with the Cy_BLE_HostRegisteredCallback, as you mentioned the device can never get start advertising. The BLE stack is possibly updated incorrectly.

Did you develop your OTA project based on app0/app1 from CE220960 directly?

If yes, please note the BLE component must run on the same CPU core for the stack(app1) and user application(app2) projects. The whole BLE stack runs only on cm0+ in app1 of CE220960 by default, you have to modify it to adapt to both cores to get consistent with user application.

0 Likes

I have configured the two ble componet to be dual core, and i have followed the appendix A in CE220960 on how to configure the stack and application for dual core mode.

I have found a solution for my problem though. The solution i ended up using until such a time that the true error is located is:

1. In the stack application i create a function called BLE_BUG_FIX_RegisterAppHostCallback all it is doing is calling a function:

void BLE_BUG_FIX_RegisterAppHostCallback(cy_ble_app_notify_callback_t callback)

{

    Cy_BLE_RegisterAppHostCallback(callback);

}

2. I add the function to the symole file, and in the bootload_cm4.ld so the function is not removed by the complier and so the profile application can call it.

3. In the profile application i can now call the BLE_BUG_FIX_RegisterAppHostCallback  instead of the Cy_BLE_RegisterAppHostCallback, and that is it.

When i use this method my callback is correctly triggered, and this enables me to process the BLE event on demand from the M0 core. This fixes my issues.

0 Likes