I'm trying to update my ESP32 through OTA by downloading a file from my Google Drive.
When I start the OTA update, the system starts to write in the partition but then it quits.
I'm sharing a link to google drive that works as direct download link (tested).
I use an ESP32-WROOM-32 with 4MB of RAM, 1 factory and 2 OTA partition table. ESP-IDF v4.4.
Here I attach my code:
- static esp_err_t
- client_event_handler (esp_http_client_event_t * p_evt)
- {
- switch (p_evt->event_id)
- {
- case HTTP_EVENT_ERROR:
- ESP_LOGI(TAG, "HTTP_EVENT_ERROR");
- break;
- case HTTP_EVENT_ON_CONNECTED:
- ESP_LOGI(TAG, "HTTP_EVENT_ON_CONNECTED");
- break;
- case HTTP_EVENT_HEADERS_SENT:
- ESP_LOGI(TAG, "HTTP_EVENT_HEADERS_SENT");
- break;
- case HTTP_EVENT_ON_HEADER:
- ESP_LOGI(TAG, "HTTP_EVENT_ON_HEADER, key=%s, value=%s", p_evt->header_key, p_evt->header_value);
- break;
- case HTTP_EVENT_ON_DATA:
- ESP_LOGI(TAG, "HTTP_EVENT_ON_DATA, len=%d", p_evt->data_len);
- break;
- case HTTP_EVENT_ON_FINISH:
- ESP_LOGI(TAG, "HTTP_EVENT_ON_FINISH");
- break;
- case HTTP_EVENT_DISCONNECTED:
- ESP_LOGI(TAG, "HTTP_EVENT_DISCONNECTED");
- break;
- }
- return ESP_OK;
- }
- static void
- task_ota (void * p_param)
- {
- for (;;)
- {
- xSemaphoreTake(gh_ota_semaphore, portMAX_DELAY);
- ESP_LOGI(TAG, "Invoking OTA");
- esp_http_client_config_t client_config = {
- .url = "https://drive.google.com/uc?authuser=0&id=1wnJTjI31OjusFE5X4pqWlO_-GpFpfh3c&export=download",
- .event_handler = client_event_handler,
- .cert_pem = (char *) g_server_cert_pem_start,
- };
- esp_err_t ret = esp_https_ota(&client_config);
- if (ESP_OK == ret)
- {
- ESP_LOGI(TAG, "OTA flash successful for version %d", g_software_version);
- printf("restarting in 5 seconds\n");
- vTaskDelay(5000 / portTICK_PERIOD_MS);
- esp_restart();
- }
- else
- {
- ESP_LOGE(TAG, "Failed to update the firmare, error %s", esp_err_to_name(ret));
- }
- }
- }
Also, it starts writing to partition, but I don't see any HTTP_EVENT_ON_DATA in my client_event_handler(), so I think there is something strange when I try to receive the data.
Code: Select all
I (987) wifi: connected
W (997) wifi:<ba-add>idx:0 (ifx:0, 54:af:97:96:fd:14), tid:0, ssn:2, winSize:64
I (1067) wifi:AP's beacon interval = 102400 us, DTIM period = 1
I (2097) wifi: got ip
I (2097) esp_netif_handlers: sta ip: 192.168.1.101, mask: 255.255.255.0, gw: 192.168.1.1
I (28657) OTA: Invoking OTA
W (29537) wifi:<ba-add>idx:1 (ifx:0, 54:af:97:96:fd:14), tid:4, ssn:0, winSize:64
I (32967) OTA: HTTP_EVENT_ON_CONNECTED
I (32967) OTA: HTTP_EVENT_HEADERS_SENT
I (33637) OTA: HTTP_EVENT_ON_HEADER, key=Content-Type, value=application/binary
I (33637) OTA: HTTP_EVENT_ON_HEADER, key=Cache-Control, value=no-cache, no-store, max-age=0, must-revalidate
I (33647) OTA: HTTP_EVENT_ON_HEADER, key=Pragma, value=no-cache
I (33657) OTA: HTTP_EVENT_ON_HEADER, key=Expires, value=Mon, 01 Jan 1990 00:00:00 GMT
I (33667) OTA: HTTP_EVENT_ON_HEADER, key=Date, value=Sun, 05 Mar 2023 14:46:30 GMT
I (33667) OTA: HTTP_EVENT_ON_HEADER, key=Location, value=https://doc-14-20-docs.googleusercontent.com/docs/securesc/ha0ro937gcuc7l7deffksulhg5h7mbp1/6ir6a96hmgvcs9brg6n22srp2sbkm7u0/1678027575000/09062185099277447438/*/1wnJTjI31OjusFE5X4pqWlO_-GpFpfh3c?e=download&uuid=49b47a62-a14f-4620-96b2-8c6d7411b5d4
I (33697) OTA: HTTP_EVENT_ON_HEADER, key=Strict-Transport-Security, value=max-age=31536000
I (33707) OTA: HTTP_EVENT_ON_HEADER, key=Content-Security-Policy, value=require-trusted-types-for 'script';report-uri /_/DriveUntrustedContentHttp/cspreport
I (33727) OTA: HTTP_EVENT_ON_HEADER, key=Content-Security-Policy, value=script-src 'report-sample' 'nonce-XMIgXLmtSKVl__jItA-H2g' 'unsafe-inline';object-src 'none';base-uri 'self';report-uri /_/DriveUntrustedContentHttp/cspreport;worker-src 'self'
I (33747) OTA: HTTP_EVENT_ON_HEADER, key=Cross-Origin-Opener-Policy, value=same-origin
I (33757) OTA: HTTP_EVENT_ON_HEADER, key=Permissions-Policy, value=ch-ua-arch=*, ch-ua-bitness=*, ch-ua-full-version=*, ch-ua-full-version-list=*, ch-ua-model=*, ch-ua-wow64=*, ch-ua-platform=*, ch-ua-platform-version=*
I (33777) OTA: HTTP_EVENT_ON_HEADER, key=Accept-CH, value=Sec-CH-UA-Arch, Sec-CH-UA-Bitness, Sec-CH-UA-Full-Version, Sec-CH-UA-Full-Version-List, Sec-CH-UA-Model, Sec-CH-UA-WoW64, Sec-CH-UA-Platform, Sec-CH-UA-Platform-Version
I (33797) OTA: HTTP_EVENT_ON_HEADER, key=Server, value=ESF
I (33797) OTA: HTTP_EVENT_ON_HEADER, key=Content-Length, value=0
I (33807) OTA: HTTP_EVENT_ON_HEADER, key=X-XSS-Protection, value=0
I (33817) OTA: HTTP_EVENT_ON_HEADER, key=X-Frame-Options, value=SAMEORIGIN
I (33827) OTA: HTTP_EVENT_ON_HEADER, key=X-Content-Type-Options, value=nosniff
I (33827) OTA: HTTP_EVENT_ON_HEADER, key=Alt-Svc, value=h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
I (33837) esp_https_ota: Starting OTA...
I (33847) esp_https_ota: Writing to partition subtype 16 at offset 0x110000
I (33857) OTA: HTTP_EVENT_DISCONNECTED
I (33867) OTA: HTTP_EVENT_DISCONNECTED
E (33867) OTA: Failed to update the firmare, error ESP_ERR_INVALID_ARG