Error Demo FreeRTOS on ZCU106

Hello,

I am using the FREERTOS Demo for ZCU106 (Xilinx Zynqmp) running on R5, I managed to build it correctly using vitis and the blinky demo works fine, however, when running the full Demo, I always receive the following error

Pass, status code = 0, tick count = 5003
Error: Reg Test 2, status code = 1572866, tick count = 10003
ASSERT! Line 357 of file …/RTOSDemo_R5/src/Full_Demo/main_full.c

I do not know the meaning of the error and the meaning of the status code. Can you please help me figure out the problem?
I know the demo is targeting zcu102, but as far as I observed nothing needs to be changed in the FREERTOS_Config.h file, is that correct too?

Hello shrief: in this function prvCheckTask(), you see a series of tests. At the bottom (line 357) there is a call to configASSERT():

    /* Output the system status string. */
    xil_printf( "%s, status code = %lu, tick count = %lu\r\n",
        pcStatusString, ulErrorFound, xTaskGetTickCount() );

    configASSERT( ulErrorFound == pdFALSE );

Here you find help about configASSERT: https://www.freertos.org/a00110.html#configASSERT
Apparently, one of the tests has failed. The output will show which test failed. Or, if you can step through the code, you can check the value of ulErrorFound.

Hello @htibosch, thanks for your reply.

Yes, you are right. I have already done that but I do not understand what the error means or what is causing it. The following code returns the error, but only in the second time it is run

/* Check that the register test 2 task is still running. */
if( ulLastRegTest2Value == ulRegTest2LoopCounter )
{
ulErrorFound |= 1UL << 20UL;
pcStatusString = “Error: Reg Test 2”;
}

The value of ulErrorfound=0x00180002, but I also do not know what it means.

Do you know what this does: ulErrorFound |= 1UL << 20UL?
It sets the 20th bit in a variable called ulErrorFound.
The 20th bit can also be expressed as a hex number0x00100000.
Now can you find out which other bits are set in 0x00180002?
Hint, 3 errors have occurred.
It looks like you would do good to get a book about C that also has exercises.
I learned it most from K&R, but that is extremely old by now :slight_smile:

But if you want to know what the individual errors mean, you will have to dive into the source code. I don’t know that neither.

perhaps a bit of misunderstanding here. The code I am showing is from the Demo of the FreeRTOS package, which I assume should be working without modifications from my side.
I do understand how this code snippet is changing the value of the variable, but the meaning of the error is not explained anywhere, that’s why I would like to understand the meaning or the cause of the error to fix it

perhaps a bit of misunderstanding here

It looks like it, and I am sorry if I understood you wrong.

All I see is that these 3 tests have failed on your board:

0x000002 : xAreMathsTaskStillRunning() 
0x080000 : Check that the register test 1 task is still running
0x100000 : Check that the register test 2 task is still running

But I’m afraid that you will have to do some debugging to see why the tests do not succeed. Maybe the tasks were never started? Maybe there was a heap problem?
Hein

No problem, thanks for your help.

Can you please tell me from where did you get the meaning of these error flags? is it on the website?
Additionally, is there a deeper description for the meaning of register test 1 and 2?

I’m not sure which demo you are running, but the links below are for the Cortex-R core of the Zynq Ultrascale.

The reg test tasks are described here: https://github.com/FreeRTOS/FreeRTOS/blob/master/FreeRTOS/Demo/CORTEX_R5_UltraScale_MPSoC/RTOSDemo_R5/src/Full_Demo/main_full.c#L55

The task that is ensuring all the other tasks, including the reg test tasks, are executing without error is called the ‘check’ task. It is described here: https://github.com/FreeRTOS/FreeRTOS/blob/master/FreeRTOS/Demo/CORTEX_R5_UltraScale_MPSoC/RTOSDemo_R5/src/Full_Demo/main_full.c#L62

The loop that implements the check task, with a little explanation, is here: https://github.com/FreeRTOS/FreeRTOS/blob/master/FreeRTOS/Demo/CORTEX_R5_UltraScale_MPSoC/RTOSDemo_R5/src/Full_Demo/main_full.c#L246

