diff --git a/Dockerfile b/Dockerfile index 9a0954e1..00704030 100755 --- a/Dockerfile +++ b/Dockerfile @@ -66,10 +66,6 @@ RUN pre-commit install-hooks # Add /project as a safe git repository RUN git config --global --add safe.directory /project -# Patch esp_efuse_startup.c -COPY ./patch_esp_efuse_startup.sh / -RUN ./patch_esp_efuse_startup.sh - # Patch FreeRTOSConfig.h COPY ./patch_esp_trace_include.sh / RUN ./patch_esp_trace_include.sh diff --git a/grid_esp/main/grid_esp32.c b/grid_esp/main/grid_esp32.c index c47b7c14..e758336c 100644 --- a/grid_esp/main/grid_esp32.c +++ b/grid_esp/main/grid_esp32.c @@ -8,6 +8,34 @@ static const char* TAG = "grid_esp32"; +void grid_esp32_setup_rom_log_scheme(void) { + // Configure ROM bootloader to only log when GPIO is high. + // This speeds up boot by suppressing ROM logs on normal boots. + // We handle this in firmware instead of via CONFIG_BOOT_ROM_LOG_ON_GPIO_HIGH + // to avoid ESP-IDF bug: https://github.com/espressif/esp-idf/issues/12894 + // The fix was supposedly merged but never actually made it to the main branch. + // IMPORTANT: sdkconfig must have CONFIG_BOOT_ROM_LOG_ALWAYS_ON=y (the default). + // Do NOT set CONFIG_BOOT_ROM_LOG_ON_GPIO_HIGH in sdkconfig - it will crash. + esp_err_t err = esp_efuse_set_rom_log_scheme(ESP_EFUSE_ROM_LOG_ON_GPIO_HIGH); + + switch (err) { + case ESP_OK: + ESP_LOGI(TAG, "ROM log scheme set to GPIO_HIGH"); + break; + case ESP_ERR_INVALID_STATE: + // eFuse already burned - this is expected after first boot + ESP_LOGD(TAG, "ROM log eFuse already configured"); + break; + case ESP_ERR_NOT_SUPPORTED: + // Chip doesn't support this feature (e.g., ESP32) + ESP_LOGD(TAG, "ROM log scheme not supported on this chip"); + break; + default: + ESP_LOGW(TAG, "Unexpected error setting ROM log scheme: %s", esp_err_to_name(err)); + break; + } +} + void vTaskGetRunTimeStats2(char* pcWriteBuffer) { TaskStatus_t* pxTaskStatusArray; diff --git a/grid_esp/main/grid_esp32.h b/grid_esp/main/grid_esp32.h index 474fad8e..2ed2b503 100644 --- a/grid_esp/main/grid_esp32.h +++ b/grid_esp/main/grid_esp32.h @@ -70,6 +70,8 @@ void grid_platform_nvm_defrag(); uint8_t grid_platform_get_adc_bit_depth(); +void grid_esp32_setup_rom_log_scheme(void); + #ifdef __cplusplus } #endif diff --git a/grid_esp/main/grid_fw.c b/grid_esp/main/grid_fw.c index f6d8eb61..13668a93 100644 --- a/grid_esp/main/grid_fw.c +++ b/grid_esp/main/grid_fw.c @@ -359,6 +359,8 @@ void app_main(void) { esp_log_level_set("*", ESP_LOG_INFO); + grid_esp32_setup_rom_log_scheme(); + TaskHandle_t core2_task_hdl; xTaskCreatePinnedToCore(system_init_core_2_task, "swd_init", 1024 * 3, NULL, 4, &core2_task_hdl, 1); diff --git a/grid_esp/sdkconfig b/grid_esp/sdkconfig index a2eabfe9..5cd6f902 100644 --- a/grid_esp/sdkconfig +++ b/grid_esp/sdkconfig @@ -536,9 +536,9 @@ CONFIG_ESP_ROM_CONSOLE_OUTPUT_SECONDARY=y # # Boot ROM Behavior # -# CONFIG_BOOT_ROM_LOG_ALWAYS_ON is not set +CONFIG_BOOT_ROM_LOG_ALWAYS_ON=y # CONFIG_BOOT_ROM_LOG_ALWAYS_OFF is not set -CONFIG_BOOT_ROM_LOG_ON_GPIO_HIGH=y +# CONFIG_BOOT_ROM_LOG_ON_GPIO_HIGH is not set # CONFIG_BOOT_ROM_LOG_ON_GPIO_LOW is not set # end of Boot ROM Behavior