Skip to content

Commit 3d70f43

Browse files
authored
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
1 parent cf21dfd commit 3d70f43

File tree

7 files changed

+35
-36
lines changed

7 files changed

+35
-36
lines changed

bootloaders/eboot/Makefile

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@ AR := $(XTENSA_TOOLCHAIN)xtensa-lx106-elf-ar
1717
LD := $(XTENSA_TOOLCHAIN)xtensa-lx106-elf-gcc
1818
OBJDUMP := $(XTENSA_TOOLCHAIN)xtensa-lx106-elf-objdump
1919

20-
20+
INC += -I../../tools/sdk/include
2121
CFLAGS += -std=gnu99
2222

2323
CFLAGS += -O0 -g -Wpointer-arith -Wno-implicit-function-declaration -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mno-text-section-literals
2424

25+
CFLAGS += $(INC)
26+
2527
LDFLAGS += -nostdlib -Wl,--no-check-sections -umain
2628

2729
LD_SCRIPT := -Teboot.ld

bootloaders/eboot/eboot.elf

24 Bytes
Binary file not shown.

bootloaders/eboot/flash.h

+8-4
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,19 @@
88
#ifndef FLASH_H
99
#define FLASH_H
1010

11+
12+
/* The geometry defines are placed in the sdk. The .h was factored out for reuse by eboot here.
13+
* Beware: this means that eboot has an external dependency.
14+
* The following .h is placed in tools/sdk/includes
15+
*/
16+
#include <spi_flash_geometry.h>
17+
1118
int SPIEraseBlock(uint32_t block);
1219
int SPIEraseSector(uint32_t sector);
1320
int SPIRead(uint32_t addr, void *dest, size_t size);
1421
int SPIWrite(uint32_t addr, void *src, size_t size);
1522
int SPIEraseAreaEx(const uint32_t start, const uint32_t size);
1623

17-
#define FLASH_SECTOR_SIZE 0x1000
18-
#define FLASH_BLOCK_SIZE 0x10000
19-
#define APP_START_OFFSET 0x1000
2024

2125
typedef struct {
2226
unsigned char magic;
@@ -25,7 +29,7 @@ typedef struct {
2529
/* SPI Flash Interface (0 = QIO, 1 = QOUT, 2 = DIO, 0x3 = DOUT) */
2630
unsigned char flash_mode;
2731

28-
/* High four bits: 0 = 512K, 1 = 256K, 2 = 1M, 3 = 2M, 4 = 4M,
32+
/* High four bits: 0 = 512K, 1 = 256K, 2 = 1M, 3 = 2M, 4 = 4M, 8 = 8M, 9 = 16M
2933
Low four bits: 0 = 40MHz, 1= 26MHz, 2 = 20MHz, 0xf = 80MHz */
3034
unsigned char flash_size_freq;
3135

cores/esp8266/flash_utils.h

+6-28
Original file line numberDiff line numberDiff line change
@@ -21,39 +21,17 @@
2121
#ifndef FLASH_UTILS_H
2222
#define FLASH_UTILS_H
2323

24+
2425
#ifdef __cplusplus
2526
extern "C" {
2627
#endif
2728

28-
int SPIEraseBlock(uint32_t block);
29-
int SPIEraseSector(uint32_t sector);
30-
int SPIRead(uint32_t addr, void *dest, size_t size);
31-
int SPIWrite(uint32_t addr, void *src, size_t size);
32-
int SPIEraseAreaEx(const uint32_t start, const uint32_t size);
33-
34-
#define FLASH_SECTOR_SIZE 0x1000
35-
#define FLASH_BLOCK_SIZE 0x10000
36-
#define APP_START_OFFSET 0x1000
37-
38-
typedef struct {
39-
unsigned char magic;
40-
unsigned char num_segments;
41-
42-
/* SPI Flash Interface (0 = QIO, 1 = QOUT, 2 = DIO, 0x3 = DOUT) */
43-
unsigned char flash_mode;
44-
45-
/* High four bits: 0 = 512K, 1 = 256K, 2 = 1M, 3 = 2M, 4 = 4M, 8 = 8M, 9 = 16M
46-
Low four bits: 0 = 40MHz, 1= 26MHz, 2 = 20MHz, 0xf = 80MHz */
47-
unsigned char flash_size_freq;
48-
49-
uint32_t entry;
50-
} image_header_t;
51-
29+
/* Definitions are placed in eboot. Include them here rather than duplicate them.
30+
* Also, prefer to have eboot standalone as much as possible and have the core depend on it
31+
* rather than have eboot depend on the core.
32+
*/
33+
#include <../../bootloaders/eboot/flash.h>
5234

53-
typedef struct {
54-
uint32_t address;
55-
uint32_t size;
56-
} section_header_t;
5735

5836
#ifdef __cplusplus
5937
}

tools/sdk/include/spi_flash.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
#ifndef SPI_FLASH_H
2626
#define SPI_FLASH_H
2727

28+
#include <spi_flash_geometry.h>
29+
2830
#ifdef __cplusplus
2931
extern "C" {
3032
#endif
@@ -44,8 +46,6 @@ typedef struct{
4446
uint32 status_mask;
4547
} SpiFlashChip;
4648

47-
#define SPI_FLASH_SEC_SIZE 4096
48-
4949
extern SpiFlashChip * flashchip; // in ram ROM-BIOS
5050

5151
uint32 spi_flash_get_id(void);
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#ifndef SPI_FLASH_GEOMETRY_H
2+
#define SPI_FLASH_GEOMETRY_H
3+
4+
/* The flash geometry is meant to be unified here. This header file should be included wherever needed.
5+
* Beware: this file is needed by eboot as well as the Arduino core.
6+
*/
7+
8+
#define FLASH_SECTOR_SIZE 0x1000
9+
#define FLASH_BLOCK_SIZE 0x10000
10+
#define APP_START_OFFSET 0x1000
11+
12+
//pulled this define from spi_flash.h for reuse in the Arduino core without pulling in a bunch of other stuff
13+
#define SPI_FLASH_SEC_SIZE FLASH_SECTOR_SIZE
14+
15+
#endif

tools/sdk/include/upgrade.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
extern "C" {
3030
#endif
3131

32+
#include <spi_flash_geometry.h>
3233

33-
#define SPI_FLASH_SEC_SIZE 4096
3434
#define LIMIT_ERASE_SIZE 0x10000
3535

3636
#define USER_BIN1 0x00

0 commit comments

Comments
 (0)