Merge branch 'bugfix/efuse_logs_v4.2' into 'release/v4.2'

esp32/esp32s2: Reduce using ESP_EARLY_LOGx and move some code after the stdout initialization in startup code (v4.2)

See merge request espressif/esp-idf!9202
This commit is contained in:
Angus Gratton 2020-06-17 16:54:34 +08:00
commit 0ea0d2ba3c
4 changed files with 27 additions and 25 deletions

View file

@ -50,7 +50,7 @@ void esp_flash_encryption_init_checks()
// (this distinction is important on ESP32 ECO3 where write-procted FLASH_CRYPT_CNT also write-protects UART_DL_DIS) // (this distinction is important on ESP32 ECO3 where write-procted FLASH_CRYPT_CNT also write-protects UART_DL_DIS)
return; return;
} }
ESP_EARLY_LOGE(TAG, "Flash encryption & Secure Boot together requires FLASH_CRYPT_CNT efuse to be write protected. Fixing now..."); ESP_LOGE(TAG, "Flash encryption & Secure Boot together requires FLASH_CRYPT_CNT efuse to be write protected. Fixing now...");
esp_flash_write_protect_crypt_cnt(); esp_flash_write_protect_crypt_cnt();
} }
} }
@ -62,13 +62,13 @@ void esp_flash_encryption_init_checks()
mode = esp_get_flash_encryption_mode(); mode = esp_get_flash_encryption_mode();
if (mode == ESP_FLASH_ENC_MODE_DEVELOPMENT) { if (mode == ESP_FLASH_ENC_MODE_DEVELOPMENT) {
#ifdef CONFIG_SECURE_FLASH_ENCRYPTION_MODE_RELEASE #ifdef CONFIG_SECURE_FLASH_ENCRYPTION_MODE_RELEASE
ESP_EARLY_LOGE(TAG, "Flash encryption settings error: app is configured for RELEASE but efuses are set for DEVELOPMENT"); ESP_LOGE(TAG, "Flash encryption settings error: app is configured for RELEASE but efuses are set for DEVELOPMENT");
ESP_EARLY_LOGE(TAG, "Mismatch found in security options in bootloader menuconfig and efuse settings. Device is not secure."); ESP_LOGE(TAG, "Mismatch found in security options in bootloader menuconfig and efuse settings. Device is not secure.");
#else #else
ESP_EARLY_LOGW(TAG, "Flash encryption mode is DEVELOPMENT (not secure)"); ESP_LOGW(TAG, "Flash encryption mode is DEVELOPMENT (not secure)");
#endif #endif
} else if (mode == ESP_FLASH_ENC_MODE_RELEASE) { } else if (mode == ESP_FLASH_ENC_MODE_RELEASE) {
ESP_EARLY_LOGI(TAG, "Flash encryption mode is RELEASE"); ESP_LOGI(TAG, "Flash encryption mode is RELEASE");
} }
} }
#endif #endif

View file

@ -72,7 +72,7 @@ void esp_efuse_disable_basic_rom_console(void)
{ {
if (!esp_efuse_read_field_bit(ESP_EFUSE_CONSOLE_DEBUG_DISABLE)) { if (!esp_efuse_read_field_bit(ESP_EFUSE_CONSOLE_DEBUG_DISABLE)) {
esp_efuse_write_field_cnt(ESP_EFUSE_CONSOLE_DEBUG_DISABLE, 1); esp_efuse_write_field_cnt(ESP_EFUSE_CONSOLE_DEBUG_DISABLE, 1);
ESP_EARLY_LOGI(TAG, "Disable BASIC ROM Console fallback via efuse..."); ESP_LOGI(TAG, "Disable BASIC ROM Console fallback via efuse...");
} }
} }

View file

@ -219,10 +219,6 @@ void IRAM_ATTR call_start_cpu0(void)
} }
ESP_EARLY_LOGI(TAG, "Starting app cpu, entry point is %p", call_start_cpu1); ESP_EARLY_LOGI(TAG, "Starting app cpu, entry point is %p", call_start_cpu1);
#ifdef CONFIG_SECURE_FLASH_ENC_ENABLED
esp_flash_encryption_init_checks();
#endif
//Flush and enable icache for APP CPU //Flush and enable icache for APP CPU
Cache_Flush(1); Cache_Flush(1);
Cache_Read_Enable(1); Cache_Read_Enable(1);
@ -363,12 +359,6 @@ void start_cpu0_default(void)
#if CONFIG_ESP32_BROWNOUT_DET #if CONFIG_ESP32_BROWNOUT_DET
esp_brownout_init(); esp_brownout_init();
#endif #endif
#if CONFIG_ESP32_DISABLE_BASIC_ROM_CONSOLE
esp_efuse_disable_basic_rom_console();
#endif
#if CONFIG_SECURE_DISABLE_ROM_DL_MODE
esp_efuse_disable_rom_download_mode();
#endif
rtc_gpio_force_hold_dis_all(); rtc_gpio_force_hold_dis_all();
@ -385,6 +375,17 @@ void start_cpu0_default(void)
#else // defined(CONFIG_VFS_SUPPORT_IO) && !defined(CONFIG_ESP_CONSOLE_UART_NONE) #else // defined(CONFIG_VFS_SUPPORT_IO) && !defined(CONFIG_ESP_CONSOLE_UART_NONE)
_REENT_SMALL_CHECK_INIT(_GLOBAL_REENT); _REENT_SMALL_CHECK_INIT(_GLOBAL_REENT);
#endif // defined(CONFIG_VFS_SUPPORT_IO) && !defined(CONFIG_ESP_CONSOLE_UART_NONE) #endif // defined(CONFIG_VFS_SUPPORT_IO) && !defined(CONFIG_ESP_CONSOLE_UART_NONE)
// After setting _GLOBAL_REENT, ESP_LOGIx can be used instead of ESP_EARLY_LOGx.
#ifdef CONFIG_SECURE_FLASH_ENC_ENABLED
esp_flash_encryption_init_checks();
#endif
#if CONFIG_ESP32_DISABLE_BASIC_ROM_CONSOLE
esp_efuse_disable_basic_rom_console();
#endif
#if CONFIG_SECURE_DISABLE_ROM_DL_MODE
esp_efuse_disable_rom_download_mode();
#endif
esp_timer_init(); esp_timer_init();
esp_set_time_from_rtc(); esp_set_time_from_rtc();

View file

@ -293,15 +293,6 @@ void start_cpu0_default(void)
esp_brownout_init(); esp_brownout_init();
#endif #endif
#if CONFIG_SECURE_DISABLE_ROM_DL_MODE
err = esp_efuse_disable_rom_download_mode();
assert(err == ESP_OK && "Failed to disable ROM download mode");
#endif
#if CONFIG_SECURE_ENABLE_SECURE_ROM_DL_MODE
err = esp_efuse_enable_rom_secure_download_mode();
assert(err == ESP_OK && "Failed to enable Secure Download mode");
#endif
rtc_gpio_force_hold_dis_all(); rtc_gpio_force_hold_dis_all();
#ifdef CONFIG_VFS_SUPPORT_IO #ifdef CONFIG_VFS_SUPPORT_IO
@ -317,6 +308,16 @@ void start_cpu0_default(void)
#else // defined(CONFIG_VFS_SUPPORT_IO) && !defined(CONFIG_ESP_CONSOLE_UART_NONE) #else // defined(CONFIG_VFS_SUPPORT_IO) && !defined(CONFIG_ESP_CONSOLE_UART_NONE)
_REENT_SMALL_CHECK_INIT(_GLOBAL_REENT); _REENT_SMALL_CHECK_INIT(_GLOBAL_REENT);
#endif // defined(CONFIG_VFS_SUPPORT_IO) && !defined(CONFIG_ESP_CONSOLE_UART_NONE) #endif // defined(CONFIG_VFS_SUPPORT_IO) && !defined(CONFIG_ESP_CONSOLE_UART_NONE)
// After setting _GLOBAL_REENT, ESP_LOGIx can be used instead of ESP_EARLY_LOGx.
#if CONFIG_SECURE_DISABLE_ROM_DL_MODE
err = esp_efuse_disable_rom_download_mode();
assert(err == ESP_OK && "Failed to disable ROM download mode");
#endif
#if CONFIG_SECURE_ENABLE_SECURE_ROM_DL_MODE
err = esp_efuse_enable_rom_secure_download_mode();
assert(err == ESP_OK && "Failed to enable Secure Download mode");
#endif
esp_timer_init(); esp_timer_init();
esp_set_time_from_rtc(); esp_set_time_from_rtc();