- 18:21:51.636 -> ESP-ROM:esp32s3-20210327
- 18:21:51.636 -> Build:Mar 27 2021
- 18:21:51.636 -> rst:0x1 (POWERON),boot:0xc (SPI_FAST_FLASH_BOOT)
- 18:21:51.636 -> SPIWP:0xee
- 18:21:51.636 -> mode:DIO, clock div:1
- 18:21:51.636 -> load:0x3fce3808,len:0x1744
- 18:21:51.636 -> load:0x403c9700,len:0xc00
- 18:21:51.636 -> load:0x403cc700,len:0x3218
- 18:21:51.636 -> entry 0x403c9968
- 18:21:51.636 -> [0;32mI (24) boot: ESP-IDF v4.4.3-dirty 2nd stage bootloader[0m
- 18:21:51.636 -> [0;32mI (25) boot: compile time 17:13:57[0m
- 18:21:51.636 -> [0;32mI (25) boot: chip revision: 0[0m
- 18:21:51.636 -> [0;32mI (27) boot.esp32s3: Boot SPI Speed : 80MHz[0m
- 18:21:51.636 -> [0;32mI (32) boot.esp32s3: SPI Mode : DIO[0m
- 18:21:51.636 -> [0;32mI (36) boot.esp32s3: SPI Flash Size : 16MB[0m
- 18:21:51.636 -> [0;32mI (41) boot: Enabling RNG early entropy source...[0m
- 18:21:51.636 -> [0;32mI (47) boot: Partition Table:[0m
- 18:21:51.636 -> [0;32mI (50) boot: ## Label Usage Type ST Offset Length[0m
- 18:21:51.636 -> [0;32mI (57) boot: 0 nvs WiFi data 01 02 00009000 00004000[0m
- 18:21:51.636 -> [0;32mI (65) boot: 1 otadata OTA data 01 00 0000d000 00002000[0m
- 18:21:51.636 -> [0;32mI (72) boot: 2 phy_init RF data 01 01 0000f000 00001000[0m
- 18:21:51.636 -> [0;32mI (80) boot: 3 factory factory app 00 00 00010000 00200000[0m
- 18:21:51.636 -> [0;32mI (87) boot: 4 ota_0 OTA app 00 10 00210000 00200000[0m
- 18:21:51.636 -> [0;32mI (95) boot: 5 ota_1 OTA app 00 11 00410000 00200000[0m
- 18:21:51.636 -> [0;32mI (102) boot: End of partition table[0m
- 18:21:51.636 -> [0;32mI (106) boot: Defaulting to factory image[0m
- 18:21:51.636 -> [0;32mI (111) esp_image: segment 0: paddr=00010020 vaddr=3c070020 size=15c74h ( 89204) map[0m
- 18:21:51.636 -> [0;32mI (136) esp_image: segment 1: paddr=00025c9c vaddr=3fc97600 size=050d8h ( 20696) load[0m
- 18:21:51.636 -> [0;32mI (140) esp_image: segment 2: paddr=0002ad7c vaddr=40374000 size=0529ch ( 21148) load[0m
- 18:21:51.636 -> [0;32mI (146) esp_image: segment 3: paddr=00030020 vaddr=42000020 size=6d768h (448360) map[0m
- 18:21:51.865 -> [0;32mI (230) esp_image: segment 4: paddr=0009d790 vaddr=4037929c size=0e35ch ( 58204) load[0m
- 18:21:51.865 -> [0;32mI (243) esp_image: segment 5: paddr=000abaf4 vaddr=50000000 size=00010h ( 16) load[0m
- 18:21:51.865 -> [0;32mI (251) boot: Loaded app from partition at offset 0x10000[0m
- 18:21:51.865 -> [0;32mI (251) boot: Disabling RNG early entropy source...[0m
- 18:21:51.865 -> [0;32mI (263) cpu_start: Pro cpu up.[0m
- 18:21:51.865 -> [0;32mI (263) cpu_start: Starting app cpu, entry point is 0x40375304[0m
- 18:21:51.865 -> [0;32mI (0) cpu_start: App cpu up.[0m
- 18:21:51.865 -> [0;32mI (277) cpu_start: Pro cpu start user code[0m
- 18:21:51.865 -> [0;32mI (278) cpu_start: cpu freq: 160000000[0m
- 18:21:51.865 -> [0;32mI (278) cpu_start: Application information:[0m
- 18:21:51.865 -> [0;32mI (280) cpu_start: Project name: VCI_AL[0m
- 18:21:51.865 -> [0;32mI (285) cpu_start: App version: 010af76-dirty[0m
- 18:21:51.865 -> [0;32mI (291) cpu_start: Compile time: Dec 6 2022 17:39:08[0m
- 18:21:51.865 -> [0;32mI (297) cpu_start: ELF file SHA256: 45e3beec6be7d774...[0m
- 18:21:51.865 -> [0;32mI (303) cpu_start: ESP-IDF: v4.4.3-dirty[0m
- 18:21:51.865 -> [0;32mI (308) heap_init: Initializing. RAM available for dynamic allocation:[0m
- 18:21:51.865 -> [0;32mI (315) heap_init: At 3FCA2148 len 000475C8 (285 KiB): D/IRAM[0m
- 18:21:51.865 -> [0;32mI (322) heap_init: At 3FCE9710 len 00005724 (21 KiB): STACK/DRAM[0m
- 18:21:51.865 -> [0;32mI (328) heap_init: At 3FCF0000 len 00008000 (32 KiB): DRAM[0m
- 18:21:51.865 -> [0;32mI (335) heap_init: At 600FE000 len 00002000 (8 KiB): RTCRAM[0m
- 18:21:51.865 -> [0;32mI (341) spi_flash: detected chip: gd[0m
- 18:21:51.865 -> [0;32mI (345) spi_flash: flash io: dio[0m
- 18:21:51.865 -> [0;32mI (350) sleep: Configure to isolate all GPIO pins in sleep state[0m
- 18:21:51.865 -> [0;32mI (356) sleep: Enable automatic switching of GPIO sleep configuration[0m
- 18:21:51.865 -> [0;32mI (363) esp_core_dump_uart: Init core dump to UART[0m
- 18:21:51.865 -> [0;32mI (368) coexist: coexist rom version e7ae62f[0m
- 18:21:51.865 -> [0;32mI (374) cpu_start: Starting scheduler on PRO CPU.[0m
- 18:21:51.865 -> [0;32mI (0) cpu_start: Starting scheduler on APP CPU.[0m
- 18:21:54.056 -> [0;32mI (4794) uart: queue free spaces: 20[0m
- 18:21:54.102 -> [0;33mW (4804) BT_INIT: esp_bt_controller_mem_release not implemented, return OK[0m
- 18:21:54.102 -> [0;32mI (4804) BT_INIT: BT controller compile version [421c279][0m
- 18:21:54.102 -> [0;32mI (4804) phy_init: phy_version 503,13653eb,Jun 1 2022,17:47:08[0m
- 18:21:54.151 -> [0;32mI (4844) system_api: Base MAC address is not set[0m
- 18:21:54.151 -> [0;32mI (4844) system_api: read default base MAC address from EFUSE[0m
- 18:21:54.151 -> [0;32mI (4844) BT_INIT: Bluetooth MAC: f4:12:fa:d5:66:7a
- 18:21:54.151 -> [0m
- 18:21:54.151 -> [0;32mI (4854) NimBLE: GAP procedure initiated: stop advertising.
- 18:21:54.151 -> [0m
- 18:21:54.151 -> [0;32mI (4864) NimBLE: GAP procedure initiated: advertise; [0m
- 18:21:54.151 -> [0;32mI (4864) NimBLE: disc_mode=2[0m
- 18:21:54.151 -> [0;32mI (4874) NimBLE: adv_channel_map=0 own_addr_type=0 adv_filter_policy=0 adv_itvl_min=0 adv_itvl_max=0[0m
- 18:21:54.151 -> [0;32mI (4884) NimBLE:
- 18:21:54.151 -> [0m
- 18:21:56.155 -> Waiting 2 Seconds . .
- 18:21:56.155 -> Copied "TOOL BUSY" into the Message
- 18:21:58.159 -> Waiting 2 Seconds . .
- 18:21:58.159 -> Copied "TOOL READY" into the Message
- 18:21:58.159 -> [0;32mI (8884) uart: queue free spaces: 20[0m
- 18:21:58.159 -> ESP32 Started;
- 18:22:18.085 -> [0;32mI (28794) UART0: [DATA_EVT]: {"Command":"UpdateOTA"};
- 18:22:18.085 -> [0m
- 18:22:18.085 -> Received Total 23 bytes of Data
- 18:22:18.085 -> The Received Data String is : {"Command":"UpdateOTA"}
- 18:22:18.085 -> Received Command: UpdateOTA
- 18:22:18.085 -> Received UpdateOTA inside parse_commands
- 18:22:20.092 -> [0;32mI (30834) MSC: Waiting for USB stick to be connected[0m
- 18:22:20.549 -> [0;32mI (31274) MSC: MSC device connected[0m
- 18:22:21.644 -> Device info:
- 18:22:21.644 -> Capacity: 14805 MB
- 18:22:21.644 -> Sector size: 512
- 18:22:21.644 -> Sector count: 30322687
- 18:22:21.644 -> PID: 0x1985
- 18:22:21.644 -> VID: 0x 3F0
- 18:22:21.644 ->
The Example (HTTPS OTA Update) over WiFi Works, but I require the USB Based OTA Function to Work.<br/>
I will hugely appreciate any help/pointers in this regard.<br/>
- #include "Common_Variables.h"
- #include "stdbool.h"
- #include "esp_ota_ops.h" //included header file for esp_ota driver
- #define OTA_MAX_BYTES_PER_BATCH 4096
- uint8_t buf[OTA_MAX_BYTES_PER_BATCH+1];
- static char* TAG = "OTA";
- static uint32_t total = 0;
- static uint32_t pct = 0;
- static uint32_t pct_send = 0;
- static char message_data[10];
- //static esp_err_t err;//Error variable to indicate when calling function return error.It is used in NVS function (WRITE,READ SERIAL number from NVS)
- static esp_ota_handle_t update_handle = 0; //should be used for subsequent esp_ota_write() and esp_ota_end() calls
- //const esp_partition_t *update_partition = NULL; //Pointer to info for partition which should be updated next.
- //NULL result indicates invalid OTA data partition, or that no eligible OTA app slot partition was found
- //Function is used to implement OTA function
- static void ota_func_task(void *pvParameter){
- //esp_err_t ota_func_task(void) {
- FILE *ota_bin_file;
- int finished = 0;
- struct stat entry_stat;
- uint32_t file_size_number = 0;
- char file_size[16];
- char ota_bin_file_path[50] = "/usb/OTA/VCI_AL.bin";
- printf("OTA Bin File Path = %s \n", ota_bin_file_path);
- ota_bin_file = fopen (ota_bin_file_path, "rb" );
- if (ota_bin_file == NULL) {
- printf("Failed to open file for reading \n");
- vTaskDelete(NULL);
- }else{
- printf("Opened OTA BIN file for reading \n");
- //stat();
- if (stat(ota_bin_file_path, &entry_stat) == -1) {
- printf("Failed to stat %s \n", ota_bin_file_path);
- //return ESP_FAIL;
- vTaskDelete(NULL);
- }
- file_size_number = (uint32_t) entry_stat.st_size;
- printf("File Size is %d \n", file_size_number);
- sprintf(file_size, "%ld", entry_stat.st_size);
- printf("Found %s : (%s bytes) \n", ota_bin_file_path, file_size);
- }
- printf("starting main task firmware update \n");
- vTaskDelay(500 / portTICK_PERIOD_MS);
- const esp_partition_t *configured = esp_ota_get_boot_partition();
- const esp_partition_t *running = esp_ota_get_running_partition();
- if (configured != running) {
- printf("Configured OTA boot partition at offset 0x%08x, but running from offset 0x%08x \n",configured->address, running->address);
- printf("This can happen if either the OTA boot data or preferred boot image become corrupted somehow.\n");
- }
- printf("Running partition type %d sub-type %d (offset 0x%08x) \n",running->type, running->subtype, running->address);
- const esp_partition_t *update_partition = esp_ota_get_next_update_partition(NULL);
- assert(update_partition != NULL);
- printf("Writing to partition subtype %d at offset 0x%x \n", update_partition->subtype, update_partition->address);
- //esp_err_t err = esp_ota_begin(update_partition, OTA_SIZE_UNKNOWN, &update_handle);
- esp_err_t err = esp_ota_begin(update_partition, file_size_number, &update_handle);
- ESP_LOGI(TAG, "esp_begin result = %d", err);
- printf("Update Handle is %d \n", update_handle);
- if (err != ESP_OK) {
- printf("esp_ota_begin failed, error=%d \n", err);
- printf("esp_ota_begin failed\n");
- vTaskDelete(NULL);
- }
- printf("esp_ota_begin succeeded \n-----------------------\n");
- while(!finished)
- {
- unsigned int retn = fread(buf, 1, OTA_MAX_BYTES_PER_BATCH, ota_bin_file);
- printf("First Byte of the Read Data Chunk is %X \n", buf[0]);
- if(retn != OTA_MAX_BYTES_PER_BATCH)
- {
- printf("Finished reading, Last Chunk size %d \n",retn);
- err = esp_ota_write(update_handle, buf, retn);
- if (err == ESP_ERR_INVALID_ARG) {
- printf("error: esp_ota_write failed! err=0x%x\n", err);
- vTaskDelete(NULL);
- } else if (err == ESP_ERR_OTA_VALIDATE_FAILED) {
- printf("error: First byte of image contains invalid app image magic byte\n");
- } else if (err == ESP_ERR_FLASH_OP_FAIL) {
- printf("error: Flash write IO Operaion failed\n");
- } else if (err == ESP_ERR_FLASH_OP_TIMEOUT) {
- printf("error: Flash write failed due to TimeOut\n");
- } else if (err == ESP_ERR_OTA_SELECT_INFO_INVALID) {
- printf("error: OTA data partition has invalid contents\n");
- } else if (err == ESP_OK) {
- printf("Wrote %d Bytes to OTA Partition \n", retn);
- }
- ESP_LOGI(TAG, "Ota result = %d", err);
- total += retn;
- pct = total * 100 / file_size_number;
- itoa(pct, message_data, 10);
- printf("Progress %s %% \n", message_data);
- printf("Total Bytes Read from the OTA BIN File is %d \n", total);
- //vTaskDelay(5000/portTICK_PERIOD_MS);
- printf("Update Handle is %d \n", update_handle);
- err = esp_ota_end(update_handle);
- if (err != ESP_OK) {
- if (err == ESP_ERR_OTA_VALIDATE_FAILED) {
- ESP_LOGE(TAG, "Image validation failed, image is corrupted");
- } else {
- ESP_LOGE(TAG, "esp_ota_end failed (%s)!", esp_err_to_name(err));
- }
- vTaskDelete(NULL);
- }
- //vTaskDelay(5000/portTICK_PERIOD_MS);
- printf("OTA Update has Ended \n");
- err = esp_ota_set_boot_partition(update_partition);
- if (err != ESP_OK) {
- ESP_LOGE(TAG, "esp_ota_set_boot_partition failed (%s)!", esp_err_to_name(err));
- }
- vTaskDelay(5000/portTICK_PERIOD_MS);
- ESP_LOGI(TAG, "Prepare to restart system!");
- finished = 1;
- break;
- }
- else
- {
- //gpio_set_level(WiFi_LED, toggle);
- //toggle = !toggle;
- err = esp_ota_write(update_handle, buf, retn);
- if (err == ESP_ERR_INVALID_ARG) {
- printf("error: esp_ota_write failed! err=0x%x\n", err);
- vTaskDelete(NULL);
- } else if (err == ESP_ERR_OTA_VALIDATE_FAILED) {
- printf("error: First byte of image contains invalid app image magic byte\n");
- } else if (err == ESP_ERR_FLASH_OP_FAIL) {
- printf("error: Flash write IO Operaion failed\n");
- } else if (err == ESP_ERR_FLASH_OP_TIMEOUT) {
- printf("error: Flash write failed due to TimeOut\n");
- } else if (err == ESP_ERR_OTA_SELECT_INFO_INVALID) {
- printf("error: OTA data partition has invalid contents\n");
- } else if (err == ESP_OK) {
- printf("Wrote %d Bytes to OTA Partition \n", retn);
- }
- total += OTA_MAX_BYTES_PER_BATCH;
- pct = total * 100 / file_size_number; //calculated percentage
- if(pct != pct_send ) //i.e. if the rounded off percentage is updated
- {
- pct_send = pct;
- itoa(pct, message_data, 10);
- printf("Progress %s %% \n", message_data);
- }
- }
- }//Reading of data from PenDrive complete
- //return ESP_OK;
- vTaskDelete(NULL);
- } //end of OTA function
- esp_err_t ota_func(){
- xTaskCreate(&ota_func_task, "ota_func_task", 8192, NULL, 5, NULL);
- return ESP_OK;
- }