ESP8266 OTA upgrade failed

tidyjiang8
Posts: 10
Joined: Tue May 30, 2017 7:10 pm

ESP8266 OTA upgrade failed

Postby tidyjiang8 » Sun Jun 04, 2017 12:00 pm

Hi,

I'm using custom server to upgrade esp8266. I can download image from server, but always upgrade failed.

I download the following .bin files to the flash(Before download, I erase the whole flash):

Code: Select all

------------ 2 MByte flash   ------------
0x0           -----  boot_v1.6.bin
0x1000     -----  user1.bin
0x1fb000  -----  blank.bin
0x1fc000  -----  esp_init_data_default.bin
0x1fe000  -----  blank.bin


Here are my log:

Code: Select all

GET /test/user2.bin HTTP/1.0
Host: 192.168.1.113:8292

sumlength = 236224
upgrade file download start.
totallen = 1460
entry smartconfig >>>
A0 A4
SmartConfig OK
totallen = 2920
totallen = 4380
。。。
totallen = 235060
totallen = 236224
upgrade file download finished.
flash_crc = 3875536896
img_crc = 395549339
upgrade_check
ota_upgrade_rsp failed


It seems that the CRC value is error. But I don't know why. And I have checked the CRC in my ubuntu, it's another value:

Code: Select all

work@ubuntu:~/esp/Scent/bin/test$ ls
user1.bin  user2.bin
work@ubuntu:~/esp/Scent/bin/test$ cksum user2.bin
68439177 236224 user2.bin
work@ubuntu:~/esp/Scent/bin/test$


And it's my upgrade code:

Code: Select all


LOCAL void ICACHE_FLASH_ATTR
ota_upgrade_rsp(void *arg)
{
    struct upgrade_server_info *server = arg;
    if (server->upgrade_flag == true)
   {
       // TODO write new version.
       os_printf("user_esp_platform_upgrade_successful\n");
      os_printf("system_upgrade_reboot\n");
        system_param_save_with_protect(ESP_PARAM_START_SEC, &now, sizeof(firmware_version_t));
      system_upgrade_reboot();
    }
   else
    {
        os_printf("ota_upgrade_rsp failed\n");
    }

    os_free(server->url);
    server->url = NULL;
    os_free(server);
    server = NULL;
}


LOCAL void ICACHE_FLASH_ATTR
ota_upgrade_begin(struct espconn *pespconn)
{
    uint8 user_bin[9] = {0};
    uint8 devkey[41] = "No Device key";
    struct upgrade_server_info *server = NULL;

   os_printf("user_ota_upgrade_begin...\n");

    server = (struct upgrade_server_info *)os_zalloc(sizeof(struct upgrade_server_info));

    server->pespconn = pespconn;
    const char remote_ip[4] = {192, 168, 1, 113};
    os_memcpy(server->ip, remote_ip, 4);
    server->port = 8292;

    server->check_cb = ota_upgrade_rsp;
    server->check_times = 120000;

    if (server->url == NULL) {
        server->url = (uint8 *)os_zalloc(512);
    }

    if (system_upgrade_userbin_check() == UPGRADE_FW_BIN1) {
        os_memcpy(user_bin, "user2.bin", 10);
    } else if (system_upgrade_userbin_check() == UPGRADE_FW_BIN2) {
        os_memcpy(user_bin, "user1.bin", 10);
    }
   
    os_sprintf(server->url, "GET /test/%s HTTP/1.0\r\nHost: "IPSTR":%d\r\n\r\n",
                user_bin, IP2STR(server->ip), server->port);
   
    os_printf("%s\n",server->url);

    if (system_upgrade_start(server) == false) {
        os_printf("upgrade is already started\n");
    }
}



Need you all help.
Thanks.

Her Mary
Posts: 537
Joined: Mon Oct 27, 2014 11:09 am

Re: ESP8266 OTA upgrade failed

Postby Her Mary » Mon Jun 05, 2017 10:25 am

Code: Select all

flash_crc = 3875536896
img_crc = 395549339

The image crc (image download from internet) and the flash crc (image write into flash) are not equal.
Maybe you can dump flash to check the image in flash whether it is the user1.bin/user2.bin.

tidyjiang8
Posts: 10
Joined: Tue May 30, 2017 7:10 pm

Re: ESP8266 OTA upgrade failed

Postby tidyjiang8 » Mon Jun 05, 2017 4:23 pm

Her Majesty wrote:

Code: Select all

flash_crc = 3875536896
img_crc = 395549339

The image crc (image download from internet) and the flash crc (image write into flash) are not equal.
Maybe you can dump flash to check the image in flash whether it is the user1.bin/user2.bin.


Thanks for your response.
I have dumped the flash @0x81000 to PC via esptool.py, and compare it with my original user2.bin via beyond compare, it's the same.
I do not know what's incorrect.

Besides, I just now compared the user1.bin and user2.bin, it's same too, is this what it should be ?
Last edited by tidyjiang8 on Mon Jun 05, 2017 4:30 pm, edited 1 time in total.

tidyjiang8
Posts: 10
Joined: Tue May 30, 2017 7:10 pm

Re: ESP8266 OTA upgrade failed

Postby tidyjiang8 » Mon Jun 05, 2017 8:12 pm

The problem is resolved. I'm using NONOS RTOS v1.3 before, after porting the code to NONOS SDK 2.0, OTA successes.

Who is online

Users browsing this forum: No registered users and 64 guests