fix: fix preencrypted ota failed with pytest server and partial http enabled
This commit is contained in:
@@ -74,6 +74,7 @@ static esp_err_t _decrypt_cb(decrypt_cb_arg_t *args, void *user_ctx)
|
||||
if (err != ESP_OK && err != ESP_ERR_NOT_FINISHED) {
|
||||
return err;
|
||||
}
|
||||
|
||||
static bool is_image_verified = false;
|
||||
if (pargs.data_out_len > 0) {
|
||||
args->data_out = pargs.data_out;
|
||||
@@ -143,6 +144,7 @@ void pre_encrypted_ota_task(void *pvParameter)
|
||||
#endif
|
||||
.decrypt_cb = _decrypt_cb,
|
||||
.decrypt_user_ctx = (void *)decrypt_handle,
|
||||
.enc_img_header_size = esp_encrypted_img_get_header_size(),
|
||||
};
|
||||
|
||||
esp_https_ota_handle_t https_ota_handle = NULL;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||
import http.server
|
||||
import multiprocessing
|
||||
@@ -82,3 +82,47 @@ def test_examples_protocol_pre_encrypted_ota_example(dut: Dut) -> None:
|
||||
dut.expect('Loaded app from partition at offset', timeout=30)
|
||||
finally:
|
||||
thread1.terminate()
|
||||
|
||||
|
||||
@pytest.mark.esp32
|
||||
@pytest.mark.ethernet_ota
|
||||
@pytest.mark.parametrize('config', ['partial_download',], indirect=True)
|
||||
def test_examples_protocol_pre_encrypted_ota_example_partial_request(dut: Dut) -> None:
|
||||
server_port = 8001
|
||||
# Size of partial HTTP request
|
||||
request_size = int(dut.app.sdkconfig.get('EXAMPLE_HTTP_REQUEST_SIZE'))
|
||||
# File to be downloaded. This file is generated after compilation
|
||||
binary_file = os.path.join(dut.app.binary_path, enc_bin_name)
|
||||
bin_size = os.path.getsize(binary_file)
|
||||
http_requests = int((bin_size / request_size) - 1)
|
||||
assert http_requests > 1
|
||||
|
||||
# Start server
|
||||
thread1 = multiprocessing.Process(target=start_https_server, args=(dut.app.binary_path, '0.0.0.0', server_port))
|
||||
thread1.daemon = True
|
||||
thread1.start()
|
||||
|
||||
try:
|
||||
dut.expect('Loaded app from partition at offset', timeout=30)
|
||||
try:
|
||||
ip_address = dut.expect(r'IPv4 address: (\d+\.\d+\.\d+\.\d+)[^\d]', timeout=30)[1].decode()
|
||||
print('Connected to AP/Ethernet with IP: {}'.format(ip_address))
|
||||
except pexpect.exceptions.TIMEOUT:
|
||||
raise ValueError('ENV_TEST_FAILURE: Cannot connect to AP/Ethernet')
|
||||
host_ip = get_host_ip4_by_dest_ip(ip_address)
|
||||
|
||||
dut.expect('Starting Pre Encrypted OTA example', timeout=30)
|
||||
print('writing to device: {}'.format('https://' + host_ip + ':' + str(server_port) + '/' + enc_bin_name))
|
||||
dut.write('https://' + host_ip + ':' + str(server_port) + '/' + enc_bin_name)
|
||||
dut.expect('Magic Verified', timeout=30)
|
||||
dut.expect('Reading RSA private key', timeout=30)
|
||||
|
||||
for _ in range(http_requests):
|
||||
dut.expect('Connection closed', timeout=60)
|
||||
|
||||
dut.expect('upgrade successful. Rebooting', timeout=60)
|
||||
# after reboot
|
||||
dut.expect('Loaded app from partition at offset', timeout=30)
|
||||
|
||||
finally:
|
||||
thread1.terminate()
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
CONFIG_EXAMPLE_FIRMWARE_UPGRADE_URL="FROM_STDIN"
|
||||
CONFIG_EXAMPLE_SKIP_COMMON_NAME_CHECK=y
|
||||
CONFIG_EXAMPLE_SKIP_VERSION_CHECK=y
|
||||
CONFIG_EXAMPLE_OTA_RECV_TIMEOUT=3000
|
||||
CONFIG_EXAMPLE_ENABLE_PARTIAL_HTTP_DOWNLOAD=y
|
||||
CONFIG_LOG_DEFAULT_LEVEL_DEBUG=y
|
||||
|
||||
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_MBEDTLS_TLS_CLIENT_ONLY=y
|
||||
CONFIG_COMPILER_OPTIMIZATION_SIZE=y
|
||||
CONFIG_EXAMPLE_CONNECT_IPV6=n
|
||||
Reference in New Issue
Block a user