I added OTA features to my esp32 project and have some problems:
When I use WiFi sta mode, OTA (I refer to and migrate the code which is esp / ESP IDF / examples / system / OTA / simple_ota_example) works well; however, when I use Ethernet mode, esp_https_ota always returns an error "0x1503" (ESP_ERR_OTA_VALIDATE_FAILED);The detailed output log is as follows:
[17:19:42:378] <0x1b>[0;32mI (631532) esp_https_ota: Starting OTA...<0x1b>[0m␍␊
[17:19:42:378] <0x1b>[0;32mI (631532) esp_https_ota: Writing to partition subtype 17 at offset 0x200000<0x1b>[0m␍␊
[17:19:53:354] <0x1b>[0;31mE (642512) esp-tls: read error :-76:<0x1b>[0m␍␊
[17:19:53:354] <0x1b>[0;31mE (642512) TRANS_SSL: esp_tls_conn_read error, errno=No more processes<0x1b>[0m␍␊
[17:19:58:409] <0x1b>[0;32mI (647572) esp_https_ota: Connection closed, all data received<0x1b>[0m␍␊
[17:19:58:425] <0x1b>[0;32mI (647572) esp_image: segment 0: paddr=0x00200020 vaddr=0x3f400020 size=0x33b54 (211796) map<0x1b>[0m␍␊
[17:19:58:585] <0x1b>[0;31mE (647732) esp_image: invalid segment length 0xffffffff<0x1b>[0m␍␊
[17:19:58:585] <0x1b>[0;31mE (647742) main: Firmware Upgrades Failed 5379, 0x00001503<0x1b>[0m␍␊
I don't know why. My hardware is ESP32-Ethernet-Kit_A_V1.1(ESP32-WROVER-B + IP101), and my IDF version is ESP-IDF v4.0-beta1-180-ga21eb04cc.I have installed the Ethernet driver correctly and got the local IP (DHCP succeeded); my eth code:
Code: Select all
static void initialise_eth(void)
{
ESP_LOGI(TAG, "init eths");
ESP_ERROR_CHECK(tcpip_adapter_clear_default_wifi_handlers());
ESP_ERROR_CHECK(tcpip_adapter_set_default_eth_handlers());
ESP_ERROR_CHECK(esp_event_handler_register(ETH_EVENT, ESP_EVENT_ANY_ID, ð_event_handler, NULL));
ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, IP_EVENT_ETH_GOT_IP, ð_ip_event_handler, NULL));
eth_mac_config_t mac_config = ETH_MAC_DEFAULT_CONFIG();
eth_phy_config_t phy_config = ETH_PHY_DEFAULT_CONFIG();
esp_eth_mac_t *mac = esp_eth_mac_new_esp32(&mac_config);
esp_eth_phy_t *phy = esp_eth_phy_new_ip101(&phy_config);
esp_eth_config_t config = ETH_DEFAULT_CONFIG(mac, phy);
esp_eth_handle_t eth_handle = NULL;
ESP_ERROR_CHECK(esp_eth_driver_install(&config, ð_handle));
}
Code: Select all
esp_http_client_config_t config = {
.url = ota_url,
.port = configure_using->ota_info.rport,
.cert_pem = (char *)server_cert_pem_start,
.event_handler = _http_event_handler,
.transport_type = HTTP_TRANSPORT_OVER_SSL,
.buffer_size = 4096,
.buffer_size_tx = 1024
};
esp_err_t ret = esp_https_ota(&config);
if (ret == ESP_OK) {
ESP_LOGE(TAG, "Firmware Upgrades success");
task_delay(100);
esp_restart();
} else {
ESP_LOGE(TAG, "Firmware Upgrades Failed %d, 0x%08X", ret, ret);
}