ESP Chip Startup Time Optimization
Introduction
The startup time of ESP chips refers to the time it takes for the ESP chip to power on and execute the app_main function. The unoptimized startup process usually takes a long time (generally around 300 milliseconds), making it unable to meet the requirements of applications with high real-time requirements (such as turning on/off lights at any time). At the same time, it also accompanies high power consumption, resulting in high average power consumption in Deep-sleep low-power mode. To avoid these problems, fine optimization of the startup process is necessary.
Hardware and Software Environment
Hardware: ESP32-S3 and ESP32-C6
Software: ESP-IDF v5.2.1
Optional Optimization Items
Configuring the following options through menuconfig can significantly reduce startup time:
Disable Bootloader Log Printing
CONFIG_BOOTLOADER_LOG_LEVEL_NONE=y
CONFIG_BOOTLOADER_LOG_LEVEL=0
Skip Image Validation
CONFIG_BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP=y
CONFIG_BOOTLOADER_SKIP_VALIDATE_ON_POWER_ON=y
CONFIG_BOOTLOADER_SKIP_VALIDATE_ALWAYS=y
Disable Boot ROM Log Printing
CONFIG_BOOT_ROM_LOG_ALWAYS_OFF=y
In addition to this configuration, you also need to use the espefuse.py command in the terminal to configure the eFuse values related to controlling ROM log output (see the Boot Log Printing Control section of the Technical Reference Manual <https://www.espressif.com/sites/default/files/documentation/esp32-s3_technical_reference_manual_en.pdf>`__ for details; note that writing eFuse operations is irreversible). The specific command is as follows:
espefuse.py burn_efuse UART_PRINT_CONTROL 3 espefuse.py burn_efuse DIS_USB_SERIAL_JTAG_ROM_PRINT 1
After running the above two commands, you can use the espefuse.py summary command to check whether the writing is successful. If you see the following information, it means the configuration is successful:
Modify SPI Flash Mode and Frequency
CONFIG_ESPTOOLPY_FLASHMODE_QIO=y
CONFIG_ESPTOOLPY_FLASHFREQ_80M=y
Disable Boot Calibration
CONFIG_ESP_PHY_CALIBRATION_AND_DATA_STORAGE=y
CONFIG_ESP_PHY_CALIBRATION_MODE=1
Modify FreeRTOS Configuration
CONFIG_FREERTOS_UNICORE=y
CONFIG_FREERTOS_HZ=1000
Disable Log Printing
CONFIG_LOG_DEFAULT_LEVEL_NONE=y
CONFIG_LOG_DEFAULT_LEVEL=0
If further optimization of the time to connect to the AP after power-on is required on the basis of optimizing the startup time, the following operations can be performed synchronously:
Enable LWIP_DHCP_RESTORE_LAST_IP Configuration Option
CONFIG_LWIP_DHCP_RESTORE_LAST_IP=y
Startup Time and Average Power Consumption During Startup Results Statistics
Startup time and average power consumption statistics of ESP32-S3 at different main frequencies:
CPU Frequency |
80 M |
160 M |
240 M |
---|---|---|---|
Startup Time Before Optimization (ms) |
318.8 |
318.7 |
318.7 |
Startup Power Consumption Before Optimization (mA) |
44.1 |
51.4 |
57.3 |
Startup Time After Optimization (ms) |
26.87 |
26.875 |
26.965 |
Startup Power Consumption After Optimization (mA) |
29.69 |
29.77 |
29.74 |
Startup time and average power consumption statistics of ESP32-C6 at different main frequencies:
CPU Frequency |
80 M |
120 M |
160 M |
---|---|---|---|
Startup Time Before Optimization (ms) |
328.0 |
327.9 |
327.8 |
Startup Power Consumption Before Optimization (mA) |
34.1 |
35.8 |
37.6 |
Startup Time After Optimization (ms) |
33.31 |
33.315 |
33.315 |
Startup Power Consumption After Optimization (mA) |
28.23 |
28.19 |
28.16 |