From b930f7a96d24b2440e7b80305e418b4f7486b573 Mon Sep 17 00:00:00 2001 From: Shubham Kulkarni Date: Tue, 30 Jun 2020 18:28:37 +0530 Subject: [PATCH] simple_ota_example: Add example test with flash encryption enabled --- .../ota/simple_ota_example/example_test.py | 38 +++++++++++++++++++ .../simple_ota_example/sdkconfig.ci.flash_enc | 20 ++++++++++ tools/ci/config/target-test.yml | 8 +++- 3 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 examples/system/ota/simple_ota_example/sdkconfig.ci.flash_enc diff --git a/examples/system/ota/simple_ota_example/example_test.py b/examples/system/ota/simple_ota_example/example_test.py index d0a1037dd1..56a69f467c 100644 --- a/examples/system/ota/simple_ota_example/example_test.py +++ b/examples/system/ota/simple_ota_example/example_test.py @@ -163,6 +163,44 @@ def test_examples_protocol_simple_ota_example_ethernet_with_spiram_config(env, e dut1.expect("Starting OTA example", timeout=30) +@ttfw_idf.idf_example_test(env_tag="Example_Flash_Encryption_OTA") +def test_examples_protocol_simple_ota_example_with_flash_encryption(env, extra_data): + """ + steps: | + 1. join AP + 2. Fetch OTA image over HTTPS + 3. Reboot with the new OTA image + """ + dut1 = env.get_dut("simple_ota_example", "examples/system/ota/simple_ota_example", dut_class=ttfw_idf.ESP32DUT, app_config_name='flash_enc') + # check and log bin size + binary_file = os.path.join(dut1.app.binary_path, "simple_ota.bin") + bin_size = os.path.getsize(binary_file) + ttfw_idf.log_performance("simple_ota_bin_size", "{}KB".format(bin_size // 1024)) + ttfw_idf.check_performance("simple_ota_bin_size", bin_size // 1024, dut1.TARGET) + # start test + host_ip = get_my_ip() + thread1 = Thread(target=start_https_server, args=(dut1.app.binary_path, host_ip, 8000)) + thread1.daemon = True + thread1.start() + dut1.start_app() + dut1.expect("Loaded app from partition at offset 0x20000", timeout=30) + dut1.expect("Flash encryption mode is DEVELOPMENT (not secure)", timeout=10) + try: + ip_address = dut1.expect(re.compile(r" eth ip: ([^,]+),"), timeout=30) + print("Connected to AP with IP: {}".format(ip_address)) + except DUT.ExpectTimeout: + raise ValueError('ENV_TEST_FAILURE: Cannot connect to AP') + thread1.close() + dut1.expect("Starting OTA example", timeout=30) + + print("writing to device: {}".format("https://" + host_ip + ":8000/simple_ota.bin")) + dut1.write("https://" + host_ip + ":8000/simple_ota.bin") + dut1.expect("Loaded app from partition at offset 0x120000", timeout=60) + dut1.expect("Flash encryption mode is DEVELOPMENT (not secure)", timeout=10) + dut1.expect("Starting OTA example", timeout=30) + + if __name__ == '__main__': test_examples_protocol_simple_ota_example() test_examples_protocol_simple_ota_example_ethernet_with_spiram_config() + test_examples_protocol_simple_ota_example_with_flash_encryption() diff --git a/examples/system/ota/simple_ota_example/sdkconfig.ci.flash_enc b/examples/system/ota/simple_ota_example/sdkconfig.ci.flash_enc new file mode 100644 index 0000000000..3021ab18d8 --- /dev/null +++ b/examples/system/ota/simple_ota_example/sdkconfig.ci.flash_enc @@ -0,0 +1,20 @@ +CONFIG_EXAMPLE_FIRMWARE_UPGRADE_URL="FROM_STDIN" +CONFIG_EXAMPLE_SKIP_COMMON_NAME_CHECK=y +CONFIG_SECURE_FLASH_ENC_ENABLED=y +CONFIG_SECURE_FLASH_ENCRYPTION_MODE_DEVELOPMENT=y +CONFIG_SECURE_BOOT_ALLOW_ROM_BASIC=y +CONFIG_SECURE_BOOT_ALLOW_JTAG=y +CONFIG_SECURE_FLASH_UART_BOOTLOADER_ALLOW_ENC=y +CONFIG_SECURE_FLASH_UART_BOOTLOADER_ALLOW_DEC=y +CONFIG_SECURE_FLASH_UART_BOOTLOADER_ALLOW_CACHE=y +CONFIG_SECURE_FLASH_REQUIRE_ALREADY_ENABLED=y +CONFIG_PARTITION_TABLE_OFFSET=0x9000 +CONFIG_EXAMPLE_CONNECT_ETHERNET=y +CONFIG_EXAMPLE_CONNECT_WIFI=n +CONFIG_EXAMPLE_USE_INTERNAL_ETHERNET=y +CONFIG_EXAMPLE_ETH_PHY_IP101=y +CONFIG_EXAMPLE_ETH_MDC_GPIO=23 +CONFIG_EXAMPLE_ETH_MDIO_GPIO=18 +CONFIG_EXAMPLE_ETH_PHY_RST_GPIO=5 +CONFIG_EXAMPLE_ETH_PHY_ADDR=1 +CONFIG_EXAMPLE_CONNECT_IPV6=y diff --git a/tools/ci/config/target-test.yml b/tools/ci/config/target-test.yml index f6a072b9a1..76e63caf31 100644 --- a/tools/ci/config/target-test.yml +++ b/tools/ci/config/target-test.yml @@ -300,12 +300,18 @@ example_test_007: - ESP32 - Example_I2C_CCS811_SENSOR -example_test_008: +example_test_008A: extends: .example_test_template tags: - ESP32 - Example_Flash_Encryption +example_test_008B: + extends: .example_test_template + tags: + - ESP32 + - Example_Flash_Encryption_OTA + example_test_009: extends: .example_test_template tags: