Skip to content

Commit e0eecd2

Browse files
committed
update idf to v4.3
- update idf submodule to release/v4.3 - finish todo tasks held due to [email protected] - update SPI & I2C to make them v4.3 compatible
1 parent 47a6b13 commit e0eecd2

File tree

21 files changed

+237
-401
lines changed

21 files changed

+237
-401
lines changed

.gitmodules

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@
153153
[submodule "ports/esp32s2/esp-idf"]
154154
path = ports/esp32s2/esp-idf
155155
url = https://github.com/adafruit/esp-idf.git
156+
branch = circuitpython-v4.3
156157
[submodule "ports/esp32s2/certificates/nina-fw"]
157158
path = ports/esp32s2/certificates/nina-fw
158159
url = https://github.com/adafruit/nina-fw.git

locale/circuitpython.pot

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1997,6 +1997,10 @@ msgstr ""
19971997
msgid "SPI Re-initialization error"
19981998
msgstr ""
19991999

2000+
#: ports/esp32s2/common-hal/busio/SPI.c
2001+
msgid "SPI configuration failed"
2002+
msgstr ""
2003+
20002004
#: ports/raspberrypi/common-hal/busio/SPI.c
20012005
msgid "SPI peripheral in use"
20022006
msgstr ""

ports/esp32s2/Makefile

Lines changed: 73 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@ PORT ?= /dev/tty.SLAB_USBtoUART
3838
BUILD ?= build-$(BOARD)
3939

4040
include ../../py/mkenv.mk
41+
4142
# Board-specific
4243
include boards/$(BOARD)/mpconfigboard.mk
44+
4345
# Port-specific
4446
include mpconfigport.mk
4547

@@ -64,51 +66,52 @@ CROSS_COMPILE = xtensa-esp32s2-elf-
6466
#######################################
6567

6668
INC += -I.
67-
INC += -I../..
68-
INC += -I$(BUILD)
69-
INC += -I$(BUILD)/genhdr
7069
INC += -I./boards
7170
INC += -I./boards/$(BOARD)
7271
INC += -I./peripherals
72+
INC += -I../..
7373
INC += -I../../lib/mp-readline
7474
INC += -I../../lib/tinyusb/src
7575
INC += -I../../supervisor/shared/usb
76+
INC += -I$(BUILD)
77+
INC += -I$(BUILD)/genhdr
78+
INC += -I$(BUILD)/esp-idf/config
7679

7780
INC += -isystem esp-idf
81+
INC += -isystem esp-idf/components/app_update/include
82+
INC += -isystem esp-idf/components/bootloader_support/include
83+
INC += -isystem esp-idf/components/driver/esp32s2/include
7884
INC += -isystem esp-idf/components/driver/include
79-
INC += -isystem esp-idf/components/freertos/include/freertos
80-
INC += -isystem esp-idf/components/freertos/xtensa/include
8185
INC += -isystem esp-idf/components/esp32s2/include
82-
INC += -isystem esp-idf/components/xtensa/esp32s2/include
8386
INC += -isystem esp-idf/components/esp_common/include
8487
INC += -isystem esp-idf/components/esp_event/include
88+
INC += -isystem esp-idf/components/esp_hw_support/include
8589
INC += -isystem esp-idf/components/esp_netif/include
90+
INC += -isystem esp-idf/components/esp_pm/include
8691
INC += -isystem esp-idf/components/esp_ringbuf/include
8792
INC += -isystem esp-idf/components/esp_rom/include
88-
INC += -isystem esp-idf/components/esp_wifi/include
89-
INC += -isystem esp-idf/components/xtensa/include
93+
INC += -isystem esp-idf/components/esp_system/include
9094
INC += -isystem esp-idf/components/esp_timer/include
91-
INC += -isystem esp-idf/components/mbedtls/mbedtls/include
92-
INC += -isystem esp-idf/components/mbedtls/port/include/
93-
INC += -isystem esp-idf/components/newlib/platform_include
94-
INC += -isystem esp-idf/components/lwip/lwip/src/include
95-
INC += -isystem esp-idf/components/lwip/port/esp32/include
96-
INC += -isystem esp-idf/components/lwip/include/apps/sntp
95+
INC += -isystem esp-idf/components/esp_wifi/include
96+
INC += -isystem esp-idf/components/freertos/include
97+
INC += -isystem esp-idf/components/freertos/include/freertos
98+
INC += -isystem esp-idf/components/freertos/port/xtensa/include
9799
INC += -isystem esp-idf/components/hal/include
98100
INC += -isystem esp-idf/components/hal/esp32s2/include
101+
INC += -isystem esp-idf/components/heap/include
99102
INC += -isystem esp-idf/components/log/include/
100-
INC += -isystem esp-idf/components/driver/esp32s2/include
103+
INC += -isystem esp-idf/components/lwip/lwip/src/include
104+
INC += -isystem esp-idf/components/lwip/port/esp32/include
105+
INC += -isystem esp-idf/components/lwip/include/apps/sntp
106+
INC += -isystem esp-idf/components/mbedtls/mbedtls/include
107+
INC += -isystem esp-idf/components/mbedtls/port/include/
108+
INC += -isystem esp-idf/components/newlib/platform_include
109+
INC += -isystem esp-idf/components/nvs_flash/include
101110
INC += -isystem esp-idf/components/soc/include
102-
INC += -isystem esp-idf/components/soc/src/esp32s2/include
103-
INC += -isystem esp-idf/components/soc/soc/include
104-
INC += -isystem esp-idf/components/soc/soc/esp32s2/include
105-
INC += -isystem esp-idf/components/heap/include
106-
INC += -isystem esp-idf/components/esp_system/include
111+
INC += -isystem esp-idf/components/soc/esp32s2/include
107112
INC += -isystem esp-idf/components/spi_flash/include
108-
INC += -isystem esp-idf/components/nvs_flash/include
109-
INC += -isystem esp-idf/components/app_update/include
110-
INC += -isystem esp-idf/components/bootloader_support/include
111-
INC += -I$(BUILD)/esp-idf/config
113+
INC += -isystem esp-idf/components/xtensa/esp32s2/include
114+
INC += -isystem esp-idf/components/xtensa/include
112115

