自己的 ota upgrade server

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

自己的 ota upgrade server

Postby alexchang » Wed Apr 29, 2015 9:20 pm

查詢 SDK 更新函數時,瞭解到下方這個結構,想請問自己要做更新服務器的話,要怎麼進行呢?

struct upgrade_server_info {
uint8 ip[4];
uint16 port;

uint8 upgrade_flag;

uint8 pre_version[16];
uint8 upgrade_version[16];

uint32 check_times;
uint8 *url;

upgrade_states_check_callback check_cb;
struct espconn *pespconn;
};

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

Re: 自己的 ota upgrade server

Postby ESP_Faye » Mon May 04, 2015 3:23 pm

Hi,

struct upgrade_server_info {
uint8 ip[4]; // server ip
uint16 port; // server port

uint8 upgrade_flag; // need not set

uint8 pre_version[16]; // need not set
uint8 upgrade_version[16]; // need not set

uint32 check_times; // timeout,unit:second
uint8 *url; // url of bin file need to be download

upgrade_states_check_callback check_cb; // download callback
struct espconn *pespconn; // need not set unless using Espressif Cloud
};

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

Re: 自己的 ota upgrade server

Postby alexchang » Mon May 04, 2015 6:50 pm

你好,

這一段我知道,也清楚函數怎麼呼叫與使用 ^^"

我想瞭解的是,如果我要從自己的 apache/php 或是 nodejs 主機下載升級的 rom ,我要提供的是不是直接就是一個檔案的下載點?

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

Re: 自己的 ota upgrade server

Postby alexchang » Mon May 04, 2015 11:16 pm

請問我們用這樣一個檔案連結是否可以做 ota?
http://52.68.48.85/download/file/user1.1024.new.bin

試了很久很多次都是錯誤:
http://52.68.48.85/download/file/user1.1024.new.bin
system_upgrade_start
upgrade_connect
upgrade_check
user_esp_platform_upgrade_failed
Fatal exception (9):
epc1=0x40100632, epc2=0x00000000, epc3=0x00000000, excvaddr=0x3ffe9d9a, depc=0x00000000
rm match
del if0
bcn 0
del if1
usl
sul 0 0

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

Re: 自己的 ota upgrade server

Postby alexchang » Tue May 05, 2015 11:31 am

應該要用
http://52.68.48.85/download/file/user2.1024.new.bin
才對,因為目前是在 user1,正在執行中。

等了很久直到 cb 被呼叫還是 server->upgrade_flag == false

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

Re: 自己的 ota upgrade server

Postby ESP_Faye » Tue May 05, 2015 1:45 pm

Hi,

Please have a try with this demo.

Notice that when running user1.bin, you need to download user2.bin; when running user2.bin, we download user1.bin.
Attachments
upgrade_demo.zip
(2.22 KiB) Downloaded 1960 times

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

Re: 自己的 ota upgrade server

Postby alexchang » Tue May 05, 2015 2:39 pm

現在可以下載了,不過會寫壞自己然後當機 > <
當機後就開不進去了,我下載的是 user2.bin,不過看起來好像寫到 user1 這個區塊。

