cesanta / mongoose-os

Mongoose OS - an IoT Firmware Development Framework. Supported microcontrollers: ESP32, ESP8266, CC3220, CC3200, STM32F4, STM32L4, STM32F7. Amazon AWS IoT, Microsoft Azure, Google IoT Core integrated. Code in C or JavaScript.
https://mongoose-os.com
Other
2.48k stars 430 forks source link

ESP32 set clock frequency in mos.yml? #538

Open Harvie opened 4 years ago

Harvie commented 4 years ago

I've noticed that ESP32 can run under various speeds 40MHz, 80MHz, 160MHz, 240MHz. Can this be set in mos.yml ?

Can this be set during runtime? I've noticed esp-idf has api for this, but i am not sure if nothing will break on mongoose side when i use it...

rojer commented 4 years ago

it can be set in mos.yml via SDK options. for example, to run at 240 mhz:

ESP_IDF_SDKCONFIG_OPTS: "${build_vars.ESP_IDF_SDKCONFIG_OPTS} CONFIG_ESP32_DEFAULT_CPU_FREQ_80= CONFIG_ESP32_DEFAULT_CPU_FREQ_160= CONFIG_ESP32_DEFAULT_CPU_FREQ_240=y CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ=240"

changing frequency at runtime should be possible as long as APB frequency stays constant, otherwise peripheral frequency dividers need to be adjusted, which is not currently done.

you need to keep in mind that not all chips are qualified to run at 240 mhz. ones that are, have special efuse set and if it's not set, it will refuse to run.