Skip to content
Merged

Puyafix #6619

Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions cores/esp8266/Arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 12 additions & 4 deletions cores/esp8266/Esp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <memory>
Expand All @@ -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
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand All @@ -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

Expand Down
9 changes: 0 additions & 9 deletions cores/esp8266/Esp.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,6 @@

#include <Arduino.h>

#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 {
Expand Down