Freertos Build Error for Queues

Hi,
I am trying to implement Queues for my application having three tasks. Two tasks sending messages and third task will receive the messages from task 1 and task 2.

But when I build I am getting this errors.

20:52:21 **** Incremental Build of configuration Debug for project GPS_UART_1 ****
make -j4 all
arm-none-eabi-gcc “…/Core/Src/main.c” -mcpu=cortex-m4 -std=gnu11 -g3 -DUSE_HAL_DRIVER -DDEBUG -DSTM32F407xx -c -I…/Middlewares/Third_Party/FreeRTOS/Source/include -I…/Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F -I…/Drivers/CMSIS/Include -I…/Drivers/STM32F4xx_HAL_Driver/Inc -I…/Core/Inc -I…/Drivers/CMSIS/Device/ST/STM32F4xx/Include -I…/Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2 -I…/Drivers/STM32F4xx_HAL_Driver/Inc/Legacy -O0 -ffunction-sections -fdata-sections -fstack-usage -MMD -MP -MF"Core/Src/main.d" -MT"Core/Src/main.o" --specs=nano.specs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb -o “Core/Src/main.o”
arm-none-eabi-gcc -o “GPS_UART_1.elf” @“objects.list” -mcpu=cortex-m4 -T"F:\Target\STM32Proto\GPS_UART_Reception\STM32F407VGTX_FLASH.ld" --specs=nosys.specs -Wl,-Map=“GPS_UART_1.map” -Wl,–gc-sections -static --specs=nano.specs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb -u _printf_float -u _scanf_float -Wl,–start-group -lc -lm -Wl,–end-group
Core/Src/main.o: In function main': F:/Target/STM32Proto/GPS_UART_Reception/Debug/../Core/Src/main.c:238: undefined reference to xQueueCreateSet’
F:/Target/STM32Proto/GPS_UART_Reception/Debug/…/Core/Src/main.c:241: undefined reference to xQueueAddToSet' F:/Target/STM32Proto/GPS_UART_Reception/Debug/../Core/Src/main.c:242: undefined reference to xQueueAddToSet’
Core/Src/main.o: In function Serial_Receive_2': F:/Target/STM32Proto/GPS_UART_Reception/Debug/../Core/Src/main.c:467: undefined reference to xQueueSelectFromSet’
collect2.exe: error: ld returned 1 exit status
make: *** [makefile:49: GPS_UART_1.elf] Error 1
“make -j4 all” terminated with exit code 2. Build might be incomplete.

20:52:28 Build Failed. 5 errors, 0 warnings. (took 7s.366ms)

Please help me out.

Regards,
Kumar

If you are using queue sets then you must have configUSE_QUEUE_SETS set to 1 in FreeRTOSCOnfig.h.

I find the fastest way to resolve this type of error is to Google search the missing function. In this case searching “xQueueCreateSet” takes me to this page as the first search result:
https://www.freertos.org/xQueueCreateSet.html - the first line of the documentation page then tells me how to resolve the error.

Hi,
Mr. Richard. Thanks for the reply.
I have not found this flag configUSE_QUEUE_SETS set to 1 in FreeRTOSCOnfig.h.

Here is the attached file. But I added that macro in the header file. It compiled successfully.

Regards,
Kumar.FreeRTOSConfig.h (6.5 KB)

Hi,
Mr.Richard I have compiled the code successfully. But I have got no output. Here is the code.
The code blocks in LED_Task1.

#include “main.h”
#include “cmsis_os.h”
#include<stdio.h>
#include<stdint.h>
#include “FreeRTOSConfig.h”
#include “task.h”
#include “queue.h”

/* Definitions for DefaultTask_1 /
osThreadId_t DefaultTask_1Handle;
const osThreadAttr_t DefaultTask_1_attributes = {
.name = “DefaultTask_1”,
.priority = (osPriority_t) osPriorityNormal,
.stack_size = 1000
};
/
Definitions for Serial_Task_2 /
osThreadId_t Serial_Task_2Handle;
const osThreadAttr_t Serial_Task_2_attributes = {
.name = “Serial_Task_2”,
.priority = (osPriority_t) osPriorityNormal1,
.stack_size = 1000
};
/
Definitions for GPS_Task_03 /
osThreadId_t GPS_Task_03Handle;
const osThreadAttr_t GPS_Task_03_attributes = {
.name = “GPS_Task_03”,
.priority = (osPriority_t) osPriorityNormal,
.stack_size = 1000
};
/
Definitions for xQueue1 /
osMessageQueueId_t xQueue1Handle;
const osMessageQueueAttr_t xQueue1_attributes = {
.name = “xQueue1”
};
/
Definitions for xQueue2 /
osMessageQueueId_t xQueue2Handle;
const osMessageQueueAttr_t xQueue2_attributes = {
.name = “xQueue2”
};
/
USER CODE BEGIN PV /
/
Declare two variables of type QueueHandle_t. Both queues are added to the same queue set. /
static QueueHandle_t xQueue1 = NULL, xQueue2 = NULL;
/
Declare a variable of type QueueSetHandle_t. This is the queue set to which the two queues are added. */
static QueueSetHandle_t xQueueSet = NULL;

/* USER CODE END PV */

