-
Notifications
You must be signed in to change notification settings - Fork 7.7k
PowerManagement support #9083
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
PowerManagement support #9083
Conversation
👋 Hello tshcherban, we appreciate your contribution to this project! Click to see more instructions ...
Review and merge process you can expect ...
|
@SuGlider @VojtechBartoska is it possible to migrate from patching SDK-Config in github actions to just copy corresponding sdkconfig.defaults.target? that would be a bit more easy editing defaults, separate them for different targets and reuse for some other purposes (i.e. copy for examples, use in CMake build checks).
CLA assistant check
All committers have signed the CLA.
@SuGlider @VojtechBartoska is it possible to migrate from patching SDK-Config in github actions to just copy corresponding sdkconfig.defaults.target? that would be a bit more easy editing defaults, separate them for different targets and reuse for some other purposes (i.e. copy for examples, use in CMake build checks).
Actually we need to add this IDF sdkconfig changes to the Lib Builder scripts.
sdkconfig is used by Lib Builder to compile and build all IDF libraries, therefore, when using Arduino, all settings from sdkconfig are setled in the static IDF libs.
The only way to changed sdkconfig and test it is by using Arduino as IDF Component and then build some examples that will verify how PM and light sleep will work.
Found an issue IDFGH-11870 with IDF's UART implementation , it prevents UART usage with automatic llight sleep in some cases.
It would work if we have WiFi/BLE active or some other tasks, which prevents CPU for sleeping too long, however that not seems reliable.
Also I might have a fix for it, so waiting for the IDF maintainers response.
@igrr @VojtechBartoska @SuGlider for a BLE PowerManagement - i dont have ESP32 board with an external crystal, so for that part I would need your help in testing. On an ESP32S3 I'm planning to use Main XTAL as low power source by default.
@tshcherban -
On top of this PR, I'd like to work on an API that will allow the user to set the source clock too.
This is part of another Task which also wants to add Power Management feature based on automatic Dynamic Frequency Scaling (DFS). The proposal is that the user will be able to set the Clock Source for each peripheral and also set it in a Global way whenever necessary in order to increase DFS applicability.
This should be ready for Arduino 3.0.0 final release.
Is that OK for you?
Yes, for sure.
Do i need to grant you an access to my repository? so all the changes come from the one codebase.
P.S. however i didnt noticed too much gain from DFS enabled, while just changing modem sleep pattern to the MAX_MODEM and enabling automatic light sleep improved the things significantly.
Also please beware we still have a bug coming from IDF uart implementation, which can lead sometimes to a dedlock (workaroundable via Serial.Flush
call).
Test Results
56 files 56 suites 5m 16s ⏱️
21 tests 21 ✅ 0 💤 0 ❌
135 runs 135 ✅ 0 💤 0 ❌
Results for commit 205db45.
♻️ This comment has been updated with latest results.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it would be good to indicate the units of this parameter. As written it could be interpreted as milliseconds, seconds, minutes, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unit is specified here (AP beacon intervals). It is determined by the access point parameters, I've often seen a 102400us value during testing with different routers, however it can differ.
API and its comments are incompatible:
bool setAutomaticLightSleep(bool enabled);
and
/**
* @brief Set automatic light sleep state. CPU will go into light sleep if no ongoing activity (active task, peripheral activity etc.)
* @param enabled true to enable automatic lightSleep
* @return
* - ESP_OK on success
* - ESP_ERR_NOT_SUPPORTED if CONFIG_PM_ENABLE is not enabled in sdkconfig
*/
return type is bool (not [esp_return_type])
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from
(wifi_interface_t)ESP_IF_WIFI_STA
to
wifi_interface_t::WIFI_IF_STA
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from
uint32_t cpuFreq = getCpuFrequencyMhz();
to
const uint32_t cpuFreq = getCpuFrequencyMhz();
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from
(wifi_interface_t)ESP_IF_WIFI_STA
to
wifi_interface_t::WIFI_IF_STA
?
Uh oh!
There was an error while loading. Please reload this page.
Description of Change
Enables Power Management support for arduino sketches.
API changes
Extended
WiFi.setSleep
function to accept listenIntervalAdded
setAutomaticLightSleep
function to enable/disable automatic LightSleep (without changing the CPU frequency)Tests scenarios
Tested WiFi connectivity, BLE scanning, OneWire, TwoWire, SPI, Serial on ESP32, ESP32-S3, ESP32-C3 boards.
Related links
Solves #6563 partially