From fabd169abceebb0a5fee306850b9176d98b80795 Mon Sep 17 00:00:00 2001 From: david gauchard Date: Tue, 8 Oct 2019 00:31:30 +0200 Subject: [PATCH] Puyafix (#6619) * PUYA was not correctly enabled * remove duplicate --- cores/esp8266/Arduino.h | 4 ---- cores/esp8266/Esp.cpp | 16 ++++++++++++---- cores/esp8266/Esp.h | 9 --------- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/cores/esp8266/Arduino.h b/cores/esp8266/Arduino.h index 516a2f569..54919ba10 100644 --- a/cores/esp8266/Arduino.h +++ b/cores/esp8266/Arduino.h @@ -285,10 +285,6 @@ void configTime(const char* tz, const char* server1, #include "pins_arduino.h" -#ifndef PUYA_SUPPORT -#define PUYA_SUPPORT 1 -#endif - #endif #ifdef DEBUG_ESP_OOM diff --git a/cores/esp8266/Esp.cpp b/cores/esp8266/Esp.cpp index c7d66cef4..29222d6df 100644 --- a/cores/esp8266/Esp.cpp +++ b/cores/esp8266/Esp.cpp @@ -18,7 +18,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "Arduino.h" +#include "Esp.h" #include "flash_utils.h" #include "eboot_command.h" #include @@ -36,6 +36,14 @@ extern struct rst_info resetInfo; //#define DEBUG_SERIAL Serial +#ifndef PUYA_SUPPORT + #define PUYA_SUPPORT 1 +#endif +#ifndef PUYA_BUFFER_SIZE + // Good alternative for buffer size is: SPI_FLASH_SEC_SIZE (= 4k) + // Always use a multiple of flash page size (256 bytes) + #define PUYA_BUFFER_SIZE 256 +#endif /** * User-defined Literals @@ -577,7 +585,7 @@ bool EspClass::flashEraseSector(uint32_t sector) { } #if PUYA_SUPPORT -static int spi_flash_write_puya(uint32_t offset, uint32_t *data, size_t size) { +static SpiFlashOpResult spi_flash_write_puya(uint32_t offset, uint32_t *data, size_t size) { if (data == nullptr) { return SPI_FLASH_RESULT_ERR; } @@ -607,7 +615,7 @@ static int spi_flash_write_puya(uint32_t offset, uint32_t *data, size_t size) { } rc = spi_flash_read(pos, flash_write_puya_buf, bytesNow); if (rc != SPI_FLASH_RESULT_OK) { - return (int)rc; + return rc; } for (size_t i = 0; i < bytesNow / 4; ++i) { flash_write_puya_buf[i] &= *ptr; @@ -616,7 +624,7 @@ static int spi_flash_write_puya(uint32_t offset, uint32_t *data, size_t size) { rc = spi_flash_write(pos, flash_write_puya_buf, bytesNow); pos += bytesNow; } - return (int)rc; + return rc; } #endif diff --git a/cores/esp8266/Esp.h b/cores/esp8266/Esp.h index 33c7f10ad..726633d61 100644 --- a/cores/esp8266/Esp.h +++ b/cores/esp8266/Esp.h @@ -23,15 +23,6 @@ #include -#ifndef PUYA_SUPPORT - #define PUYA_SUPPORT 0 -#endif -#ifndef PUYA_BUFFER_SIZE - // Good alternative for buffer size is: SPI_FLASH_SEC_SIZE (= 4k) - // Always use a multiple of flash page size (256 bytes) - #define PUYA_BUFFER_SIZE 256 -#endif - // Vendor IDs taken from Flashrom project // https://review.coreboot.org/cgit/flashrom.git/tree/flashchips.h?h=1.0.x typedef enum {