ESP-IDF and FreeRTOS

drmacro
Posts: 26
Joined: Tue Dec 25, 2018 8:25 pm

ESP-IDF and FreeRTOS

Postby drmacro » Tue Dec 17, 2019 8:19 pm

I've been reading up in the FreeRTOS documentation about how to use things like, for example, the startup hook daemon.

It says to set configUSE_DAEMON_TASK_STARTUP_HOOK = 1 in the FreeRTOSConfig.h file.

This value does not appear in ./framework-espidf/components/freertos/include/freertos/FreeRTOS.h or FreeRTOSConfig.h.

Does the ESP-IDF not include these features?

ESP_Dazz
Posts: 308
Joined: Fri Jun 02, 2017 6:50 am

Re: ESP-IDF and FreeRTOS

Postby ESP_Dazz » Wed Dec 18, 2019 7:18 am

ESP-IDF does not include this feature because this feature was added in FreeRTOS V9.0.0rc1. ESP-IDF FreeRTOS is based on FreeRTOS v8.2

drmacro
Posts: 26
Joined: Tue Dec 25, 2018 8:25 pm

Re: ESP-IDF and FreeRTOS

Postby drmacro » Wed Dec 18, 2019 1:52 pm

So, ESP-IDF is 2 versions behind freertos.

I searched this forum and couldn't find any discussion of freertos referring to plans for updating freertos.

Makes learning freertos a bit more challenging trying to translate tutorials and examples backward to version 8. :(

I started looking at this because I wanted to use the daemon hook to ensure startup sequences get executed before task start to run... :?

Oh well...

ESP_Sprite
Posts: 9580
Joined: Thu Nov 26, 2015 4:08 am

Re: ESP-IDF and FreeRTOS

Postby ESP_Sprite » Thu Dec 19, 2019 2:44 am

Note that you may get the same effect (code run before FreeRTOS starts) by defining your function as a constructor:

Code: Select all

void __attribute__((constructor)) my_function(void) {
    ...
}
Make sure that the C file where you put this function in has something (another function or a variable or symbol) that gets referenced by the rest of the code, though, otherwise the linker will ignore your file thinking it's never used.

drmacro
Posts: 26
Joined: Tue Dec 25, 2018 8:25 pm

Re: ESP-IDF and FreeRTOS

Postby drmacro » Thu Dec 19, 2019 3:17 pm

ESP_Sprite wrote:
Thu Dec 19, 2019 2:44 am
Note that you may get the same effect (code run before FreeRTOS starts) by defining your function as a constructor:

Code: Select all

void __attribute__((constructor)) my_function(void) {
    ...
}
Make sure that the C file where you put this function in has something (another function or a variable or symbol) that gets referenced by the rest of the code, though, otherwise the linker will ignore your file thinking it's never used.
I'll have to google that...I'm not familiar with the use of constructors in non-object oriented languages...

ESP_Sprite
Posts: 9580
Joined: Thu Nov 26, 2015 4:08 am

Re: ESP-IDF and FreeRTOS

Postby ESP_Sprite » Fri Dec 20, 2019 5:56 am

It may be a gcc extension to C, I don't know, but it works the same as static c++ constructors. The net effect is that functions marked like this are collected by the linker and their addresses are put in a list (__init_array_start to _end) in the final binary. In the startup code in esp-idf/components/esp32/cpu_start.c, we then execute all of them (in do_global_ctors()).

Who is online

Users browsing this forum: Google Adsense [Bot] and 163 guests