Mutex errors and chVTGetSystemTime errors

Discussions and support about ChibiOS/RT, the free embedded RTOS.
jcbless
Posts: 39
Joined: Wed Apr 16, 2025 2:29 pm
Has thanked: 6 times
Been thanked: 3 times

Mutex errors and chVTGetSystemTime errors

Postby jcbless » Fri Oct 24, 2025 11:06 pm

First, I tried adding the usage of chVTGetSystemTime() to a file in my code. Without any header files referenced I got a "undefined reference to" type error. So I tried adding #include "chvt.h". With that added I got a bunch of errors like these:

Code: Select all

../../chibios_stable-21.11.x/os/rt/include/chvt.h:74:19: error: unknown type name 'virtual_timer_t'
../../chibios_stable-21.11.x/os/rt/include/chvt.h:74:41: error: unknown type name 'sysinterval_t'
../../chibios_stable-21.11.x/os/rt/include/chvt.h:75:19: error: unknown type name 'vtfunc_t'


I would have expected that one header file to include the other header files in order to define all of those types as well as all of the other symbols in the errors. Did I pick the wrong header file? Did I need to be adding other header files?

Similarly for adding mutex functionality: I added #include "chmtx.h" and "static mutex_t mtx;".

With that I got errors such as:

Code: Select all

../../chibios_stable-21.11.x/os/rt/include/chmtx.h:58:3: error: unknown type name 'ch_queue_t'
../../chibios_stable-21.11.x/os/rt/include/chmtx.h:60:3: error: unknown type name 'thread_t'
../../chibios_stable-21.11.x/os/rt/include/chmtx.h:65:3: error: unknown type name 'cnt_t'


What sort of thing am I appearing to do wrong?

Once again this is code based on demo code with my old code added in.

User avatar
Giovanni
Site Admin
Posts: 14773
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1170 times
Been thanked: 974 times

Re: Mutex errors and chVTGetSystemTime errors

Postby Giovanni » Sat Oct 25, 2025 4:37 am

Something is missing in the Makefile, those types are fundamental.

Make sure to take a makefile from a demo then add your source code under /source (no need to add files to the makefile, anything under /source is compiled automatically).

Giovanni

jcbless
Posts: 39
Joined: Wed Apr 16, 2025 2:29 pm
Has thanked: 6 times
Been thanked: 3 times

Re: Mutex errors and chVTGetSystemTime errors

Postby jcbless » Mon Oct 27, 2025 10:52 pm

It turned out we were missing an important #include in one of our files. It was this:

Code: Select all

#include "ch.h"


That was what got the missing types included.

It should also be noted that source/ worked for our c files, but it did not work for compiling our c++ files that we had. Listing our c++ files under CPPSRC appeared to be necessary. Is there another folder which would automatically compile C++ files?

User avatar
Giovanni
Site Admin
Posts: 14773
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1170 times
Been thanked: 974 times

Re: Mutex errors and chVTGetSystemTime errors

Postby Giovanni » Tue Oct 28, 2025 9:29 am

Hi,

There is no C++ equivalent, I will look into adding .cpp and .hpp support to /source.

You could give it a try yourself, it is one of the .mk inclusions in makefiles and it is not that complex.

Giovanni


Return to “ChibiOS/RT”

Who is online

Users browsing this forum: No registered users and 26 guests