int main(void)
{
/* USER CODE BEGIN 1 */

/* USER CODE END 1 */


/* MCU Configuration--------------------------------------------------------*/

/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();

/* USER CODE BEGIN Init */

/* USER CODE END Init */

/* Configure the system clock */
SystemClock_Config();

/* USER CODE BEGIN SysInit */

/* USER CODE END SysInit */

/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_USART2_UART_Init();
MX_USART3_UART_Init();

/* USER CODE END 2 /
/
Init scheduler */
osKernelInitialize();

/* USER CODE BEGIN RTOS_MUTEX */
/* add mutexes, ... */
/* USER CODE END RTOS_MUTEX */

/* USER CODE BEGIN RTOS_SEMAPHORES */
/* add semaphores, ... */
/* USER CODE END RTOS_SEMAPHORES */

/* USER CODE BEGIN RTOS_TIMERS */
/* start timers, add new ones, ... */
/* USER CODE END RTOS_TIMERS */

/* Create the queue(s) */
/* creation of xQueue1 */
xQueue1Handle = osMessageQueueNew (16, sizeof(uint8_t), &xQueue1_attributes);

/* creation of xQueue2 */
xQueue2Handle = osMessageQueueNew (16, sizeof(uint8_t), &xQueue2_attributes);


/* Create the queue set. Two queues will be added to the set, each of which can
	contain 1 item, so the maximum number of queue handles the queue set will ever
	have to hold at one time is 2 (2 queues multiplied by 1 item per queue). */
xQueueSet = xQueueCreateSet( 1 * 2 );

/* Add the two queues to the set. */
xQueueAddToSet( xQueue1Handle, xQueueSet );
xQueueAddToSet( xQueue2Handle, xQueueSet );


/* USER CODE BEGIN RTOS_QUEUES */
/* add queues, ... */
/* USER CODE END RTOS_QUEUES */

/* Create the thread(s) */
/* creation of DefaultTask_1 */
DefaultTask_1Handle = osThreadNew(LED_Task_1, NULL, &DefaultTask_1_attributes);

/* creation of Serial_Task_2 */
Serial_Task_2Handle = osThreadNew(Serial_Receive_2, NULL, &Serial_Task_2_attributes);

/* creation of GPS_Task_03 */
GPS_Task_03Handle = osThreadNew(GPS_Task_3, NULL, &GPS_Task_03_attributes);

/* USER CODE BEGIN RTOS_THREADS */
/* add threads, ... */
/* USER CODE END RTOS_THREADS */

/* Start scheduler */
osKernelStart();

/* We should never get here as control is now taken by the scheduler */

/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
	/* USER CODE END WHILE */

	/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */

}
void LED_Task_1(void argument)
{
/
USER CODE BEGIN 5 */
const TickType_t xBlockTime = pdMS_TO_TICKS( 100 );
const char * const pcMessage = “Message from LED_Task_1 \r\n”;

/* Infinite loop */
for(;;)
{
	HAL_GPIO_TogglePin(GPIOD, GPIO_PIN_13);
	/* osDelay(100); */
	/* Block for 100ms. */
	vTaskDelay(xBlockTime);

	/* Send this task's string to xQueue1 */
	xQueueSend( xQueue1, &pcMessage, 0 );
}

osDelay(1);
/* USER CODE END 5 */

}

/* USER CODE BEGIN Header_Serial_Receive_2 /
/
*

  • @brief Function implementing the Serial_Task_2 thread.

  • @param argument: Not used

  • @retval None
    /
    /
    USER CODE END Header_Serial_Receive_2 */
    void Serial_Receive_2(void argument)
    {
    /
    USER CODE BEGIN Serial_Receive_2 */
    // HAL_UART_Receive_IT(&huart3, (uint8_t *)&pc, 1); //Restart receive interrupt

    QueueHandle_t xQueueThatContainsData;
    char *pcReceivedString;

    /* Infinite loop /
    for(;:wink:
    {
    /
    Block on the queue set to wait for one of the queues in the set to contain data.
    Cast the QueueSetMemberHandle_t value returned from xQueueSelectFromSet() to a
    QueueHandle_t, as it is known all the members of the set are queues (the queue set
    does not contain any semaphores). /
    xQueueThatContainsData = ( QueueHandle_t ) xQueueSelectFromSet( xQueueSet,portMAX_DELAY );
    /
    An indefinite block time was used when reading from the queue set, so
    xQueueSelectFromSet() will not have returned unless one of the queues in the set
    contained data, and xQueueThatContainsData cannot be NULL. Read from the queue. It
    is not necessary to specify a block time because it is known the queue contains
    data. The block time is set to 0. */
    xQueueReceive( xQueueThatContainsData, &pcReceivedString, 0 );

/* HAL_UART_Transmit_IT(&huart2, (uint8_t )pcReceivedString,strlen((const char)pcReceivedString)); //Restart Transmit Interrupt
while (HAL_UART_GetState(&huart2) == HAL_UART_STATE_BUSY_TX ||
HAL_UART_GetState(&huart2) == HAL_UART_STATE_BUSY_TX_RX); */
HAL_UART_Transmit(&huart2, (uint8_t )pcReceivedString,strlen((const char)pcReceivedString) , 100);

}
/* USER CODE END Serial_Receive_2 */
osDelay(1);

}

/* USER CODE BEGIN Header_GPS_Task_3 /
/
*

  • @brief Function implementing the GPS_Task_03 thread.

  • @param argument: Not used

  • @retval None
    /
    /
    USER CODE END Header_GPS_Task_3 */
    void GPS_Task_3(void argument)
    {
    /
    USER CODE BEGIN GPS_Task_3 */
    const TickType_t xBlockTime = pdMS_TO_TICKS( 200 );
    const char * const pcMessage = “Message from GPS_Task_3\r\n”;

    /* Infinite loop /
    for(;:wink:
    {
    /
    Block for 200ms. */
    vTaskDelay(xBlockTime);

     /* Send this task's string to xQueue2 */
     xQueueSend( xQueue2, &pcMessage, 0 );
    

    }
    /* USER CODE END GPS_Task_3 */
    osDelay(1);
    }

Please let me know any mistake I have done in the code.

But I pause the debugger the control goes to the xQueueGenericSend function

and configASSERT( pxQueue ) and it doesn’t comes out of this.

Regards,
Kumar