mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-19 23:22:16 +03:00
Merge pull request #7547 from earlephilhower/noboom
Don't overwrite boot sector unless OTA changes it
This commit is contained in:
commit
d02bc02fac
@ -159,11 +159,6 @@ int copy_raw(const uint32_t src_addr,
|
|||||||
gzip = true;
|
gzip = true;
|
||||||
}
|
}
|
||||||
while (left > 0) {
|
while (left > 0) {
|
||||||
if (!verify) {
|
|
||||||
if (SPIEraseSector(daddr/buffer_size)) {
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!gzip) {
|
if (!gzip) {
|
||||||
if (SPIRead(saddr, buffer, buffer_size)) {
|
if (SPIRead(saddr, buffer, buffer_size)) {
|
||||||
return 3;
|
return 3;
|
||||||
@ -190,8 +185,25 @@ int copy_raw(const uint32_t src_addr,
|
|||||||
return 9;
|
return 9;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (SPIWrite(daddr, buffer, buffer_size)) {
|
// Special treatment for address 0 (bootloader). Only erase and
|
||||||
return 4;
|
// rewrite if the data is different (i.e. very rarely).
|
||||||
|
bool skip = false;
|
||||||
|
if (daddr == 0) {
|
||||||
|
if (SPIRead(daddr, buffer2, buffer_size)) {
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
if (!memcmp(buffer2, buffer, buffer_size)) {
|
||||||
|
ets_putc('B'); // Note we skipped the bootloader in output
|
||||||
|
skip = true; // And skip erase/write
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!skip) {
|
||||||
|
if (SPIEraseSector(daddr/buffer_size)) {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
if (SPIWrite(daddr, buffer, buffer_size)) {
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
saddr += buffer_size;
|
saddr += buffer_size;
|
||||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user