PSOC6: FreeRTOS lock up when app is in DFU mode

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

cross mob
MiRo_263836
Level 5
Level 5
100 replies posted 50 likes received 50 replies posted

Trying to add OTA DFU to our project, and some parts of it are working great. The OTA DFU loader application is working perfectly and can install an image in the app 1 section. The newly flashed app starts and runs on both CM0 and CM4 as well.

The problem I'm running into is with FreeRTOS on the CM4. The CM4 starts, the initialization before starting the rtos task scheduler runs fine, but once the task scheduler starts, the core freezes up. I don't know of a way to debug the second app when its running in DFU mode, so I'm stuck trying to find what could possibly be wrong with my setup. I gave the cm4 in app 1 more ram and flash in the linker script (15000 bytes of ram and 50000 flash) but that didn't change anything. I've tried giving the freertos task more stack memory and changed the rtos heap size as well but that hasn't helped either. The final thing I tried was to give the CM4 more stack and heap, but that also didn't help. Wondering if there's anything left I can try. The example I based this code off was CE216767 for reference.

0 Likes
1 Solution
AdCr_4275466
Level 1
Level 1
First like received

I was in contact with OP about this topic and found out the problem.

The first was redirection the start address of the CM4 code which was fixed in the second reply here.

The other problem was not enough RAM allocation. I was using a custom linker script and forgot to update the ones used for DFU instead of the original ones, leaving me with a tiny fraction of the RAM needed to run the FreeRTOS task scheduler. I believe I needed 1024*48 bytes allocated in FreeRTOS.h and without increasing the RAM in the linker script for app1, the script would fail on the stack over ram check.

All is solved now however and the program works perfectly!

View solution in original post

3 Replies
ShipingW_81
Moderator
Moderator
Moderator
500 replies posted 250 solutions authored 250 replies posted

Did you use costom FW or code example? Have you ever tried any FreeRTOS code example as DFU app1?

I will also try to test this case, and show you my test result.

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

I have tried out a FreeRTOS code example under DFU mode and there is no any problem. Did you get this working?

For cm4 successful start in DFU app1, note change below line in main_cm0p.c

Cy_SysEnableCM4(CY_CORTEX_M4_APPL_ADDR);

to

Cy_SysEnableCM4(&__cy_app_core1_start_addr);

0 Likes
AdCr_4275466
Level 1
Level 1
First like received

I was in contact with OP about this topic and found out the problem.

The first was redirection the start address of the CM4 code which was fixed in the second reply here.

The other problem was not enough RAM allocation. I was using a custom linker script and forgot to update the ones used for DFU instead of the original ones, leaving me with a tiny fraction of the RAM needed to run the FreeRTOS task scheduler. I believe I needed 1024*48 bytes allocated in FreeRTOS.h and without increasing the RAM in the linker script for app1, the script would fail on the stack over ram check.

All is solved now however and the program works perfectly!