espressif / esp-mesh-lite

A lite version Wi-Fi Mesh, each node can access the network over the IP layer.
126 stars 18 forks source link

MESH-LITE-LAN-OTA (AEGHB-696) #98

Closed LYL14 closed 3 months ago

LYL14 commented 3 months ago

根节点给子节点传输固件和子节点向上层请求都是通过esp_mesh_lite_transmit_file_start这一个函数吗函数吗。怎么进行子节点升级

LYL14 commented 3 months ago

我的子节点和根节点共用一套程序,我用一下代码,发现实现不了lan-ota功能,有大神吗 esp_err_t ota_finish_err = ESP_OK; esp_http_client_config_t config = { .url = "http://192.168.1.77:8888/s3-mesh-ota.bin", // .crt_bundle_attach = esp_crt_bundle_attach, // .event_handler = _http_event_handler, // .keep_alive_enable = true, };

esp_https_ota_config_t ota_config = {
    .http_config = &config,
    // .http_client_init_cb = _http_client_init_cb, // Register a callback to be invoked after esp_http_client is initialized
};

esp_https_ota_handle_t https_ota_handle = NULL;
esp_err_t err = esp_https_ota_begin(&ota_config, &https_ota_handle);
if (err != ESP_OK)
{
    ESP_LOGE(TAG, "ESP HTTPS OTA Begin failed");
    vTaskDelete(NULL);
}

esp_app_desc_t new_app_desc;
err = esp_https_ota_get_img_desc(https_ota_handle, &new_app_desc);

printf("11111111esp_https_ota_handle_t===%s\n", new_app_desc.version);

if (err != ESP_OK)
{
    printf("esp_https_ota_read_img_desc failed\n");
    ESP_LOGE(TAG, "esp_https_ota_read_img_desc failed");
    esp_https_ota_abort(https_ota_handle);
    // vTaskDelete(NULL);
}

// Root node, start the OTA process
if (esp_mesh_lite_get_level() > 1)
{
    /* Processing flow of child nodes. */
    int filesize = esp_https_ota_get_image_size(https_ota_handle);
    printf("esp_https_ota_get_image_size=%d\n", filesize);
    esp_mesh_lite_file_transmit_config_t transmit_config = {
        .type = ESP_MESH_LITE_OTA_TRANSMIT_FIRMWARE,
        .size = filesize,
        .extern_url_ota_cb = NULL,
    };
    esp_mesh_lite_transmit_file_start(&transmit_config);
}
else
{
    esp_mesh_lite_ota_notify_child_node_pause();
}

if (esp_mesh_lite_get_level() >= 1)
{
    while (1)
    {
        if (esp_mesh_lite_wait_ota_allow() != ESP_OK)
        {
            err = ESP_FAIL;
            break;
        }
        err = esp_https_ota_perform(https_ota_handle);
        if (err != ESP_ERR_HTTPS_OTA_IN_PROGRESS)
        {
            printf("--err-%0x\n", err);
            break;
        }
        int image_len_read = esp_https_ota_get_image_len_read(https_ota_handle);
        int total_size = esp_https_ota_get_image_size(https_ota_handle);
        float progress = (float)image_len_read / total_size * 100;
        ESP_LOGI(TAG, "OTA Progress: %.2f%%", progress);
        ESP_LOGD(TAG, "Image bytes read: %d", esp_https_ota_get_image_len_read(https_ota_handle));
    }
    if (err != ESP_OK)
    {
        printf(" esp_https_ota_abort(https_ota_handle)\n");
        esp_https_ota_abort(https_ota_handle);
        // vTaskDelete(NULL);
    }
}
printf("otaend/n");

ota_finish_err = esp_https_ota_finish(https_ota_handle);
if (ota_finish_err == ESP_OK)
{
    ESP_LOGI(TAG, "ESP_HTTPS_OTA upgrade successful. Rebooting ...");
    vTaskDelay(5000 / portTICK_PERIOD_MS);
    esp_restart();
}
else
{
    if (ota_finish_err == ESP_ERR_OTA_VALIDATE_FAILED)
    {
        ESP_LOGE(TAG, "Image validation failed, image is corrupted");
    }
    ESP_LOGE(TAG, "ESP_HTTPS_OTA upgrade failed 0x%x", ota_finish_err);
    // vTaskDelete(NULL);
}
LYL14 commented 3 months ago

W (41581) [ESP_Mesh_Lite_OTA]: OTA Image version for Project: 9. Expected:
W (41591) [ESP_Mesh_Lite_OTA]: OTA Pending W (41601) [ESP_Mesh_Lite_OTA]: OTA Pending

assert failed: tlsf_free tlsf.c:1120 (!block_is_free(block) && "block already marked as free")

LYL14 commented 3 months ago

I (108395) local_control: OTA Progress: 26.79% I (108395) local_control: OTA Progress: 26.89% I (108435) local_control: OTA Progress: 26.99% I (108505) Mesh-Lite: LAN OTA Percentage: 100% I (108505) esp_image: segment 0: paddr=00210020 vaddr=3c0c0020 size=2c180h (180608) map I (108535) esp_image: segment 1: paddr=0023c1a8 vaddr=3fc98a00 size=03d5ch ( 15708) I (108535) esp_image: segment 2: paddr=0023ff0c vaddr=40374000 size=0010ch ( 268) I (108535) esp_image: segment 3: paddr=00240020 vaddr=42000020 size=b3ac4h (735940) map I (108645) esp_image: segment 4: paddr=002f3aec vaddr=4037410c size=1488ch ( 84108) E (108655) esp_image: Checksum failed. Calculated 0x3b read 0x3 I (108655) esp_image: segment 0: paddr=00210020 vaddr=3c0c0020 size=2c180h (180608) map I (108685) esp_image: segment 1: paddr=0023c1a8 vaddr=3fc98a00 size=03d5ch ( 15708) I (108685) esp_image: segment 2: paddr=0023ff0c vaddr=40374000 size=0010ch ( 268) I (108685) esp_image: segment 3: paddr=00240020 vaddr=42000020 size=b3ac4h (735940) map I (108795) esp_image: segment 4: paddr=002f3aec vaddr=4037410c size=1488ch ( 84108) E (108805) esp_image: Checksum failed. Calculated 0x3b read 0x3 E (108805) [ESP_Mesh_Lite_OTA]: esp_ota_set_boot_partition failed! err=0x1503 I (108805) [ESP_Mesh_Lite_OTA]: OTA End E (108815) Mesh-Lite: LAN OTA Fail! Reason: 7

为什么会mesh-lite-lan-ota和http-ota同时进行,并且基于mesh的OTA100%后,依然失败???

LYL14 commented 3 months ago
esp_err_t ota_finish_err = ESP_OK;
esp_http_client_config_t config = {
    .url = "http://192.168.1.77:8888/s3-mesh-ota.bin",
};

esp_https_ota_config_t ota_config = {
    .http_config = &config,
    .http_client_init_cb = _http_event_handler, // Register a callback to be invoked after esp_http_client is initialized
};

esp_https_ota_handle_t https_ota_handle = NULL;
esp_err_t err = esp_https_ota_begin(&ota_config, &https_ota_handle);
if (err != ESP_OK)
{
    ESP_LOGE(TAG, "ESP HTTPS OTA Begin failed");
    vTaskDelete(NULL);
}
esp_app_desc_t new_app_desc;
err = esp_https_ota_get_img_desc(https_ota_handle, &new_app_desc);
printf("11111111esp_https_ota_handle_t===%s\n", new_app_desc.version);

if (err != ESP_OK)
{
    printf("esp_https_ota_read_img_desc failed\n");
    ESP_LOGE(TAG, "esp_https_ota_read_img_desc failed");
    // esp_https_ota_abort(https_ota_handle);
    vTaskDelete(NULL);
}

// Root node, start the OTA process if (esp_mesh_lite_get_level() > 1) { / Processing flow of child nodes. / int filesize = esp_https_ota_get_image_size(https_ota_handle); printf("esp_https_ota_get_image_size=%d\n", filesize); esp_mesh_lite_file_transmit_config_t transmit_config = { .type = ESP_MESH_LITE_OTA_TRANSMIT_FIRMWARE, .size = filesize, .extern_url_ota_cb = NULL, }; esp_mesh_lite_transmit_file_start(&transmit_config); } else { esp_mesh_lite_ota_notify_child_node_pause(); }

if (esp_mesh_lite_get_level() >= 1)
{
    while (1)
    {
        if (esp_mesh_lite_wait_ota_allow() != ESP_OK)
        {
            err = ESP_FAIL;
            break;
        }
        err = esp_https_ota_perform(https_ota_handle);
        if (err != ESP_ERR_HTTPS_OTA_IN_PROGRESS)
        {
            printf("--err-%0x\n", err);
            break;
        }
        int image_len_read = esp_https_ota_get_image_len_read(https_ota_handle);
        int total_size = esp_https_ota_get_image_size(https_ota_handle);
        float progress = (float)image_len_read / total_size * 100;
        ESP_LOGI(TAG, "OTA Progress: %.2f%%", progress);
        ESP_LOGD(TAG, "Image bytes read: %d", esp_https_ota_get_image_len_read(https_ota_handle));
    }
    if (err != ESP_OK)
    {
        printf(" esp_https_ota_perfo=%0x\n", err);
        esp_https_ota_abort(https_ota_handle);
        // vTaskDelete(NULL);
    }
}
printf("otaend/n");

ota_finish_err = esp_https_ota_finish(https_ota_handle);
if (ota_finish_err == ESP_OK)
{
    ESP_LOGI(TAG, "ESP_HTTPS_OTA upgrade successful. Rebooting ...");
    vTaskDelay(5000 / portTICK_PERIOD_MS);
    esp_restart();
}
else
{
    if (ota_finish_err == ESP_ERR_OTA_VALIDATE_FAILED)
    {
        ESP_LOGE(TAG, "Image validation failed, image is corrupted");
    }
    ESP_LOGE(TAG, "ESP_HTTPS_OTA upgrade failed 0x%x", ota_finish_err);
    // vTaskDelete(NULL);
}