[PUYA] Apply generic patch on all builds checking for PUYA flash

Applied this patch made by @uzi18
https://github.com/esp8266/Arduino/issues/4061#issuecomment-368273656
It is now included in all builds
This commit is contained in:
TD-er
2018-11-06 15:56:36 +01:00
parent 2f8962ec52
commit 0a72b711f9
8 changed files with 49 additions and 58 deletions
+3 -6
View File
@@ -25,18 +25,15 @@ install:
- pip install -U platformio sphinx recommonmark sphinx_bootstrap_theme
script:
# patch platformio core libs for PUYA bug (https://github.com/letscontrolit/ESPEasy/issues/650)
- cd patches; ./check_puya_patch; cd ..
# - bash ./preflight.sh # make sure input files are OK before wasting time with prereqs
# - cppcheck --enable=warning src/*.ino -q --force -I src --include=src/ESPEasy.ino --error-exitcode=1
# - ./memanalyzer.py ~/.platformio/packages/toolchain-xtensa/bin/xtensa-lx106-elf-objdump
- PLATFORMIO_BUILD_FLAGS="-D CONTINUOUS_INTEGRATION" platformio run
- PLATFORMIO_BUILD_FLAGS="-D CONTINUOUS_INTEGRATION" platformio run
# patch platformio core libs for PUYA bug (https://github.com/letscontrolit/ESPEasy/issues/650)
- cd patches; ./check_puya_patch; cd ..
- PLATFORMIO_BUILD_FLAGS="-D CONTINUOUS_INTEGRATION" platformio run -s --environment dev_ESP8266PUYA_1024
- PLATFORMIO_BUILD_FLAGS="-D CONTINUOUS_INTEGRATION" platformio run -s --environment dev_ESP8266PUYA_1024
before_deploy:
- ./before_deploy
- export RELEASE_FILE=$(ls ESPEasy*.zip)
-2
View File
@@ -20,8 +20,6 @@ for ENV in \
dev_ESP8266_1024\
dev_ESP8266_4096\
dev_ESP8285_1024\
dev_ESP8266PUYA_1024\
dev_ESP8266PUYA_1024_VCC\
hard_SONOFF_POW\
hard_SONOFF_POW_R2_4M\
minimal_ESP8266_1024_OTA\
+2 -6
View File
@@ -23,16 +23,12 @@ There is also a number of special builds:
- normal_IR => "Normal" + IR receiver/transmitter plugins and library
- hard_xxxxx => Special builds for some off-the-shelf hardware.
- normal_core_241 => "Normal" using core 2.4.1, since 2.4.2 has issues with PWM
- minimal_ESP82xx_1024_OTA => Minimum number of plugins and a limited set of controllers included to be able to perform a 2-step OTA on 1 MB flash nodes.
Chip can be:
- ESP8266 => Most likely option
- ESP8285 => Used in some Sonoff modules
- ESP32 => Experimental support at this moment
- ESP8266PUYA => For ESP modules with a flash chip labeled "PUYA" (often 1 MB)
The "PUYA" version deserves a bit more attention.
If you cannot save settings, better try to see if the flash chip has "PUYA" written on it.
If so, try the "PUYA" build.
MemorySize can be:
- 1024 => 1 MB flash modules (e.g. almost all Sonoff modules)
@@ -62,7 +58,7 @@ for it to fetch the COM ports correctly. If you want you may save YOUR settings
too small you can experiment with the "Pixels Per Inch" variable in the
..\Settings\Default.ini file. Setting it to =96 is working for most users but the
application will try to find the most optimal value by default. Sometimes it fails to
do that. More information about the tool is found here:
do that. More information about the tool is found here:
https://github.com/Grovkillen/ESP_Easy_Flasher
Further reading:
+2 -2
View File
@@ -1,11 +1,11 @@
#!/bin/bash
PATCH=puya.patch
PATCH=puya_v2.patch
for DIR in ~/.platformio/packages/framework-arduinoespressif8266*/; do
#not applied yet? (in upstream or otherwise)
if ! grep FLASH_QUIRK_WRITE_0_TO_1 $DIR/cores/esp8266/Esp.cpp >/dev/null; then
if ! grep "0x146085 PUYA" $DIR/cores/esp8266/Esp.cpp >/dev/null; then
echo "Patching $DIR"
patch -p1 -d $DIR < $PATCH
fi
+36
View File
@@ -0,0 +1,36 @@
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) {
-42
View File
@@ -580,48 +580,6 @@ build_unflags = ${esp8266_4M.build_unflags}
build_flags = ${esp8266_4M.build_flags} ${dev.build_flags}
;;; DEV + PUYA ; ****; ****; ****; ****; ****; ****; ****; ****; ****; ****; ****; ****;;;
; special patched version for PUYA flash chips, see issue ;650 at Github ;
; *********************************************************************
; DEV+PUYA : 1024k version -----------------------
[env:dev_ESP8266PUYA_1024]
platform = ${dev.platform}
lib_deps = ${common.lib_deps}
lib_ignore = ${common.lib_ignore}
lib_ldf_mode = ${common.lib_ldf_mode}
lib_archive = ${common.lib_archive}
framework = ${common.framework}
board = ${common.board}
upload_speed = ${common.upload_speed}
monitor_speed = ${common.monitor_speed}
board_upload.maximum_size = ${esp8266_1M.board_upload.maximum_size}
board_build.f_cpu = ${esp8266_1M.board_build.f_cpu}
board_build.flash_mode = ${esp8266_1M.board_build.flash_mode}
build_unflags = ${esp8266_1M.build_unflags}
build_flags = ${esp8266_1M.build_flags} ${dev.build_flags} -D FLASH_QUIRK_WRITE_0_TO_1
; DEV+PUYA : 1024k version + FEATURE_ADC_VCC -----
[env:dev_ESP8266PUYA_1024_VCC]
platform = ${dev.platform}
lib_deps = ${common.lib_deps}
lib_ignore = ${common.lib_ignore}
lib_ldf_mode = ${common.lib_ldf_mode}
lib_archive = ${common.lib_archive}
framework = ${common.framework}
board = ${common.board}
upload_speed = ${common.upload_speed}
monitor_speed = ${common.monitor_speed}
board_upload.maximum_size = ${esp8266_1M.board_upload.maximum_size}
board_build.f_cpu = ${esp8266_1M.board_build.f_cpu}
board_build.flash_mode = ${esp8266_1M.board_build.flash_mode}
build_unflags = ${esp8266_1M.build_unflags}
build_flags = ${esp8266_1M.build_flags} ${dev.build_flags} -D FLASH_QUIRK_WRITE_0_TO_1 -D FEATURE_ADC_VCC=true
;;; HARDWARE SPECIFIC VERSIONS ; ****; ****; ****; ****; ****; ****; ****; ****; ****;;;;;
; versions specially designed to fit, and contents only needed plugins for each hardware ;
; *********************************************************************
+2
View File
@@ -409,6 +409,8 @@ void updateLoopStats() {
return;
}
const long usecSince = usecPassedSince(lastLoopStart);
miscStats[LOOP_STATS].add(usecSince);
loop_usec_duration_total += usecSince;
lastLoopStart = micros();
if (usecSince <= 0 || usecSince > 10000000)
+4
View File
@@ -5865,6 +5865,10 @@ void handle_sysinfo() {
// Where manufacturer is 0xE0 and device is 0x4016.
TXBuffer += F("Vendor: ");
TXBuffer += formatToHex(flashChipId & 0xFF);
if ((flashChipId & 0x000000ff) == 0x85) { // 0x146085 PUYA
TXBuffer += F(" (PUYA)");
TXBuffer += F(HTML_SYMBOL_WARNING);
}
TXBuffer += F(" Device: ");
uint32_t flashDevice = (flashChipId & 0xFF00) | ((flashChipId >> 16) & 0xFF);
TXBuffer += formatToHex(flashDevice);