自己的 ota upgrade server

alexchang
Posts: 52
Joined: Mon Apr 06, 2015 5:47 pm

Re: 自己的 ota upgrade server

Postby alexchang » Sun May 10, 2015 2:59 pm

這個部分原來是正常完成,沒當機,問題在 console 連線被重置,需要重連 console terminal 就可以了,謝謝!

-------------------------
測試情境換成:
完全重寫 rom ,使用
boot_v1.2.bin
blank.bin
esp_init_data_default.bin
user1.bin
這幾個檔案,接著 ota 升級 user2,升級完(成功)用
system_upgrade_flag_set(2);
system_upgrade_reboot();
重新開機,會當機。
upgrade file download finished.
upgrade_check
reboot to use2
rm match
del if0
bcn 0
del if1
usl
sul 0 0

ESP_Faye
Posts: 1646
Joined: Mon Oct 27, 2014 11:08 am

Re: 自己的 ota upgrade server

Postby ESP_Faye » Mon May 11, 2015 1:58 pm

您好,

麻烦提供您的 user1.bin、user2.bin 和 bin upgrade 的下载链接。

“重新開機,會當機” 一般是由于您编译 user2.bin 的方式不正确,应该如下:
编译时,先在 STEP 2 选择 1 ,编译 user1;
make clean 清掉上次编译生成的临时文件;
再次编译,在 STEP 2 选择 2,编译 user2。
compile_user2.jpg
compile_user2.jpg (31.96 KiB) Viewed 33533 times

alexchang
Posts: 52
Joined: Mon Apr 06, 2015 5:47 pm

Re: 自己的 ota upgrade server

Postby alexchang » Mon May 11, 2015 4:29 pm

是有遇過這個問題,但如您所說,已經都有 make clean 後才重新產生 user1 與 user2。

目前都使用 normal boot 已經不會當機了,謝謝!

SpenZerX
Posts: 41
Joined: Thu Apr 16, 2015 9:30 pm
Location: Germany
Contact:

Re: 自己的 ota upgrade server

Postby SpenZerX » Thu Jun 11, 2015 7:30 pm

Hello,

can you help me,

When doing OTA upgrade:
How to get feedback/progress indicator for the user how many bytes are transfered? I noticed serial output on debug output only.
Will OTA upgrade fail if version is the same or older then current version? Who has to check? Why not to allow flashing older bin?
Do i need master-device-key.bin when using OTA upgrade on own server?
Where is the difference between master-device-key.bin and getchipID from SDK.

Is esp_init_data_default.bin in your definition a user parameter or a system parameter?
Is it possible to flash the last block in the flash memory 3FF000 on (32mbit) with blank.bin? (i got errors, can not flash this block, same on 4mbit) is it protected?)


Have you tested the whole OTA upgrade thing? I get 5-10% soft-bricked modules after OTA upgrade.
OTA upgrade needs a lot of memory. Should i check available memory before starting OTA upgrade?

ESP_Faye
Posts: 1646
Joined: Mon Oct 27, 2014 11:08 am

Re: 自己的 ota upgrade server

Postby ESP_Faye » Mon Jun 15, 2015 11:05 am

Hi,

Here is a documentation "99C-ESP8266_OTA_Upgrade" introduces upgrade http://bbs.espressif.com/viewtopic.php?f=21&t=413

Sorry that we won't check version info now, we are running user1.bin and downloading user2.bin, because user1.bin is running, if flashing it , the program will crash.
master-device-key.bin is an ID got from Espressif Cloud, so if you needn't Espressif Cloud, you are using your own server, master-device-key.bin is not needed.

Thanks for your interest in ESP8266 !

mojhggn
Posts: 3
Joined: Tue Jun 23, 2015 1:32 am

Re: 自己的 ota upgrade server

Postby mojhggn » Tue Jun 23, 2015 1:44 am

Thanks for giving us this amazing piece of hardware. But i find mastering SDK baffling. I am using esp-open-sdk toolchain to build IoT_Demo in examples. What should be the complete directory structure for included makefile to work? Does same makefile builds OTA and non-OTA firmware? Please help.

ESP_Faye
Posts: 1646
Joined: Mon Oct 27, 2014 11:08 am

Re: 自己的 ota upgrade server

Postby ESP_Faye » Tue Jun 23, 2015 3:45 pm

Hi,

How to set up compiling environment http://bbs.espressif.com/viewtopic.php?f=21&t=86

How to compile and download bin files please refer to documentation "2A-ESP8266__IOT_SDK_User_Manual" http://bbs.espressif.com/viewtopic.php?f=7&t=641

Documentation about upgrade is "99C-ESP8266_OTA_Upgrade" http://bbs.espressif.com/viewtopic.php?f=21&t=413

Thanks for your interest in ESP8266 !

thuwrx10
Posts: 10
Joined: Wed Aug 19, 2015 3:59 pm

Re: 自己的 ota upgrade server

Postby thuwrx10 » Tue Sep 01, 2015 7:39 pm

My code works properly (Normally it finishes upgrade and reboot before check_upgrade_result is called):

Code: Select all

