Skip to content

Commit 8db517f

Browse files
jimmodpgeorge
authored andcommitted
esp32: Add per-board configs, following other ports.
Replaces the `SDKCONFIG` makefile variable with `BOARD`. Defaults to BOARD=GENERIC. spiram can be enabled with `BOARD=GENERIC_SPIRAM` Add example definition for TINYPICO, currently identical to GENERIC_SPIRAM but with custom board/SoC names for the uPy banner.
1 parent 497683b commit 8db517f

File tree

11 files changed

+63
-47
lines changed

11 files changed

+63
-47
lines changed

ports/esp32/Makefile

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,30 @@
1+
# Select the board to build for: if not given on the command line,
2+
# then default to GENERIC.
3+
BOARD ?= GENERIC
4+
5+
# If the build directory is not given, make it reflect the board name.
6+
BUILD ?= build-$(BOARD)
7+
8+
BOARD_DIR ?= boards/$(BOARD)
9+
ifeq ($(wildcard $(BOARD_DIR)/.),)
10+
$(error Invalid BOARD specified: $(BOARD_DIR))
11+
endif
12+
113
include ../../py/mkenv.mk
214

15+
# Optional (not currently used for ESP32)
16+
-include mpconfigport.mk
17+
18+
ifneq ($(SDKCONFIG),)
19+
$(error Use the BOARD variable instead of SDKCONFIG)
20+
endif
21+
22+
# Expected to set SDKCONFIG
23+
include $(BOARD_DIR)/mpconfigboard.mk
24+
325
# qstr definitions (must come before including py.mk)
426
QSTR_DEFS = qstrdefsport.h
27+
QSTR_GLOBAL_DEPENDENCIES = $(BOARD_DIR)/mpconfigboard.h
528

629
MICROPY_PY_USSL = 0
730
MICROPY_SSL_AXTLS = 0
@@ -22,8 +45,7 @@ FLASH_SIZE ?= 4MB
2245
CROSS_COMPILE ?= xtensa-esp32-elf-
2346
OBJDUMP = $(CROSS_COMPILE)objdump
2447

25-
# SDKCONFIG should be overridden to get a different configuration
26-
SDKCONFIG ?= boards/sdkconfig
48+
SDKCONFIG_COMBINED = $(BUILD)/sdkconfig.combined
2749
SDKCONFIG_H = $(BUILD)/sdkconfig.h
2850

2951
# the git hash of the currently supported ESP IDF version
@@ -130,6 +152,7 @@ CFLAGS_BASE = -std=gnu99 $(CFLAGS_COMMON) -DMBEDTLS_CONFIG_FILE='"mbedtls/esp_co
130152
CFLAGS = $(CFLAGS_BASE) $(INC) $(INC_ESPCOMP)
131153
CFLAGS += -DIDF_VER=\"$(IDF_VER)\"
132154
CFLAGS += $(CFLAGS_MOD) $(CFLAGS_EXTRA)
155+
CFLAGS += -I$(BOARD_DIR)
133156

