8000 esp8266: Add board variant support. · micropython/micropython@abe4a5a · GitHub
[go: up one dir, main page]

Skip to content

Commit abe4a5a

Browse files
committed
esp8266: Add board variant support.
This merges the existing GENERIC, GENERIC_1M, and GENERIC_512k boards into variants of the new ESP8266_ 8000 GENERIC board (renamed from GENERIC so as not to clash with other ports). Also moves the generation of the "OTA" variant (previously generated by autobuild/build-esp8266-latest.sh) into the variant. Following the convention established for the WEACTSTUDIO rp2 board, the names of the variants are FLASH_1M and FLASH_512K (but rename the .ld files to use MiB and kiB). This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
1 parent 21f4eb4 commit abe4a5a

26 files changed

+170
-195
lines changed

ports/esp8266/Makefile

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,22 @@ ifdef BOARD_DIR
44
# the path as the board name.
55
BOARD ?= $(notdir $(BOARD_DIR:/=))
66
else
7-
# If not given on the command line, then default to GENERIC.
8-
BOARD ?= GENERIC
7+
# If not given on the command line, then default to ESP8266_GENERIC.
8+
BOARD ?= ESP8266_GENERIC
99
BOARD_DIR ?= boards/$(BOARD)
1010
endif
1111

1212
ifeq ($(wildcard $(BOARD_DIR)/.),)
1313
$(error Invalid BOARD specified: $(BOARD_DIR))
1414
endif
1515

16-
# If the build directory is not given, make it reflect the board name.
16+
# If the build directory is not given, make it reflect the board name (and
17+
# optionally the board variant).
18+
ifneq ($(BOARD_VARIANT),)
19+
BUILD ?= build-$(BOARD)-$(BOARD_VARIANT)
20+
else
1721
BUILD ?= build-$(BOARD)
22+
endif
1823

1924
include ../../py/mkenv.mk
2025

@@ -213,20 +218,26 @@ erase:
213218
reset:
214219
echo -e "\r\nimport machine; machine.reset()\r\n" >$(PORT)
215220

221+
ifeq ($(BOARD_VARIANT),OTA)
222+
$(FWBIN): $(BUILD)/firmware.elf
223+
$(ECHO) "Create $@"
224+
$(Q)esptool.py elf2image $^
225+
$(Q)$(PYTHON) makeimg.py $(BUILD)/firmware.elf-0x00000.bin $(BUILD)/firmware.elf-0x[0-5][1-f]000.bin $(BUILD)/firmware-combined-ota.bin
226+
227+
$(Q)cat $(YAOTA8266)/yaota8266.bin $(BUILD)/firmware-combined-ota.bin > $@
228+
$(Q)$(PYTHON) $(YAOTA8266)/ota-client/ota_client.py sign $@
229+
else
216230
$(FWBIN): $(BUILD)/firmware.elf
217231
$(ECHO) "Create $@"
218232
$(Q)esptool.py elf2image $^
219233
$(Q)$(PYTHON) makeimg.py $(BUILD)/firmware.elf-0x00000.bin $(BUILD)/firmware.elf-0x[0-5][1-f]000.bin $@
234+
endif
220235

