From 3d70f43277aea997f66c78c6e0495a3e71324683 Mon Sep 17 00:00:00 2001 From: Develo Date: Sat, 24 Nov 2018 02:59:12 -0300 Subject: [PATCH] cleanup/unify flash sector size define value (#5327) * cleanup/unify sector size define value * replicate spi_flash_sec_size.h file for host tests * further flash geometry cleanup, remove host test duplicate file --- bootloaders/eboot/Makefile | 4 ++- bootloaders/eboot/eboot.elf | Bin 10352 -> 10376 bytes bootloaders/eboot/flash.h | 12 ++++++--- cores/esp8266/flash_utils.h | 34 +++++-------------------- tools/sdk/include/spi_flash.h | 4 +-- tools/sdk/include/spi_flash_geometry.h | 15 +++++++++++ tools/sdk/include/upgrade.h | 2 +- 7 files changed, 35 insertions(+), 36 deletions(-) create mode 100644 tools/sdk/include/spi_flash_geometry.h diff --git a/bootloaders/eboot/Makefile b/bootloaders/eboot/Makefile index e078263ca..3e25eb139 100644 --- a/bootloaders/eboot/Makefile +++ b/bootloaders/eboot/Makefile @@ -17,11 +17,13 @@ AR := $(XTENSA_TOOLCHAIN)xtensa-lx106-elf-ar LD := $(XTENSA_TOOLCHAIN)xtensa-lx106-elf-gcc OBJDUMP := $(XTENSA_TOOLCHAIN)xtensa-lx106-elf-objdump - +INC += -I../../tools/sdk/include CFLAGS += -std=gnu99 CFLAGS += -O0 -g -Wpointer-arith -Wno-implicit-function-declaration -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mno-text-section-literals +CFLAGS += $(INC) + LDFLAGS += -nostdlib -Wl,--no-check-sections -umain LD_SCRIPT := -Teboot.ld diff --git a/bootloaders/eboot/eboot.elf b/bootloaders/eboot/eboot.elf index 1ccbe25fc312cfa70690fa91a8737c38c2aa678f..da0f8452785eb278f8a32f0ed05a0b8a67627195 100755 GIT binary patch delta 745 zcmb7AO=uHQ5Pt7%Hg7l0wi}z8#>9;_ZDNge(}*<(CA9}dQPfaDBS;#vnAqypCbfDf zUR9`npu!CNn~w;ZIP_SAz14+bh&EP{tXp@$ppLu z(eXFCmpNOZ@Qr6!m_fg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Jn{mJ4U=W%)mfLwFfdF7i^TxNrcBP2S7%h&JXQWP2LOe`x + int SPIEraseBlock(uint32_t block); int SPIEraseSector(uint32_t sector); int SPIRead(uint32_t addr, void *dest, size_t size); int SPIWrite(uint32_t addr, void *src, size_t size); int SPIEraseAreaEx(const uint32_t start, const uint32_t size); -#define FLASH_SECTOR_SIZE 0x1000 -#define FLASH_BLOCK_SIZE 0x10000 -#define APP_START_OFFSET 0x1000 typedef struct { unsigned char magic; @@ -25,7 +29,7 @@ typedef struct { /* SPI Flash Interface (0 = QIO, 1 = QOUT, 2 = DIO, 0x3 = DOUT) */ unsigned char flash_mode; - /* High four bits: 0 = 512K, 1 = 256K, 2 = 1M, 3 = 2M, 4 = 4M, + /* High four bits: 0 = 512K, 1 = 256K, 2 = 1M, 3 = 2M, 4 = 4M, 8 = 8M, 9 = 16M Low four bits: 0 = 40MHz, 1= 26MHz, 2 = 20MHz, 0xf = 80MHz */ unsigned char flash_size_freq; diff --git a/cores/esp8266/flash_utils.h b/cores/esp8266/flash_utils.h index 67dc6ebad..eade691a5 100644 --- a/cores/esp8266/flash_utils.h +++ b/cores/esp8266/flash_utils.h @@ -21,39 +21,17 @@ #ifndef FLASH_UTILS_H #define FLASH_UTILS_H + #ifdef __cplusplus extern "C" { #endif -int SPIEraseBlock(uint32_t block); -int SPIEraseSector(uint32_t sector); -int SPIRead(uint32_t addr, void *dest, size_t size); -int SPIWrite(uint32_t addr, void *src, size_t size); -int SPIEraseAreaEx(const uint32_t start, const uint32_t size); +/* Definitions are placed in eboot. Include them here rather than duplicate them. + * Also, prefer to have eboot standalone as much as possible and have the core depend on it + * rather than have eboot depend on the core. + */ +#include <../../bootloaders/eboot/flash.h> -#define FLASH_SECTOR_SIZE 0x1000 -#define FLASH_BLOCK_SIZE 0x10000 -#define APP_START_OFFSET 0x1000 - -typedef struct { - unsigned char magic; - unsigned char num_segments; - - /* SPI Flash Interface (0 = QIO, 1 = QOUT, 2 = DIO, 0x3 = DOUT) */ - unsigned char flash_mode; - - /* High four bits: 0 = 512K, 1 = 256K, 2 = 1M, 3 = 2M, 4 = 4M, 8 = 8M, 9 = 16M - Low four bits: 0 = 40MHz, 1= 26MHz, 2 = 20MHz, 0xf = 80MHz */ - unsigned char flash_size_freq; - - uint32_t entry; -} image_header_t; - - -typedef struct { - uint32_t address; - uint32_t size; -} section_header_t; #ifdef __cplusplus } diff --git a/tools/sdk/include/spi_flash.h b/tools/sdk/include/spi_flash.h index 00f8a08b7..4e5a94f83 100644 --- a/tools/sdk/include/spi_flash.h +++ b/tools/sdk/include/spi_flash.h @@ -25,6 +25,8 @@ #ifndef SPI_FLASH_H #define SPI_FLASH_H +#include + #ifdef __cplusplus extern "C" { #endif @@ -44,8 +46,6 @@ typedef struct{ uint32 status_mask; } SpiFlashChip; -#define SPI_FLASH_SEC_SIZE 4096 - extern SpiFlashChip * flashchip; // in ram ROM-BIOS uint32 spi_flash_get_id(void); diff --git a/tools/sdk/include/spi_flash_geometry.h b/tools/sdk/include/spi_flash_geometry.h new file mode 100644 index 000000000..bb8c0ea22 --- /dev/null +++ b/tools/sdk/include/spi_flash_geometry.h @@ -0,0 +1,15 @@ +#ifndef SPI_FLASH_GEOMETRY_H +#define SPI_FLASH_GEOMETRY_H + +/* The flash geometry is meant to be unified here. This header file should be included wherever needed. + * Beware: this file is needed by eboot as well as the Arduino core. + */ + +#define FLASH_SECTOR_SIZE 0x1000 +#define FLASH_BLOCK_SIZE 0x10000 +#define APP_START_OFFSET 0x1000 + +//pulled this define from spi_flash.h for reuse in the Arduino core without pulling in a bunch of other stuff +#define SPI_FLASH_SEC_SIZE FLASH_SECTOR_SIZE + +#endif diff --git a/tools/sdk/include/upgrade.h b/tools/sdk/include/upgrade.h index 6c88f9a04..8d5f6cd7c 100644 --- a/tools/sdk/include/upgrade.h +++ b/tools/sdk/include/upgrade.h @@ -29,8 +29,8 @@ extern "C" { #endif +#include -#define SPI_FLASH_SEC_SIZE 4096 #define LIMIT_ERASE_SIZE 0x10000 #define USER_BIN1 0x00