Page 1 of 1
ESP-IDF and FreeRTOS
Posted: Tue Dec 17, 2019 8:19 pm
by drmacro
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?
Re: ESP-IDF and FreeRTOS
Posted: Wed Dec 18, 2019 7:18 am
by ESP_Dazz
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
Re: ESP-IDF and FreeRTOS
Posted: Wed Dec 18, 2019 1:52 pm
by drmacro
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...
Re: ESP-IDF and FreeRTOS
Posted: Thu Dec 19, 2019 2:44 am
by ESP_Sprite
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.
Re: ESP-IDF and FreeRTOS
Posted: Thu Dec 19, 2019 3:17 pm
by drmacro
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...
Re: ESP-IDF and FreeRTOS
Posted: Fri Dec 20, 2019 5:56 am
by ESP_Sprite
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()).