Setting up freeRTOS for SAME70Q21

I’m trying to setup freeRTOS on SAME70Q21 but without using an IDE. I’m using gcc to compile my code.
I have added the freeRTOS source code into my project
Screenshot 2023-03-30 at 10.53.51

I have a FreeRTOSConfig.h and also updated my make file

CFLAGS += -I$~/firmware/lib/Source
CFLAGS += -I$~/firmware/lib/Source/include
CFLAGS += -I$~/firmware/lib/Source/portable/GCC/ARM7_AT91SAM7S

in my main.c file, I have something simple

int main( void )
	vTaskDelay(1000 / portTICK_PERIOD_MS);
    for( ;; );

just to test if it’s working.
however, I get the following error main.c:(.text.main+0xe): undefined reference to ‘vTaskDelay’`

Seems you didn’t add the FreeRTOS sources (*.c files) to your makefile yet.

I thought this should be enough?
CFLAGS += -I$~/firmware/lib/Source

Also, check if the macro INCLUDE_vTaskDelay is defined as 1 in FreeRTOSConfig.h. Please check This page describes the RTOS vTaskDelay() FreeRTOS API function which is part of the RTOS task control API. FreeRTOS is a professional grade, small footprint, open source RTOS for microcontrollers. for more info.

The -I is for include paths. Please have a look at one of the FreeRTOS demo examples based on Makefile.

I want to add a bit of an explanation to what @hs2 and @urutva have already mentioned - which is the cause of your problem.

The -I option is for including directories of header files (doc). This option does not include source code .c files into your project. While this error message is specifically telling you that the code isn’t defined, it isn’t warning you that the function is undeclared. An undeclared warning would suggest that the function declaration - present in a header file - is missing. In your case, you’re including the headers, so it’s not missing. Undefined errors suggest that the implementation (or definition) of the function is missing. This definition will be present in the source file.

The Makefile mentioned above includes the source files when compiling by compiling all of the source files into the executable/binary/image at once. Line 105-106 expands to compile all of the OBJ_FILES. The SOURCE_FILES are added to the OBJ_FILES on line 98.

I hope you find this helpful. Feel free to reach back out if you continue to have issues with your FreeRTOS project :slight_smile:

1 Like