Undefined reference to xTaskCreate()

I’m using PlatformIO to run a FreeRTOS code on the Nexys RISC-V framework. Shown below is the platformio.ini file:

[env:swervolf_nexys]
platform = chipsalliance
board = swervolf_nexys
framework = wd-riscv-sdk, freertos
debug_tool = whisper

Here’s my program:

#include "FreeRTOS.h"

#include "task.h"

#include <bsp_printf.h>

#include <bsp_mem_map.h>

#include <bsp_version.h>

void vTask1(void *pvParameters);

void vTask2(void *pvParameters);

int main(void)

{

    

    xTaskCreate(&vTask1, "Task 1", 1024, NULL, 1, NULL);

    xTaskCreate(&vTask2, "Task 2", 1024, NULL, 1, NULL);

    vTaskStartScheduler();

    return 0;

}

void vTask1(void *pvParameters)

{

    for (;;)

    {

        printfNexys("Task 1\r\n");

        vTaskDelay(pdMS_TO_TICKS(1000));

    }

    vTaskDelete(NULL);

}

void vTask2(void *pvParameters)

{

    for (;;)

    {

        printfNexys("Task 2\r\n");

        vTaskDelay(pdMS_TO_TICKS(1000));

    }

    vTaskDelete(NULL);

}

I’m getting the below error:
task_code.c:14: undefined reference to `xTaskCreate’

Please help me resolve this issue.

Undefined reference to xTaskCreate means you didn’t compile and link the related FreeRTOS source files (in this case tasks.c) to your program. You need to setup your build environment correctly.

To my knowledge the source files have been compiled. But where should they be located in PlatformIO to compile ?

Sorry - I’m not familiar with PlatformIO. But isn’t there a working demo you could check or use as starting point ?

Yes, there exists a working demo and that was running fine. However when I tried to compile my own code, I wasn’t able to.

The undefined reference error most likely comes from the linker, so you appear to have problems with your linker setup.

I don’t have much knowledge about the linker setup. Could you help me with that?

@vinceab : I found a demo for the same board over on this github.

Could you try replacing the following line in your platform.ini

[env:swervolf_nexys]

with

[env:rvfpga]

Thanks much,
Paul

It’s still not compiling. The demo used in the GitHub repo. did not use the FreeRTOS header files. It created its own custom source files.

Do you have configSUPPORT_DYNAMIC_ALLOCATION set in your FreeRTOS config?