1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-19 23:22:16 +03:00

Make sure WDT is re-enabled in eboot even in case of error (#517)

This commit is contained in:
Ivan Grokhotkov 2015-07-23 16:39:56 +03:00
parent 481cee6460
commit 91ca9ba75b
2 changed files with 25 additions and 27 deletions

View File

@ -90,25 +90,21 @@ int copy_raw(const uint32_t src_addr,
uint32_t saddr = src_addr; uint32_t saddr = src_addr;
uint32_t daddr = dst_addr; uint32_t daddr = dst_addr;
ets_wdt_disable();
while (left) { while (left) {
if (SPIEraseSector(daddr/buffer_size)) { if (SPIEraseSector(daddr/buffer_size)) {
return 2; return 2;
} }
if (SPIRead(saddr, buffer, buffer_size)) { if (SPIRead(saddr, buffer, buffer_size)) {
return 3; return 3;
} }
if (SPIWrite(daddr, buffer, buffer_size)) { if (SPIWrite(daddr, buffer, buffer_size)) {
return 4; return 4;
} }
saddr += buffer_size; saddr += buffer_size;
daddr += buffer_size; daddr += buffer_size;
left -= buffer_size; left -= buffer_size;
} }
ets_wdt_enable();
return 0; return 0;
} }
@ -130,7 +126,9 @@ void main()
if (cmd.action == ACTION_COPY_RAW) { if (cmd.action == ACTION_COPY_RAW) {
ets_putc('c'); ets_putc('p'); ets_putc(':'); ets_putc('c'); ets_putc('p'); ets_putc(':');
ets_wdt_disable();
res = copy_raw(cmd.args[0], cmd.args[1], cmd.args[2]); res = copy_raw(cmd.args[0], cmd.args[1], cmd.args[2]);
ets_wdt_enable();
ets_putc('0'+res); ets_putc('\n'); ets_putc('0'+res); ets_putc('\n');
if (res == 0) { if (res == 0) {
cmd.action = ACTION_LOAD_APP; cmd.action = ACTION_LOAD_APP;
@ -139,14 +137,14 @@ void main()
} }
if (cmd.action == ACTION_LOAD_APP) { if (cmd.action == ACTION_LOAD_APP) {
ets_putc('l'); ets_putc('d'); ets_putc('\n'); ets_putc('l'); ets_putc('d'); ets_putc('\n');
res = load_app_from_flash_raw(cmd.args[0]); res = load_app_from_flash_raw(cmd.args[0]);
//we will get to this only on load fail //we will get to this only on load fail
ets_putc('e'); ets_putc(':'); ets_putc('0'+res); ets_putc('\n'); ets_putc('e'); ets_putc(':'); ets_putc('0'+res); ets_putc('\n');
} }
if (res) { if (res) {
SWRST; SWRST;
} }
while(true){} while(true){}

Binary file not shown.