From c36cd5238c9b87e891210e496704926f585118f1 Mon Sep 17 00:00:00 2001 From: Marius Vikhammer Date: Wed, 24 Aug 2022 17:39:01 +0800 Subject: [PATCH] bootloader: allow skip image validation on C2 BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP is not supported on C2 due to no RTC memory, but BOOTLOADER_SKIP_VALIDATE_ALWAYS should still be supported. --- components/bootloader/Kconfig.projbuild | 2 +- docs/en/api-guides/performance/speed.rst | 2 +- examples/system/.build-test-rules.yml | 6 ----- examples/system/startup_time/example_test.py | 22 ------------------- .../startup_time/pytest_startup_time.py | 20 +++++++++++++++++ .../startup_time/sdkconfig.ci.always_skip | 1 + .../system/startup_time/sdkconfig.ci.defaults | 0 7 files changed, 23 insertions(+), 30 deletions(-) delete mode 100644 examples/system/startup_time/example_test.py create mode 100644 examples/system/startup_time/pytest_startup_time.py create mode 100644 examples/system/startup_time/sdkconfig.ci.always_skip create mode 100644 examples/system/startup_time/sdkconfig.ci.defaults diff --git a/components/bootloader/Kconfig.projbuild b/components/bootloader/Kconfig.projbuild index 0318ef106335..c9b55a7d7736 100644 --- a/components/bootloader/Kconfig.projbuild +++ b/components/bootloader/Kconfig.projbuild @@ -366,7 +366,7 @@ menu "Bootloader config" # only available if both Secure Boot and Check Signature on Boot are disabled depends on !SECURE_SIGNED_ON_BOOT default n - select BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP + select BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP if SOC_RTC_FAST_MEM_SUPPORTED select BOOTLOADER_SKIP_VALIDATE_ON_POWER_ON help Selecting this option prevents the bootloader from ever validating the app image before diff --git a/docs/en/api-guides/performance/speed.rst b/docs/en/api-guides/performance/speed.rst index f9b2f4bdb80c..860f6a385c08 100644 --- a/docs/en/api-guides/performance/speed.rst +++ b/docs/en/api-guides/performance/speed.rst @@ -126,7 +126,7 @@ In addition to the overall performance improvements shown above, the following o .. list:: - Minimizing the :ref:`CONFIG_LOG_DEFAULT_LEVEL` and :ref:`CONFIG_BOOTLOADER_LOG_LEVEL` has a large impact on startup time. To enable more logging after the app starts up, set the :ref:`CONFIG_LOG_MAXIMUM_LEVEL` as well and then call :cpp:func:`esp_log_level_set` to restore higher level logs. The :example:`system/startup_time` main function shows how to do this. - - If using deep sleep, setting :ref:`CONFIG_BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP` allows a faster wake from sleep. Note that if using Secure Boot this represents a security compromise, as Secure Boot validation will not be performed on wake. + :SOC_RTC_FAST_MEM_SUPPORTED: - If using deep sleep, setting :ref:`CONFIG_BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP` allows a faster wake from sleep. Note that if using Secure Boot this represents a security compromise, as Secure Boot validation will not be performed on wake. - Setting :ref:`CONFIG_BOOTLOADER_SKIP_VALIDATE_ON_POWER_ON` will skip verifying the binary on every boot from power-on reset. How much time this saves depends on the binary size and the flash settings. Note that this setting carries some risk if the flash becomes corrupt unexpectedly. Read the help text of the :ref:`config item ` for an explanation and recommendations if using this option. - It's possible to save a small amount of time during boot by disabling RTC slow clock calibration. To do so, set :ref:`CONFIG_RTC_CLK_CAL_CYCLES` to 0. Any part of the firmware that uses RTC slow clock as a timing source will be less accurate as a result. diff --git a/examples/system/.build-test-rules.yml b/examples/system/.build-test-rules.yml index 26179c8764f0..e1d33c807be0 100644 --- a/examples/system/.build-test-rules.yml +++ b/examples/system/.build-test-rules.yml @@ -136,12 +136,6 @@ examples/system/select: temporary: true reason: lack of runners -examples/system/startup_time: - disable_test: - - if: IDF_TARGET == "esp32s3" or IDF_TARGET == "esp32c2" - temporary: true - reason: lack of runners - examples/system/sysview_tracing: disable_test: - if: IDF_TARGET != "esp32" diff --git a/examples/system/startup_time/example_test.py b/examples/system/startup_time/example_test.py deleted file mode 100644 index 68fbe7991812..000000000000 --- a/examples/system/startup_time/example_test.py +++ /dev/null @@ -1,22 +0,0 @@ -from __future__ import print_function - -import re - -import ttfw_idf -from tiny_test_fw import TinyFW - - -@ttfw_idf.idf_example_test(env_tag='Example_GENERIC', target=['esp32', 'esp32s2', 'esp32c3']) -def test_startup_time_example(env, _): - key = 'startup_time' - dut = env.get_dut(key, 'examples/system/startup_time') - dut.start_app() - - res = dut.expect(re.compile(r'\((\d+)\) [^:]+: App started!')) - time = int(res[0]) - - TinyFW.JunitReport.update_performance([(key, time)]) - - -if __name__ == '__main__': - test_startup_time_example() diff --git a/examples/system/startup_time/pytest_startup_time.py b/examples/system/startup_time/pytest_startup_time.py new file mode 100644 index 000000000000..a2eff33822ce --- /dev/null +++ b/examples/system/startup_time/pytest_startup_time.py @@ -0,0 +1,20 @@ +# SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD +# SPDX-License-Identifier: CC0-1.0 +import logging + +import pytest +from pytest_embedded import Dut + + +@pytest.mark.supported_targets +@pytest.mark.generic +@pytest.mark.parametrize('config', [ + 'defaults', + 'always_skip', +], indirect=True) +def test_startup_time_example(dut: Dut) -> None: + + res = dut.expect(r'\((\d+)\) [^:]+: App started!') + time = int(res[1]) + + logging.info(f'[Performance][startup_time]: {time}') diff --git a/examples/system/startup_time/sdkconfig.ci.always_skip b/examples/system/startup_time/sdkconfig.ci.always_skip new file mode 100644 index 000000000000..951b84e129e5 --- /dev/null +++ b/examples/system/startup_time/sdkconfig.ci.always_skip @@ -0,0 +1 @@ +CONFIG_BOOTLOADER_SKIP_VALIDATE_ALWAYS=y diff --git a/examples/system/startup_time/sdkconfig.ci.defaults b/examples/system/startup_time/sdkconfig.ci.defaults new file mode 100644 index 000000000000..e69de29bb2d1