@@ -51,6 +51,7 @@ INC += \
51
51
-isystem esp-idf \
52
52
-isystem esp-idf/components/app_update/include \
53
53
-isystem esp-idf/components/bootloader_support/include \
54
+ -isystem esp-idf/components/bootloader_support/bootloader_flash/include \
54
55
-isystem esp-idf/components/bt/include/$(IDF_TARGET ) /include \
55
56
-isystem esp-idf/components/bt/host/nimble/esp-hci/include \
56
57
-isystem esp-idf/components/bt/host/nimble/nimble/nimble/controller/include \
@@ -62,28 +63,31 @@ INC += \
62
63
-isystem esp-idf/components/bt/host/nimble/nimble/porting/npl/freertos/include \
63
64
-isystem esp-idf/components/bt/host/nimble/port/include \
64
65
-isystem esp-idf/components/driver/include \
66
+ -isystem esp-idf/components/driver/deprecated \
65
67
-isystem esp-idf/components/driver/$(IDF_TARGET ) /include \
66
68
-isystem esp-idf/components/efuse/include \
67
69
-isystem esp-idf/components/efuse/$(IDF_TARGET ) /include \
68
70
-isystem esp-idf/components/$(IDF_TARGET ) /include \
69
- -isystem esp-idf/components/esp_adc_cal/include \
71
+ -isystem esp-idf/components/esp_adc/deprecated/include \
72
+ -isystem esp-idf/components/esp_app_format/include \
70
73
-isystem esp-idf/components/esp_common/include \
71
74
-isystem esp-idf/components/esp_event/include \
72
75
-isystem esp-idf/components/esp_hw_support/include \
73
76
-isystem esp-idf/components/esp_hw_support/include/soc \
74
- -isystem esp-idf/components/esp_ipc/include \
75
77
-isystem esp-idf/components/esp_netif/include \
78
+ -isystem esp-idf/components/esp_partition/include \
76
79
-isystem esp-idf/components/esp_pm/include \
80
+ -isystem esp-idf/components/esp_psram/include \
77
81
-isystem esp-idf/components/esp_ringbuf/include \
78
82
-isystem esp-idf/components/esp_rom/include \
79
83
-isystem esp-idf/components/esp_system/include \
80
84
-isystem esp-idf/components/esp_timer/include \
81
85
-isystem esp-idf/components/esp_wifi/include \
82
- -isystem esp-idf/components/freertos/include \
83
- -isystem esp-idf/components/freertos/include/freertos \
84
- -isystem esp-idf/components/freertos/include/esp_additions \
85
- -isystem esp-idf/components/freertos/include/esp_additions /freertos \
86
- -isystem esp-idf/components/freertos/port /$(IDF_TARGET_ARCH ) /include \
86
+ -isystem esp-idf/components/freertos/esp_additions/ include \
87
+ -isystem esp-idf/components/freertos/esp_additions/ include/freertos \
88
+ -isystem esp-idf/components/freertos/FreeRTOS-Kernel/include \
89
+ -isystem esp-idf/components/freertos/FreeRTOS-Kernel/include /freertos \
90
+ -isystem esp-idf/components/freertos/FreeRTOS-Kernel/portable /$(IDF_TARGET_ARCH ) /include \
87
91
-isystem esp-idf/components/hal/include \
88
92
-isystem esp-idf/components/hal/$(IDF_TARGET ) /include \
89
93
-isystem esp-idf/components/hal/platform_port/include \
@@ -100,13 +104,13 @@ INC += \
100
104
-isystem esp-idf/components/soc/include \
101
105
-isystem esp-idf/components/soc/$(IDF_TARGET ) /include \
102
106
-isystem esp-idf/components/spi_flash/include \
107
+ -isystem esp-idf/components/ulp/ulp_fsm/include \
108
+ -isystem esp-idf/components/ulp/ulp_riscv/include \
109
+ -isystem esp-idf/components/ulp/ulp_common/include \
110
+ -isystem esp-idf/components/ulp/ulp_common/include/$(IDF_TARGET ) \
103
111
-isystem esp-idf/components/$(IDF_TARGET_ARCH ) /include \
104
- -isystem esp-idf/components/$(IDF_TARGET_ARCH ) /$(IDF_TARGET ) /include
105
-
106
- # See https://github.com/espressif/esp-idf/issues/6906
107
- ifeq ($(IDF_TARGET ) ,esp32c3)
108
- CFLAGS += -include "esp32c3_fix.h"
109
- endif
112
+ -isystem esp-idf/components/$(IDF_TARGET_ARCH ) /$(IDF_TARGET ) /include \
113
+ -isystem esp-protocols/components/mdns/include
110
114
111
115
CFLAGS += \
112
116
-DHAVE_CONFIG_H \
@@ -131,7 +135,7 @@ ifeq ($(DEBUG), 1)
131
135
# You may want to enable these flags to make setting breakpoints easier.
132
136
# CFLAGS += -fno-inline -fno-ipa-sra
133
137
else
134
- CFLAGS += -DNDEBUG -ggdb3
138
+ CFLAGS += -DNDEBUG
135
139
# RISC-V is larger than xtensa
136
140
# Use -Os for RISC-V when it overflows
137
141
ifeq ($(IDF_TARGET_ARCH),riscv)
@@ -146,6 +150,11 @@ CFLAGS += $(OPTIMIZATION_FLAGS)
146
150
147
151
CFLAGS += $(INC ) -Werror -Wall -std=gnu11 -Wl,--gc-sections $(BASE_CFLAGS ) $(C_DEFS ) $(CFLAGS_MOD ) $(COPT ) -Werror=missing-prototypes
148
152
153
+ # Most current ESPs have nano versions of newlib in ROM so we use them.
154
+ ifneq ($(IDF_TARGET ) ,esp32c6)
155
+ CFLAGS += --specs=nano.specs
156
+ endif
157
+
149
158
ifeq ($(IDF_TARGET_ARCH ) ,xtensa)
150
159
CFLAGS += -mlongcalls
151
160
else ifeq ($(IDF_TARGET_ARCH),riscv)
@@ -232,23 +241,16 @@ SRC_C += \
232
241
peripherals/timer.c \
233
242
peripherals/$(IDF_TARGET ) /pins.c
234
243
235
- ifneq ($(IDF_TARGET ) ,esp32c3)
236
- SRC_C += \
237
- peripherals/pcnt.c \
238
- peripherals/touch.c
239
- ifeq ($(IDF_TARGET ) ,esp32s2)
240
- SRC_C += \
241
- i2s_lcd_esp32s2_driver.c
242
- endif
243
- endif
244
+ SRC_C += $(wildcard common-hal/espidf/* .c)
244
245
245
246
ifeq ($(IDF_TARGET ) ,esp32c3)
247
+ SRC_C += supervisor/usb_serial_jtag.c
248
+ else
246
249
SRC_C += \
247
- supervisor/usb_serial_jtag.c
250
+ peripherals/pcnt.c \
251
+ peripherals/touch.c
248
252
endif
249
253
250
- $(BUILD ) /i2s_lcd_esp32s2_driver.o : CFLAGS += -Wno-sign-compare
251
-
252
254
ifneq ($(CIRCUITPY_USB ) ,0)
253
255
SRC_C += lib/tinyusb/src/portable/espressif/esp32sx/dcd_esp32sx.c
254
256
endif
@@ -257,6 +259,17 @@ ifneq ($(CIRCUITPY_BLEIO),0)
257
259
SRC_C += common-hal/_bleio/ble_events.c
258
260
endif
259
261
262
+ ifneq ($(CIRCUITPY_PARALLELDISPLAY ) ,0)
263
+ ifeq ($(IDF_TARGET ) ,esp32s3)
264
+ LCD_SRC = 8080_lcd_$(IDF_TARGET )
265
+ else
266
+ LCD_SRC = i2s_lcd_$(IDF_TARGET ) _driver
267
+ endif
268
+ SRC_C += esp-iot-solution/components/bus/$(LCD_SRC ) .c
269
+ $(BUILD ) /esp-iot-solution/components/bus/$(LCD_SRC ) .o : CFLAGS += -Wno-sign-compare
270
+ CFLAGS += -isystem esp-iot-solution/components/bus/include
271
+ endif
272
+
260
273
ifneq ($(CIRCUITPY_DOTCLOCKFRAMEBUFFER ) ,0)
261
274
CFLAGS += -isystem esp-idf/components/esp_lcd/include
262
275
CFLAGS += -isystem esp-idf/components/esp_lcd/interface
@@ -267,8 +280,8 @@ SRC_CAMERA := \
267
280
$(wildcard common-hal/espcamera/* .c) \
268
281
$(wildcard bindings/espcamera/* .c)
269
282
SRC_C += $(SRC_CAMERA )
270
- CFLAGS += -isystem esp32 -camera/driver/include
271
- CFLAGS += -isystem esp32 -camera/conversions/include
283
+ CFLAGS += -isystem esp -camera/driver/include
284
+ CFLAGS += -isystem esp -camera/conversions/include
272
285
endif
273
286
274
287
ifneq ($(CIRCUITPY_ESPIDF ) ,0)
@@ -290,8 +303,6 @@ SRC_ULP := \
290
303
$(wildcard common-hal/espulp/* .c) \
291
304
$(wildcard bindings/espulp/* .c)
292
305
SRC_C += $(SRC_ULP )
293
- CFLAGS += -isystem esp-idf/components/ulp/include
294
- CFLAGS += -isystem esp-idf/components/ulp/ulp_riscv/include
295
306
endif
296
307
297
308
SRC_COMMON_HAL_EXPANDED = \
@@ -334,32 +345,42 @@ $(BUILD)/esp-idf:
334
345
335
346
TARGET_SDKCONFIG = esp-idf-config/sdkconfig-$(IDF_TARGET ) .defaults
336
347
348
+
337
349
ifeq ($(CIRCUITPY_ESP_FLASH_SIZE ) , 2MB)
338
- FLASH_SDKCONFIG ?= esp-idf-config/sdkconfig-$(CIRCUITPY_ESP_FLASH_SIZE)-no-ota-no-uf2.defaults
350
+ FLASH_SIZE_SDKCONFIG ?= esp-idf-config/sdkconfig-flash -$(CIRCUITPY_ESP_FLASH_SIZE)-no-ota-no-uf2.defaults
339
351
else
340
352
UF2_BOOTLOADER ?= $(CIRCUITPY_USB )
341
353
ifeq ($(UF2_BOOTLOADER ) , 1)
342
- FLASH_SDKCONFIG ?= esp-idf-config/sdkconfig-$(CIRCUITPY_ESP_FLASH_SIZE).defaults
354
+ FLASH_SIZE_SDKCONFIG ?= esp-idf-config/sdkconfig-flash -$(CIRCUITPY_ESP_FLASH_SIZE).defaults
343
355
else
344
- FLASH_SDKCONFIG ?= esp-idf-config/sdkconfig-$(CIRCUITPY_ESP_FLASH_SIZE)-no-uf2.defaults
356
+ FLASH_SIZE_SDKCONFIG ?= esp-idf-config/sdkconfig-flash -$(CIRCUITPY_ESP_FLASH_SIZE)-no-uf2.defaults
345
357
endif
346
358
endif
359
+ FLASH_MODE_SDKCONFIG ?= esp-idf-config/sdkconfig-flash-$(CIRCUITPY_ESP_FLASH_MODE ) .defaults
360
+ FLASH_SPEED_SDKCONFIG ?= esp-idf-config/sdkconfig-flash-$(CIRCUITPY_ESP_FLASH_FREQ ) .defaults
361
+
362
+ ifneq ($(CIRCUITPY_ESP_PSRAM_SIZE ) , 0)
363
+ PSRAM_SDKCONFIG = esp-idf-config/sdkconfig-psram.defaults
364
+ PSRAM_SIZE_SDKCONFIG = esp-idf-config/sdkconfig-psram-$(CIRCUITPY_ESP_PSRAM_SIZE).defaults
365
+ PSRAM_MODE_SDKCONFIG = esp-idf-config/sdkconfig-psram-$(CIRCUITPY_ESP_PSRAM_MODE).defaults
366
+ PSRAM_SPEED_SDKCONFIG = esp-idf-config/sdkconfig-psram-$(CIRCUITPY_ESP_PSRAM_FREQ).defaults
367
+ endif
347
368
348
369
ifeq ($(DEBUG ) , 1)
349
370
DEBUG_SDKCONFIG = esp-idf-config/sdkconfig-debug.defaults
350
371
else
351
372
DEBUG_SDKCONFIG = esp-idf-config/sdkconfig-opt.defaults
352
373
endif
353
374
354
- SDKCONFIGS := esp-idf-config/sdkconfig.defaults;$(DEBUG_SDKCONFIG ) ;$(FLASH_SDKCONFIG ) ;$(TARGET_SDKCONFIG ) ;boards/$(BOARD ) /sdkconfig
375
+ SDKCONFIGS := esp-idf-config/sdkconfig.defaults;$(DEBUG_SDKCONFIG ) ;$(FLASH_SIZE_SDKCONFIG ) ; $( FLASH_MODE_SDKCONFIG ) ; $( FLASH_SPEED_SDKCONFIG ) ; $( PSRAM_SDKCONFIG ) ; $( PSRAM_SIZE_SDKCONFIG ) ; $( PSRAM_MODE_SDKCONFIG ) ; $( PSRAM_SPEED_SDKCONFIG ) ;$(TARGET_SDKCONFIG ) ;boards/$(BOARD ) /sdkconfig
355
376
ifneq ($(CIRCUITPY_BLEIO ) ,0)
356
377
SDKCONFIGS := esp-idf-config/sdkconfig-ble.defaults;$(SDKCONFIGS)
357
378
endif
358
379
# create the config headers
359
380
.PHONY : do-sdkconfig
360
381
do-sdkconfig : $(BUILD ) /esp-idf/config/sdkconfig.h
361
382
QSTR_GLOBAL_REQUIREMENTS += $(BUILD ) /esp-idf/config/sdkconfig.h
362
- $(BUILD ) /esp-idf/config/sdkconfig.h : boards/$(BOARD ) /sdkconfig CMakeLists.txt | $(BUILD ) /esp-idf
383
+ $(BUILD ) /esp-idf/config/sdkconfig.h : boards/$(BOARD ) /sdkconfig boards/ $( BOARD ) /mpconfigboard.mk CMakeLists.txt | $(BUILD ) /esp-idf
363
384
IDF_PATH=$(IDF_PATH ) cmake -S . -B $(BUILD ) /esp-idf -DSDKCONFIG=$(BUILD ) /esp-idf/sdkconfig -DSDKCONFIG_DEFAULTS=" $( SDKCONFIGS) " -DCMAKE_TOOLCHAIN_FILE=$(IDF_PATH ) /tools/cmake/toolchain-$(IDF_TARGET ) .cmake -DIDF_TARGET=$(IDF_TARGET ) -GNinja
364
385
365
386
# build a lib
@@ -379,8 +400,12 @@ $(BUILD)/esp-idf/partition_table/partition-table.bin: $(BUILD)/esp-idf/config/sd
379
400
# run menuconfig and then remove standard settings
380
401
menuconfig : $(BUILD ) /esp-idf/config $(BUILD ) /esp-idf/config/sdkconfig.h
381
402
$(Q ) ninja -C $(BUILD ) /esp-idf menuconfig
382
- # Newer versions of the idf will have save-defconfig that will only include non-default values.
383
- # We should use that when available. For now, we sort out everything.
403
+ python tools/update_sdkconfig.py --board=$(BOARD ) --debug=$(DEBUG )
404
+
405
+ update-all-sdkconfigs : $(BUILD ) /esp-idf/config/sdkconfig.h
406
+ python tools/update_sdkconfig.py --update_all --board=$(BOARD ) --debug=$(DEBUG )
407
+
408
+ update-board-sdkconfig : $(BUILD ) /esp-idf/config/sdkconfig.h
384
409
python tools/update_sdkconfig.py --board=$(BOARD ) --debug=$(DEBUG )
385
410
386
411
BINARY_WIFI_BLOBS = libcoexist.a libcore.a libespnow.a libmesh.a libnet80211.a libpp.a libsmartconfig.a libwapi.a
@@ -389,15 +414,22 @@ ifeq ($(IDF_TARGET),esp32)
389
414
BINARY_BLOBS += esp-idf/components/esp_phy/lib/$(IDF_TARGET ) /librtc.a
390
415
endif
391
416
392
- ESP_IDF_COMPONENTS_LINK = $(IDF_TARGET_ARCH ) app_update bootloader_support driver efuse esp_adc_cal esp_common esp_event esp_hw_support esp_ipc esp_netif esp_pm esp_phy esp_ringbuf esp_rom esp_system esp_timer esp-tls esp_wifi freertos hal heap log lwip mbedtls mdns newlib nvs_flash pthread soc spi_flash vfs wpa_supplicant
417
+ ESP_IDF_COMPONENTS_LINK = $(IDF_TARGET_ARCH ) app_update bootloader_support driver efuse esp_adc esp_app_format esp_common esp_event esp_hw_support esp_netif esp_partition esp_phy esp_pm esp_ringbuf esp_rom esp_system esp_timer esp-tls esp_wifi freertos hal heap log lwip mbedtls mdns newlib nvs_flash pthread soc spi_flash vfs wpa_supplicant
393
418
ifneq ($(CIRCUITPY_BLEIO ) ,0)
394
419
ESP_IDF_COMPONENTS_LINK += bt
420
+ ifeq ($(IDF_TARGET),esp32)
421
+ BINARY_BLOBS += esp-idf/components/bt/controller/lib_esp32/$(IDF_TARGET)/libbtdm_app.a
422
+ else
395
423
BINARY_BLOBS += esp-idf/components/esp_phy/lib/$(IDF_TARGET)/libbtbb.a \
396
- esp-idf/components/bt/controller/lib_esp32c3_family/$(IDF_TARGET)/libbtdm_app.a
424
+ esp-idf/components/bt/controller/lib_esp32c3_family/$(IDF_TARGET)/libbtdm_app.a
425
+ endif
397
426
endif
398
427
ifneq ($(CIRCUITPY_ESPULP ) ,0)
399
428
ESP_IDF_COMPONENTS_LINK += ulp
400
429
endif
430
+ ifneq ($(CIRCUITPY_ESP_PSRAM_SIZE ) ,0)
431
+ ESP_IDF_COMPONENTS_LINK += esp_psram
432
+ endif
401
433
ifneq ($(CIRCUITPY_DOTCLOCKFRAMEBUFFER ) ,0)
402
434
ESP_IDF_COMPONENTS_LINK += esp_lcd
403
435
endif
@@ -413,7 +445,7 @@ ESP_IDF_COMPONENTS_EXPANDED += esp-idf/components/xtensa/$(IDF_TARGET)/libxt_hal
413
445
endif
414
446
415
447
ifneq ($(CIRCUITPY_ESPCAMERA ) ,0)
416
- ESP_IDF_COMPONENTS_EXPANDED += $(BUILD ) /esp-idf/esp-idf/esp32 -camera/libesp32 -camera.a
448
+ ESP_IDF_COMPONENTS_EXPANDED += $(BUILD ) /esp-idf/esp-idf/esp -camera/libesp -camera.a
417
449
# $(error $(ESP_IDF_COMPONENTS_EXPANDED))
418
450
endif
419
451
@@ -440,9 +472,26 @@ IDF_CMAKE_TARGETS = \
440
472
PARTITION_TABLE_OFFSET = 0x8000
441
473
FIRMWARE_OFFSET = 0x10000
442
474
443
- ESP_AUTOGEN_LD = $(BUILD ) /esp-idf/esp-idf/$(IDF_TARGET ) /$(IDF_TARGET ) _out.ld $(BUILD ) /esp-idf/esp-idf/$(IDF_TARGET ) /ld/$(IDF_TARGET ) .project.ld
475
+ # Map the flash's run mode to flashing mode (only dual is supported by the early bootloaders).
476
+ # https://github.com/espressif/esp-idf/blob/82cceabc6e6a0a2d8c40e2249bc59917cc5e577a/components/esptool_py/Kconfig.projbuild#L74-L87
477
+ ifeq ($(CIRCUITPY_ESP_FLASH_MODE ) ,dout)
478
+ ESPTOOLPY_FLASHMODE = "dout"
479
+ endif
480
+ ifeq ($(CIRCUITPY_ESP_FLASH_MODE ) ,opi)
481
+ ESPTOOLPY_FLASHMODE = "dout"
482
+ endif
483
+ # Most modes can flash with dio
484
+ ESPTOOLPY_FLASHMODE ?= "dio"
485
+
486
+ # Cap the flash speed to 80m.
487
+ # https://github.com/espressif/esp-idf/blob/82cceabc6e6a0a2d8c40e2249bc59917cc5e577a/components/esptool_py/Kconfig.projbuild#L74-L87
488
+ ifeq ($(CIRCUITPY_ESP_FLASH_FREQ ) ,120m)
489
+ ESPTOOLPY_FLASHFREQ = "80m"
490
+ else
491
+ ESPTOOLPY_FLASHFREQ = $(CIRCUITPY_ESP_FLASH_FREQ)
492
+ endif
444
493
445
- FLASH_FLAGS = --flash_mode $(CIRCUITPY_ESP_FLASH_MODE ) --flash_freq $(CIRCUITPY_ESP_FLASH_FREQ ) --flash_size $(CIRCUITPY_ESP_FLASH_SIZE )
494
+ FLASH_FLAGS = --flash_mode $(ESPTOOLPY_FLASHMODE ) --flash_freq $(ESPTOOLPY_FLASHFREQ ) --flash_size $(CIRCUITPY_ESP_FLASH_SIZE )
446
495
447
496
ESPTOOL_FLAGS ?= --before=default_reset --after=no_reset --baud 921600
448
497
@@ -460,7 +509,7 @@ esp-idf-stamp: $(BUILD)/esp-idf/config/sdkconfig.h
460
509
461
510
$(BUILD ) /firmware.elf : $(OBJ ) | esp-idf-stamp $(IDF_CMAKE_TARGETS )
462
511
$(STEPECHO ) " LINK $@ "
463
- $(Q )$(CC ) -o $@ $(LDFLAGS ) $^ -Wl,--start-group $(ESP_IDF_COMPONENTS_EXPANDED ) $(BINARY_BLOBS ) $(MBEDTLS_COMPONENTS_LINK_EXPANDED ) $(BUILD ) /esp-idf/esp-idf/newlib/libnewlib.a -Wl,--end-group -u newlib_include_pthread_impl -u ld_include_highint_hdl -Wl,--start-group $( LIBS ) -Wl,--end-group $( BUILD ) /esp-idf/esp-idf/pthread/libpthread.a -u __cxx_fatal_exception
512
+ $(Q )$(CC ) -o $@ $(LDFLAGS ) $^ -Wl,--start-group $(ESP_IDF_COMPONENTS_EXPANDED ) $(BINARY_BLOBS ) $(MBEDTLS_COMPONENTS_LINK_EXPANDED ) $(LIBS ) -Wl,--end-group -u newlib_include_pthread_impl -u ld_include_highint_hdl -u __cxx_fatal_exception
464
513
465
514
$(BUILD ) /circuitpython-firmware.bin : $(BUILD ) /firmware.elf | tools/build_memory_info.py
466
515
$(STEPECHO ) " Create $@ "
0 commit comments