113116
CFLAGS += -DHAVE_CONFIG_H \
114117
-DMBEDTLS_CONFIG_FILE=\"mbedtls/esp_config.h\" \
@@ -136,27 +139,28 @@ CFLAGS += $(OPTIMIZATION_FLAGS)
136139

137140
CFLAGS += $(INC) -Werror -Wall -mlongcalls -std=gnu11 -Wl,--gc-sections $(BASE_CFLAGS) $(C_DEFS) $(CFLAGS_MOD) $(COPT)
138141

139-
LDFLAGS = $(CFLAGS) -Wl,-nostdlib -Wl,-Map=$@.map -Wl,-cref -Wl,--undefined=uxTopUsedPriority
140-
LDFLAGS += -L$(BUILD)/esp-idf/esp-idf/esp32s2 \
141-
-Tesp32s2_out.ld \
142-
-L$(BUILD)/esp-idf/esp-idf/esp32s2/ld \
143-
-Tesp32s2.project.ld \
144-
-Lesp-idf/components/esp32s2/ld \
145-
-Tesp32s2.peripherals.ld \
146-
-Lesp-idf/components/esp_rom/esp32s2/ld \
147-
-Tesp32s2.rom.ld \
148-
-Tesp32s2.rom.libgcc.ld \
149-
-Tesp32s2.rom.newlib-data.ld \
150-
-Tesp32s2.rom.newlib-funcs.ld \
151-
-Tesp32s2.rom.spiflash.ld
152-
LIBS := -lgcc -lc -lstdc++
142+
LDFLAGS = $(CFLAGS) -Wl,-nostdlib -Wl,-Map=$@.map -Wl,-cref -Wl,--undefined=uxTopUsedPriority
153143

154-
#
144+
LDFLAGS += -L$(BUILD)/esp-idf/esp-idf/esp32s2 \
145+
-L$(BUILD)/esp-idf/esp-idf/esp32s2/ld \
146+
-Lesp-idf/components/esp32s2/ld \
147+
-Lesp-idf/components/esp_rom/esp32s2/ld \
148+
-Tesp32s2_out.ld \
149+
-Tesp32s2.project.ld \
150+
-Tesp32s2.peripherals.ld \
151+
-Tesp32s2.rom.ld \
152+
-Tesp32s2.rom.api.ld \
153+
-Tesp32s2.rom.libgcc.ld \
154+
-Tesp32s2.rom.newlib-data.ld \
155+
-Tesp32s2.rom.newlib-funcs.ld \
156+
-Tesp32s2.rom.spiflash.ld
157+
158+
LDFLAGS += -Wl,-Bstatic \
159+
-Wl,--no-warn-mismatch \
160+
-Wl,--build-id=none \
161+
-fno-rtti
155162

156-
LDFLAGS += -Wl,-Bstatic \
157-
-Wl,--no-warn-mismatch \
158-
-Wl,--build-id=none \
159-
-fno-rtti
163+
LIBS := -lgcc -lc -lstdc++
160164

161165
# Use toolchain libm if we're not using our own.
162166
ifndef INTERNAL_LIBM
@@ -272,23 +276,19 @@ menuconfig: $(BUILD)/esp-idf/config
272276
# qstr builds include headers so we need to make sure they are up to date
273277
$(HEADER_BUILD)/qstr.split: | $(BUILD)/esp-idf/config/sdkconfig.h
274278

275-
ESP_IDF_COMPONENTS_LINK = freertos log esp_system esp_adc_cal esp32s2 bootloader_support pthread esp_timer vfs spi_flash app_update esp_common esp32s2 heap newlib driver xtensa soc esp_ringbuf esp_wifi esp_event wpa_supplicant mbedtls efuse nvs_flash esp_netif lwip esp-tls
276-
277-
ESP_IDF_COMPONENTS_INCLUDE = driver freertos log soc
278-
279-
INC += $(foreach component, $(ESP_IDF_COMPONENTS_INCLUDE), -isystem esp-idf/components/$(component)/include)
279+
ESP_IDF_COMPONENTS_LINK = app_update bootloader_support driver efuse esp32s2 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 xtensa
280280

281281
ESP_IDF_COMPONENTS_EXPANDED = $(foreach component, $(ESP_IDF_COMPONENTS_LINK), $(BUILD)/esp-idf/esp-idf/$(component)/lib$(component).a)
282282
ESP_IDF_WIFI_COMPONENTS_EXPANDED = $(foreach component, $(ESP_IDF_WIFI_COMPONENTS_LINK), $(BUILD)/esp-idf/esp-idf/$(component)/lib$(component).a)
283283

284284
MBEDTLS_COMPONENTS_LINK = crypto tls x509
285285
MBEDTLS_COMPONENTS_LINK_EXPANDED = $(foreach component, $(MBEDTLS_COMPONENTS_LINK), $(BUILD)/esp-idf/esp-idf/mbedtls/mbedtls/library/libmbed$(component).a)
286286

287-
BINARY_BLOBS = esp-idf/components/xtensa/esp32s2/libhal.a
287+
BINARY_BLOBS = esp-idf/components/xtensa/esp32s2/libxt_hal.a
288288
BINARY_WIFI_BLOBS = libcoexist.a libcore.a libespnow.a libmesh.a libnet80211.a libpp.a librtc.a libsmartconfig.a libphy.a
289289
BINARY_BLOBS += $(addprefix esp-idf/components/esp_wifi/lib/esp32s2/, $(BINARY_WIFI_BLOBS))
290290

291-
ESP_IDF_COMPONENTS_EXPANDED += $(BUILD)/esp-idf/esp-idf/soc/soc/esp32s2/libsoc_esp32s2.a
291+
ESP_IDF_COMPONENTS_EXPANDED += esp-idf/components/xtensa/esp32s2/libxt_hal.a
292292
ESP_AUTOGEN_LD = $(BUILD)/esp-idf/esp-idf/esp32s2/esp32s2_out.ld $(BUILD)/esp-idf/esp-idf/esp32s2/ld/esp32s2.project.ld
293293

294294
FLASH_FLAGS = --flash_mode $(CIRCUITPY_ESP_FLASH_MODE) --flash_freq $(CIRCUITPY_ESP_FLASH_FREQ) --flash_size $(CIRCUITPY_ESP_FLASH_SIZE)
@@ -301,24 +301,42 @@ all: $(BUILD)/firmware.bin $(BUILD)/firmware.uf2
301301
esp-idf-stamp: $(BUILD)/esp-idf/config/sdkconfig.h
302302
$(Q)ninja -C $(BUILD)/esp-idf \
303303
bootloader/bootloader.bin \
304+
esp-idf/app_update/libapp_update.a \
304305
esp-idf/bootloader_support/libbootloader_support.a \
305-
esp-idf/esp-tls/libesp-tls.a \
306+
esp-idf/driver/libdriver.a \
307+
esp-idf/efuse/libefuse.a \
308+
esp-idf/esp32s2/libesp32s2.a \
306309
esp-idf/esp32s2/ld/esp32s2.project.ld \
310+
esp-idf/esp_adc_cal/libesp_adc_cal.a \
311+
esp-idf/esp_common/libesp_common.a \
307312
esp-idf/esp_event/libesp_event.a \
313+
esp-idf/esp_hw_support/libesp_hw_support.a \
308314
esp-idf/esp_netif/libesp_netif.a \
315+
esp-idf/esp_pm/libesp_pm.a \
316+
esp-idf/esp_ringbuf/libesp_ringbuf.a \
317+
esp-idf/esp_rom/libesp_rom.a \
309318
esp-idf/esp_system/libesp_system.a \
319+
esp-idf/esp_timer/libesp_timer.a \
320+
esp-idf/esp-tls/libesp-tls.a \
310321
esp-idf/esp_wifi/libesp_wifi.a \
322+
esp-idf/freertos/libfreertos.a \
323+
esp-idf/hal/libhal.a \
324+
esp-idf/heap/libheap.a \
325+
esp-idf/log/liblog.a \
311326
esp-idf/lwip/liblwip.a \
327+
esp-idf/mbedtls/libmbedtls.a \
328+
esp-idf/newlib/libnewlib.a \
312329
esp-idf/nvs_flash/libnvs_flash.a \
330+
esp-idf/pthread/libpthread.a \
331+
esp-idf/soc/libsoc.a \
332+
esp-idf/spi_flash/libspi_flash.a \
333+
esp-idf/vfs/libvfs.a \
313334
esp-idf/wpa_supplicant/libwpa_supplicant.a \
314-
esp-idf/mbedtls/libmbedtls.a \
315-
esp-idf/freertos/libfreertos.a \
316-
esp-idf/log/liblog.a \
317335
esp-idf/xtensa/libxtensa.a
318336

