cancel
Showing results for 
Search instead for 
Did you mean: 

Undefined reference to osMessageGet/Put from cmsis_os.h [STM32CubeIDE]

ACeli.1
Associate

Hello everyone,

So I am currently following: https://www.youtube.com/watch?v=Iyc0vk4jG1E&list=PLnMKNibPkDnFeFV4eBfDQ9e5IrGL_dx1Q&index=14

I am using STM32CubeIDE with a Windows 10 machine.

I used the IDE to generate code for 1 queue, and 2 tasks.

I have been getting undefined reference errors for "osMessageGet" and "osMessagePut":

0693W000000WN8gQAG.png

I have "#include "cmsis_os.h"" at the top of my "main.c", yet I am still continuing to get these errors.

Has anyone run into this problem before? I am confused as to why I am getting this error if I include the file properly, and the link to the header file is part of the path in my project configuration.

Thank you for your help!

-Augusto

5 REPLIES 5
TDK
Guru

The definitions are there, but the linker is saying it can't find those objects. It looks like cmsis_os.c is not being compiled.

If you feel a post has answered your question, please click "Accept as Solution".

Is there a way you know if I can check that?

Zidxein
Associate

I ran into this issue using CMSIS v2.

I think there are 2 solutions:

  • Change to CMSIS v1 (using CubeMX - Go to System view, select FREERTOS, and inside Config parameters change FreeRTOS API to CMSIS v1) (I did not test this as my application will use v2.)
  • Use CMSIS v2 using functions osMessageQueuePut and osMessageQueueGet instead of the original osMessagePut or osMessageGet which are for CMSIS v1.

If you decide to use CMSIS v2, here is a way to make the sample code in the video work:

Sample Sender1:

void StartSender1(void *argument)
{
  /* USER CODE BEGIN StartSender1 */
	struct MsgPrio {
		uint8_t message;
		uint8_t priority;
	} tx;
 
	tx.message = 0x01;
	tx.priority = 0;
 
  /* Infinite loop */
  for(;;)
  {
	  printf("Task1\n");
	  osMessageQueuePut(Queue1Handle, &tx.message, tx.priority, 200);
	  printf("Task1 delay\n");
	  osDelay(1000);
  }
  /* USER CODE END StartSender1 */
}

Sample Receiver:

void StartReceiver(void *argument)
{
  /* USER CODE BEGIN StartReceiver */
 	uint8_t buffer_get[1];
  /* Infinite loop */
  for(;;)
  {
	  printf("Task2\n");
	  osMessageQueueGet(Queue01Handle, &buffer_get, NULL, 4000);
	  printf("Received: %d\n", (int)buffer_get[0]);
  }
  /* USER CODE END StartReceiver */
}

Thank you for this additional information

JC

Not applicable

Hello I'm having similar problems, I'm trying to create a new USB Host MSC project (USBdisk), I noticed that the sample library uses version 1 of RTOS.

Here is a website that talks a little more about these differences:

https://arm-software.github.io/CMSIS_5/RTOS2/html/os2MigrationFunctions.html

0693W000004IHlpQAG.png

Hello @Ons KOOLI​ , how are you?

If possible, please update the projects with native examples for STM32CubeIDE and RTOS V2.

It would be very useful if STM updates these examples with STM32CubeIDE and RTOS V2.

It takes time for the new user to find the differences and also prevents new questions about the differences from being created. Thank you.