134157
# this is what ESPIDF uses for c++ compilation
135158
CXXFLAGS = -std=gnu++11 $(CFLAGS_COMMON) $(INC) $(INC_ESPCOMP)
@@ -201,6 +224,7 @@ SRC_C = \
201224
mpthreadport.c \
202225
machine_rtc.c \
203226
machine_sdcard.c \
227+
$(wildcard $(BOARD_DIR)/*.c) \
204228
$(SRC_MOD)
205229

206230
EXTMOD_SRC_C = $(addprefix extmod/,\
@@ -242,7 +266,11 @@ SRC_QSTR_AUTO_DEPS +=
242266
################################################################################
243267
# Generate sdkconfig.h from sdkconfig
244268

245-
$(SDKCONFIG_H): $(SDKCONFIG)
269+
$(SDKCONFIG_COMBINED): $(SDKCONFIG)
270+
$(Q)$(MKDIR) -p $(dir $@)
271+
$(Q)$(CAT) $^ > $@
272+
273+
$(SDKCONFIG_H): $(SDKCONFIG_COMBINED)
246274
$(ECHO) "GEN $@"
247275
$(Q)$(MKDIR) -p $(dir $@)
248276
$(Q)$(PYTHON) $(ESPIDF)/tools/kconfig_new/confgen.py \
@@ -255,7 +283,7 @@ $(SDKCONFIG_H): $(SDKCONFIG)
255283
--env "COMPONENT_KCONFIGS_PROJBUILD=$(ESPCOMP_KCONFIGS_PROJBUILD)"
256284
$(Q)touch $@
257285

258-
$(HEADER_BUILD)/qstrdefs.generated.h: $(SDKCONFIG_H)
286+
$(HEADER_BUILD)/qstrdefs.generated.h: $(SDKCONFIG_H) $(BOARD_DIR)/mpconfigboard.h
259287

260288
################################################################################
261289
# List of object files from the ESP32 IDF components
@@ -429,12 +457,12 @@ $(eval $(foreach lib,$(LIB_ESPIDF),$(eval $(call gen_sections_info_rule,$(BUILD_
429457
$(LDGEN_SECTION_INFOS): $(LDGEN_SECTIONS_INFO) $(ESPIDF)/make/ldgen.mk
430458
$(Q)printf "$(foreach info,$(LDGEN_SECTIONS_INFO),$(info)\n)" > $@
431459

432-
$(BUILD)/esp32.project.ld: $(ESPCOMP)/esp32/ld/esp32.project.ld.in $(LDGEN_FRAGMENTS) $(SDKCONFIG) $(LDGEN_SECTION_INFOS)
460+
$(BUILD)/esp32.project.ld: $(ESPCOMP)/esp32/ld/esp32.project.ld.in $(LDGEN_FRAGMENTS) $(SDKCONFIG_COMBINED) $(LDGEN_SECTION_INFOS)
433461
$(ECHO) "GEN $@"
434462
$(Q)$(PYTHON) $(ESPIDF)/tools/ldgen/ldgen.py \
435463
--input $< \
436464
--output $@ \
437-
--config $(SDKCONFIG) \
465+
--config $(SDKCONFIG_COMBINED) \
438466
--kconfig $(ESPIDF)/Kconfig \
439467
--fragments $(LDGEN_FRAGMENTS) \
440468
--sections $(LDGEN_SECTION_INFOS) \
@@ -472,6 +500,7 @@ OBJ = $(OBJ_MP)
472500

473501
APP_LD_ARGS =
474502
APP_LD_ARGS += $(LDFLAGS_MOD)
503+
APP_LD_ARGS += $(addprefix -T,$(LD_FILES))
475504
APP_LD_ARGS += --start-group
476505
APP_LD_ARGS += -L$(dir $(LIBGCC_FILE_NAME)) -lgcc
477506
APP_LD_ARGS += -L$(dir $(LIBSTDCXX_FILE_NAME)) -lstdc++
@@ -653,7 +682,9 @@ $(BUILD)/bootloader.elf: $(BOOTLOADER_OBJ) $(addprefix $(BOOTLOADER_LIB_DIR)/lib
653682
# Declarations to build the partitions
654683

655684
PYTHON2 ?= python2
656-
PART_SRC = partitions.csv
685+
686+
# Can be overriden by mkconfigboard.mk.
687+
PART_SRC ?= partitions.csv
657688

658689
$(BUILD)/partitions.bin: $(PART_SRC)
659690
$(ECHO) "Create $@"

ports/esp32/README.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ variables for the build. In that case, create a new file in the esp32
7474
directory called `makefile` and add the following lines to that file:
7575
```
7676
ESPIDF = <path to root of esp-idf repository>
77+
BOARD = GENERIC
7778
#PORT = /dev/ttyUSB0
7879
#FLASH_MODE = qio
7980
#FLASH_SIZE = 4MB
8081
#CROSS_COMPILE = xtensa-esp32-elf-
81-
#SDKCONFIG = boards/sdkconfig.spiram
8282
8383
include Makefile
8484
```
@@ -92,16 +92,18 @@ are `PORT` for the serial port of your esp32 module, and `FLASH_MODE`
9292
(which may need to be `dio` for some modules)
9393
and `FLASH_SIZE`. See the Makefile for further information.
9494

95-
The default ESP IDF configuration settings are provided in the file
96-
`boards/sdkconfig`, and this file is specified in the build by the make
97-
variable `SDKCONFIG`. To use a custom configuration either set `SDKCONFIG`
98-
in your custom `makefile` (or `GNUmakefile`) or set this variable on the
99-
command line:
95+
The default ESP IDF configuration settings are provided by the `GENERIC`
96+
board definition in the directory `boards/GENERIC`. For a custom configuration
97+
you can define your own board directory.
98+
99+
The `BOARD` variable can be set on the make command line:
100100
```bash
101-
$ make SDKCONFIG=sdkconfig.myboard
101+
$ make BOARD=TINYPICO
102102
```
103-
The file `boards/sdkconfig.spiram` is provided for ESP32 modules that have
104-
external SPIRAM.
103+
or added to your custom `makefile` (or `GNUmakefile`) described above. There
104+
is also a `GENERIC_SPIRAM` board for for ESP32 modules that have external
105+
SPIRAM, but prefer to use a specific board target (or define your own as
106+
necessary).
105107

106108
Building the firmware
107109
---------------------
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#define MICROPY_HW_BOARD_NAME "ESP32 module"
2+
#define MICROPY_HW_MCU_NAME "ESP32"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
SDKCONFIG += boards/sdkconfig.base
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#define MICROPY_HW_BOARD_NAME "ESP32 module (spiram)"
2+
#define MICROPY_HW_MCU_NAME "ESP32"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
SDKCONFIG += boards/sdkconfig.base
2+
SDKCONFIG += boards/sdkconfig.spiram
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#define MICROPY_HW_BOARD_NAME "TinyPICO"
2+
#define MICROPY_HW_MCU_NAME "ESP32-PICO-D4"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
SDKCONFIG += boards/sdkconfig.base
2+
SDKCONFIG += boards/sdkconfig.spiram
File renamed without changes.

ports/esp32/boards/sdkconfig.spiram

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,5 @@
11
# MicroPython on ESP32, ESP IDF configuration with SPIRAM support
2-
# The following options override the defaults
32

4-
CONFIG_IDF_TARGET="esp32"
5-
6-
# Application manager
7-
CONFIG_APP_EXCLUDE_PROJECT_VER_VAR=y
8-
CONFIG_APP_EXCLUDE_PROJECT_NAME_VAR=y
9-
10-
# Bootloader config
11-
CONFIG_LOG_BOOTLOADER_LEVEL_WARN=y
12-
13-
# ESP32-specific
14-
CONFIG_ESP32_DEFAULT_CPU_FREQ_240=y
153
CONFIG_SPIRAM_SUPPORT=y
164
CONFIG_SPIRAM_IGNORE_NOTFOUND=y
175
CONFIG_SPIRAM_USE_MEMMAP=y
18-
CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU0=n
19-
CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU1=n
20-
CONFIG_ESP32_XTAL_FREQ_AUTO=y
21-
22-
# Power Management
23-
CONFIG_PM_ENABLE=y
24-
25-
# FreeRTOS
26-
CONFIG_FREERTOS_THREAD_LOCAL_STORAGE_POINTERS=2
27-
CONFIG_SUPPORT_STATIC_ALLOCATION=y
28-
CONFIG_ENABLE_STATIC_TASK_CLEAN_UP_HOOK=y
29-
30-
# UDP
31-
CONFIG_PPP_SUPPORT=y
32-
CONFIG_PPP_PAP_SUPPORT=y
33-
CONFIG_PPP_CHAP_SUPPORT=y

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy