Skip to content

Commit cedd677

Browse files
committed
Fix Funhouse and update to IDF 5.3
The Funhouse problem was due to a locking change for SPI. The Funhouse is one of a few boards with DotStar status LEDs that use SPI and have this bug. I thought it might be IDF related so I updated it first. :-) Fixes #9486
1 parent dd03d4f commit cedd677

File tree

21 files changed

+152
-69
lines changed

21 files changed

+152
-69
lines changed

.gitmodules

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@
143143
[submodule "ports/espressif/esp-idf"]
144144
path = ports/espressif/esp-idf
145145
url = https://github.com/adafruit/esp-idf.git
146-
branch = circuitpython-v5.2.2
146+
branch = circuitpython-v5.3
147147
[submodule "ports/espressif/esp-protocols"]
148148
path = ports/espressif/esp-protocols
149149
url = https://github.com/espressif/esp-protocols.git
@@ -354,8 +354,8 @@
354354
url = https://github.com/adafruit/certificates
355355
[submodule "lib/tlsf"]
356356
path = lib/tlsf
357-
url = https://github.com/adafruit/tlsf.git
358-
branch = circuitpython
357+
url = https://github.com/espressif/tlsf.git
358+
branch = idf
359359
[submodule "frozen/CircuitPython_AXP313A"]
360360
path = frozen/CircuitPython_AXP313A
361361
url = https://github.com/bill88t/CircuitPython_AXP313A

ports/espressif/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ cmake_minimum_required(VERSION 3.16)
55
set(ENV{IDF_PATH} ${CMAKE_SOURCE_DIR}/esp-idf)
66

77
# The component list here determines what options we get in menuconfig and what the ninja file can build.
8-
set(COMPONENTS bt driver esp-tls esp_adc_cal esp_event esp_netif esp_psram esp_wifi esptool_py freertos log lwip main mbedtls mdns soc ulp usb wpa_supplicant esp-camera esp_lcd)
8+
set(COMPONENTS bt driver esp_driver_dac esp_driver_gpio esp_driver_gptimer esp_driver_i2s esp_driver_ledc esp_driver_pcnt esp_driver_rmt esp_driver_spi esp_driver_tsens esp_driver_uart esp-tls esp_adc_cal esp_event esp_netif esp_psram esp_wifi esptool_py freertos log lwip main mbedtls mdns soc ulp usb wpa_supplicant esp-camera esp_lcd vfs esp_vfs_console)
99
set(EXTRA_COMPONENT_DIRS "esp-protocols/components/mdns" "esp-camera")
1010

1111
include($ENV{IDF_PATH}/tools/cmake/project.cmake)

ports/espressif/Makefile