The variable in which errors are latched, one bit position per error, is initialised to false (0) here: https://github.com/FreeRTOS/FreeRTOS/blob/master/FreeRTOS/Demo/CORTEX_R5_UltraScale_MPSoC/RTOSDemo_R5/src/Full_Demo/main_full.c#L228

The loop in the check task monitors a whole load of different tests, including the reg test tasks, and sets a bit in the error code variable if any fail. So if the error code is not zero, then at least one error has been found. In most cases the error is a false positive, not a real error, and will be because something in the timing changed since the demo/test was created: https://github.com/FreeRTOS/FreeRTOS/blob/master/FreeRTOS/Demo/CORTEX_R5_UltraScale_MPSoC/RTOSDemo_R5/src/Full_Demo/main_full.c#L357

A little more, although slightly outdated info, is found on the FreeRTOS.org site, for example: https://www.freertos.org/a00102.html

Thanks a lot @rtel for the clarification. However, it is still not clear for me how to fix the errors that I am seeing. I am using the same demo project as per the links you sent. I keep getting the same 3 errors with xAreMathsTaskStillRunning() and Reg test 1 and 2. Any ideas what would be the reason they are not running correctly?

I don’t know for sure, but would guess the two failures would be related as both could indicate corrupted register values during context switches. Try taking out the maths tasks by commenting out these two calls and see if the reg test tasks still fail:

vStartMathsTask() https://github.com/FreeRTOS/FreeRTOS/blob/master/FreeRTOS/Demo/CORTEX_R5_UltraScale_MPSoC/RTOSDemo_R5/src/Full_Demo/main_full.c#L188

vAreMathsTasksStillRunning() - comment out the whole if() block = https://github.com/FreeRTOS/FreeRTOS/blob/master/FreeRTOS/Demo/CORTEX_R5_UltraScale_MPSoC/RTOSDemo_R5/src/Full_Demo/main_full.c#L254

ok, I commented them as per your suggestion. The reg test tasks still fail

Pass, status code = 0, tick count = 5000
Error: Reg Test 2, status code = 1572866, tick count = 10000
Error: Reg Test 2, status code = 1572866, tick count = 15000
Error: Reg Test 2, status code = 1572866, tick count = 20000
Error: Reg Test 2, status code = 1572866, tick count = 25000

I would appreciate any further suggestions. Thanks!

@rtel It seems that the main problem lies in the floating point calculations. I can see that the portTASK_FUNCTION(s) in flop.c are failing. It only works correct the first time, but it fails after that. I am using the vfpv3-d16 flag during compilation and portTASK_USES_FLOATING_POINT() is called before the task. Not sure where the problem is. Would you have any ideas?

Depending on the compiler, you may find the standard library is using the floating point registers to optimise memory moves, which would require every task to have a floating point context. You can get around that in two ways, first is to provide your own implementations of things like memcpy() and memset() (and check the generated asm code for them, you may also have to use the ‘no-builtin’ compiler option), or give every task a floating point context. The easiest way to do the latter is to set configUSE_TASK_FPU_SUPPORT to 2 in FreeRTOSConfig.h.

Hi @shrief,

Did you ever solve this issue?

I’m having the exact same case with R5 on ZCU104 board. Xilinx SDK v2019.1, FreeRTOS v10.3.1 and RTOSDemo_R5 application project imported on top of own base design and standalone bsp.

Blinky demo works, but full demo gives same error code for math tasks + both register tests after 10000 ticks.

I disabled math tasks and added configUSE_TASK_FPU_SUPPORT 2 to FreeRTOSConfig.h as it was missing it. No effect.

I would really like to know if this is a real issue or demo effect. I’m planning on using the CLI and a couple of control algorithm and sensor tasks so would be good to know that the math is not going to keep on failing.

Thanks,
Harri

Hi @harahika,

unfortunately, the solution also did not work for me. It still gives the same error.
There seems to be a problem in the Demo itself, but I did not find it.

Best regards,
Shrief