319337
$(BUILD)/firmware.elf: $(OBJ) | esp-idf-stamp
320338
$(STEPECHO) "LINK $@"
321-
$(Q)$(CC) -o $@ $(LDFLAGS) $^ -Wl,--start-group $(ESP_IDF_COMPONENTS_EXPANDED) $(BINARY_BLOBS) $(MBEDTLS_COMPONENTS_LINK_EXPANDED) build-$(BOARD)/esp-idf/esp-idf/newlib/libnewlib.a -Wl,--end-group -u newlib_include_pthread_impl -Wl,--start-group $(LIBS) -Wl,--end-group build-$(BOARD)/esp-idf/esp-idf/pthread/libpthread.a -u __cxx_fatal_exception
339+
$(Q)$(CC) -o $@ $(LDFLAGS) $^ -Wl,--start-group $(ESP_IDF_COMPONENTS_EXPANDED) $(BINARY_BLOBS) $(MBEDTLS_COMPONENTS_LINK_EXPANDED) $(BUILD)/esp-idf/esp-idf/newlib/libnewlib.a -Wl,--end-group -u newlib_include_pthread_impl -Wl,--start-group $(LIBS) -Wl,--end-group $(BUILD)/esp-idf/esp-idf/pthread/libpthread.a -u __cxx_fatal_exception
322340

323341
$(BUILD)/circuitpython-firmware.bin: $(BUILD)/firmware.elf | tools/build_memory_info.py
324342
$(STEPECHO) "Create $@"
Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
# CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE is not set
2-
# CONFIG_COMPILER_OPTIMIZATION_SIZE is not set
3-
# CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT is not set
4-
# TWAI configuration
5-
#
6-
# CONFIG_TWAI_ISR_IN_IRAM is not set
7-
# end of TWAI configuration
8-
9-
#
101
CONFIG_ESP32S2_SPIRAM_SUPPORT=y
112

123
#
@@ -27,7 +18,6 @@ CONFIG_DEFAULT_PSRAM_CS_IO=26
2718

2819
# CONFIG_SPIRAM_FETCH_INSTRUCTIONS is not set
2920
# CONFIG_SPIRAM_RODATA is not set
30-
# CONFIG_SPIRAM_USE_AHB_DBUS3 is not set
3121
# CONFIG_SPIRAM_SPEED_80M is not set
3222
CONFIG_SPIRAM_SPEED_40M=y
3323
# CONFIG_SPIRAM_SPEED_26M is not set
@@ -41,16 +31,3 @@ CONFIG_SPIRAM_USE_MEMMAP=y
4131
CONFIG_SPIRAM_MEMTEST=y
4232
# CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set
4333
# end of SPI RAM config
44-
45-
# CONFIG_ESP_CONSOLE_UART_NONE is not set
46-
CONFIG_ESP_CONSOLE_UART_TX_GPIO=43
47-
CONFIG_ESP_CONSOLE_UART_RX_GPIO=44
48-
CONFIG_FREERTOS_TASK_FUNCTION_WRAPPER=y
49-
CONFIG_LWIP_TCP_HIGH_SPEED_RETRANSMISSION=y
50-
CONFIG_COMPILER_OPTIMIZATION_LEVEL_DEBUG=y
51-
# CONFIG_COMPILER_OPTIMIZATION_LEVEL_RELEASE is not set
52-
CONFIG_OPTIMIZATION_ASSERTIONS_ENABLED=y
53-
# CONFIG_OPTIMIZATION_ASSERTIONS_SILENT is not set
54-
# CONFIG_CONSOLE_UART_NONE is not set
55-
CONFIG_CONSOLE_UART_TX_GPIO=43
56-
CONFIG_CONSOLE_UART_RX_GPIO=44

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444

