-
Notifications
You must be signed in to change notification settings - Fork 7.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parametrize some FreeRTOS config fields (configIDLE_SHOULD_YIELD and configUSE_PREEMPTION) (IDFGH-6716) #8345
Comments
There are some IDF system level considerations that force most (if not all) FreeRTOS configurations to be hardcoded. We've already made
|
Thanks for the answer @Dazza0 . I understand the Regarding the I have tried (in order to avoid changing the I'm assuming that the warnings are already preventing to use 'sched_yields' and similars in this hooks. Carles |
Any news on that? |
Hi @carlessole , There is a way to force the macros that you want when compiling ESP-IDF without modifying ESP-IDF. Let's take the example Edit its
Right after This will force the inclusion of the file Thus, we need to create that file, #pragma once
// Force the inclusion of FreeRTOS config to make sure we can redefine any macro right after
#include "freertos/FreeRTOSConfig.h"
// New value for configIDLE_SHOULD_YIELD
#undef configIDLE_SHOULD_YIELD
#define configIDLE_SHOULD_YIELD 1 Now you can compile IDF, your new macro will be taken into account for all sources, including FreeRTOS' |
@carlessole I'm still hesitant to expose I'm also open to allowing users to override FreeRTOS config (but not exposing them as Kconfig options). One method is described above by @o-marshmallow. But, adding something like user provided |
@o-marshmallow Thanks!! It is really a nice way to override some symbols in ESP-IDF without modifying its source code :). But anyway, I need to be sure that if 'configIDLE_SHOULD_YIELD' is '1', all the architecture is readyy to support that. |
@Dazza0 I understand it. I will try to expose my reasons to wanting that. Main reason is that we are migrating many existing projects from another microcontroller to ESP32. Then all the code is already done and it is expecting a certain scheduler behavior. They are big projects that involves many and many files. Then, regarding 'configUSE_PREEMPTION': All the existing code supposes that if no 'delay(n)' or 'sched_yield()' is called, no one can take the control of a running task. Then many data structures shared between tasks are not well protected with 'mutexes' or 'semaphores' as 'configUSE_PREEMPTION = 0' was a precondition. That has been solved protecting them with 'mutexes' and 'semaphores', but anyway keeping the same behavior as the old scheduler (which one has been taken as reference to develop ALL the existing code) should be very nice for us. As I said I understand that many ESP-IDF components have been created with 'configUSE_PREEMPTION = 1' in mind, so, not big deal about not being able to change this option ('configUSE_PREEMPTION') Regarding 'configIDLE_SHOULD_YIELD': The existing projects have many tasks running (about 20). None of them perform a 'delay(n)', they just perform and 'sched_yield()', that means that once a tasks gives away the uP control, the task is immediately ready again to enter (it is placed in the scheduler queue). To achieve that all the tasks have the same priority (the IDLE task priority). The refresh time of each task has been calculated with oscilloscope and in the old platform it was OK as there were no tasks that keeps running too much time. So it is very important that IDLE tasks can yield once they have finished their job and not waiting until a freeRTOS tick happens (see here). |
@Dazza0 Any feedback on that? Thanks! |
Why has this not been worked on and is now unassigned? Specifically the tickless idle will only go to sleep when "The Idle task is the only task able to run because all the application tasks are either in the Blocked state or in the Suspended state" and the sleep will exceed the minimum based on ESP-IDF changing the value of There are parts of ESP-IDF code that are not RTOS compliant yet cannot currently be run as priority 0 tasks because of this wrong configuration setting for idle yield. One example is in examples/phy/cert_test where some RF commands require running and do a frequent yield but should not be delayed in running or they will not work properly. The cert_test code sets the priority of tasks to 2 but that requires the task watchdog timer to be disabled (which that example project says to do) which is the wrong way to address this. If the RF task were at priority 0, it yields to the idle task properly so the watchdog timer gets tickled/fed but the ESP-IDF setting of A related problem with ESP-IDF not being RTOS compliant is for the ESP32-C3 where for some reason the USB serial/JTAG is using a non-blocking driver instead of using a blocking driver. That leads to bad loop code polling serial if one is parsing for such input. Yet the console component installs a blocking driver which is the right thing to do where one would use a blocked read in a task (so would get blocked) so why isn't this the default so that developers are given strong incentive to write RTOS compliant code? FYI, the ONLY reason to set Also FYI, the only other place I found (so far) in ESP-IDF code that is not RTOS-compliant is in flash erase that uses a vTaskDelay(1) call in a polling loop looking at a status register. Here again there should be an interrupt when Flash is done erasing so one should be blocking until that interrupt. Nevertheless, this vTaskDelay is still better than a yield that won't give lower priority tasks any time. It's just an inefficient forced blocking for a 1 tick interval. |
After some discussion we agree that having For the reasons already stated, we do not at this moment plan to support turning of preemption, but please feel free to continue leaving comments/thumbsups in this issue if you feel this is an important feature. If there is a big demand for this then we can always reconsider the request at a later date. |
Hello,
I have seen that almost all the freeRTOS config fields (defined in FreeRTOSConfig.h) are hardcoded and can not be modified (not by sdkconfig and as far as I know, this file is recommended to not modify it, right?).
I see that in master branch is the same: https://github.com/espressif/esp-idf/blob/master/components/freertos/esp_additions/include/freertos/FreeRTOSConfig.h
Is there any idea to support/let modify some config fields? I would like to be able to modify the:
esp-idf/components/freertos/esp_additions/include/freertos/FreeRTOSConfig.h
Line 145 in a470ae2
esp-idf/components/freertos/esp_additions/include/freertos/FreeRTOSConfig.h
Line 64 in a470ae2
As for example:
esp-idf/components/freertos/esp_additions/include/freertos/FreeRTOSConfig.h
Line 68 in a470ae2
Thanks
The text was updated successfully, but these errors were encountered: