@@ -62,19 +62,7 @@ INC += \
6262 -isystem esp-idf/components/bt/host/nimble/nimble/porting/nimble/include \
6363 -isystem esp-idf/components/bt/host/nimble/nimble/porting/npl/freertos/include \
6464 -isystem esp-idf/components/bt/host/nimble/port/include \
65- -isystem esp-idf/components/driver/include \
66- -isystem esp-idf/components/driver/deprecated \
67- -isystem esp-idf/components/driver/dac/include \
68- -isystem esp-idf/components/driver/gpio/include \
69- -isystem esp-idf/components/driver/gptimer/include \
7065 -isystem esp-idf/components/driver/i2c/include \
71- -isystem esp-idf/components/driver/i2s/include \
72- -isystem esp-idf/components/driver/$(IDF_TARGET ) /include \
73- -isystem esp-idf/components/driver/ledc/include \
74- -isystem esp-idf/components/driver/pcnt/include \
75- -isystem esp-idf/components/driver/rmt/include \
76- -isystem esp-idf/components/driver/spi/include \
77- -isystem esp-idf/components/driver/temperature_sensor/include \
7866 -isystem esp-idf/components/driver/touch_sensor/include \
7967 -isystem esp-idf/components/driver/touch_sensor/$(IDF_TARGET ) /include \
8068 -isystem esp-idf/components/driver/twai/include \
@@ -86,7 +74,21 @@ INC += \
8674 -isystem esp-idf/components/esp_app_format/include \
8775 -isystem esp-idf/components/esp_bootloader_format/include \
8876 -isystem esp-idf/components/esp_common/include \
77+ -isystem esp-idf/components/esp_driver_deprecated \
78+ -isystem esp-idf/components/esp_driver_dac/include \
79+ -isystem esp-idf/components/esp_driver_gpio/include \
80+ -isystem esp-idf/components/esp_driver_gptimer/include \
81+ -isystem esp-idf/components/esp_driver_i2c/include \
82+ -isystem esp-idf/components/esp_driver_i2s/include \
83+ -isystem esp-idf/components/esp_driver_$(IDF_TARGET ) /include \
84+ -isystem esp-idf/components/esp_driver_ledc/include \
85+ -isystem esp-idf/components/esp_driver_pcnt/include \
86+ -isystem esp-idf/components/esp_driver_rmt/include \
87+ -isystem esp-idf/components/esp_driver_spi/include \
88+ -isystem esp-idf/components/esp_driver_tsens/include \
89+ -isystem esp-idf/components/esp_driver_uart/include \
8990 -isystem esp-idf/components/esp_event/include \
91+ -isystem esp-idf/components/esp_hw_support/dma/include \
9092 -isystem esp-idf/components/esp_hw_support/include \
9193 -isystem esp-idf/components/esp_hw_support/include/soc \
9294 -isystem esp-idf/components/esp_netif/include \
@@ -98,6 +100,7 @@ INC += \
98100 -isystem esp-idf/components/esp_system/include \
99101 -isystem esp-idf/components/esp_timer/include \
100102 -isystem esp-idf/components/esp_wifi/include \
103+ -isystem esp-idf/components/esp_wifi/include/local \
101104 -isystem esp-idf/components/freertos/config/include \
102105 -isystem esp-idf/components/freertos/config/include/freertos \
103106 -isystem esp-idf/components/freertos/config/$(IDF_TARGET_ARCH ) /include \
@@ -146,6 +149,29 @@ CFLAGS += \
146149# This define is in FreeRTOS as tskSTACK_FILL_BYTE 0xa5U which we expand out to a full word.
147150CFLAGS += -DSTACK_CANARY_VALUE=0xa5a5a5a5
148151
152+ # IDF 5.3 uses a new ESP_SYSTEM_INIT_FN macro to "register" functions to run on
153+ # init. They work by placing function pointers into a linker section that ends
154+ # up as a function pointer array. To ensure the linker includes these functions,
155+ # one must provide `-u` arguments to state the symbols are missing. This would
156+ # normally happen implicitly by another function calling to these.
157+ REGISTRATION_FUNCTIONS = \
158+ -u newlib_include_pthread_impl \
159+ -u ld_include_highint_hdl \
160+ -u __cxx_fatal_exception \
161+ -u esp_app_desc \
162+ -u esp_timer_init_include_func \
163+ -u uart_vfs_include_dev_init \
164+ -u esp_vfs_include_console_register \
165+ -u __ubsan_include \
166+ -u esp_system_include_startup_funcs \
167+ -u esp_efuse_startup_include_func \
168+ -u newlib_include_heap_impl \
169+ -u newlib_include_syscalls_impl \
170+ -u newlib_include_pthread_impl \
171+ -u newlib_include_assert_impl \
172+ -u newlib_include_getentropy_impl \
173+ -u newlib_include_init_funcs
174+
149175# Debugging/Optimization
150176ifeq ($(DEBUG ) , 1)
151177 CFLAGS += -ggdb
@@ -178,6 +204,8 @@ CFLAGS += $(INC) -Werror -Wall -std=gnu11 -Wl,--gc-sections $(BASE_CFLAGS) $(C_D
178204ifneq ($(IDF_TARGET ) ,esp32c6)
179205 CFLAGS += --specs=nano.specs
180206 LDFLAGS += -T$(IDF_TARGET).rom.newlib-nano.ld
207+ else
208+ LDFLAGS += -T$(IDF_TARGET).rom.newlib-normal.ld
181209endif
182210
183211ifeq ($(IDF_TARGET_ARCH ) ,xtensa)
@@ -187,11 +215,14 @@ ifeq ($(IDF_TARGET_ARCH),xtensa)
187215CFLAGS += -mlongcalls -isystem esp-idf/components/xtensa/deprecated_include/ -Wno-error=cpp
188216else ifeq ($(IDF_TARGET_ARCH),riscv)
189217CFLAGS += -march=rv32imac_zicsr_zifencei
218+ LDFLAGS += \
219+ -Lesp-idf/components/riscv/ld \
220+ -Trom.api.ld
190221endif
191222
192223$(BUILD ) /lib/tlsf/tlsf.o : CFLAGS += -Wno-cast-align
193224
194- LDFLAGS = $(CFLAGS ) -Wl,-nostdlib -Wl,-Map=$@ .map -Wl,-cref -Wl,--undefined=uxTopUsedPriority
225+ LDFLAGS + = $(CFLAGS ) -Wl,-nostdlib -Wl,-Map=$@ .map -Wl,-cref -Wl,--undefined=uxTopUsedPriority
195226
196227LDFLAGS += \
197228 -L$(BUILD ) /esp-idf/esp-idf/esp_system/ld \
@@ -210,20 +241,37 @@ LDFLAGS += \
210241
211242ifeq ($(IDF_TARGET ) ,esp32)
212243LDFLAGS += \
213- -T$(IDF_TARGET ) .rom.newlib-data.ld \
214- -T$(IDF_TARGET ) .rom.newlib-funcs.ld \
215- -T$(IDF_TARGET ) .rom.spiflash.ld
244+ -Tesp32.rom.newlib-data.ld \
245+ -Tesp32.rom.newlib-funcs.ld \
246+ -Tesp32.rom.newlib-time.ld \
247+ -Tesp32.rom.spiflash_legacy.ld
248+
249+ CHIP_COMPONENTS = \
250+ esp_driver_dac
251+
216252else ifeq ($(IDF_TARGET),esp32c2)
217253LDFLAGS += \
218254 -Tesp32c2.rom.heap.ld \
219255 -Tesp32c2.rom.newlib.ld \
220- -Tesp32c2.rom.version.ld
256+ -Tesp32c2.rom.version.ld \
257+ -Tesp32c2.rom.systimer.ld \
258+ -Tesp32c2.rom.wdt.ld
259+
221260CFLAGS += -DSOC_XTAL_FREQ_MHZ=CONFIG_XTAL_FREQ
261+
262+ CHIP_COMPONENTS = \
263+ esp_driver_tsens
264+
222265else ifeq ($(IDF_TARGET),esp32c3)
223266LDFLAGS += \
224267 -Tesp32c3.rom.newlib.ld \
268+ -Tesp32c3.rom.newlib-time.ld \
225269 -Tesp32c3.rom.version.ld \
226270 -Tesp32c3.rom.eco3.ld
271+
272+ CHIP_COMPONENTS = \
273+ esp_driver_tsens
274+
227275else ifeq ($(IDF_TARGET),esp32c6)
228276LDFLAGS += \
229277 -Tesp32c6.rom.phy.ld \
@@ -234,21 +282,43 @@ LDFLAGS += \
234282 -Tesp32c6.rom.heap.ld \
235283 -Tesp32c6.rom.systimer.ld \
236284 -Tesp32c6.rom.wdt.ld
285+
286+
287+ CHIP_COMPONENTS = \
288+ esp_driver_tsens
289+
237290else ifeq ($(IDF_TARGET),esp32h2)
238291LDFLAGS += \
239292 -Tesp32h2.rom.heap.ld \
240293 -Tesp32h2.rom.newlib.ld \
241294 -Tesp32h2.rom.systimer.ld \
242295 -Tesp32h2.rom.wdt.ld
296+
297+ CHIP_COMPONENTS = \
298+ esp_driver_tsens
299+
243300else ifeq ($(IDF_TARGET),esp32s2)
244301LDFLAGS += \
245- -T$(IDF_TARGET ) .rom.newlib-data.ld \
246- -T$(IDF_TARGET ) .rom.newlib-funcs.ld \
247- -T$(IDF_TARGET ) .rom.spiflash.ld
302+ -Tesp32s2.rom.newlib-data.ld \
303+ -Tesp32s2.rom.newlib-funcs.ld \
304+ -Tesp32s2.rom.newlib-time.ld \
305+ -Tesp32s2.rom.spiflash_legacy.ld
306+
307+ CHIP_COMPONENTS = \
308+ esp_driver_dac \
309+ esp_driver_tsens
310+
248311else ifeq ($(IDF_TARGET),esp32s3)
249312LDFLAGS += \
250313 -Tesp32s3.rom.newlib.ld \
251- -Tesp32s3.rom.version.ld
314+ -Tesp32s3.rom.newlib-time.ld \
315+ -Tesp32s3.rom.version.ld \
316+ -Tesp32s3.rom.systimer.ld \
317+ -Tesp32s3.rom.wdt.ld
318+
319+ CHIP_COMPONENTS = \
320+ esp_driver_tsens
321+
252322endif
253323
254324LIBS := -lgcc -lc -lstdc++
@@ -322,6 +392,10 @@ ifneq ($(CIRCUITPY_USB_DEVICE),0)
322392SRC_C += lib/tinyusb/src/portable/espressif/esp32sx/dcd_esp32sx.c
323393endif
324394
395+ ifneq ($(CIRCUITPY_AUDIOBUSIO ) ,0)
396+ CHIP_COMPONENTS += esp_driver_i2s
397+ endif
398+
325399ifneq ($(CIRCUITPY_BLEIO ) ,0)
326400SRC_C += common-hal/_bleio/ble_events.c
327401endif
@@ -361,6 +435,18 @@ SRC_ULP := \
361435SRC_C += $(SRC_ULP )
362436endif
363437
438+ ifneq ($(CIRCUITPY_NEOPIXEL_WRITE ) ,0)
439+ CHIP_COMPONENTS += esp_driver_rmt
440+ endif
441+
442+ ifneq ($(CIRCUITPY_COUNTIO ) ,0)
443+ CHIP_COMPONENTS += esp_driver_pcnt
444+ endif
445+
446+ ifneq ($(CIRCUITPY_ROTARYIO ) ,0)
447+ CHIP_COMPONENTS += esp_driver_pcnt
448+ endif
449+
364450SRC_COMMON_HAL_EXPANDED = \
365451 $(addprefix shared-bindings/, $(SRC_COMMON_HAL ) ) \
366452 $(addprefix shared-bindings/, $(SRC_BINDINGS_ENUMS ) ) \
@@ -490,7 +576,7 @@ ifeq ($(IDF_TARGET),esp32)
490576BINARY_BLOBS += esp-idf/components/esp_phy/lib/$(IDF_TARGET ) /librtc.a
491577endif
492578
493- 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
579+ ESP_IDF_COMPONENTS_LINK = $(IDF_TARGET_ARCH ) $( CHIP_COMPONENTS ) app_update bootloader_support driver esp_driver_gpio esp_driver_gptimer esp_driver_ledc esp_driver_spi esp_driver_uart 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 esp_vfs_console
494580ifneq ($(CIRCUITPY_WIFI ) ,0)
495581 ESP_IDF_COMPONENTS_LINK += esp_coex esp_netif esp-tls esp_wifi lwip mbedtls mdns wpa_supplicant
496582endif
@@ -507,7 +593,7 @@ ifneq ($(CIRCUITPY_BLEIO),0)
507593 ifeq ($(BLE_IMPL),esp32)
508594 # BLE will hang the ESP32 and trigger an interrupt watchdog without this undefined symbol at
509595 # link because a weak version of the interrupt that BLE uses will be linked incorrectly.
510- LDFLAGS += -u ld_include_hli_vectors_bt
596+ REGISTRATION_FUNCTIONS += -u ld_include_hli_vectors_bt
511597 BINARY_BLOBS += esp-idf/components/bt/controller/lib_esp32/$(IDF_TARGET)/libbtdm_app.a
512598 endif
513599
@@ -619,7 +705,7 @@ esp-idf-stamp: $(BUILD)/esp-idf/config/sdkconfig.h
619705
620706$(BUILD ) /firmware.elf : $(OBJ ) | esp-idf-stamp $(IDF_CMAKE_TARGETS )
621707 $(STEPECHO ) " LINK $@ "
622- $(Q )$(CC ) -o $@ $(LDFLAGS ) $^ -Wl,--print-memory-usage -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 -u esp_app_desc
708+ $(Q )$(CC ) -o $@ $(LDFLAGS ) $^ -Wl,--print-memory-usage -Wl,--start-group $(ESP_IDF_COMPONENTS_EXPANDED ) $(BINARY_BLOBS ) $(MBEDTLS_COMPONENTS_LINK_EXPANDED ) $(LIBS ) -Wl,--end-group $( REGISTRATION_FUNCTIONS )
623709
624710$(BUILD ) /circuitpython-firmware.bin : $(BUILD ) /firmware.elf | tools/build_memory_info.py
625711 $(STEPECHO ) " Create $@ "
0 commit comments