CPU_FREQ_MAX always held by rtos0 / rtos1 power management locks? And other oddities.
Posted: Mon Jan 13, 2025 4:41 pm
Hello,
Just wondering if this is the normal behaviour. We're trying to do frequency scaling to save some power, but noticed right off the bat that rtos0 and rtos1 both hold a CPU_FREQ_MAX power management lock, in what appears to be anytime they exit their idle hook.
Wouldn't that imply they anytime code is running it's always at CPU_FREQ_MAX anytime the given core is not idle, and not suspended by light sleep?
Some other oddities:
1) Checking the cpu frequency using ets_get_cpu_frequency(), always reveals the CPU is running at 240 Mhz... Even if there are no locks, by commenting out the acquire / release in pm_impl.c.
2) The power management information statement shows APB_MAX of 240... Odd, I thought the APB max is 80 Mhz?
I (1240) pm: Frequency switching config: CPU_MAX: 240, APB_MAX: 240, APB_MIN: 80, Light sleep: ENABLED
Regards,
With the locks in pm_impl.c commented out for testing, the CPU still appears to be running at 240 Mhz.
Just wondering if this is the normal behaviour. We're trying to do frequency scaling to save some power, but noticed right off the bat that rtos0 and rtos1 both hold a CPU_FREQ_MAX power management lock, in what appears to be anytime they exit their idle hook.
Wouldn't that imply they anytime code is running it's always at CPU_FREQ_MAX anytime the given core is not idle, and not suspended by light sleep?
Some other oddities:
1) Checking the cpu frequency using ets_get_cpu_frequency(), always reveals the CPU is running at 240 Mhz... Even if there are no locks, by commenting out the acquire / release in pm_impl.c.
2) The power management information statement shows APB_MAX of 240... Odd, I thought the APB max is 80 Mhz?
I (1240) pm: Frequency switching config: CPU_MAX: 240, APB_MAX: 240, APB_MIN: 80, Light sleep: ENABLED
Regards,
Code: Select all
esp_pm_config_esp32_t pm_config;
pm_config.light_sleep_enable = true;
pm_config.min_freq_mhz = 80;
pm_config.max_freq_mhz = 240;
esp_err_t ret_pm_config;
ret_pm_config = esp_pm_configure(&pm_config);
ESP_ERROR_CHECK(ret_pm_config);
while (true){
uint32_t value = 0;
ESP_ERROR_CHECK(esp_clk_tree_src_get_freq_hz(SOC_MOD_CLK_CPU, 0, &value));
ESP_LOGW(TAG, "Cpu Freq: %lu", value);
esp_pm_dump_locks(stdout);
vTaskDelay(pdMS_TO_TICKS(1000 * 5));
}
Code: Select all
I (11) boot: ESP-IDF v5.1.5-dirty 2nd stage bootloader
I (11) boot: compile time Jan 13 2025 09:15:55
I (11) boot: Multicore bootloader
I (15) boot: chip revision: v3.1
I (19) qio_mode: Enabling default flash chip QIO
I (24) boot.esp32: SPI Speed : 80MHz
I (29) boot.esp32: SPI Mode : QIO
I (33) boot.esp32: SPI Flash Size : 8MB
I (38) boot: Enabling RNG early entropy source...
I (43) boot: Partition Table:
I (47) boot: ## Label Usage Type ST Offset Length
I (54) boot: 0 efuse efuse 01 05 0000b000 00002000
I (62) boot: 1 emul_efuse efuse 01 05 0000d000 00002000
I (69) boot: 2 otadata OTA data 01 00 0000f000 00002000
I (77) boot: 3 phy_init RF data 01 01 00011000 00001000
I (84) boot: 4 nvs_keys NVS keys 01 04 00012000 00001000
I (1050) cpu_start: Pro cpu start user code
I (1050) cpu_start: cpu freq: 240000000 Hz
I (1050) cpu_start: Application information:
I (1054) cpu_start: Project name: liberty
I (1059) cpu_start: App version: Liberty One
I (1064) cpu_start: Compile time: Jan 13 2025 09:15:23
I (1070) cpu_start: ELF file SHA256: 4fe14240638da244...
I (1076) cpu_start: ESP-IDF: v5.1.5-dirty
I (1082) cpu_start: Min chip rev: v3.0
I (1086) cpu_start: Max chip rev: v3.99
I (1091) cpu_start: Chip rev: v3.1
I (1096) heap_init: Initializing. RAM available for dynamic allocation:
I (1104) heap_init: At 3FFAFF10 len 000000F0 (0 KiB): DRAM
I (1110) heap_init: At 3FFB7CD8 len 00000328 (0 KiB): DRAM
I (1116) heap_init: At 3FFB9A20 len 00004108 (16 KiB): DRAM
I (1122) heap_init: At 3FFC2358 len 0001DCA8 (119 KiB): DRAM
I (1128) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (1135) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (1141) heap_init: At 40090004 len 0000FFFC (63 KiB): IRAM
I (1148) esp_psram: Adding pool of 2048K of PSRAM memory to heap allocator
I (1156) spi_flash: detected chip: generic
I (1160) spi_flash: flash io: qio
I (1175) pm: Frequency switching config: CPU_MAX: 240, APB_MAX: 240, APB_MIN: 40, Light sleep: DISABLED
I (1223) coexist: coex firmware version: 27d8387
I (1229) app_start: Starting scheduler on CPU0
I (1234) app_start: Starting scheduler on CPU1
I (1234) main_task: Started on CPU0
I (1244) main_task: Calling app_main()
W (1244) ******** LIBERTY MAIN START (1.055) ********
I (1254) gpio: GPIO[14]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (1259) pm: Frequency switching config: CPU_MAX: 240, APB_MAX: 240, APB_MIN: 80, Light sleep: ENABLED
W (1269) LIBERTY: Cpu Freq: 240
Lock stats:
Name Type Arg Active
lib_no_sleep NO_LIGHT_SLEEP 0 0
rtos1 CPU_FREQ_MAX 0 0
rtos0 CPU_FREQ_MAX 0 1
W (6299) LIBERTY: Cpu Freq: 240
Lock stats:
Name Type Arg Active
lib_no_sleep NO_LIGHT_SLEEP 0 0
rtos1 CPU_FREQ_MAX 0 0
rtos0 CPU_FREQ_MAX 0 1
W (11314) LIBERTY: Cpu Freq: 240
Lock stats:
Name Type Arg Active
lib_no_sleep NO_LIGHT_SLEEP 0 0
rtos1 CPU_FREQ_MAX 0 0
rtos0 CPU_FREQ_MAX 0 1
Code: Select all
W (446705) LIBERTY: Cpu Freq: 240000000
Lock stats:
Name Type Arg Active
rtos1 APB_FREQ_MAX 0 0
rtos0 APB_FREQ_MAX 0 0