@@ -27,11 +27,23 @@ include ../../py/circuitpy_mkenv.mk
2727ifeq ($(IDF_TARGET ) ,esp32c3)
2828IDF_TARGET_ARCH = riscv
2929CROSS_COMPILE = riscv32-esp-elf-
30+ else ifeq ($(IDF_TARGET),esp32c6)
31+ IDF_TARGET_ARCH = riscv
32+ CROSS_COMPILE = riscv32-esp-elf-
33+ else ifeq ($(IDF_TARGET),esp32h2)
34+ IDF_TARGET_ARCH = riscv
35+ CROSS_COMPILE = riscv32-esp-elf-
3036else
3137IDF_TARGET_ARCH = xtensa
3238CROSS_COMPILE = xtensa-$(IDF_TARGET ) -elf-
3339endif
3440
41+ ifeq ($(IDF_TARGET ) ,esp32s3)
42+ BT_IDF_TARGET = esp32c3
43+ else
44+ BT_IDF_TARGET = $(IDF_TARGET )
45+ endif
46+
3547# ######################################
3648# CFLAGS
3749# ######################################
@@ -52,23 +64,35 @@ INC += \
5264 -isystem esp-idf/components/app_update/include \
5365 -isystem esp-idf/components/bootloader_support/include \
5466 -isystem esp-idf/components/bootloader_support/bootloader_flash/include \
55- -isystem esp-idf/components/bt/include/$(IDF_TARGET ) /include \
67+ -isystem esp-idf/components/bt/include/$(BT_IDF_TARGET ) /include \
5668 -isystem esp-idf/components/bt/host/nimble/esp-hci/include \
5769 -isystem esp-idf/components/bt/host/nimble/nimble/nimble/controller/include \
5870 -isystem esp-idf/components/bt/host/nimble/nimble/nimble/host/include \
5971 -isystem esp-idf/components/bt/host/nimble/nimble/nimble/host/services/gap/include \
6072 -isystem esp-idf/components/bt/host/nimble/nimble/nimble/include \
6173 -isystem esp-idf/components/bt/host/nimble/nimble/nimble/host/util/include \
74+ -isystem esp-idf/components/bt/host/nimble/nimble/nimble/transport/include \
6275 -isystem esp-idf/components/bt/host/nimble/nimble/porting/nimble/include \
6376 -isystem esp-idf/components/bt/host/nimble/nimble/porting/npl/freertos/include \
6477 -isystem esp-idf/components/bt/host/nimble/port/include \
6578 -isystem esp-idf/components/driver/include \
6679 -isystem esp-idf/components/driver/deprecated \
80+ -isystem esp-idf/components/driver/dac/include \
81+ -isystem esp-idf/components/driver/gpio/include \
82+ -isystem esp-idf/components/driver/i2c/include \
83+ -isystem esp-idf/components/driver/i2s/include \
6784 -isystem esp-idf/components/driver/$(IDF_TARGET ) /include \
85+ -isystem esp-idf/components/driver/ledc/include \
86+ -isystem esp-idf/components/driver/spi/include \
87+ -isystem esp-idf/components/driver/temperature_sensor/include \
88+ -isystem esp-idf/components/driver/touch_sensor/include \
89+ -isystem esp-idf/components/driver/touch_sensor/$(IDF_TARGET ) /include \
90+ -isystem esp-idf/components/driver/twai/include \
6891 -isystem esp-idf/components/efuse/include \
6992 -isystem esp-idf/components/efuse/$(IDF_TARGET ) /include \
7093 -isystem esp-idf/components/$(IDF_TARGET ) /include \
71- -isystem esp-idf/components/esp_adc/deprecated/include \
94+ -isystem esp-idf/components/esp_adc/include \
95+ -isystem esp-idf/components/esp_adc/$(IDF_TARGET ) /include \
7296 -isystem esp-idf/components/esp_app_format/include \
7397 -isystem esp-idf/components/esp_common/include \
7498 -isystem esp-idf/components/esp_event/include \
@@ -85,6 +109,7 @@ INC += \
85109 -isystem esp-idf/components/esp_wifi/include \
86110 -isystem esp-idf/components/freertos/esp_additions/include \
87111 -isystem esp-idf/components/freertos/esp_additions/include/freertos \
112+ -isystem esp-idf/components/freertos/esp_additions/arch/$(IDF_TARGET_ARCH ) /include \
88113 -isystem esp-idf/components/freertos/FreeRTOS-Kernel/include \
89114 -isystem esp-idf/components/freertos/FreeRTOS-Kernel/include/freertos \
90115 -isystem esp-idf/components/freertos/FreeRTOS-Kernel/portable/$(IDF_TARGET_ARCH ) /include \
@@ -95,7 +120,9 @@ INC += \
95120 -isystem esp-idf/components/log/include \
96121 -isystem esp-idf/components/lwip/include \
97122 -isystem esp-idf/components/lwip/lwip/src/include \
98- -isystem esp-idf/components/lwip/port/esp32/include \
123+ -isystem esp-idf/components/lwip/port/include \
124+ -isystem esp-idf/components/lwip/port/esp32xx/include \
125+ -isystem esp-idf/components/lwip/port/freertos/include \
99126 -isystem esp-idf/components/mbedtls/esp_crt_bundle/include \
100127 -isystem esp-idf/components/mbedtls/mbedtls/include \
101128 -isystem esp-idf/components/mbedtls/port/include \
@@ -153,12 +180,13 @@ CFLAGS += $(INC) -Werror -Wall -std=gnu11 -Wl,--gc-sections $(BASE_CFLAGS) $(C_D
153180# Most current ESPs have nano versions of newlib in ROM so we use them.
154181ifneq ($(IDF_TARGET ) ,esp32c6)
155182 CFLAGS += --specs=nano.specs
183+ LDFLAGS += -T$(IDF_TARGET).rom.newlib-nano.ld
156184endif
157185
158186ifeq ($(IDF_TARGET_ARCH ) ,xtensa)
159187CFLAGS += -mlongcalls
160188else ifeq ($(IDF_TARGET_ARCH),riscv)
161- CFLAGS += -march=rv32imc
189+ CFLAGS += -march=rv32imac_zicsr_zifencei
162190endif
163191
164192LDFLAGS = $(CFLAGS ) -Wl,-nostdlib -Wl,-Map=$@ .map -Wl,-cref -Wl,--undefined=uxTopUsedPriority
@@ -173,7 +201,6 @@ LDFLAGS += \
173201 -T$(IDF_TARGET ) .rom.ld \
174202 -T$(IDF_TARGET ) .rom.api.ld \
175203 -T$(IDF_TARGET ) .rom.libgcc.ld \
176- -T$(IDF_TARGET ) .rom.newlib-nano.ld \
177204 -Wl,-Bstatic \
178205 -Wl,--no-warn-mismatch \
179206 -Wl,--build-id=none \
@@ -189,6 +216,20 @@ LDFLAGS += \
189216 -Tesp32c3.rom.newlib.ld \
190217 -Tesp32c3.rom.version.ld \
191218 -Tesp32c3.rom.eco3.ld
219+ else ifeq ($(IDF_TARGET),esp32c6)
220+ LDFLAGS += \
221+ -Tesp32c6.rom.phy.ld \
222+ -Tesp32c6.rom.pp.ld \
223+ -Tesp32c6.rom.net80211.ld \
224+ -Tesp32c6.rom.newlib.ld \
225+ -Tesp32c6.rom.coexist.ld \
226+ -Tesp32c6.rom.heap.ld \
227+ -Tesp32c6.rom.wdt.ld
228+ else ifeq ($(IDF_TARGET),esp32h2)
229+ LDFLAGS += \
230+ -Tesp32h2.rom.heap.ld \
231+ -Tesp32h2.rom.newlib.ld \
232+ -Tesp32h2.rom.wdt.ld
192233else ifeq ($(IDF_TARGET),esp32s2)
193234LDFLAGS += \
194235 -T$(IDF_TARGET ) .rom.newlib-data.ld \
@@ -203,7 +244,7 @@ endif
203244LIBS := -lgcc -lc -lstdc++
204245
205246# Use toolchain libm if we're not using our own.
206- ifndef INTERNAL_LIBM
247+ ifneq ( $( INTERNAL_LIBM ) ,1)
207248LIBS += -lm
208249endif
209250
@@ -243,12 +284,16 @@ SRC_C += \
243284
244285SRC_C += $(wildcard common-hal/espidf/* .c)
245286
246- ifeq ($(IDF_TARGET ) ,esp32c3 )
287+ ifneq ($(CIRCUITPY_ESP_USB_SERIAL_JTAG ) ,0 )
247288SRC_C += supervisor/usb_serial_jtag.c
248- else
249- SRC_C += \
250- peripherals/pcnt.c \
251- peripherals/touch.c
289+ endif
290+
291+ ifneq ($(CIRCUITPY_COUNTIO ) ,0)
292+ SRC_C += peripherals/pcnt.c
293+ endif
294+
295+ ifneq ($(CIRCUITPY_TOUCHIO_USE_NATIVE ) ,0)
296+ SRC_C += peripherals/touch.c
252297endif
253298
254299ifneq ($(CIRCUITPY_USB ) ,0)
@@ -408,21 +453,42 @@ update-all-sdkconfigs: $(BUILD)/esp-idf/config/sdkconfig.h
408453update-board-sdkconfig : $(BUILD ) /esp-idf/config/sdkconfig.h
409454 python tools/update_sdkconfig.py --board=$(BOARD ) --debug=$(DEBUG )
410455
411- BINARY_WIFI_BLOBS = libcoexist.a libcore.a libespnow.a libmesh.a libnet80211.a libpp.a libsmartconfig.a libwapi.a
412- BINARY_BLOBS = esp-idf/components/esp_phy/lib/$(IDF_TARGET ) /libphy.a $(addprefix esp-idf/components/esp_wifi/lib/$(IDF_TARGET ) /, $(BINARY_WIFI_BLOBS ) )
456+ BINARY_WIFI_BLOBS = libcore.a libespnow.a libmesh.a libnet80211.a libpp.a libsmartconfig.a libwapi.a
457+ BINARY_BLOBS = esp-idf/components/esp_phy/lib/$(IDF_TARGET ) /libphy.a
458+ ifneq ($(CIRCUITPY_WIFI ) ,0)
459+ BINARY_BLOBS += esp-idf/components/esp_coex/lib/$(IDF_TARGET)/libcoexist.a $(addprefix esp-idf/components/esp_wifi/lib/$(IDF_TARGET)/, $(BINARY_WIFI_BLOBS))
460+ endif
413461ifeq ($(IDF_TARGET ) ,esp32)
414462BINARY_BLOBS += esp-idf/components/esp_phy/lib/$(IDF_TARGET ) /librtc.a
415463endif
416464
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
465+ 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_mm esp_partition esp_phy esp_pm esp_ringbuf esp_rom esp_system esp_timer freertos hal heap log newlib nvs_flash pthread soc spi_flash vfs
466+ ifneq ($(CIRCUITPY_WIFI ) ,0)
467+ ESP_IDF_COMPONENTS_LINK += esp_coex esp_netif esp-tls esp_wifi lwip mbedtls mdns wpa_supplicant
468+ endif
418469ifneq ($(CIRCUITPY_BLEIO ) ,0)
470+ BLE_IMPL_esp32 := esp32
471+ BLE_IMPL_esp32s3 := esp32c3
472+ BLE_IMPL_esp32c2 := libble
473+ BLE_IMPL_esp32c3 := esp32c3
474+ BLE_IMPL_esp32c6 := libble
475+ BLE_IMPL_esp32h2 := libble
476+ BLE_IMPL = $(BLE_IMPL_$(IDF_TARGET))
477+
419478 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
479+ ifeq ($(BLE_IMPL),esp32)
480+ BINARY_BLOBS += esp-idf/components/bt/controller/lib_esp32/$(IDF_TARGET)/libbtdm_app.a
481+ endif
482+
483+ ifeq ($(BLE_IMPL),esp32c3)
423484 BINARY_BLOBS += esp-idf/components/esp_phy/lib/$(IDF_TARGET)/libbtbb.a \
424485 esp-idf/components/bt/controller/lib_esp32c3_family/$(IDF_TARGET)/libbtdm_app.a
425486 endif
487+
488+ ifeq ($(BLE_IMPL),libble)
489+ BINARY_BLOBS += esp-idf/components/esp_phy/lib/$(IDF_TARGET)/libbtbb.a \
490+ esp-idf/components/bt/controller/lib_$(IDF_TARGET)/$(IDF_TARGET)-bt-lib/libble_app.a
491+ endif
426492endif
427493ifneq ($(CIRCUITPY_ESPULP ) ,0)
428494 ESP_IDF_COMPONENTS_LINK += ulp
@@ -450,11 +516,16 @@ ESP_IDF_COMPONENTS_EXPANDED += $(BUILD)/esp-idf/esp-idf/esp-camera/libesp-camera
450516endif
451517
452518ifneq ($(VALID_BOARD ) ,)
519+ # From esp-idf/components/bootloader/Kconfig.projbuild
453520# BOOTLOADER_OFFSET is determined by chip type, based on the ROM bootloader, and is not changeable.
454521ifeq ($(IDF_TARGET ) ,esp32)
455522BOOTLOADER_OFFSET = 0x1000
523+ else ifeq ($(IDF_TARGET),esp32h2)
524+ BOOTLOADER_OFFSET = 0x0
456525else ifeq ($(IDF_TARGET),esp32c3)
457526BOOTLOADER_OFFSET = 0x0
527+ else ifeq ($(IDF_TARGET),esp32c6)
528+ BOOTLOADER_OFFSET = 0x0
458529else ifeq ($(IDF_TARGET),esp32s3)
459530BOOTLOADER_OFFSET = 0x0
460531else ifeq ($(IDF_TARGET),esp32s2)
0 commit comments