diff --git a/bootloaders/eboot/Makefile b/bootloaders/eboot/Makefile index e078263caa..3e25eb139e 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 1ccbe25fc3..da0f845278 100755 Binary files a/bootloaders/eboot/eboot.elf and b/bootloaders/eboot/eboot.elf differ diff --git a/bootloaders/eboot/flash.h b/bootloaders/eboot/flash.h index ea8b65c1fa..38c528869a 100644 --- a/bootloaders/eboot/flash.h +++ b/bootloaders/eboot/flash.h @@ -8,15 +8,19 @@ #ifndef FLASH_H #define FLASH_H + +/* The geometry defines are placed in the sdk. The .h was factored out for reuse by eboot here. + * Beware: this means that eboot has an external dependency. + * The following .h is placed in tools/sdk/includes + */ +#include + 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 67dc6ebadd..eade691a5b 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); - -#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; - +/* 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> -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 00f8a08b79..4e5a94f831 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 0000000000..bb8c0ea22f --- /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 6c88f9a043..8d5f6cd7cf 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