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.