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

@ -1,4 +1,4 @@
/* Copyright (c) 2015 Ivan Grokhotkov. All rights reserved. /* Copyright (c) 2015 Ivan Grokhotkov. All rights reserved.
* This file is part of eboot bootloader. * This file is part of eboot bootloader.
* *
* Redistribution and use is permitted according to the conditions of the * Redistribution and use is permitted according to the conditions of the
@ -26,10 +26,10 @@ int load_app_from_flash_raw(const uint32_t flash_addr)
return 1; return 1;
} }
pos += sizeof(image_header); pos += sizeof(image_header);
for (uint32_t section_index = 0; for (uint32_t section_index = 0;
section_index < image_header.num_segments; section_index < image_header.num_segments;
++section_index) ++section_index)
{ {
section_header_t section_header = {0}; section_header_t section_header = {0};
@ -74,8 +74,8 @@ int load_app_from_flash_raw(const uint32_t flash_addr)
int copy_raw(const uint32_t src_addr, int copy_raw(const uint32_t src_addr,
const uint32_t dst_addr, const uint32_t dst_addr,
const uint32_t size) const uint32_t size)
{ {
// require regions to be aligned // require regions to be aligned
@ -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;
} }
@ -127,10 +123,12 @@ void main()
ets_putc('@'); ets_putc('@');
} }
eboot_command_clear(); eboot_command_clear();
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.