@@ -59,76 +59,81 @@ include $(TOP)/supervisor/supervisor.mk
5959# Include make rules and variables common across CircuitPython builds.
6060include $(TOP ) /py/circuitpy_defns.mk
6161
62- ifeq ($(IDF_TARGET ) ,esp32s2)
63- IDF_TARGET_ARCH = xtensa
64- CROSS_COMPILE = xtensa-$(IDF_TARGET ) -elf-
65- else ifeq ($(IDF_TARGET),esp32c3)
62+ ifeq ($(IDF_TARGET ) ,esp32c3)
6663IDF_TARGET_ARCH = riscv
6764CROSS_COMPILE = riscv32-esp-elf-
65+ else
66+ IDF_TARGET_ARCH = xtensa
67+ CROSS_COMPILE = xtensa-$(IDF_TARGET ) -elf-
6868endif
6969
7070# ######################################
7171# CFLAGS
7272# ######################################
7373
74- INC += -I.\
75- -I./boards \
76- -I./boards/$(BOARD ) \
77- -I./peripherals \
78- -I../.. \
79- -I../../lib/mp-readline \
80- -I../../lib/tinyusb/src \
81- -I../../supervisor/shared/usb \
82- -I$(BUILD ) \
83- -I$(BUILD ) /genhdr \
84- -I$(BUILD ) /esp-idf/config \
85- -isystem esp-idf \
86- -isystem esp-idf/components/app_update/include \
87- -isystem esp-idf/components/bootloader_support/include \
88- -isystem esp-idf/components/driver/include \
89- -isystem esp-idf/components/driver/$(IDF_TARGET ) /include \
90- -isystem esp-idf/components/$(IDF_TARGET ) /include \
91- -isystem esp-idf/components/esp_adc_cal/include \
92- -isystem esp-idf/components/esp_common/include \
93- -isystem esp-idf/components/esp_event/include \
94- -isystem esp-idf/components/esp_hw_support/include \
95- -isystem esp-idf/components/esp_netif/include \
96- -isystem esp-idf/components/esp_pm/include \
97- -isystem esp-idf/components/esp_ringbuf/include \
98- -isystem esp-idf/components/esp_rom/include \
99- -isystem esp-idf/components/esp_system/include \
100- -isystem esp-idf/components/esp_timer/include \
101- -isystem esp-idf/components/esp_wifi/include \
102- -isystem esp-idf/components/freertos/include \
103- -isystem esp-idf/components/freertos/include/freertos \
104- -isystem esp-idf/components/freertos/port/$(IDF_TARGET_ARCH ) /include \
105- -isystem esp-idf/components/hal/include \
106- -isystem esp-idf/components/hal/$(IDF_TARGET ) /include \
107- -isystem esp-idf/components/hal/platform_port/include \
108- -isystem esp-idf/components/heap/include \
109- -isystem esp-idf/components/log/include \
110- -isystem esp-idf/components/lwip/include \
111- -isystem esp-idf/components/lwip/lwip/src/include \
112- -isystem esp-idf/components/lwip/port/esp32/include \
113- -isystem esp-idf/components/mbedtls/esp_crt_bundle/include \
114- -isystem esp-idf/components/mbedtls/mbedtls/include \
115- -isystem esp-idf/components/mbedtls/port/include \
116- -isystem esp-idf/components/newlib/platform_include \
117- -isystem esp-idf/components/nvs_flash/include \
118- -isystem esp-idf/components/soc/include \
119- -isystem esp-idf/components/soc/$(IDF_TARGET ) /include \
120- -isystem esp-idf/components/spi_flash/include \
121- -isystem esp-idf/components/$(IDF_TARGET_ARCH ) /include \
122- -isystem esp-idf/components/$(IDF_TARGET_ARCH ) /$(IDF_TARGET ) /include
74+ INC += \
75+ -I.\
76+ -I./boards \
77+ -I./boards/$(BOARD ) \
78+ -I./peripherals \
79+ -I../.. \
80+ -I../../lib/mp-readline \
81+ -I../../lib/tinyusb/src \
82+ -I../../supervisor/shared/usb \
83+ -I$(BUILD ) \
84+ -I$(BUILD ) /genhdr \
85+ -I$(BUILD ) /esp-idf/config \
86+ -isystem esp-idf \
87+ -isystem esp-idf/components/app_update/include \
88+ -isystem esp-idf/components/bootloader_support/include \
89+ -isystem esp-idf/components/driver/include \
90+ -isystem esp-idf/components/driver/$(IDF_TARGET ) /include \
91+ -isystem esp-idf/components/$(IDF_TARGET ) /include \
92+ -isystem esp-idf/components/esp_adc_cal/include \
93+ -isystem esp-idf/components/esp_common/include \
94+ -isystem esp-idf/components/esp_event/include \
95+ -isystem esp-idf/components/esp_hw_support/include \
96+ -isystem esp-idf/components/esp_hw_support/include/soc \
97+ -isystem esp-idf/components/esp_netif/include \
98+ -isystem esp-idf/components/esp_pm/include \
99+ -isystem esp-idf/components/esp_ringbuf/include \
100+ -isystem esp-idf/components/esp_rom/include \
101+ -isystem esp-idf/components/esp_system/include \
102+ -isystem esp-idf/components/esp_timer/include \
103+ -isystem esp-idf/components/esp_wifi/include \
104+ -isystem esp-idf/components/freertos/include \
105+ -isystem esp-idf/components/freertos/include/freertos \
106+ -isystem esp-idf/components/freertos/include/esp_additions \
107+ -isystem esp-idf/components/freertos/include/esp_additions/freertos \
108+ -isystem esp-idf/components/freertos/port/$(IDF_TARGET_ARCH ) /include \
109+ -isystem esp-idf/components/hal/include \
110+ -isystem esp-idf/components/hal/$(IDF_TARGET ) /include \
111+ -isystem esp-idf/components/hal/platform_port/include \
112+ -isystem esp-idf/components/heap/include \
113+ -isystem esp-idf/components/log/include \
114+ -isystem esp-idf/components/lwip/include \
115+ -isystem esp-idf/components/lwip/lwip/src/include \
116+ -isystem esp-idf/components/lwip/port/esp32/include \
117+ -isystem esp-idf/components/mbedtls/esp_crt_bundle/include \
118+ -isystem esp-idf/components/mbedtls/mbedtls/include \
119+ -isystem esp-idf/components/mbedtls/port/include \
120+ -isystem esp-idf/components/newlib/platform_include \
121+ -isystem esp-idf/components/nvs_flash/include \
122+ -isystem esp-idf/components/soc/include \
123+ -isystem esp-idf/components/soc/$(IDF_TARGET ) /include \
124+ -isystem esp-idf/components/spi_flash/include \
125+ -isystem esp-idf/components/$(IDF_TARGET_ARCH ) /include \
126+ -isystem esp-idf/components/$(IDF_TARGET_ARCH ) /$(IDF_TARGET ) /include
123127
124128# See https://github.com/espressif/esp-idf/issues/6906
125129ifeq ($(IDF_TARGET ) ,esp32c3)
126130CFLAGS += -include "esp32c3_fix.h"
127131endif
128132
129- CFLAGS += -DHAVE_CONFIG_H \
130- -DMBEDTLS_CONFIG_FILE=\"mbedtls/esp_config.h\" \
131- -DUNITY_INCLUDE_CONFIG_H -DWITH_POSIX
133+ CFLAGS += \
134+ -DHAVE_CONFIG_H \
135+ -DMBEDTLS_CONFIG_FILE=\"mbedtls/esp_config.h\" \
136+ -DUNITY_INCLUDE_CONFIG_H -DWITH_POSIX
132137
133138# Make our canary value match FreeRTOS's
134139# This define is in FreeRTOS as tskSTACK_FILL_BYTE 0xa5U which we expand out to a full word.
@@ -158,33 +163,38 @@ endif
158163
159164LDFLAGS = $(CFLAGS ) -Wl,-nostdlib -Wl,-Map=$@ .map -Wl,-cref -Wl,--undefined=uxTopUsedPriority
160165
161- LDFLAGS += -L$(BUILD ) /esp-idf/esp-idf/$(IDF_TARGET ) \
162- -L$(BUILD ) /esp-idf/esp-idf/$(IDF_TARGET ) /ld \
163- -Lesp-idf/components/$(IDF_TARGET ) /ld \
164- -Lesp-idf/components/esp_rom/$(IDF_TARGET ) /ld \
165- -T$(IDF_TARGET ) _out.ld \
166- -T$(IDF_TARGET ) .project.ld \
167- -T$(IDF_TARGET ) .peripherals.ld \
168- -T$(IDF_TARGET ) .rom.ld \
169- -T$(IDF_TARGET ) .rom.api.ld \
170- -T$(IDF_TARGET ) .rom.libgcc.ld \
171- -T$(IDF_TARGET ) .rom.newlib-nano.ld
166+ LDFLAGS += \
167+ -L$(BUILD ) /esp-idf/esp-idf/esp_system/ld \
168+ -Lesp-idf/components/esp_rom/$(IDF_TARGET ) /ld \
169+ -Lesp-idf/components/soc/$(IDF_TARGET ) /ld \
170+ -Tmemory.ld \
171+ -Tsections.ld \
172+ -T$(IDF_TARGET ) .peripherals.ld \
173+ -T$(IDF_TARGET ) .rom.ld \
174+ -T$(IDF_TARGET ) .rom.api.ld \
175+ -T$(IDF_TARGET ) .rom.libgcc.ld \
176+ -T$(IDF_TARGET ) .rom.newlib-nano.ld \
177+ -Wl,-Bstatic \
178+ -Wl,--no-warn-mismatch \
179+ -Wl,--build-id=none \
180+ -fno-rtti
172181
173182ifeq ($(IDF_TARGET ) ,esp32c3)
174- LDFLAGS += -Tesp32c3.rom.newlib.ld \
175- -Tesp32c3.rom.version.ld \
176- -Tesp32c3.rom.eco3.ld
177- else
178- LDFLAGS += -T$(IDF_TARGET ) .rom.newlib-data.ld \
179- -T$(IDF_TARGET ) .rom.newlib-funcs.ld \
180- -T$(IDF_TARGET ) .rom.spiflash.ld
183+ LDFLAGS += \
184+ -Tesp32c3.rom.newlib.ld \
185+ -Tesp32c3.rom.version.ld \
186+ -Tesp32c3.rom.eco3.ld
187+ else ifeq ($(IDF_TARGET),esp32s2)
188+ LDFLAGS += \
189+ -T$(IDF_TARGET ) .rom.newlib-data.ld \
190+ -T$(IDF_TARGET ) .rom.newlib-funcs.ld \
191+ -T$(IDF_TARGET ) .rom.spiflash.ld
192+ else ifeq ($(IDF_TARGET),esp32s3)
193+ LDFLAGS += \
194+ -Tesp32s3.rom.newlib.ld \
195+ -Tesp32s3.rom.version.ld
181196endif
182197
183- LDFLAGS += -Wl,-Bstatic \
184- -Wl,--no-warn-mismatch \
185- -Wl,--build-id=none \
186- -fno-rtti
187-
188198LIBS := -lgcc -lc -lstdc++
189199
190200# Use toolchain libm if we're not using our own.
@@ -226,10 +236,13 @@ SRC_C += \
226236
227237ifneq ($(IDF_TARGET ) ,esp32c3)
228238SRC_C += \
229- cam.c \
230- i2s_lcd_esp32s2_driver.c \
231239 peripherals/pcnt.c \
232240 peripherals/touch.c
241+ ifeq ($(IDF_TARGET ) ,esp32s2)
242+ SRC_C += \
243+ cam.c \
244+ i2s_lcd_esp32s2_driver.c
245+ endif
233246endif
234247
235248$(BUILD ) /i2s_lcd_esp32s2_driver.o : CFLAGS += -Wno-sign-compare
@@ -238,16 +251,15 @@ ifneq ($(CIRCUITPY_USB),0)
238251SRC_C += lib/tinyusb/src/portable/espressif/esp32sx/dcd_esp32sx.c
239252endif
240253
241- SRC_S =
242-
243- SRC_COMMON_HAL_EXPANDED = $(addprefix shared-bindings/, $(SRC_COMMON_HAL ) ) \
244- $(addprefix shared-bindings/, $(SRC_BINDINGS_ENUMS ) ) \
245- $(addprefix common-hal/, $(SRC_COMMON_HAL ) )
246-
247- SRC_SHARED_MODULE_EXPANDED = $(addprefix shared-bindings/, $(SRC_SHARED_MODULE ) ) \
248- $(addprefix shared-module/, $(SRC_SHARED_MODULE ) ) \
249- $(addprefix shared-module/, $(SRC_SHARED_MODULE_INTERNAL ) )
254+ SRC_COMMON_HAL_EXPANDED = \
255+ $(addprefix shared-bindings/, $(SRC_COMMON_HAL ) ) \
256+ $(addprefix shared-bindings/, $(SRC_BINDINGS_ENUMS ) ) \
257+ $(addprefix common-hal/, $(SRC_COMMON_HAL ) )
250258
259+ SRC_SHARED_MODULE_EXPANDED = \
260+ $(addprefix shared-bindings/, $(SRC_SHARED_MODULE ) ) \
261+ $(addprefix shared-module/, $(SRC_SHARED_MODULE ) ) \
262+ $(addprefix shared-module/, $(SRC_SHARED_MODULE_INTERNAL ) )
251263
252264ifneq ($(FROZEN_MPY_DIR ) ,)
253265FROZEN_MPY_PY_FILES := $(shell find -L $(FROZEN_MPY_DIR ) -type f -name '* .py')
@@ -261,7 +273,6 @@ ifeq ($(INTERNAL_LIBM),1)
261273OBJ += $(addprefix $(BUILD ) /, $(SRC_LIBM:.c=.o ) )
262274endif
263275OBJ += $(addprefix $(BUILD ) /, $(SRC_CIRCUITPY_COMMON:.c=.o ) )
264- OBJ += $(addprefix $(BUILD ) /, $(SRC_S:.S=.o ) )
265276OBJ += $(addprefix $(BUILD ) /, $(SRC_MOD:.c=.o ) )
266277
267278$(BUILD ) /$(FATFS_DIR ) /ff.o : COPT += -Os
@@ -271,8 +282,6 @@ $(BUILD)/lib/protomatter/src/core.o: CFLAGS += -DESP32
271282
272283# List of sources for qstr extraction
273284SRC_QSTR += $(SRC_C ) $(SRC_SUPERVISOR ) $(SRC_MOD ) $(SRC_COMMON_HAL_EXPANDED ) $(SRC_SHARED_MODULE_EXPANDED )
274- # Sources that only hold QSTRs after pre-processing.
275- SRC_QSTR_PREPROCESSOR +=
276285
277286# IDF build commands
278287IDF_PATH = $(realpath ./esp-idf)
@@ -315,40 +324,36 @@ menuconfig: $(BUILD)/esp-idf/config
315324# qstr builds include headers so we need to make sure they are up to date
316325$(HEADER_BUILD ) /qstr.split : | $(BUILD ) /esp-idf/config/sdkconfig.h
317326
318- ESP_IDF_COMPONENTS_LINK = $(IDF_TARGET ) $(IDF_TARGET_ARCH ) app_update bootloader_support driver efuse esp_adc_cal esp_common esp_event esp_hw_support esp_netif esp_pm esp_ringbuf esp_rom esp_system esp_timer esp-tls esp_wifi freertos hal heap log lwip mbedtls newlib nvs_flash pthread soc spi_flash vfs wpa_supplicant
327+ BINARY_WIFI_BLOBS = libcoexist.a libcore.a libespnow.a libmesh.a libnet80211.a libpp.a libsmartconfig.a libwapi.a
328+ BINARY_BLOBS = esp-idf/components/esp_phy/lib/$(IDF_TARGET ) /libphy.a $(addprefix esp-idf/components/esp_wifi/lib/$(IDF_TARGET ) /, $(BINARY_WIFI_BLOBS ) )
319329
330+ 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 newlib nvs_flash pthread soc spi_flash vfs wpa_supplicant
320331ESP_IDF_COMPONENTS_EXPANDED = $(foreach component, $(ESP_IDF_COMPONENTS_LINK ) , $(BUILD ) /esp-idf/esp-idf/$(component ) /lib$(component ) .a)
321- ESP_IDF_WIFI_COMPONENTS_EXPANDED = $(foreach component, $(ESP_IDF_WIFI_COMPONENTS_LINK ) , $(BUILD ) /esp-idf/esp-idf/$(component ) /lib$(component ) .a)
322332
323333MBEDTLS_COMPONENTS_LINK = crypto tls x509
324334MBEDTLS_COMPONENTS_LINK_EXPANDED = $(foreach component, $(MBEDTLS_COMPONENTS_LINK ) , $(BUILD ) /esp-idf/esp-idf/mbedtls/mbedtls/library/libmbed$(component ) .a)
325335
326- BINARY_WIFI_BLOBS = libcoexist.a libcore.a libespnow.a libmesh.a libnet80211.a libpp.a libsmartconfig.a libphy.a
327- ifneq ($(IDF_TARGET ) ,esp32c3)
328- BINARY_WIFI_BLOBS += librtc.a
329- endif
330- BINARY_BLOBS = $(addprefix esp-idf/components/esp_wifi/lib/$(IDF_TARGET ) /, $(BINARY_WIFI_BLOBS ) )
331-
332336ifeq ($(IDF_TARGET_ARCH ) ,xtensa)
333337BINARY_BLOBS += esp-idf/components/xtensa/$(IDF_TARGET ) /libxt_hal.a
334338ESP_IDF_COMPONENTS_EXPANDED += esp-idf/components/xtensa/$(IDF_TARGET ) /libxt_hal.a
335339endif
336340
337- ifeq ($(IDF_TARGET ) , esp32c3)
338- ESPTOOL_BAUDRATE = 230400
339- BOOTLOADER_OFFSET = 0x0000
341+ ifeq ($(IDF_TARGET ) ,esp32c3)
342+ BOOTLOADER_OFFSET = 0x0
343+ else ifeq ($(IDF_TARGET),esp32s3)
344+ BOOTLOADER_OFFSET = 0x0
340345else
341- ESPTOOL_BAUDRATE = 460800
342346BOOTLOADER_OFFSET = 0x1000
343347endif
348+
344349PARTITION_TABLE_OFFSET = 0x8000
345350FIRMWARE_OFFSET = 0x10000
346351
347352ESP_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
348353
349354FLASH_FLAGS = --flash_mode $(CIRCUITPY_ESP_FLASH_MODE ) --flash_freq $(CIRCUITPY_ESP_FLASH_FREQ ) --flash_size $(CIRCUITPY_ESP_FLASH_SIZE )
350355
351- ESPTOOL_FLAGS ?= -b $( ESPTOOL_BAUDRATE ) - -before=default_reset --after=no_reset
356+ ESPTOOL_FLAGS ?= --before=default_reset --after=no_reset
352357
353358ifeq ($(IDF_TARGET ) ,esp32c3)
354359all : $(BUILD ) /firmware.bin
@@ -360,17 +365,18 @@ endif
360365esp-idf-stamp : $(BUILD ) /esp-idf/config/sdkconfig.h
361366 $(Q ) ninja -C $(BUILD ) /esp-idf \
362367 bootloader/bootloader.bin \
368+ esp-idf/esp_system/__ldgen_output_sections.ld \
363369 esp-idf/app_update/libapp_update.a \
364370 esp-idf/bootloader_support/libbootloader_support.a \
365371 esp-idf/driver/libdriver.a \
366372 esp-idf/efuse/libefuse.a \
367- esp-idf/$(IDF_TARGET ) /lib$(IDF_TARGET ) .a \
368- esp-idf/$(IDF_TARGET ) /ld/$(IDF_TARGET ) .project.ld \
369373 esp-idf/esp_adc_cal/libesp_adc_cal.a \
370374 esp-idf/esp_common/libesp_common.a \
371375 esp-idf/esp_event/libesp_event.a \
372376 esp-idf/esp_hw_support/libesp_hw_support.a \
377+ esp-idf/esp_ipc/libesp_ipc.a \
373378 esp-idf/esp_netif/libesp_netif.a \
379+ esp-idf/esp_phy/libesp_phy.a \
374380 esp-idf/esp_pm/libesp_pm.a \
375381 esp-idf/esp_ringbuf/libesp_ringbuf.a \
376382 esp-idf/esp_rom/libesp_rom.a \
0 commit comments