esp8266: Add per-board configs, following other ports.
The specific board can be selected with the BOARD makefile variable. This defaults (if not specified) to BOARD=GENERIC, which is the original default firmware build. For the 512k target use BOARD=GENERIC_512K.
This commit is contained in:
parent
2863dcdf4f
commit
53a9b45da1
@ -1,13 +1,29 @@
|
||||
# Select the board to build for: if not given on the command line,
|
||||
# then default to GENERIC.
|
||||
BOARD ?= GENERIC
|
||||
|
||||
# If the build directory is not given, make it reflect the board name.
|
||||
BUILD ?= build-$(BOARD)
|
||||
|
||||
BOARD_DIR ?= boards/$(BOARD)
|
||||
ifeq ($(wildcard $(BOARD_DIR)/.),)
|
||||
$(error Invalid BOARD specified: $(BOARD_DIR))
|
||||
endif
|
||||
|
||||
include ../../py/mkenv.mk
|
||||
|
||||
# Optional
|
||||
-include $(BOARD_DIR)/mpconfigboard.mk
|
||||
|
||||
# qstr definitions (must come before including py.mk)
|
||||
QSTR_DEFS = qstrdefsport.h #$(BUILD)/pins_qstr.h
|
||||
QSTR_GLOBAL_DEPENDENCIES = $(BOARD_DIR)/mpconfigboard.h
|
||||
|
||||
MICROPY_PY_USSL = 1
|
||||
MICROPY_SSL_AXTLS = 1
|
||||
AXTLS_DEFS_EXTRA = -Dabort=abort_ -DRT_MAX_PLAIN_LENGTH=1024 -DRT_EXTRA=4096
|
||||
MICROPY_FATFS = 1
|
||||
MICROPY_PY_BTREE = 1
|
||||
MICROPY_FATFS ?= 1
|
||||
MICROPY_PY_BTREE ?= 1
|
||||
BTREE_DEFS_EXTRA = -DDEFPSIZE=1024 -DMINCACHE=3
|
||||
|
||||
FROZEN_DIR ?= scripts
|
||||
@ -40,10 +56,10 @@ CFLAGS_XTENSA = -fsingle-precision-constant -Wdouble-promotion \
|
||||
-DLWIP_OPEN_SRC
|
||||
|
||||
CFLAGS = $(INC) -Wall -Wpointer-arith -Werror -std=gnu99 -nostdlib -DUART_OS=$(UART_OS) \
|
||||
$(CFLAGS_XTENSA) $(CFLAGS_MOD) $(COPT) $(CFLAGS_EXTRA)
|
||||
$(CFLAGS_XTENSA) $(CFLAGS_MOD) $(COPT) $(CFLAGS_EXTRA) -I$(BOARD_DIR)
|
||||
|
||||
LDSCRIPT = esp8266.ld
|
||||
LDFLAGS = -nostdlib -T $(LDSCRIPT) -Map=$(@:.elf=.map) --cref
|
||||
LD_FILES ?= boards/esp8266.ld
|
||||
LDFLAGS = -nostdlib -T $(LD_FILES) -Map=$(@:.elf=.map) --cref
|
||||
LIBS = -L$(ESP_SDK)/lib -lmain -ljson -llwip_open -lpp -lnet80211 -lwpa -lphy -lnet80211 $(LDFLAGS_MOD)
|
||||
|
||||
LIBGCC_FILE_NAME = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
|
||||
@ -92,6 +108,7 @@ SRC_C = \
|
||||
fatfs_port.c \
|
||||
posix_helpers.c \
|
||||
hspi.c \
|
||||
$(wildcard $(BOARD_DIR)/*.c) \
|
||||
$(SRC_MOD)
|
||||
|
||||
EXTMOD_SRC_C = $(addprefix extmod/,\
|
||||
@ -192,15 +209,12 @@ $(BUILD)/firmware.elf: $(OBJ)
|
||||
$(Q)$(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
|
||||
$(Q)$(SIZE) $@
|
||||
|
||||
512k:
|
||||
$(MAKE) LDSCRIPT=esp8266_512k.ld CFLAGS_EXTRA='-DMP_CONFIGFILE="<mpconfigport_512k.h>"' MICROPY_FATFS=0 MICROPY_PY_BTREE=0
|
||||
|
||||
ota:
|
||||
rm -f $(BUILD)/firmware.elf $(BUILD)/firmware.elf*.bin
|
||||
$(MAKE) LDSCRIPT=esp8266_ota.ld FWBIN=$(BUILD)/firmware-ota.bin
|
||||
$(MAKE) LD_FILES=boards/esp8266_ota.ld FWBIN=$(BUILD)/firmware-ota.bin
|
||||
|
||||
include $(TOP)/py/mkrules.mk
|
||||
|
||||
clean-modules:
|
||||
git clean -f -d modules
|
||||
rm -f build/frozen*.c
|
||||
rm -f $(BUILD)/frozen*.c
|
||||
|
@ -52,12 +52,11 @@ Then, to build MicroPython for the ESP8266, just run:
|
||||
$ cd ports/esp8266
|
||||
$ make
|
||||
```
|
||||
This will produce binary images in the `build/` subdirectory. If you install
|
||||
MicroPython to your module for the first time, or after installing any other
|
||||
firmware, you should erase flash completely:
|
||||
|
||||
```
|
||||
esptool.py --port /dev/ttyXXX erase_flash
|
||||
This will produce binary images in the `build-GENERIC/` subdirectory. If you
|
||||
install MicroPython to your module for the first time, or after installing any
|
||||
other firmware, you should erase flash completely:
|
||||
```bash
|
||||
$ esptool.py --port /dev/ttyXXX erase_flash
|
||||
```
|
||||
|
||||
Erase flash also as a troubleshooting measure, if a module doesn't behave as
|
||||
@ -76,17 +75,25 @@ that flash size is in megabits):
|
||||
$ make PORT=/dev/ttyUSB0 FLASH_MODE=qio FLASH_SIZE=32m deploy
|
||||
```
|
||||
|
||||
The image produced is `build/firmware-combined.bin`, to be flashed at 0x00000.
|
||||
The image produced is `build-GENERIC/firmware-combined.bin`, to be flashed at 0x00000.
|
||||
|
||||
The default board definition is the directory `boards/GENERIC`.
|
||||
For a custom configuration you can define your own board in the directory `boards/`.
|
||||
|
||||
The `BOARD` variable can be set on the make command line, for example:
|
||||
```bash
|
||||
$ make BOARD=GENERIC_512K
|
||||
```
|
||||
|
||||
__512KB FlashROM version__
|
||||
|
||||
The normal build described above requires modules with at least 1MB of FlashROM
|
||||
onboard. There's a special configuration for 512KB modules, which can be
|
||||
built with `make 512k`. This configuration is highly limited, lacks filesystem
|
||||
support, WebREPL, and has many other features disabled. It's mostly suitable
|
||||
for advanced users who are interested to fine-tune options to achieve a required
|
||||
setup. If you are an end user, please consider using a module with at least 1MB
|
||||
of FlashROM.
|
||||
built with `make BOARD=GENERIC_512K`. This configuration is highly limited, lacks
|
||||
filesystem support, WebREPL, and has many other features disabled. It's mostly
|
||||
suitable for advanced users who are interested to fine-tune options to achieve a
|
||||
required setup. If you are an end user, please consider using a module with at
|
||||
least 1MB of FlashROM.
|
||||
|
||||
First start
|
||||
-----------
|
||||
|
21
ports/esp8266/boards/GENERIC/mpconfigboard.h
Normal file
21
ports/esp8266/boards/GENERIC/mpconfigboard.h
Normal file
@ -0,0 +1,21 @@
|
||||
#define MICROPY_HW_BOARD_NAME "ESP module"
|
||||
#define MICROPY_HW_MCU_NAME "ESP8266"
|
||||
|
||||
#define MICROPY_PERSISTENT_CODE_LOAD (1)
|
||||
#define MICROPY_EMIT_XTENSA (1)
|
||||
#define MICROPY_EMIT_INLINE_XTENSA (1)
|
||||
|
||||
#define MICROPY_DEBUG_PRINTERS (1)
|
||||
#define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_NORMAL)
|
||||
|
||||
#define MICROPY_READER_VFS (MICROPY_VFS)
|
||||
#define MICROPY_VFS (1)
|
||||
#define MICROPY_VFS_FAT (1)
|
||||
|
||||
#define MICROPY_PY_BUILTINS_SLICE_ATTRS (1)
|
||||
#define MICROPY_PY_ALL_SPECIAL_METHODS (1)
|
||||
#define MICROPY_PY_IO_FILEIO (1)
|
||||
#define MICROPY_PY_SYS_STDIO_BUFFER (1)
|
||||
#define MICROPY_PY_URE_SUB (1)
|
||||
#define MICROPY_PY_UCRYPTOLIB (1)
|
||||
#define MICROPY_PY_FRAMEBUF (1)
|
4
ports/esp8266/boards/GENERIC_512K/mpconfigboard.h
Normal file
4
ports/esp8266/boards/GENERIC_512K/mpconfigboard.h
Normal file
@ -0,0 +1,4 @@
|
||||
#define MICROPY_HW_BOARD_NAME "ESP module (512K)"
|
||||
#define MICROPY_HW_MCU_NAME "ESP8266"
|
||||
|
||||
#define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_TERSE)
|
3
ports/esp8266/boards/GENERIC_512K/mpconfigboard.mk
Normal file
3
ports/esp8266/boards/GENERIC_512K/mpconfigboard.mk
Normal file
@ -0,0 +1,3 @@
|
||||
MICROPY_FATFS = 0
|
||||
MICROPY_PY_BTREE = 0
|
||||
LD_FILES = boards/esp8266_512k.ld
|
@ -9,4 +9,4 @@ MEMORY
|
||||
}
|
||||
|
||||
/* define common sections and symbols */
|
||||
INCLUDE esp8266_common.ld
|
||||
INCLUDE boards/esp8266_common.ld
|
@ -9,4 +9,4 @@ MEMORY
|
||||
}
|
||||
|
||||
/* define common sections and symbols */
|
||||
INCLUDE esp8266_common.ld
|
||||
INCLUDE boards/esp8266_common.ld
|
@ -142,7 +142,7 @@ SECTIONS
|
||||
*lib/utils/interrupt_char.o*(.literal.mp_hal_set_interrupt_char, .text.mp_hal_set_interrupt_char)
|
||||
*drivers/bus/*.o(.literal* .text*)
|
||||
|
||||
build/main.o(.literal* .text*)
|
||||
build-*/main.o(.literal* .text*)
|
||||
*fatfs_port.o(.literal* .text*)
|
||||
*gccollect.o(.literal* .text*)
|
||||
*gchelper.o(.literal* .text*)
|
||||
@ -179,7 +179,7 @@ SECTIONS
|
||||
*/frozen.o(.rodata.mp_frozen_content) /* frozen modules */
|
||||
|
||||
/* for -mforce-l32 */
|
||||
build/*.o(.rodata*)
|
||||
build-*/*.o(.rodata*)
|
||||
|
||||
_irom0_text_end = ABSOLUTE(.);
|
||||
} >irom0_0_seg :irom0_0_phdr
|
||||
@ -313,4 +313,4 @@ SECTIONS
|
||||
}
|
||||
|
||||
/* get ROM code address */
|
||||
INCLUDE "eagle.rom.addr.v6.ld"
|
||||
INCLUDE "boards/eagle.rom.addr.v6.ld"
|
@ -10,4 +10,4 @@ MEMORY
|
||||
}
|
||||
|
||||
/* define common sections and symbols */
|
||||
INCLUDE esp8266_common.ld
|
||||
INCLUDE boards/esp8266_common.ld
|
@ -1,6 +1,10 @@
|
||||
#include <stdint.h>
|
||||
// Options to control how MicroPython is built for this port,
|
||||
// overriding defaults in py/mpconfig.h.
|
||||
|
||||
// options to control how MicroPython is built
|
||||
// Board-specific definitions
|
||||
#include "mpconfigboard.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define MICROPY_OBJ_REPR (MICROPY_OBJ_REPR_C)
|
||||
#define MICROPY_GC_STACK_ENTRY_TYPE uint16_t
|
||||
@ -10,13 +14,8 @@
|
||||
#define MICROPY_ALLOC_PARSE_RULE_INC (8)
|
||||
#define MICROPY_ALLOC_PARSE_RESULT_INC (8)
|
||||
#define MICROPY_ALLOC_PARSE_CHUNK_INIT (64)
|
||||
#define MICROPY_PERSISTENT_CODE_LOAD (1)
|
||||
#define MICROPY_EMIT_XTENSA (1)
|
||||
#define MICROPY_EMIT_INLINE_XTENSA (1)
|
||||
#define MICROPY_MEM_STATS (0)
|
||||
#define MICROPY_DEBUG_PRINTER (&mp_debug_print)
|
||||
#define MICROPY_DEBUG_PRINTERS (1)
|
||||
#define MICROPY_READER_VFS (MICROPY_VFS)
|
||||
#define MICROPY_ENABLE_GC (1)
|
||||
#define MICROPY_ENABLE_FINALISER (1)
|
||||
#define MICROPY_STACK_CHECK (1)
|
||||
@ -32,7 +31,6 @@
|
||||
#define MICROPY_USE_INTERNAL_ERRNO (1)
|
||||
#define MICROPY_ENABLE_SCHEDULER (1)
|
||||
#define MICROPY_PY_DESCRIPTORS (1)
|
||||
#define MICROPY_PY_ALL_SPECIAL_METHODS (1)
|
||||
#define MICROPY_PY_BUILTINS_COMPLEX (0)
|
||||
#define MICROPY_PY_BUILTINS_STR_UNICODE (1)
|
||||
#define MICROPY_PY_BUILTINS_BYTEARRAY (1)
|
||||
@ -40,7 +38,6 @@
|
||||
#define MICROPY_PY_BUILTINS_FROZENSET (1)
|
||||
#define MICROPY_PY_BUILTINS_SET (1)
|
||||
#define MICROPY_PY_BUILTINS_SLICE (1)
|
||||
#define MICROPY_PY_BUILTINS_SLICE_ATTRS (1)
|
||||
#define MICROPY_PY_BUILTINS_PROPERTY (1)
|
||||
#define MICROPY_PY_BUILTINS_ROUND_INT (1)
|
||||
#define MICROPY_PY_BUILTINS_INPUT (1)
|
||||
@ -58,25 +55,21 @@
|
||||
#define MICROPY_PY_CMATH (0)
|
||||
#define MICROPY_PY_IO (1)
|
||||
#define MICROPY_PY_IO_IOBASE (1)
|
||||
#define MICROPY_PY_IO_FILEIO (1)
|
||||
#define MICROPY_PY_STRUCT (1)
|
||||
#define MICROPY_PY_SYS (1)
|
||||
#define MICROPY_PY_SYS_MAXSIZE (1)
|
||||
#define MICROPY_PY_SYS_EXIT (1)
|
||||
#define MICROPY_PY_SYS_STDFILES (1)
|
||||
#define MICROPY_PY_SYS_STDIO_BUFFER (1)
|
||||
#define MICROPY_PY_UERRNO (1)
|
||||
#define MICROPY_PY_UBINASCII (1)
|
||||
#define MICROPY_PY_UCTYPES (1)
|
||||
#define MICROPY_PY_UHASHLIB (1)
|
||||
#define MICROPY_PY_UHASHLIB_SHA1 (MICROPY_PY_USSL && MICROPY_SSL_AXTLS)
|
||||
#define MICROPY_PY_UCRYPTOLIB (1)
|
||||
#define MICROPY_PY_UHEAPQ (1)
|
||||
#define MICROPY_PY_UTIMEQ (1)
|
||||
#define MICROPY_PY_UJSON (1)
|
||||
#define MICROPY_PY_URANDOM (1)
|
||||
#define MICROPY_PY_URE (1)
|
||||
#define MICROPY_PY_URE_SUB (1)
|
||||
#define MICROPY_PY_USELECT (1)
|
||||
#define MICROPY_PY_UTIME_MP_HAL (1)
|
||||
#define MICROPY_PY_UZLIB (1)
|
||||
@ -92,13 +85,11 @@
|
||||
#define MICROPY_PY_WEBREPL (1)
|
||||
#define MICROPY_PY_WEBREPL_DELAY (20)
|
||||
#define MICROPY_PY_WEBREPL_STATIC_FILEBUF (1)
|
||||
#define MICROPY_PY_FRAMEBUF (1)
|
||||
#define MICROPY_PY_MICROPYTHON_MEM_INFO (1)
|
||||
#define MICROPY_PY_OS_DUPTERM (2)
|
||||
#define MICROPY_CPYTHON_COMPAT (1)
|
||||
#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ)
|
||||
#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_FLOAT)
|
||||
#define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_NORMAL)
|
||||
#define MICROPY_WARNINGS (1)
|
||||
#define MICROPY_PY_STR_BYTES_CMP_WARN (1)
|
||||
#define MICROPY_STREAMS_NON_BLOCK (1)
|
||||
@ -108,12 +99,10 @@
|
||||
#define MICROPY_MODULE_FROZEN_LEXER mp_lexer_new_from_str32
|
||||
#define MICROPY_QSTR_EXTRA_POOL mp_qstr_frozen_const_pool
|
||||
|
||||
#define MICROPY_VFS (1)
|
||||
#define MICROPY_FATFS_ENABLE_LFN (1)
|
||||
#define MICROPY_FATFS_RPATH (2)
|
||||
#define MICROPY_FATFS_MAX_SS (4096)
|
||||
#define MICROPY_FATFS_LFN_CODE_PAGE 437 /* 1=SFN/ANSI 437=LFN/U.S.(OEM) */
|
||||
#define MICROPY_VFS_FAT (1)
|
||||
#define MICROPY_ESP8266_APA102 (1)
|
||||
#define MICROPY_ESP8266_NEOPIXEL (1)
|
||||
|
||||
@ -211,8 +200,6 @@ extern const struct _mp_obj_module_t mp_module_onewire;
|
||||
// board specifics
|
||||
|
||||
#define MICROPY_MPHALPORT_H "esp_mphal.h"
|
||||
#define MICROPY_HW_BOARD_NAME "ESP module"
|
||||
#define MICROPY_HW_MCU_NAME "ESP8266"
|
||||
#define MICROPY_PY_SYS_PLATFORM "esp8266"
|
||||
|
||||
#define MP_FASTCODE(n) __attribute__((section(".iram0.text." #n))) n
|
||||
|
@ -1,43 +0,0 @@
|
||||
#include <mpconfigport.h>
|
||||
|
||||
#undef MICROPY_EMIT_XTENSA
|
||||
#define MICROPY_EMIT_XTENSA (0)
|
||||
#undef MICROPY_EMIT_INLINE_XTENSA
|
||||
#define MICROPY_EMIT_INLINE_XTENSA (0)
|
||||
|
||||
#undef MICROPY_DEBUG_PRINTERS
|
||||
#define MICROPY_DEBUG_PRINTERS (0)
|
||||
|
||||
#undef MICROPY_ERROR_REPORTING
|
||||
#define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_TERSE)
|
||||
|
||||
#undef MICROPY_VFS
|
||||
#define MICROPY_VFS (0)
|
||||
#undef MICROPY_VFS_FAT
|
||||
#define MICROPY_VFS_FAT (0)
|
||||
|
||||
#undef MICROPY_PERSISTENT_CODE_LOAD
|
||||
#define MICROPY_PERSISTENT_CODE_LOAD (0)
|
||||
|
||||
#undef MICROPY_PY_IO_FILEIO
|
||||
#define MICROPY_PY_IO_FILEIO (0)
|
||||
|
||||
#undef MICROPY_PY_SYS_STDIO_BUFFER
|
||||
#define MICROPY_PY_SYS_STDIO_BUFFER (0)
|
||||
#undef MICROPY_PY_BUILTINS_SLICE_ATTRS
|
||||
#define MICROPY_PY_BUILTINS_SLICE_ATTRS (0)
|
||||
#undef MICROPY_PY_ALL_SPECIAL_METHODS
|
||||
#define MICROPY_PY_ALL_SPECIAL_METHODS (0)
|
||||
|
||||
#undef MICROPY_PY_FRAMEBUF
|
||||
#define MICROPY_PY_FRAMEBUF (0)
|
||||
|
||||
#undef MICROPY_PY_URE_SUB
|
||||
#define MICROPY_PY_URE_SUB (0)
|
||||
|
||||
#undef MICROPY_PY_UCRYPTOLIB
|
||||
#define MICROPY_PY_UCRYPTOLIB (0)
|
||||
|
||||
#undef mp_import_stat
|
||||
#undef mp_builtin_open
|
||||
#undef mp_builtin_open_obj
|
Loading…
x
Reference in New Issue
Block a user