221236
$(BUILD)/firmware.elf: $(OBJ)
222237
$(ECHO) "LINK $@"
223238
$(Q)$(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
224239
$(Q)$(SIZE) $@
225240

226-
ota:
227-
rm -f $(BUILD)/firmware.elf $(BUILD)/firmware.elf*.bin
228-
$(MAKE) LD_FILES=boards/esp8266_ota.ld FWBIN=$(BUILD)/firmware-ota.bin
229-
230241
include $(TOP)/py/mkrules.mk
231242

232243
clean-modules:

ports/esp8266/README.md

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ Supported features include:
2323

2424
Documentation is available at http://docs.micropython.org/en/latest/esp8266/quickref.html.
2525

26+
The default build requires a 2MiB flash chip, but see below for support for
27+
1MiB and 512kB options.
28+
2629
Build instructions
2730
------------------
2831

@@ -67,10 +70,10 @@ Then to compile the ESP8266 firmware:
6770

6871
```
6972
$ cd ports/esp8266
70-
$ docker run --rm -v $HOME:$HOME -u $UID -w $PWD larsks/esp-open-sdk make -j BOARD=GENERIC
73+
$ docker run --rm -v $HOME:$HOME -u $UID -w $PWD larsks/esp-open-sdk make -j BOARD=ESP8266_GENERIC
7174
```
7275

73-
This will produce binary images in the `build-GENERIC/` subdirectory.
76+
This will produce binary images in the `build-ESP8266_GENERIC/` subdirectory.
7477
Substitute the board for whichever board you're using.
7578

7679
__Building with a local toolchain__
@@ -106,10 +109,10 @@ Then to compile the ESP8266 firmware:
106109

107110
```
108111
$ cd ports/esp8266
109-
$ make -j BOARD=GENERIC
112+
$ make -j BOARD=ESP8266_GENERIC
110113
```
111114

112-
This will produce binary images in the `build-GENERIC/` subdirectory.
115+
This will produce binary images in the `build-ESP8266_GENERIC/` subdirectory.
113116
Substitute the board for whichever board you're using.
114117

115118

@@ -149,25 +152,29 @@ $ make PORT=/dev/ttyUSB0 FLASH_MODE=qio FLASH_SIZE=32m deploy
149152
(note that flash size is in megabits)
150153

151154
If you want to flash manually using `esptool.py` directly, the image produced is
152-
`build-GENERIC/firmware-combined.bin`, to be flashed at 0x00000.
155+
`build-ESP8266_GENERIC/firmware-combined.bin`, to be flashed at 0x00000.
153156

154-
The default board definition is the directory `boards/GENERIC`.
157+
The default board definition is the directory `boards/ESP8266_GENERIC`.
155158
For a custom configuration you can define your own board in the directory `boards/`.
156159

157-
The `BOARD` variable can be set on the make command line, for example:
158-
```bash
159-
$ make BOARD=GENERIC_512K
160-
```
160+
__Reduced FlashROM variants__
161161

162-
__512KB FlashROM version__
162+
The normal build described above requires modules with at least 2MiB of
163+
FlashROM onboard. There's a special configuration for 512KiB modules, which can
164+
be built with the `FLASH_512K` variant. This configuration is highly limited,
165+
lacks filesystem support, WebREPL, and has many other features disabled. It's
166+
mostly suitable for advanced users who are interested to fine-tune options to
167+
achieve a required setup. If you are an end user, please consider using a
168+
module with at least 2MiB of FlashROM.
163169

164-
The normal build described above requires modules with at least 1MB of FlashROM
165-
onboard. There's a special configuration for 512KB modules, which can be
166-
built with `make BOARD=GENERIC_512K`. This configuration is highly limited, lacks
167-
filesystem support, WebREPL, and has many other features disabled. It's mostly
168-
suitable for advanced users who are interested to fine-tune options to achieve a
169-
required setup. If you are an end user, please consider using a module with at
170-
least 1MB of FlashROM.
170+
A variant is also provided for 1MiB modules which just lacks the included
171+
micropython-lib packages.
172+
173+
The variant can be set on the make command line, for example:
174+
```bash
175+
$ make BOARD=ESP8266_GENERIC BOARD_VARIANT=FLASH_512K
176+
$ make BOARD=ESP8266_GENERIC BOARD_VARIANT=FLASH_1M
177+
```
171178

172179
First start
173180
-----------
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Minimal _boot.py for the 512kB variant. Does not set up a block device or
2+
# filesystem. Other variants use esp8266/modules/_boot.py.
3+
4+
import gc
5+
6+
gc.threshold((gc.mem_free() + gc.mem_alloc()) // 4)

ports/esp8266/boards/GENERIC/board.json renamed to ports/esp8266/boards/ESP8266_GENERIC/board.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@
99
],
1010
"images": [],
1111
"mcu": "esp8266",
12-
"product": "ESP8266 with 2MiB+ flash",
12+
"product": "ESP8266",
1313
"thumbnail": "",
1414
"url": "https://www.espressif.com/en/products/modules",
1515
"variants": {
16-
"ota": "OTA compatible"
16+
"OTA": "OTA compatible",
17+
"FLASH_1M": "1MiB flash",
18+
"FLASH_512K": "512kiB flash"
1719
},
1820
"vendor": "Espressif"
1921
}

ports/esp8266/boards/GENERIC/board.md renamed to ports/esp8266/boards/ESP8266_GENERIC/board.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1-
The following are daily builds of the ESP8266 firmware for boards with at
2-
least 2MiB of flash. They have the latest features and bug fixes, WebREPL is
3-
not automatically started, and debugging is enabled by default.
< B94F /td>1+
The following are daily builds of the ESP8266 firmware. This will work on
2+
boards with at least 2MiB of flash. They have the latest features and bug
3+
fixes, WebREPL is not automatically started, and debugging is enabled by
4+
default.
5+
6+
For boards with 1MiB or 512k of flash, two variants are provided with reduced
7+
functionality. The 1MiB variant removes asyncio and FAT-filesystem support as
8+
well as some modules from micropython-lib. The 512kB variant further removes
9+
all filesystem support, as well as framebuffer support, some Python language
10+
features, and has less detailed error messages.
411

