diff --git a/examples/system/.build-test-rules.yml b/examples/system/.build-test-rules.yml index 65dc132016..984cef3e91 100644 --- a/examples/system/.build-test-rules.yml +++ b/examples/system/.build-test-rules.yml @@ -132,10 +132,6 @@ examples/system/nmi_isr: reason: test NMI for Xtensa targets only examples/system/ota/advanced_https_ota: - disable: - - if: IDF_TARGET in ["esp32h2"] - temporary: true - reason: target esp32h2 is not supported yet disable_test: - if: IDF_TARGET not in ["esp32", "esp32c3", "esp32s3"] temporary: true @@ -150,12 +146,9 @@ examples/system/ota/advanced_https_ota: - esp_phy - bt - protocol_examples_common + - openthread examples/system/ota/native_ota_example: - disable: - - if: IDF_TARGET in ["esp32h2"] - temporary: true - reason: target esp32h2 is not supported yet disable_test: - if: IDF_TARGET != "esp32" reason: Only esp32 has ethernet runners @@ -167,16 +160,13 @@ examples/system/ota/native_ota_example: - esp_driver_gpio - bootloader_support - protocol_examples_common + - openthread examples/system/ota/otatool: enable: - if: INCLUDE_DEFAULT == 1 or IDF_TARGET in ["esp32c5", "esp32c61"] examples/system/ota/pre_encrypted_ota: - disable: - - if: IDF_TARGET in ["esp32h2"] - temporary: true - reason: target esp32h2 is not supported yet disable_test: - if: IDF_TARGET != "esp32" temporary: true @@ -189,12 +179,10 @@ examples/system/ota/pre_encrypted_ota: - mbedtls - bootloader_support - protocol_examples_common + - openthread examples/system/ota/simple_ota_example: disable: - - if: IDF_TARGET in ["esp32h2"] - temporary: true - reason: target esp32h2 is not supported yet - if: CONFIG_NAME == "spiram" and SOC_SPIRAM_SUPPORTED != 1 disable_test: - if: IDF_TARGET not in ["esp32", "esp32c3", "esp32s3"] @@ -209,6 +197,7 @@ examples/system/ota/simple_ota_example: - esp_wifi - esp_phy - mbedtls + - openthread examples/system/perfmon: enable: diff --git a/examples/system/ota/README.md b/examples/system/ota/README.md index 09d15d6b83..d046aa14ab 100644 --- a/examples/system/ota/README.md +++ b/examples/system/ota/README.md @@ -150,6 +150,46 @@ The ``native_ota_example`` contains code to demonstrate how to check the version In ``native_ota_example``, ``$PROJECT_PATH/version.txt`` is used to define the app version. Change the version in the file to compile the new firmware. +## OTA over Thread + +These examples also support OTA (Over-the-Air) updates over a Thread network and supports binding to a Thread interface on targets with native IEEE 802.15.4 support, such as the ESP32-H2. + +### Thread Connectivity Prerequisites + +To enable OTA over Thread, you need a Thread End Device (which is the "ESP-Dev-Board", for example, ESP32-H2) and a [Thread Border Router](https://github.com/espressif/esp-thread-br). IPv6 connectivity must be established between the Thread End Device, the Thread Border Router, and the HTTP server. You can follow the guide in [Bi-directional IPv6 Connectivity](https://docs.espressif.com/projects/esp-thread-br/en/latest/codelab/connectivity.html) for setup instructions. + +Once IPv6 connectivity is established, the HTTP server will receive a valid IPv6 address starting with the On-link Prefix assigned by the Thread Border Router. This address will be used by the Thread End Device to retrieve the OTA binary. + +### HTTP(S) Server Requirements + +When running the HTTP(S) server, ensure that it supports IPv6. This can be achieved using a OpenSSL based server as detailed above: + +``` +openssl s_server -WWW -key ca_key.pem -cert ca_cert.pem -port 8070 +``` + +* **Note:** Use the IPv6 address from the Bi-directional IPv6 Connectivity guide to generate the certificate (CN prompt). + +* **Note:** The example script for the Python based server does not support IPv6 by default. + +An alternative means of debugging with IPv6 support is to use Python's built-in HTTP server with the `--bind ::` option: + +``` +python -m http.server 8070 --bind :: +``` + +OTA over Thread only supports IPv6 addresses. If the HTTP(S) server can only be accessed via an IPv4 address, the End Device will need to synthesize an IPv6 address using the [NAT64](https://docs.espressif.com/projects/esp-thread-br/en/latest/codelab/nat64.html) feature. + +### Thread Configuration Options (End Device) + +- `idf.py menuconfig → Component config → OpenThread → OpenThread` = `y` *(enabled by default for ESP32-H2)* +- `idf.py menuconfig → Component config → OpenThread → Thread Core Features → Thread Operational Dataset` — must match the Border Router configuration +- `idf.py menuconfig → Component config → Example Configuration → firmware upgrade URL endpoint` = `"https://[fda3:e29:9416:af10:db46:b477:354e:416e]:8070/blink.bin"` + *(Refer to [Thread Connectivity Prerequisites](#thread-connectivity-prerequisites) for details on obtaining this IPv6 address, which belongs to the HTTP(S) server host PC and is accessible by the end device.)* + +> **Note:** +> Thread network throughput is typically lower than Wi-Fi or Ethernet. It is recommended to start with a small OTA binary such as `blink.bin` from `examples/get-started/blink` to validate connectivity. + ## Troubleshooting * Check that your PC can ping the "ESP-Dev-Board" using its IP, and that the IP, AP and other configuration settings are correctly configured in menuconfig diff --git a/examples/system/ota/advanced_https_ota/README.md b/examples/system/ota/advanced_https_ota/README.md index f3eea9565c..0a6d262ba3 100644 --- a/examples/system/ota/advanced_https_ota/README.md +++ b/examples/system/ota/advanced_https_ota/README.md @@ -1,5 +1,5 @@ -| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-P4 | ESP32-S2 | ESP32-S3 | -| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- | +| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-P4 | ESP32-S2 | ESP32-S3 | +| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | # Advanced HTTPS OTA example diff --git a/examples/system/ota/advanced_https_ota/sdkconfig.defaults.esp32h2 b/examples/system/ota/advanced_https_ota/sdkconfig.defaults.esp32h2 new file mode 100644 index 0000000000..eec43a72e9 --- /dev/null +++ b/examples/system/ota/advanced_https_ota/sdkconfig.defaults.esp32h2 @@ -0,0 +1,7 @@ +CONFIG_OPENTHREAD_ENABLED=y + +# CMAC is required for openthread +CONFIG_MBEDTLS_CMAC_C=y + +# ESP32-H2 requires larger OTA partitions for this example +CONFIG_PARTITION_TABLE_TWO_OTA_LARGE=y diff --git a/examples/system/ota/native_ota_example/README.md b/examples/system/ota/native_ota_example/README.md index 311f6e9b83..c0b2203421 100644 --- a/examples/system/ota/native_ota_example/README.md +++ b/examples/system/ota/native_ota_example/README.md @@ -1,5 +1,5 @@ -| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-P4 | ESP32-S2 | ESP32-S3 | -| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- | +| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-P4 | ESP32-S2 | ESP32-S3 | +| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | # Native OTA example diff --git a/examples/system/ota/native_ota_example/sdkconfig.defaults.esp32h2 b/examples/system/ota/native_ota_example/sdkconfig.defaults.esp32h2 new file mode 100644 index 0000000000..909d9d7a8a --- /dev/null +++ b/examples/system/ota/native_ota_example/sdkconfig.defaults.esp32h2 @@ -0,0 +1,4 @@ +CONFIG_OPENTHREAD_ENABLED=y + +# CMAC is required for openthread +CONFIG_MBEDTLS_CMAC_C=y diff --git a/examples/system/ota/pre_encrypted_ota/README.md b/examples/system/ota/pre_encrypted_ota/README.md index 52198e0cd7..765fa8705e 100644 --- a/examples/system/ota/pre_encrypted_ota/README.md +++ b/examples/system/ota/pre_encrypted_ota/README.md @@ -1,5 +1,5 @@ -| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-P4 | ESP32-S2 | ESP32-S3 | -| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- | +| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-P4 | ESP32-S2 | ESP32-S3 | +| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | # Encrypted Binary OTA diff --git a/examples/system/ota/pre_encrypted_ota/sdkconfig.defaults.esp32h2 b/examples/system/ota/pre_encrypted_ota/sdkconfig.defaults.esp32h2 new file mode 100644 index 0000000000..909d9d7a8a --- /dev/null +++ b/examples/system/ota/pre_encrypted_ota/sdkconfig.defaults.esp32h2 @@ -0,0 +1,4 @@ +CONFIG_OPENTHREAD_ENABLED=y + +# CMAC is required for openthread +CONFIG_MBEDTLS_CMAC_C=y diff --git a/examples/system/ota/simple_ota_example/README.md b/examples/system/ota/simple_ota_example/README.md index 4bef69af3c..a45c60c670 100644 --- a/examples/system/ota/simple_ota_example/README.md +++ b/examples/system/ota/simple_ota_example/README.md @@ -1,5 +1,5 @@ -| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-P4 | ESP32-S2 | ESP32-S3 | -| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- | +| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-P4 | ESP32-S2 | ESP32-S3 | +| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | # Simple OTA example diff --git a/examples/system/ota/simple_ota_example/main/Kconfig.projbuild b/examples/system/ota/simple_ota_example/main/Kconfig.projbuild index 4404a99f44..ec64ddedf4 100644 --- a/examples/system/ota/simple_ota_example/main/Kconfig.projbuild +++ b/examples/system/ota/simple_ota_example/main/Kconfig.projbuild @@ -50,6 +50,12 @@ menu "Example Configuration" depends on EXAMPLE_CONNECT_ETHERNET help Select ethernet interface to pass the OTA data. + + config EXAMPLE_FIRMWARE_UPGRADE_BIND_IF_THREAD + bool "Bind thread interface" + depends on EXAMPLE_CONNECT_THREAD + help + Select Thread interface to pass the OTA data. endchoice config EXAMPLE_TLS_DYN_BUF_RX_STATIC diff --git a/examples/system/ota/simple_ota_example/main/simple_ota_example.c b/examples/system/ota/simple_ota_example/main/simple_ota_example.c index 52e1bac6bb..aeb87816d0 100644 --- a/examples/system/ota/simple_ota_example/main/simple_ota_example.c +++ b/examples/system/ota/simple_ota_example/main/simple_ota_example.c @@ -36,6 +36,8 @@ static const char *bind_interface_name = EXAMPLE_NETIF_DESC_ETH; #elif CONFIG_EXAMPLE_FIRMWARE_UPGRADE_BIND_IF_STA static const char *bind_interface_name = EXAMPLE_NETIF_DESC_STA; +#elif CONFIG_EXAMPLE_FIRMWARE_UPGRADE_BIND_IF_THREAD +static const char *bind_interface_name = EXAMPLE_NETIF_DESC_THREAD; #endif #endif diff --git a/examples/system/ota/simple_ota_example/sdkconfig.defaults.esp32h2 b/examples/system/ota/simple_ota_example/sdkconfig.defaults.esp32h2 new file mode 100644 index 0000000000..909d9d7a8a --- /dev/null +++ b/examples/system/ota/simple_ota_example/sdkconfig.defaults.esp32h2 @@ -0,0 +1,4 @@ +CONFIG_OPENTHREAD_ENABLED=y + +# CMAC is required for openthread +CONFIG_MBEDTLS_CMAC_C=y