I’m getting the below error:
task_code.c:14: undefined reference to `xTaskCreate’
Please help me resolve this issue. The demo present for FreeRTOS seemed to be working fine. However, when I trie dto compile my own code, error was observed.
First of all: One is not supposed to use the FreeRTOS functions like xTaskCreate directly. The SDK has the RTOSAL (RTOS-abstraction-layer) which provides you with functions like
under the hood, they call the right function for the selected underlying RTOS (FreeRTOS, ThreadX, etc.)
So you should really be using rtosalTaskCreate instead of xTaskCreate(). All other direct FreeRTOS calls should also be replaced by the rtosal calls.
And lastly: Due to the FreeRTOS configuration that is done in the SDK
The function xTaskCreate is not available since it dynamically allocates the stack memory of the task. That means you can use xTaskCreateStatic() as in
However, above is untested and might not work because it does not do the correct interrupt handler initialization as shown in the original implementation as well the timer period calculation per demo code.
I have tried to active the dynamic allocation support (build_flags = -DconfigSUPPORT_DYNAMIC_ALLOCATION=1 in the platformio.ini plus changing the above config file), but that one gives just errors about the heap functions not being available (from e.g. heap_3.c)
c:/users/max/.platformio/packages/toolchain-riscv/bin/../lib/gcc/riscv64-unknown-elf/8.3.0/../../../../riscv64-unknown-elf/bin/ld.exe: .pio\build\swervolf_nexys\libFreeRTOS.a(tasks.o): in function `xTaskCreate':
tasks.c:(.text.xTaskCreate+0x1a): undefined reference to `pvPortMalloc'
c:/users/max/.platformio/packages/toolchain-riscv/bin/../lib/gcc/riscv64-unknown-elf/8.3.0/../../../../riscv64-unknown-elf/bin/ld.exe: tasks.c:(.text.xTaskCreate+0x2a): undefined reference to `pvPortMalloc'
c:/users/max/.platformio/packages/toolchain-riscv/bin/../lib/gcc/riscv64-unknown-elf/8.3.0/../../../../riscv64-unknown-elf/bin/ld.exe: tasks.c:(.text.xTaskCreate+0x62): undefined reference to `vPortFree'
And that would need more additions to work. I wouldn’t recommend changing the SDK files, just use what the SDK provides you.