512
Note: v1.12-334 and newer (including v1.13) require an ESP8266 module with
613
2MiB of flash or more, and use littlefs as the filesystem by default. When
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#if defined(MICROPY_ESP8266_2M)
2+
3+
#define MICROPY_HW_BOARD_NAME "ESP module"
4+
#define MICROPY_HW_MCU_NAME "ESP8266"
5+
6+
#define MICROPY_PERSISTENT_CODE_LOAD (1)
7+
#define MICROPY_EMIT_XTENSA (1)
8+
#define MICROPY_EMIT_INLINE_XTENSA (1)
9+
10+
#define MICROPY_DEBUG_PRINTERS (1)
11+
#define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_NORMAL)
12+
13+
#define MICROPY_READER_VFS (MICROPY_VFS)
14+
#define MICROPY_VFS (1)
15+
16+
#define MICROPY_PY_CRYPTOLIB (1)
17+
18+
#elif defined(MICROPY_ESP8266_1M)
19+
20+
#define MICROPY_HW_BOARD_NAME "ESP module (1M)"
21+
#define MICROPY_HW_MCU_NAME "ESP8266"
22+
23+
#define MICROPY_PERSISTENT_CODE_LOAD (1)
24+
#define MICROPY_EMIT_XTENSA (1)
25+
#define MICROPY_EMIT_INLINE_XTENSA (1)
26+
27+
#define MICROPY_DEBUG_PRINTERS (1)
28+
#define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_NORMAL)
29+
30+
#define MICROPY_READER_VFS (MICROPY_VFS)
31+
#define MICROPY_VFS (1)
32+
33+
34+
#define MICROPY_PY_CRYPTOLIB (1)
35+
36+
#elif defined(MICROPY_ESP8266_512K)
37+
38+
#define MICROPY_HW_BOARD_NAME "ESP module (512K)"
39+
#define MICROPY_HW_MCU_NAME "ESP8266"
40+
41+
#define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_TERSE)
42+
43+
#define MICROPY_PY_FSTRINGS (0)
44+
#define MICROPY_PY_BUILTINS_SLICE_ATTRS (0)
45+
#define MICROPY_PY_ALL_SPECIAL_METHODS (0)
46+
#define MICROPY_PY_REVERSE_SPECIAL_METHODS (0)
47+
#define MICROPY_PY_SYS_STDIO_BUFFER (0)
48+
#define MICROPY_PY_ASYNCIO (0)
49+
#define MICROPY_PY_RE_SUB (0)
50+
#define MICROPY_PY_FRAMEBUF (0)
51+
52+
#endif
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
ifeq ($(BOARD_VARIANT),)
2+
LD_FILES = boards/esp8266_2MiB.ld
3+
4+
MICROPY_ESPNOW ?= 1
5+
MICROPY_PY_BTREE ?= 1
6+
MICROPY_VFS_FAT ?= 1
7+
MICROPY_VFS_LFS2 ?= 1
8+
9+
# Add asyncio and extra micropython-lib packages (in addition to the port manifest).
10+
FROZEN_MANIFEST ?= $(BOARD_DIR)/manifest_2MiB.py
11+
12+
# Configure mpconfigboard.h.
13+
CFLAGS += -DMICROPY_ESP8266_2M
14+
endif
15+
16+
ifeq ($(BOARD_VARIANT),FLASH_1M)
17+
LD_FILES = boards/esp8266_1MiB.ld
18+
19+
MICROPY_ESPNOW ?= 1
20+
MICROPY_PY_BTREE ?= 1
21+
MICROPY_VFS_LFS2 ?= 1
22+
23+
# Note: Implicitly uses the port manifest.
24+
25+
# Configure mpconfigboard.h.
26+
CFLAGS += -DMICROPY_ESP8266_1M
27+
endif
28+
29+
ifeq ($(BOARD_VARIANT),OTA)
30+
LD_FILES = boards/esp8266_ota.ld
31+
32+
MICROPY_ESPNOW ?= 1
33+
MICROPY_PY_BTREE ?= 1
34+
MICROPY_VFS_LFS2 ?= 1
35+
36+
# Note: Implicitly uses the port manifest.
37+
38+
# Configure mpconfigboard.h.
39+
CFLAGS += -DMICROPY_ESP8266_1M
40+
endif
41+
42+
ifeq ($(BOARD_VARIANT),FLASH_512K)
43+
LD_FILES = boards/esp8266_512kiB.ld
44+
45+
# Note: Use the minimal manifest.py.
46+
FROZEN_MANIFEST ?= $(BOARD_DIR)/manifest_512kiB.py
47+
48+
# Configure mpconfigboard.h.
49+
CFLAGS += -DMICROPY_ESP8266_512K
50+
endif

ports/esp8266/boards/GENERIC/mpconfigboard.h

Lines changed: 0 additions & 14 deletions
This file was deleted.

ports/esp8266/boards/GENERIC/mpconfigboard.mk

Lines chan 10000 ged: 0 additions & 8 deletions
This file was deleted.

ports/esp8266/boards/GENERIC_1M/board.json

Lines changed: 0 additions & 16 deletions
This file was deleted.

ports/esp8266/boards/GENERIC_1M/board.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

ports/esp8266/boards/GENERIC_1M/mpconfigboard.h

Lines changed: 0 additions & 17 deletions
This file was deleted.

ports/esp8266/boards/GENERIC_1M/mpconfigboard.mk

Lines changed: 0 additions & 5 deletions
This file was deleted.

ports/esp8266/boards/GENERIC_512K/_boot.py

Lines changed: 0 additions & 3 deletions
This file was deleted.

ports/esp8266/boards/GENERIC_512K/board.json

Lines changed: 0 additions & 16 deletions
This file was deleted.

ports/esp8266/boards/GENERIC_512K/board.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

ports/esp8266/boards/GENERIC_512K/mpconfigboard.h

Lines changed: 0 additions & 13 deletions
This file was deleted.

ports/esp8266/boards/GENERIC_512K/mpconfigboard.mk

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)
0