4545
#include "esp_sleep.h"
4646

47-
#include "components/soc/soc/esp32s2/include/soc/rtc_cntl_reg.h"
47+
#include "components/soc/esp32s2/include/soc/rtc_cntl_reg.h"
4848
#include "components/driver/include/driver/uart.h"
4949

5050
// Singleton instance of SleepMemory.

ports/esp32s2/common-hal/alarm/pin/PinAlarm.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,16 @@
2727

2828
#include "py/runtime.h"
2929

30+
#include "supervisor/esp_port.h"
3031
#include "shared-bindings/alarm/pin/PinAlarm.h"
31-
#include "shared-bindings/microcontroller/__init__.h"
3232
#include "shared-bindings/microcontroller/Pin.h"
33-
#include "supervisor/esp_port.h"
33+
#include "shared-bindings/microcontroller/__init__.h"
3434

3535
#include "components/driver/include/driver/rtc_io.h"
36-
#include "components/esp32s2/include/esp_sleep.h"
37-
#include "components/freertos/include/freertos/FreeRTOS.h"
38-
#include "components/soc/src/esp32s2/include/hal/gpio_ll.h"
36+
#include "components/esp_system/include/esp_sleep.h"
37+
#include "components/hal/esp32s2/include/hal/gpio_ll.h"
3938
#include "components/xtensa/include/esp_debug_helpers.h"
39+
#include "components/freertos/include/freertos/FreeRTOS.h"
4040

4141
void common_hal_alarm_pin_pinalarm_construct(alarm_pin_pinalarm_obj_t *self, const mcu_pin_obj_t *pin, bool value, bool edge, bool pull) {
4242
if (edge) {

ports/esp32s2/common-hal/analogio/AnalogIn.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
#include "common-hal/microcontroller/Pin.h"
3131

32-
#include "components/soc/include/hal/adc_types.h"
32+
#include "components/hal/include/hal/adc_types.h"
3333
#include "FreeRTOS.h"
3434
#include "freertos/semphr.h"
3535
#include "py/obj.h"

ports/esp32s2/common-hal/busio/I2C.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self,
8888
}
8989
#endif
9090

91-
92-
if (xSemaphoreCreateMutexStatic(&self->semaphore) != &self->semaphore) {
91+
self->xSemaphore = xSemaphoreCreateMutexStatic(&self->xSemaphoreBuffer);
92+
if (self->xSemaphore == NULL) {
9393
mp_raise_RuntimeError(translate("Unable to create lock"));
9494
}
9595
self->sda_pin = sda;
@@ -168,7 +168,7 @@ bool common_hal_busio_i2c_try_lock(busio_i2c_obj_t *self) {
168168
if (self->has_lock) {
169169
return false;
170170
}
171-
self->has_lock = xSemaphoreTake(&self->semaphore, 0) == pdTRUE;
171+
self->has_lock = xSemaphoreTake(self->xSemaphore, 0) == pdTRUE;
172172
return self->has_lock;
173173
}
174174

@@ -177,7 +177,7 @@ bool common_hal_busio_i2c_has_lock(busio_i2c_obj_t *self) {
177177
}
178178

179179
void common_hal_busio_i2c_unlock(busio_i2c_obj_t *self) {
180-
xSemaphoreGive(&self->semaphore);
180+
xSemaphoreGive(self->xSemaphore);
181181
self->has_lock = false;
182182
}
183183

ports/esp32s2/common-hal/busio/I2C.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
#include "common-hal/microcontroller/Pin.h"
3131

32-
#include "components/soc/include/hal/i2c_types.h"
32+
#include "components/hal/include/hal/i2c_types.h"
3333
#include "FreeRTOS.h"
3434
#include "freertos/semphr.h"
3535
#include "py/obj.h"
@@ -39,7 +39,8 @@ typedef struct {
3939
const mcu_pin_obj_t *scl_pin;
4040
const mcu_pin_obj_t *sda_pin;
4141
i2c_port_t i2c_num;
42-
StaticSemaphore_t semaphore;
42+
SemaphoreHandle_t xSemaphore;
43+
StaticSemaphore_t xSemaphoreBuffer;
4344
bool has_lock;
4445
} busio_i2c_obj_t;
4546

0 commit comments

Comments
 (0)