Lines changed: 110 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -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.
147150
CFLAGS += -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
150176
ifeq ($(DEBUG), 1)
151177
CFLAGS += -ggdb
@@ -178,6 +204,8 @@ CFLAGS += $(INC) -Werror -Wall -std=gnu11 -Wl,--gc-sections $(BASE_CFLAGS) $(C_D
178204
ifneq ($(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
181209
endif
182210

183211
ifeq ($(IDF_TARGET_ARCH),xtensa)
@@ -187,11 +215,14 @@ ifeq ($(IDF_TARGET_ARCH),xtensa)
187215
CFLAGS += -mlongcalls -isystem esp-idf/components/xtensa/deprecated_include/ -Wno-error=cpp
188216
else ifeq ($(IDF_TARGET_ARCH),riscv)
189217
CFLAGS += -march=rv32imac_zicsr_zifencei
218+
LDFLAGS += \
219+
-Lesp-idf/components/riscv/ld \
220+
-Trom.api.ld
190221
endif
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

196227
LDFLAGS += \
197228
-L$(BUILD)/esp-idf/esp-idf/esp_system/ld \
@@ -210,20 +241,37 @@ LDFLAGS += \
210241

211242
ifeq ($(IDF_TARGET),esp32)
212243
LDFLAGS += \
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+
216252
else ifeq ($(IDF_TARGET),esp32c2)
217253
LDFLAGS += \
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+
221260
CFLAGS += -DSOC_XTAL_FREQ_MHZ=CONFIG_XTAL_FREQ
261+
262+
CHIP_COMPONENTS = \
263+
esp_driver_tsens
264+
222265
else ifeq ($(IDF_TARGET),esp32c3)
223266
LDFLAGS += \
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+
227275
else ifeq ($(IDF_TARGET),esp32c6)
228276
LDFLAGS += \
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+
237290
else ifeq ($(IDF_TARGET),esp32h2)
238291
LDFLAGS += \
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+
243300
else ifeq ($(IDF_TARGET),esp32s2)
244301
LDFLAGS += \
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+
248311
else ifeq ($(IDF_TARGET),esp32s3)
249312
LDFLAGS += \
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+
252322
endif
253323

254324
LIBS := -lgcc -lc -lstdc++
@@ -322,6 +392,10 @@ ifneq ($(CIRCUITPY_USB_DEVICE),0)
322392
SRC_C += lib/tinyusb/src/portable/espressif/esp32sx/dcd_esp32sx.c
323393
endif
324394

395+
ifneq ($(CIRCUITPY_AUDIOBUSIO),0)
396+
CHIP_COMPONENTS += esp_driver_i2s
397+
endif
398+
325399
ifneq ($(CIRCUITPY_BLEIO),0)
326400
SRC_C += common-hal/_bleio/ble_events.c
327401
endif
@@ -361,6 +435,18 @@ SRC_ULP := \
361435
SRC_C += $(SRC_ULP)
362436
endif
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+
364450
SRC_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)
490576
BINARY_BLOBS += esp-idf/components/esp_phy/lib/$(IDF_TARGET)/librtc.a
491577
endif
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
494580
ifneq ($(CIRCUITPY_WIFI),0)
495581
ESP_IDF_COMPONENTS_LINK += esp_coex esp_netif esp-tls esp_wifi lwip mbedtls mdns wpa_supplicant
496582
endif
@@ -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 $@"

ports/espressif/boards/adafruit_funhouse/mpconfigboard.mk

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ CIRCUITPY_ESP_FLASH_FREQ = 80m
1010
CIRCUITPY_ESP_FLASH_SIZE = 4MB
1111

1212
CIRCUITPY_ESPCAMERA = 0
13+
CIRCUITPY_MAX3421E = 0
14+
CIRCUITPY_PS2IO = 0
15+
CIRCUITPY_SDCARDIO = 0
16+
CIRCUITPY_EPAPERDISPLAY = 0
17+
CIRCUITPY_PARALLELDISPLAYBUS = 0
18+
CIRCUITPY_RGBMATRIX = 0
19+
CIRCUITPY_SHARPDISPLAY = 0
20+
CIRCUITPY_FRAMEBUFFERIO = 0
1321

1422
# Include these Python libraries in firmware.
1523
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel

ports/espressif/boards/espressif_esp32_eye/board.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
#include "supervisor/board.h"
88
#include "mpconfigboard.h"
99
#include "shared-bindings/microcontroller/Pin.h"
10-
#include "components/driver/gpio/include/driver/gpio.h"
11-
#include "components/hal/include/hal/gpio_hal.h"
10+
#include "driver/gpio.h"
11+
#include "hal/gpio_hal.h"
1212
#include "common-hal/microcontroller/Pin.h"
1313

1414
void board_init(void) {

ports/espressif/common-hal/alarm/__init__.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030

3131
#include "esp_sleep.h"
3232

33-
#include "components/driver/gpio/include/driver/gpio.h"
34-
#include "components/driver/uart/include/driver/uart.h"
33+
#include "driver/gpio.h"
34+
#include "driver/uart.h"
3535

3636
// Singleton instance of SleepMemory.
3737
const alarm_sleep_memory_obj_t alarm_sleep_memory_obj = {

ports/espressif/common-hal/alarm/touch/TouchAlarm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ void alarm_touch_touchalarm_set_alarm(const bool deep_sleep, const size_t n_alar
129129
touch_pad_isr_register(touch_interrupt, NULL);
130130
touch_pad_intr_enable();
131131
#else
132-
touch_pad_timeout_set(true, SOC_TOUCH_PAD_THRESHOLD_MAX);
132+
touch_pad_timeout_set(true, TOUCH_PAD_THRESHOLD_MAX);
133133
touch_pad_isr_register(touch_interrupt, NULL, TOUCH_PAD_INTR_MASK_ALL);
134134
touch_pad_intr_enable(TOUCH_PAD_INTR_MASK_ACTIVE | TOUCH_PAD_INTR_MASK_INACTIVE);
135135
#endif

ports/espressif/common-hal/analogio/AnalogOut.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include "common-hal/microcontroller/Pin.h"
1111

1212
#ifdef SOC_DAC_SUPPORTED
13-
#include "esp-idf/components/driver/dac/include/driver/dac_oneshot.h"
13+
#include "driver/dac_oneshot.h"
1414
#endif
1515
#include "py/obj.h"
1616

ports/espressif/common-hal/busio/UART.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include "shared-bindings/microcontroller/Pin.h"
99
#include "shared-bindings/busio/UART.h"
1010

11-
#include "components/driver/uart/include/driver/uart.h"
11+
#include "driver/uart.h"
1212

1313
#include "mpconfigport.h"
1414
#include "shared/readline/readline.h"
@@ -56,7 +56,7 @@ void uart_reset(void) {
5656
for (uart_port_t num = 0; num < UART_NUM_MAX; num++) {
5757
#ifdef CONFIG_ESP_CONSOLE_UART_NUM
5858
// Do not reset the UART used by the IDF for logging.
59-
if (num == CONFIG_ESP_CONSOLE_UART_NUM) {
59+
if ((int)num == CONFIG_ESP_CONSOLE_UART_NUM) {
6060
continue;
6161
}
6262
#endif

0 commit comments

Comments
 (0)