#include "ota_upgrade.h"
#include "upgrade.h"
#include "osapi.h"
#include "mem.h"

struct espconn upgrade_connection;
struct _esp_tcp upgrade_tcp;
struct upgrade_server_info upgrade_server;

static void ICACHE_FLASH_ATTR
check_upgrade_result(void *arg)
{
    struct upgrade_server_info *server = arg;

    if (server->upgrade_flag == true)
    {
        os_printf("Upgraded successfully.\r\n");
        system_upgrade_reboot();
    }
    else
        os_printf("Upgrade failed.\r\n");
}

void ICACHE_FLASH_ATTR
ota_upgrade(remot_info *phost_info)
{
    char user_bin[10] = {0};

    upgrade_connection.proto.tcp = &upgrade_tcp;
    upgrade_connection.type = ESPCONN_TCP;
    upgrade_connection.state = ESPCONN_NONE;

    /* Upgrade server is the TCP client that sent "upgrade\n" to esp8266 */
    os_memcpy(upgrade_tcp.remote_ip, phost_info->remote_ip, 4);
    upgrade_tcp.remote_port = 80;
   
    os_memcpy(upgrade_server.ip, phost_info->remote_ip, 4);
    upgrade_server.port = 80;

    upgrade_server.check_cb = check_upgrade_result;
    upgrade_server.check_times = 120000;

    upgrade_server.url = (uint8_t *)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(upgrade_server.url, "GET /ota/%s HTTP/1.0\r\nHost: "IPSTR":%d\r\nConnection: keep-alive\r\nCache-Control: no-cache\r\n\r\n",
            user_bin,
            IP2STR(upgrade_server.ip),
            upgrade_server.port);

    os_printf("OTA upgrade request:\r\n%s\r\n", upgrade_server.url);

    if (!system_upgrade_start(&upgrade_server))
        os_printf("Upgrade already started.\r\n");
}


The command I used to write initial firmware through serial port:

Code: Select all

esptool.py -b 512000 write_flash -ff 80m -fm qio -fs 8m 0x00000 ../bin/boot_v1.2.bin 0x01000 ../bin/upgrade/user1.1024.new.2.bin 0xfc000 ../bin/esp_init_data_default.bin 0xfe000 ../bin/blank.bin

fvpalha

Re: 自己的 ota upgrade server

Postby fvpalha » Tue Sep 15, 2015 9:31 pm

Hi thuwrx10.

Do you can sharing the full example? (zip, GitHub)

Thank you.

Xuedong
Posts: 2
Joined: Sun May 01, 2016 2:37 pm

Re: 自己的 ota upgrade server

Postby Xuedong » Sun Mar 19, 2017 4:48 pm

我遇到了类似的问题,发现由user1.bin升级为user2.bin后,flash擦除及写入都是正常的,为了明确区分到底运行的是user1.bin还是user2.bin,特意做了一个os_printf,发现在升级完成重启后,由SDK函数得到的当前运行的为user2.bin,可实际上偏偏还是运行的user1.bin,也就是说没有切换过来,却在SDK函数查询结果反映已经切换了,下面是log:

MQTT_APP: button press!!!
user_ota_start...
user_ota_updata_check...
[OTA]Server 192.168.0.2:80
update->url GET /bin/gateway/user2.4096.new.6.bin HTTP/1.1
Host: 192.168.0.2:80
Connection: keep-alive
Cache-Control: no-cache
User-Agent: Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36
Accept: */*
Accept-Encoding: gzip,deflate,sdch
Accept-Language: zh-CN,zh;q=0.8


system_upgrade_start
upgrade_connect 37240
[OTA]Upgrading...
upgrade_connect_cb
pusrdata = HTTP/1.1 200 OK
Date: Sun, 19 Mar 2017 06:38:01 GMT
Server: Apache/2.4.23 (Win32) PHP/5.6.25
Last-Modified: Sun, 19 Mar 2017 06:33:17 GMT
ETag: "4c204-54b0f960d8fa6"
Accept-Ranges: bytes
Content-Length: 311812
Connection: close
Content-Type: application/octet-stream


sumlength = 311812
sec_block 77
.............................................................................upgrade_get_sum_disconcb 34472
erase sector=129 ok
......
erase sector=205 ok

ALL=77 sectors erase ok!
upgrade_connect_cb
sumlength = 311812
upgrade file download start.
totallen = 2605
......
totallen = 311812
upgrade file download finished.
flash_crc = 858897310
img_crc = 858897310
upgrade_check
[OTA]success; rebooting!
reboot to use2
state: 5 -> 0 (0)
rm 0
pm close 7
del if0
usl

add if0
compile time:Mar 19 2017 14:33:10
SDK Version 2.0.0(656edbf)
Current userbin is user2.bin
This is user1.bin run @ 0x01000
NETWORK: Init network timer
scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 2
cnt

connected with cxd, channel 1
dhcp client start...
ip:192.168.0.101,mask:255.255.255.0,gw:192.168.0.1
NETWORK: change to network_state_sta_ok

Who is online

Users browsing this forum: No registered users and 60 guests