esp8266 nonos sdk 2.2.0 ota flash_crc!=img_crc

limuzi2012
Posts: 4
Joined: Fri Aug 18, 2017 8:24 am

esp8266 nonos sdk 2.2.0 ota flash_crc!=img_crc

Postby limuzi2012 » Fri Mar 16, 2018 8:51 am

otallen = 358876
totallen = 360336
totallen = 361396
upgrade file download finished.
flash_crc = 3525425237

[08:40:28.378]收←◆img_crc = 645727078
upgrade_check
[OTA]failed!

limuzi2012
Posts: 4
Joined: Fri Aug 18, 2017 8:24 am

Re: esp8266 nonos sdk 2.2.0 ota flash_crc!=img_crc

Postby limuzi2012 » Sat Mar 17, 2018 11:59 am

like this website :https://stackoverflow.com/questions/47147491/esp8266-nonos-sdk-fota-error-check-the-bin-file

Code: Select all

#define pheadbuffer "Connection: keep-alive\r\n\
Cache-Control: no-cache\r\n\
\r\n"

void ICACHE_FLASH_ATTR ota_start_Upgrade(uint8_t serverVersion, const char *server_ip, uint16_t port, const char *path)
{
   const char* file;
   uint8_t userBin = system_upgrade_userbin_check(); 
   switch (userBin)
   {
   case UPGRADE_FW_BIN1: file = "user2.4096.new.4.bin"; break; //  user2.bin
   case UPGRADE_FW_BIN2: file = "user1.4096.new.4.bin"; break; // user1.bin
   default:
      os_printf("[OTA]Invalid userbin number!\n");
      return;
   }

   os_printf("[OTA]system user version: %d\n", userBin);

   uint16_t version=1;   
   if (serverVersion <= version)
   {
      os_printf("[OTA]No update. Server version:%d, local version %d\n", serverVersion, version);
      return;
   }
   os_printf("[OTA]Upgrade available version: %d\n", serverVersion);

   struct upgrade_server_info* update = (struct upgrade_server_info *)os_zalloc(sizeof(struct upgrade_server_info));
   update->pespconn = (struct espconn *)os_zalloc(sizeof(struct espconn));

   os_memcpy(update->ip, server_ip, 4);
   update->port = port;
   os_printf("[OTA]Server "IPSTR":%d. Path: [%s],file: [%s]\n", IP2STR(update->ip), update->port, path, file);
   update->check_cb = ota_finished_callback; 
   update->check_times = 120000;
   update->url = (uint8 *)os_zalloc(512);

   os_sprintf((char*)update->url,
      "GET /%s%s HTTP/1.1\r\n"
      "Host: "IPSTR":%d\r\n"
      pheadbuffer,
      path, file, IP2STR(update->ip), update->port);

   if (system_upgrade_start(update) == false)
   {
      os_printf("[OTA]Could not start upgrade\n");
      os_free(update->pespconn);
      os_free(update->url);
      os_free(update);
   }
   else   
   {
      os_printf("[OTA]Upgrading...\n");
   }
}


#define pheadbuffer "Connection: keep-alive\r\n\
Cache-Control: no-cache\r\n\
\r\n"

void ICACHE_FLASH_ATTR ota_start_Upgrade(uint8_t serverVersion, const char *server_ip, uint16_t port, const char *path)
{
const char* file;
uint8_t userBin = system_upgrade_userbin_check();
switch (userBin)
{
case UPGRADE_FW_BIN1: file = "user2.4096.new.4.bin"; break; // user2.bin
case UPGRADE_FW_BIN2: file = "user1.4096.new.4.bin"; break; // user1.bin
default:
os_printf("[OTA]Invalid userbin number!\n");
return;
}

os_printf("[OTA]system user version: %d\n", userBin);

uint16_t version=1;
if (serverVersion <= version)
{
os_printf("[OTA]No update. Server version:%d, local version %d\n", serverVersion, version);
return;
}
os_printf("[OTA]Upgrade available version: %d\n", serverVersion);

struct upgrade_server_info* update = (struct upgrade_server_info *)os_zalloc(sizeof(struct upgrade_server_info));
update->pespconn = (struct espconn *)os_zalloc(sizeof(struct espconn));

os_memcpy(update->ip, server_ip, 4);
update->port = port;
os_printf("[OTA]Server "IPSTR":%d. Path: [%s],file: [%s]\n", IP2STR(update->ip), update->port, path, file);
update->check_cb = ota_finished_callback;
update->check_times = 120000;
update->url = (uint8 *)os_zalloc(512);

os_sprintf((char*)update->url,
"GET /%s%s HTTP/1.1\r\n"
"Host: "IPSTR":%d\r\n"
pheadbuffer,
path, file, IP2STR(update->ip), update->port);

if (system_upgrade_start(update) == false)
{
os_printf("[OTA]Could not start upgrade\n");
os_free(update->pespconn);
os_free(update->url);
os_free(update);
}
else
{
os_printf("[OTA]Upgrading...\n");
}
}
Attachments
QQ截图20180317115348.png

Her Majesty
Posts: 314
Joined: Mon Oct 27, 2014 11:09 am

Re: esp8266 nonos sdk 2.2.0 ota flash_crc!=img_crc

Postby Her Majesty » Tue Mar 27, 2018 5:45 pm

There is a simple demo may help. https://bbs.espressif.com/viewtopic.php?f=7&t=423#p1619
For the log you provided, it is the CRC error, maybe you should check the data you downloaded from the server, maybe it has not only the bin but also some HTTP header which cause the CRC fail.

Who is online

Users browsing this forum: No registered users and 11 guests