@@ -27,6 +27,9 @@ 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-
3033else
3134IDF_TARGET_ARCH = xtensa
3235CROSS_COMPILE = xtensa-$(IDF_TARGET ) -elf-
@@ -84,7 +87,8 @@ INC += \
8487 -isystem esp-idf/components/efuse/include \
8588 -isystem esp-idf/components/efuse/$(IDF_TARGET ) /include \
8689 -isystem esp-idf/components/$(IDF_TARGET ) /include \
87- -isystem esp-idf/components/esp_adc/deprecated/include \
90+ -isystem esp-idf/components/esp_adc/include \
91+ -isystem esp-idf/components/esp_adc/$(IDF_TARGET ) /include \
8892 -isystem esp-idf/components/esp_app_format/include \
8993 -isystem esp-idf/components/esp_common/include \
9094 -isystem esp-idf/components/esp_event/include \
@@ -172,6 +176,7 @@ CFLAGS += $(INC) -Werror -Wall -std=gnu11 -Wl,--gc-sections $(BASE_CFLAGS) $(C_D
172176# Most current ESPs have nano versions of newlib in ROM so we use them.
173177ifneq ($(IDF_TARGET ) ,esp32c6)
174178 CFLAGS += --specs=nano.specs
179+ LDFLAGS += -T$(IDF_TARGET).rom.newlib-nano.ld
175180endif
176181
177182ifeq ($(IDF_TARGET_ARCH ) ,xtensa)
@@ -192,7 +197,6 @@ LDFLAGS += \
192197 -T$(IDF_TARGET ) .rom.ld \
193198 -T$(IDF_TARGET ) .rom.api.ld \
194199 -T$(IDF_TARGET ) .rom.libgcc.ld \
195- -T$(IDF_TARGET ) .rom.newlib-nano.ld \
196200 -Wl,-Bstatic \
197201 -Wl,--no-warn-mismatch \
198202 -Wl,--build-id=none \
@@ -208,6 +212,15 @@ LDFLAGS += \
208212 -Tesp32c3.rom.newlib.ld \
209213 -Tesp32c3.rom.version.ld \
210214 -Tesp32c3.rom.eco3.ld
215+ else ifeq ($(IDF_TARGET),esp32c6)
216+ LDFLAGS += \
217+ -Tesp32c6.rom.phy.ld \
218+ -Tesp32c6.rom.pp.ld \
219+ -Tesp32c6.rom.net80211.ld \
220+ -Tesp32c6.rom.newlib.ld \
221+ -Tesp32c6.rom.coexist.ld \
222+ -Tesp32c6.rom.heap.ld \
223+ -Tesp32c6.rom.wdt.ld
211224else ifeq ($(IDF_TARGET),esp32s2)
212225LDFLAGS += \
213226 -T$(IDF_TARGET ) .rom.newlib-data.ld \
@@ -222,7 +235,7 @@ endif
222235LIBS := -lgcc -lc -lstdc++
223236
224237# Use toolchain libm if we're not using our own.
225- ifndef INTERNAL_LIBM
238+ ifneq ( $( INTERNAL_LIBM ) ,1)
226239LIBS += -lm
227240endif
228241
@@ -262,12 +275,16 @@ SRC_C += \
262275
263276SRC_C += $(wildcard common-hal/espidf/* .c)
264277
265- ifeq ($(IDF_TARGET ) ,esp32c3 )
278+ ifneq ($(CIRCUITPY_ESP_USB_SERIAL_JTAG ) ,0 )
266279SRC_C += supervisor/usb_serial_jtag.c
267- else
268- SRC_C += \
269- peripherals/pcnt.c \
270- peripherals/touch.c
280+ endif
281+
282+ ifneq ($(CIRCUITPY_COUNTIO ) ,0)
283+ SRC_C += peripherals/pcnt.c
284+ endif
285+
286+ ifneq ($(CIRCUITPY_TOUCHIO_USE_NATIVE ) ,0)
287+ SRC_C += peripherals/touch.c
271288endif
272289
273290ifneq ($(CIRCUITPY_USB ) ,0)
@@ -435,13 +452,28 @@ endif
435452
436453ESP_IDF_COMPONENTS_LINK = $(IDF_TARGET_ARCH ) app_update bootloader_support driver efuse esp_adc esp_app_format esp_coex esp_common esp_event esp_hw_support esp_mm 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
437454ifneq ($(CIRCUITPY_BLEIO ) ,0)
455+ BLE_IMPL_esp32 := esp32
456+ BLE_IMPL_esp32s3 := esp32c3
457+ BLE_IMPL_esp32c2 := libble
458+ BLE_IMPL_esp32c3 := esp32c3
459+ BLE_IMPL_esp32c6 := libble
460+ BLE_IMPL_esp32h2 := libble
461+ BLE_IMPL = $(BLE_IMPL_$(IDF_TARGET))
462+
438463 ESP_IDF_COMPONENTS_LINK += bt
439- ifeq ($(IDF_TARGET),esp32)
440- BINARY_BLOBS += esp-idf/components/bt/controller/lib_esp32/$(IDF_TARGET)/libbtdm_app.a
441- else
464+ ifeq ($(BLE_IMPL),esp32)
465+ BINARY_BLOBS += esp-idf/components/bt/controller/lib_esp32/$(IDF_TARGET)/libbtdm_app.a
466+ endif
467+
468+ ifeq ($(BLE_IMPL),esp32c3)
442469 BINARY_BLOBS += esp-idf/components/esp_phy/lib/$(IDF_TARGET)/libbtbb.a \
443470 esp-idf/components/bt/controller/lib_esp32c3_family/$(IDF_TARGET)/libbtdm_app.a
444471 endif
472+
473+ ifeq ($(BLE_IMPL),libble)
474+ BINARY_BLOBS += esp-idf/components/esp_phy/lib/$(IDF_TARGET)/libbtbb.a \
475+ esp-idf/components/bt/controller/lib_$(IDF_TARGET)/$(IDF_TARGET)-bt-lib/libble_app.a
476+ endif
445477endif
446478ifneq ($(CIRCUITPY_ESPULP ) ,0)
447479 ESP_IDF_COMPONENTS_LINK += ulp
@@ -469,11 +501,16 @@ ESP_IDF_COMPONENTS_EXPANDED += $(BUILD)/esp-idf/esp-idf/esp-camera/libesp-camera
469501endif
470502
471503ifneq ($(VALID_BOARD ) ,)
504+ # From esp-idf/components/bootloader/Kconfig.projbuild
472505# BOOTLOADER_OFFSET is determined by chip type, based on the ROM bootloader, and is not changeable.
473506ifeq ($(IDF_TARGET ) ,esp32)
474507BOOTLOADER_OFFSET = 0x1000
508+ else ifeq ($(IDF_TARGET),esp32h2)
509+ BOOTLOADER_OFFSET = 0x0
475510else ifeq ($(IDF_TARGET),esp32c3)
476511BOOTLOADER_OFFSET = 0x0
512+ else ifeq ($(IDF_TARGET),esp32c6)
513+ BOOTLOADER_OFFSET = 0x0
477514else ifeq ($(IDF_TARGET),esp32s3)
478515BOOTLOADER_OFFSET = 0x0
479516else ifeq ($(IDF_TARGET),esp32s2)
0 commit comments