server->url 我們設定的 header
GET /download/file/user2.bin HTTP/1.1
Host: 52.68.48.85
Connection: keep-alive
Cache-Control: no-cache
User-Agent: Mozilla/5.0 (Windows NT.6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36
Accept: */*
Accept-Encoding: gzip, deflate, sdch
Accept-Language: zh-TW,zh;q=0.8,en-US;q=0.6,en;q=0.4,et;q=0.2,ja;q=0.2,zh-CN;q=0.2


system_upgrade_start
upgrade_connect
upgrade_connect_cb
GET /download/file/user2.bin HTTP/1.1
Host: 52.68.48.85
Connection: keep-alive
Cache-Control: no-cache
l8upgrade file download start.
totallen = 1452
Fatal exception (9):
epc1=0x40214468, epc2=0x00000000, epc3=0x00000000, excvaddr=0x9b34feb2, depc=0x00000000
Fatal exception (0):
epc1=0x4020194c, epc2=0x00000000, epc3=0x00000000, excvaddr=0x9b34feb2, depc=0x00000000
Fatal exception (0):
epc1=0x4020194c, epc2=0x00000000, epc3=0x00000000, excvaddr=0x9b34feb2, depc=0x00000000
Fatal exception (0):
epc1=0x4020194c, epc2=0x00000000, epc3=0x00000000, excvaddr=0x9b34feb2, depc=0x00000000
Fatal exception (0):
epc1=0x4020194c, epc2=0x00000000, epc3=0x00000000, excvaddr=0x9b34feb2, depc=0x00000000
Fatal exception (0):


server 的封包:
00:00:00.485533 IP (tos 0x0, ttl 64, id 17696, offset 0, flags [DF], proto TCP (6), length 391)
10.0.0.220.80 > 122.116.70.14.49073: tcp 351
0x0000: 4500 0187 4520 4000 4006 28f3 0a00 00dc E...E.@.@.(.....
0x0010: 7a74 460e 0050 bfb1 9f47 556a 0000 1b59 ztF..P...GUj...Y
0x0020: 5018 7540 ccd7 0000 4854 5450 2f31 2e31 P.u@....HTTP/1.1
0x0030: 2032 3030 204f 4b0d 0a58 2d50 6f77 6572 .200.OK..X-Power
0x0040: 6564 2d42 793a 2045 7870 7265 7373 0d0a ed-By:.Express..
0x0050: 436f 6e74 656e 742d 4469 7370 6f73 6974 Content-Disposit
0x0060: 696f 6e3a 2061 7474 6163 686d 656e 743b ion:.attachment;
0x0070: 2066 696c 656e 616d 653d 2275 7365 7232 .filename="user2
0x0080: 2e62 696e 220d 0a41 6363 6570 742d 5261 .bin"..Accept-Ra
0x0090: 6e67 6573 3a20 6279 7465 730d 0a44 6174 nges:.bytes..Dat
0x00a0: 653a 2054 7565 2c20 3035 204d 6179 2032 e:.Tue,.05.May.2
0x00b0: 3031 3520 3036 3a32 353a 3431 2047 4d54 015.06:25:41.GMT
0x00c0: 0d0a 4361 6368 652d 436f 6e74 726f 6c3a ..Cache-Control:
0x00d0: 2070 7562 6c69 632c 206d 6178 2d61 6765 .public,.max-age
0x00e0: 3d30 0d0a 4c61 7374 2d4d 6f64 6966 6965 =0..Last-Modifie
0x00f0: 643a 204d 6f6e 2c20 3034 204d 6179 2032 d:.Mon,.04.May.2
0x0100: 3031 3520 3133 3a34 383a 3534 2047 4d54 015.13:48:54.GMT
0x0110: 0d0a 4554 6167 3a20 572f 2233 3437 3130 ..ETag:.W/"34710
0x0120: 2d37 3338 3930 3436 3731 220d 0a43 6f6e -738904671"..Con
0x0130: 7465 6e74 2d54 7970 653a 2061 7070 6c69 tent-Type:.appli
0x0140: 6361 7469 6f6e 2f6f 6374 6574 2d73 7472 cation/octet-str
0x0150: 6561 6d0d 0a43 6f6e 7465 6e74 2d4c 656e eam..Content-Len
0x0160: 6774 683a 2032 3134 3830 300d 0a43 6f6e gth:.214800..Con
0x0170: 6e65 6374 696f 6e3a 206b 6565 702d 616c nection:.keep-al
0x0180: 6976 650d 0a0d 0a ive....
00:00:05.059336 IP (tos 0x0, ttl 64, id 45064, offset 0, flags [DF], proto TCP (6), length 52)
10.0.0.220.80 > 122.116.70.14.50465: tcp 0
0x0000: 4500 0034 b008 4000 4006 bf5d 0a00 00dc E..4..@.@..]....
0x0010: 7a74 460e 0050 c521 bb1e b520 47bc a030 ztF..P.!....G..0
0x0020: 8010 0077 cb84 0000 0101 050a 47bc a02f ...w........G../
0x0030: 47bc a030 G..0
00:00:02.840933 IP (tos 0x0, ttl 64, id 52819, offset 0, flags [DF], proto TCP (6), length 43)
10.0.0.220.80 > 122.116.70.14.6179: tcp 3
0x0000: 4500 002b ce53 4000 4006 a11b 0a00 00dc E..+.S@.@.......
0x0010: 7a74 460e 0050 1823 85a5 fc92 3175 6831 ztF..P.#....1uh1
0x0020: 5018 7540 cb7b 0000 8101 33 P.u@.{....3
00:00:02.840933 IP (tos 0x0, ttl 64, id 52819, offset 0, flags [DF], proto TCP (6), length 43)
10.0.0.220.80 > 122.116.70.14.6179: tcp 3
0x0000: 4500 002b ce53 4000 4006 a11b 0a00 00dc E..+.S@.@.......
0x0010: 7a74 460e 0050 1823 85a5 fc92 3175 6831 ztF..P.#....1uh1
0x0020: 5018 7540 cb7b 0000 8101 33 P.u@.{....3
00:00:00.108306 IP (tos 0x0, ttl 64, id 26955, offset 0, flags [DF], proto TCP (6), length 43)
10.0.0.220.80 > 122.116.70.14.46613: tcp 3
0x0000: 4500 002b 694b 4000 4006 0624 0a00 00dc E..+iK@.@..$....
0x0010: 7a74 460e 0050 b615 052a 5f7f 0220 9b0f ztF..P...*_.....
0x0020: 5018 7540 cb7b 0000 8101 33 P.u@.{....3
00:00:05.651611 IP (tos 0x0, ttl 64, id 57416, offset 0, flags [DF], proto TCP (6), length 40)
10.0.0.220.80 > 122.116.70.14.50773: tcp 0
0x0000: 4500 0028 e048 4000 4006 8f29 0a00 00dc E..(.H@.@..)....
0x0010: 7a74 460e 0050 c655 193b 321b 8945 4255 ztF..P.U.;2..EBU
0x0020: 5010 007f cb78 0000 P....x..
00:00:00.002390 IP (tos 0x0, ttl 64, id 57417, offset 0, flags [DF], proto TCP (6), length 441)
10.0.0.220.80 > 122.116.70.14.50773: tcp 401
0x0000: 4500 01b9 e049 4000 4006 8d97 0a00 00dc E....I@.@.......
0x0010: 7a74 460e 0050 c655 193b 321b 8945 4255 ztF..P.U.;2..EBU
0x0020: 5018 007f cd09 0000 4854 5450 2f31 2e31 P.......HTTP/1.1
0x0030: 2032 3036 2050 6172 7469 616c 2043 6f6e .206.Partial.Con
0x0040: 7465 6e74 0d0a 582d 506f 7765 7265 642d tent..X-Powered-
0x0050: 4279 3a20 4578 7072 6573 730d 0a43 6f6e By:.Express..Con
0x0060: 7465 6e74 2d44 6973 706f 7369 7469 6f6e tent-Disposition
0x0070: 3a20 6174 7461 6368 6d65 6e74 3b20 6669 :.attachment;.fi
0x0080: 6c65 6e61 6d65 3d22 7573 6572 312e 6269 lename="user1.bi
0x0090: 6e22 0d0a 4163 6365 7074 2d52 616e 6765 n"..Accept-Range
0x00a0: 733a 2062 7974 6573 0d0a 4461 7465 3a20 s:.bytes..Date:.
0x00b0: 5475 652c 2030 3520 4d61 7920 3230 3135 Tue,.05.May.2015
0x00c0: 2030 363a 3237 3a34 3820 474d 540d 0a43 .06:27:48.GMT..C
0x00d0: 6163 6865 2d43 6f6e 7472 6f6c 3a20 7075 ache-Control:.pu
0x00e0: 626c 6963 2c20 6d61 782d 6167 653d 300d blic,.max-age=0.
0x00f0: 0a4c 6173 742d 4d6f 6469 6669 6564 3a20 .Last-Modified:.
0x0100: 4d6f 6e2c 2030 3420 4d61 7920 3230 3135 Mon,.04.May.2015
0x0110: 2031 333a 3530 3a33 3520 474d 540d 0a45 .13:50:35.GMT..E
0x0120: 5461 673a 2057 2f22 3334 3731 302d 3334 Tag:.W/"34710-34
0x0130: 3939 3934 3333 3938 220d 0a43 6f6e 7465 99943398"..Conte
0x0140: 6e74 2d54 7970 653a 2061 7070 6c69 6361 nt-Type:.applica
0x0150: 7469 6f6e 2f6f 6374 6574 2d73 7472 6561 tion/octet-strea
0x0160: 6d0d 0a43 6f6e 7465 6e74 2d52 616e 6765 m..Content-Range
0x0170: 3a20 6279 7465 7320 3131 3631 362d 3131 :.bytes.11616-11
0x0180: 3631 362f 3231 3438 3030 0d0a 436f 6e74 616/214800..Cont
0x0190: 656e 742d 4c65 6e67 7468 3a20 310d 0a43 ent-Length:.1..C
0x01a0: 6f6e 6e65 6374 696f 6e3a 206b 6565 702d onnection:.keep-
0x01b0: 616c 6976 650d 0a0d 0a alive....
00:00:00.066180 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto TCP (6), length 52)
10.0.0.220.80 > 122.116.70.14.50799: tcp 0
0x0000: 4500 0034 0000 4000 4006 6f66 0a00 00dc E..4..@.@.of....
0x0010: 7a74 460e 0050 c66f bd4a 25d7 3fcc 1e40 ztF..P.o.J%.?..@
0x0020: 8012 7210 cb84 0000 0204 05b4 0101 0402 ..r.............
0x0030: 0103 0308 ....
00:00:00.062536 IP (tos 0x0, ttl 64, id 43375, offset 0, flags [DF], proto TCP (6), length 40)
10.0.0.220.80 > 122.116.70.14.50799: tcp 0
0x0000: 4500 0028 a96f 4000 4006 c602 0a00 00dc E..(.o@.@.......
0x0010: 7a74 460e 0050 c66f bd4a 25d8 3fcc 1ffa ztF..P.o.J%.?...
0x0020: 5010 0077 cb78 0000 P..w.x..
00:00:00.001631 IP (tos 0x0, ttl 64, id 43376, offset 0, flags [DF], proto TCP (6), length 447)
10.0.0.220.80 > 122.116.70.14.50799: tcp 407
0x0000: 4500 01bf a970 4000 4006 c46a 0a00 00dc E....p@.@..j....
0x0010: 7a74 460e 0050 c66f bd4a 25d8 3fcc 1ffa ztF..P.o.J%.?...
0x0020: 5018 0077 cd0f 0000 4854 5450 2f31 2e31 P..w....HTTP/1.1
0x0030: 2032 3036 2050 6172 7469 616c 2043 6f6e .206.Partial.Con
0x0040: 7465 6e74 0d0a 582d 506f 7765 7265 642d tent..X-Powered-
0x0050: 4279 3a20 4578 7072 6573 730d 0a43 6f6e By:.Express..Con
0x0060: 7465 6e74 2d44 6973 706f 7369 7469 6f6e tent-Disposition
0x0070: 3a20 6174 7461 6368 6d65 6e74 3b20 6669 :.attachment;.fi
0x0080: 6c65 6e61 6d65 3d22 7573 6572 312e 6269 lename="user1.bi
0x0090: 6e22 0d0a 4163 6365 7074 2d52 616e 6765 n"..Accept-Range
0x00a0: 733a 2062 7974 6573 0d0a 4461 7465 3a20 s:.bytes..Date:.
0x00b0: 5475 652c 2030 3520 4d61 7920 3230 3135 Tue,.05.May.2015
0x00c0: 2030 363a 3237 3a34 3820 474d 540d 0a43 .06:27:48.GMT..C
0x00d0: 6163 6865 2d43 6f6e 7472 6f6c 3a20 7075 ache-Control:.pu
0x00e0: 626c 6963 2c20 6d61 782d 6167 653d 300d blic,.max-age=0.
0x00f0: 0a4c 6173 742d 4d6f 6469 6669 6564 3a20 .Last-Modified:.
0x0100: 4d6f 6e2c 2030 3420 4d61 7920 3230 3135 Mon,.04.May.2015
0x0110: 2031 333a 3530 3a33 3520 474d 540d 0a45 .13:50:35.GMT..E
0x0120: 5461 673a 2057 2f22 3334 3731 302d 3334 Tag:.W/"34710-34
0x0130: 3939 3934 3333 3938 220d 0a43 6f6e 7465 99943398"..Conte
0x0140: 6e74 2d54 7970 653a 2061 7070 6c69 6361 nt-Type:.applica
0x0150: 7469 6f6e 2f6f 6374 6574 2d73 7472 6561 tion/octet-strea
0x0160: 6d0d 0a43 6f6e 7465 6e74 2d52 616e 6765 m..Content-Range
0x0170: 3a20 6279 7465 7320 3131 3631 362d 3231 :.bytes.11616-21
0x0180: 3437 3939 2f32 3134 3830 300d 0a43 6f6e 4799/214800..Con
0x0190: 7465 6e74 2d4c 656e 6774 683a 2032 3033 tent-Length:.203
0x01a0: 3138 340d 0a43 6f6e 6e65 6374 696f 6e3a 184..Connection:
0x01b0: 206b 6565 702d 616c 6976 650d 0a0d 0a .keep-alive....
00:00:00.000049 IP (tos 0x0, ttl 64, id 43377, offset 0, flags [DF], proto TCP (6), length 2944)
10.0.0.220.80 > 122.116.70.14.50799: tcp 2904
0x0000: 4500 0b80 a971 4000 4006 baa8 0a00 00dc E....q@.@.......
0x0010: 7a74 460e 0050 c66f bd4a 276f 3fcc 1ffa ztF..P.o.J'o?...
0x0020: 5010 0077 d6d0 0000 7cff 42a0 6847 1672 P..w....|.B.hG.r
0x0030: 82a0 6c87 166c 0c04 3096 c016 890f 5c82 ..l..l..0.....\.
0x0040: 2716 7652 c69d 1695 0f82 a064 8716 5d92 '.vR.......d..].
0x0050: a069 9716 5722 c691 16b2 1552 c690 1695 .i..W".....R....
0x0060: 1782 c68d 16f8 1b92 a075 9716 4722 a078 .........u..G".x
0x0070: 2716 4e1b 0cc7 3e05 324c 0062 0d00 cd00 '.N...>.2L.b....
0x0080: 16b6 221b c007 3e02 6240 0046 c0ff 024e .."...>.b@.F...N
0x0090: 0008 51d8 71e8 8120 2cc0 f891 c861 12c1 ..Q.q...,....a..
0x00a0: 300d f04d 061b dd62 0d00 86e2 ff0c 2220 0..M...b......".
0x00b0: 0020 0000 740c a546 0200 4c02 2000 2000 ....t..F..L.....
0x00c0: 0074 1c05 62a0 6c67 940d 1c88 4d0a 4baa .t..b.lg....M.K.
0x00d0: a728 3848 3106 0f00 92a0 6897 9413 0091 .(8H1.....h.....
0x00e0: 041c 824d 0a4b aaa7 a202 8633 0048 3186 ...M.K.....3.H1.
0x00f0: 3400 1c86 4d0a 4baa a726 0448 3106 0500 4...M.K..&.H1...
0x0100: 1c88 4728 012c 4a48 4106 0200 1c89 4729 ..G(.,JHA.....G)
0x0110: 012c 4a48 41a9 014a 4a42 d4ff 4224 3f6d .,JHA..JJB..B$?m
0x0120: 0f2d 0c3d 0e7d 0085 cdff cd02 a801 2c53 .-.=.}........,S
0x0130: 2cdb 2cb7 0696 ffc7 be02 0694 ff32 4c00 ,.,..........2L.
0x0140: 8692 ff47 e011 0bff a61f 0cc7 3e04 2c05 ...G........>.,.
0x0150: 524c 001b cc46 fbff 1c86 4d0a 4baa a726 RL...F....M.K..&
0x0160: 0408 3106 0200 1c88 4728 012c 4a08 41c7 ..1.....G(.,J.A.
0x0170: 3e0a 0a9a 92d9 ff92 293f 924c 001b cc0b >.......)?.L....
0x0180: ffe6 1f02 0682 ffc7 3ef2 2c00 024c 0086 ........>.,..L..
0x0190: faff 1c82 4722 012c 4a48 414a faf2 dfff ....G".,JHAJ....
0x01a0: f22f 3f62 0d00 d6af 00f0 f060 1c02 2000 ./?b.......`....
0x01b0: 2000 0074 869c ff0c 85c6 c1ff 1c86 4726 ...t..........G&
0x01c0: 012c 4a48 414a 4a42 d4ff 4214 7ea9 0100 .,JHAJJB..B.~...
0x01d0: 8411 8080 3190 4893 c6d0 ff4d 0a1c 854b ....1.H....M...K
0x01e0: aa66 0f09 0c8f 0c12 2000 2000 0074 a725 .f...........t.%
0x01f0: 0648 31a9 0186 0200 1c86 4726 012c 4a48 .H1.......G&.,JH
檔案內容就略過了

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

Re: 自己的 ota upgrade server

Postby ESP_Faye » Tue May 05, 2015 2:59 pm

Hi,

If you are using 1024KB or larger flash, please refer to http://bbs.espressif.com/viewtopic.php?f=10&t=305

Please burn blank.bin into flash as initialization.

For example, 1024KB flash, please burn blank.bin into flash 0xFE000 as initialization.

If your problem is still unsolved, please offer the capture picture of your flash download tool while you burning images into flash.

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

Re: 自己的 ota upgrade server

Postby alexchang » Tue May 05, 2015 3:03 pm

請問以下邏輯是正確的嗎? 變數定義看起來 UPGRADE_FW_BIN1 那就應該使用 user1.bin 。
我兩種情況都試過,都無法正常使用。

// from suer_esp_platform.c
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);
}

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

Re: 自己的 ota upgrade server

Postby alexchang » Tue May 05, 2015 3:05 pm

Espressif_Faye wrote:Hi,

If you are using 1024KB or larger flash, please refer to http://bbs.espressif.com/viewtopic.php?f=10&t=305

Please burn blank.bin into flash as initialization.

For example, 1024KB flash, please burn blank.bin into flash 0xFE000 as initialization.


I use 1024KB flash, I did it before, but I will try it again from start, erase the first 1MB with 0xFF
and then rewrite all those blocks with below files:
0x00000 boot_v1.3(b3)
0x3E000 master-device-key.bin
0x01000 user1.1024.new.bin
0xFC000 esp_init_data_default.bin
0xFE000 blank

Who is online

Users browsing this forum: No registered users and 279 guests