This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

FreeRTOS compilation issues with nRF52820

Hello,

I am working on nRF52820 custom development board with nRF5 SDK 17.0.2. I am using FreeRTOS and I experienced a lot of problems with compiling a simple project. I've found the issue inside FreeRTOS port, but I cannot find any ticket system, so I am filling a bug report here. nRF52820 does not have FPU unit, so popping FPU registers to RTOS won't work at all, because compiler has no idea about vstmdbeq and vldmiaeq assembler instructions. To fix the compilation problems change the following in nRF5 SDK/external/freertos/portable/GCC/nrf52/port.c:

void xPortPendSVHandler( void )
{
    __asm volatile
    (
    "   mrs r0, psp                         \n"
    "   isb                                 \n"
    "                                       \n"
    "   ldr r3, =pxCurrentTCB               \n" /* Get the location of the current TCB. */
    "   ldr r2, [r3]                        \n"
#if (__FPU_PRESENT == 1U) && (__FPU_USED == 1U) /// ADD THIS LINE
    "   tst r14, #0x10                      \n" /* Is the task using the FPU context?  If so, push high vfp registers. */
    "   it eq                               \n"
    "   vstmdbeq r0!, {s16-s31}             \n"
#endif                                          /// ADD THIS LINE
    "                                       \n"
    "   stmdb r0!, {r4-r11, r14}            \n" /* Save the core registers. */
    "                                       \n"
    "   str r0, [r2]                        \n" /* Save the new top of stack into the first member of the TCB. */
    "                                       \n"
    "   stmdb sp!, {r3}                     \n"
    "   mov r0, %0                          \n"
    "   msr basepri, r0                     \n"
    "   dsb                                 \n"
    "   isb                                 \n"
    "   bl vTaskSwitchContext               \n"
    "   mov r0, #0                          \n"
    "   msr basepri, r0                     \n"
    "   ldmia sp!, {r3}                     \n"
    "                                       \n"
    "   ldr r1, [r3]                        \n" /* The first item in pxCurrentTCB is the task top of stack. */
    "   ldr r0, [r1]                        \n"
    "                                       \n"
    "   ldmia r0!, {r4-r11, r14}            \n" /* Pop the core registers. */
#if (__FPU_PRESENT == 1U) && (__FPU_USED == 1U) /// ADD THIS LINE
    "   tst r14, #0x10                      \n" /* Is the task using the FPU context?  If so, pop the high vfp registers too. */
    "   it eq                               \n"
    "   vldmiaeq r0!, {s16-s31}             \n"
#endif                                          /// ADD THIS LINE
    "                                       \n"
    "   msr psp, r0                         \n"
    "   isb                                 \n"
    "                                       \n"
    "                                       \n"
    "   bx r14                              \n"
    "                                       \n"
    "   .align 2                            \n"
    ::"i"(configMAX_SYSCALL_INTERRUPT_PRIORITY  << (8 - configPRIO_BITS))
    );
}

The compilation problems regarding FPU should be gone.

Can you guys confirm if this is really a bug and will be fixed in future releases?

Greetings,

Bartosz

Parents Reply Children
No Data
Related