mirror of
https://github.com/letscontrolit/ESPEasy.git
synced 2026-07-27 19:57:38 +00:00
Applied this patch made by @uzi18 https://github.com/esp8266/Arduino/issues/4061#issuecomment-368273656 It is now included in all builds
37 lines
1.1 KiB
Diff
37 lines
1.1 KiB
Diff
diff -urN 2.3.0.orig/cores/esp8266/Esp.cpp 2.3.0/cores/esp8266/Esp.cpp
|
|
--- 2.3.0.orig/cores/esp8266/Esp.cpp 2016-06-21 10:06:45.000000000 +0200
|
|
+++ 2.3.0/cores/esp8266/Esp.cpp 2018-02-25 00:15:28.424217374 +0100
|
|
@@ -508,10 +508,28 @@
|
|
}
|
|
|
|
bool EspClass::flashWrite(uint32_t offset, uint32_t *data, size_t size) {
|
|
- ets_isr_mask(FLASH_INT_MASK);
|
|
- int rc = spi_flash_write(offset, (uint32_t*) data, size);
|
|
- ets_isr_unmask(FLASH_INT_MASK);
|
|
- return rc == 0;
|
|
+ static uint32_t flash_chip_id = 0;
|
|
+
|
|
+ if (flash_chip_id == 0)
|
|
+ flash_chip_id = getFlashChipId();
|
|
+ ets_isr_mask(FLASH_INT_MASK);
|
|
+ int rc;
|
|
+ uint32_t* ptr = data;
|
|
+ if ((flash_chip_id & 0x000000ff) == 0x85) { // 0x146085 PUYA
|
|
+ static uint32_t read_buf[SPI_FLASH_SEC_SIZE / 4];
|
|
+ rc = spi_flash_read(offset, read_buf, size);
|
|
+ if (rc != 0) {
|
|
+ ets_isr_unmask(FLASH_INT_MASK);
|
|
+ return false;
|
|
+ }
|
|
+ for (size_t i = 0; i < size / 4; ++i) {
|
|
+ read_buf[i] &= data[i];
|
|
+ }
|
|
+ ptr = read_buf;
|
|
+ }
|
|
+ rc = spi_flash_write(offset, ptr, size);
|
|
+ ets_isr_unmask(FLASH_INT_MASK);
|
|
+ return rc == 0;
|
|
}
|
|
|
|
bool EspClass::flashRead(uint32_t offset, uint32_t *data, size_t size) {
|