vinceab
(Vincent Abraham)
August 28, 2021, 6:49am
1
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.
hs2
(Hartmut Schaefer)
August 28, 2021, 8:03am
2
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.
vinceab
(Vincent Abraham)
August 28, 2021, 8:27am
3
To my knowledge the source files have been compiled. But where should they be located in PlatformIO to compile ?
hs2
(Hartmut Schaefer)
August 28, 2021, 8:48am
4
Sorry - I’m not familiar with PlatformIO. But isn’t there a working demo you could check or use as starting point ?
vinceab
(Vincent Abraham)
August 28, 2021, 8:59am
5
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.
RAc
August 28, 2021, 9:19am
6
The undefined reference error most likely comes from the linker, so you appear to have problems with your linker setup.
vinceab
(Vincent Abraham)
August 28, 2021, 9:36am
7
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
vinceab
(Vincent Abraham)
September 3, 2021, 6:37am
9
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.
archigup
(Archit Gupta)
September 14, 2021, 12:38am
10
Do you have configSUPPORT_DYNAMIC_ALLOCATION set in your FreeRTOS config?
Torey
(Dooley)
September 24, 2021, 3:30pm
11
XTaskCreate()/xTaskGenericCreate() are base functions that are always included no matter what the configuration of the system so the only thing that comes to mind is that you are not building the source file that contains the function’s definition. Are you building FreeRTOS/Source/tasks.
RAc
September 24, 2021, 3:38pm
12
This is not C++ code by any chance? If so you need to wrap your #includes into an extern “C” declaration.
XTaskCreate needs configSUPPORT_DYNAMIC_ALLOCATION = 1 (which is the default) to be present.
You also needs tasks.c to be part of the project.