Skip to content

Commit 7ba5513

Browse files
microdev1tannewtUnexpectedMaker
committed
update espressif port
- update esp-idf to v4.4 - add esp32s3 support - add analogio on esp32c3 - disable rgbmatrix on all espressif soc Co-authored-by: Scott Shawcroft <[email protected]> Co-authored-by: Seon Rozenblum <[email protected]>
1 parent 387a8a4 commit 7ba5513

File tree

18 files changed

+243
-57
lines changed

18 files changed

+243
-57
lines changed

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@
149149
[submodule "ports/espressif/esp-idf"]
150150
path = ports/espressif/esp-idf
151151
url = https://github.com/espressif/esp-idf.git
152-
branch = release/v4.3
152+
branch = release/v4.4
153153
[submodule "ports/espressif/certificates/nina-fw"]
154154
path = ports/espressif/certificates/nina-fw
155155
url = https://github.com/adafruit/nina-fw.git

ports/espressif/Makefile

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,12 @@ include $(TOP)/supervisor/supervisor.mk
5959
# Include make rules and variables common across CircuitPython builds.
6060
include $(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)
6663
IDF_TARGET_ARCH = riscv
6764
CROSS_COMPILE = riscv32-esp-elf-
65+
else
66+
IDF_TARGET_ARCH = xtensa
67+
CROSS_COMPILE = xtensa-$(IDF_TARGET)-elf-
6868
endif
6969

7070
#######################################
@@ -92,6 +92,7 @@ INC += -I.\
9292
-isystem esp-idf/components/esp_common/include \
9393
-isystem esp-idf/components/esp_event/include \
9494
-isystem esp-idf/components/esp_hw_support/include \
95+
-isystem esp-idf/components/esp_hw_support/include/soc \
9596
-isystem esp-idf/components/esp_netif/include \
9697
-isystem esp-idf/components/esp_pm/include \
9798
-isystem esp-idf/components/esp_ringbuf/include \
@@ -101,6 +102,8 @@ INC += -I.\
101102
-isystem esp-idf/components/esp_wifi/include \
102103
-isystem esp-idf/components/freertos/include \
103104
-isystem esp-idf/components/freertos/include/freertos \
105+
-isystem esp-idf/components/freertos/include/esp_additions \
106+
-isystem esp-idf/components/freertos/include/esp_additions/freertos \
104107
-isystem esp-idf/components/freertos/port/$(IDF_TARGET_ARCH)/include \
105108
-isystem esp-idf/components/hal/include \
106109
-isystem esp-idf/components/hal/$(IDF_TARGET)/include \
@@ -158,12 +161,11 @@ endif
158161

159162
LDFLAGS = $(CFLAGS) -Wl,-nostdlib -Wl,-Map=$@.map -Wl,-cref -Wl,--undefined=uxTopUsedPriority
160163

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+
LDFLAGS += -L$(BUILD)/esp-idf/esp-idf/esp_system/ld \
164165
-Lesp-idf/components/esp_rom/$(IDF_TARGET)/ld \
165-
-T$(IDF_TARGET)_out.ld \
166-
-T$(IDF_TARGET).project.ld \
166+
-Lesp-idf/components/soc/$(IDF_TARGET)/ld \
167+
-Tmemory.ld \
168+
-Tsections.ld \
167169
-T$(IDF_TARGET).peripherals.ld \
168170
-T$(IDF_TARGET).rom.ld \
169171
-T$(IDF_TARGET).rom.api.ld \
@@ -174,10 +176,13 @@ ifeq ($(IDF_TARGET),esp32c3)
174176
LDFLAGS += -Tesp32c3.rom.newlib.ld \
175177
-Tesp32c3.rom.version.ld \
176178
-Tesp32c3.rom.eco3.ld
177-
else
179+
else ifeq ($(IDF_TARGET),esp32s2)
178180
LDFLAGS += -T$(IDF_TARGET).rom.newlib-data.ld \
179181
-T$(IDF_TARGET).rom.newlib-funcs.ld \
180182
-T$(IDF_TARGET).rom.spiflash.ld
183+
else ifeq ($(IDF_TARGET),esp32s3)
184+
LDFLAGS += -Tesp32s3.rom.newlib.ld \
185+
-Tesp32s3.rom.version.ld
181186
endif
182187

183188
LDFLAGS += -Wl,-Bstatic \
@@ -224,10 +229,14 @@ SRC_C += \
224229
peripherals/timer.c \
225230
peripherals/$(IDF_TARGET)/pins.c
226231

227-
ifneq ($(IDF_TARGET),esp32c3)
232+
ifeq ($(IDF_TARGET),esp32s2)
228233
SRC_C += \
229234
cam.c \
230-
i2s_lcd_esp32s2_driver.c \
235+
i2s_lcd_esp32s2_driver.c
236+
endif
237+
238+
ifneq ($(IDF_TARGET),esp32c3)
239+
SRC_C += \
231240
peripherals/pcnt.c \
232241
peripherals/touch.c
233242
endif
@@ -315,20 +324,15 @@ 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
320331
ESP_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

323333
MBEDTLS_COMPONENTS_LINK = crypto tls x509
324334
MBEDTLS_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-
332336
ifeq ($(IDF_TARGET_ARCH),xtensa)
333337
BINARY_BLOBS += esp-idf/components/xtensa/$(IDF_TARGET)/libxt_hal.a
334338
ESP_IDF_COMPONENTS_EXPANDED += esp-idf/components/xtensa/$(IDF_TARGET)/libxt_hal.a
@@ -360,17 +364,18 @@ endif
360364
esp-idf-stamp: $(BUILD)/esp-idf/config/sdkconfig.h
361365
$(Q)ninja -C $(BUILD)/esp-idf \
362366
bootloader/bootloader.bin \
367+
esp-idf/esp_system/__ldgen_output_sections.ld \
363368
esp-idf/app_update/libapp_update.a \
364369
esp-idf/bootloader_support/libbootloader_support.a \
365370
esp-idf/driver/libdriver.a \
366371
esp-idf/efuse/libefuse.a \
367-
esp-idf/$(IDF_TARGET)/lib$(IDF_TARGET).a \
368-
esp-idf/$(IDF_TARGET)/ld/$(IDF_TARGET).project.ld \
369372
esp-idf/esp_adc_cal/libesp_adc_cal.a \
370373
esp-idf/esp_common/libesp_common.a \
371374
esp-idf/esp_event/libesp_event.a \
372375
esp-idf/esp_hw_support/libesp_hw_support.a \
376+
esp-idf/esp_ipc/libesp_ipc.a \
373377
esp-idf/esp_netif/libesp_netif.a \
378+
esp-idf/esp_phy/libesp_phy.a \
374379
esp-idf/esp_pm/libesp_pm.a \
375380
esp-idf/esp_ringbuf/libesp_ringbuf.a \
376381
esp-idf/esp_rom/libesp_rom.a \

ports/espressif/cam.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,13 @@
2121
#include "esp_log.h"
2222
#include "soc/i2s_struct.h"
2323
#include "soc/apb_ctrl_reg.h"
24+
#ifdef CONFIG_IDF_TARGET_ESP32S2
2425
#include "esp32s2/rom/lldesc.h"
2526
#include "esp32s2/rom/cache.h"
27+
#elif defined(CONFIG_IDF_TARGET_ESP32S3)
28+
#include "esp32s3/rom/lldesc.h"
29+
#include "esp32s3/rom/cache.h"
30+
#endif
2631
#include "soc/dport_access.h"
2732
#include "soc/dport_reg.h"
2833
#include "driver/ledc.h"

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@
3232
#include "shared-bindings/microcontroller/Pin.h"
3333
#include "shared-bindings/microcontroller/__init__.h"
3434

35+
#include "esp_sleep.h"
3536
#include "hal/gpio_ll.h"
3637
#include "esp_debug_helpers.h"
3738

3839
#include "components/driver/include/driver/rtc_io.h"
39-
#include "components/esp_system/include/esp_sleep.h"
4040
#include "components/freertos/include/freertos/FreeRTOS.h"
4141

4242
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) {

ports/espressif/common-hal/analogio/AnalogIn.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,13 @@
4040
#define DEFAULT_VREF 1100
4141
#define NO_OF_SAMPLES 2
4242
#define ATTENUATION ADC_ATTEN_DB_11
43+
#ifdef CONFIG_IDF_TARGET_ESP32C3
44+
#define DATA_WIDTH ADC_WIDTH_BIT_12
45+
#elif defined(CONFIG_IDF_TARGET_ESP32S2)
4346
#define DATA_WIDTH ADC_WIDTH_BIT_13
47+
#elif defined(CONFIG_IDF_TARGET_ESP32S3)
48+
#define DATA_WIDTH ADC_WIDTH_BIT_12
49+
#endif
4450

4551
void common_hal_analogio_analogin_construct(analogio_analogin_obj_t *self,
4652
const mcu_pin_obj_t *pin) {

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141

4242
void common_hal_analogio_analogout_construct(analogio_analogout_obj_t *self,
4343
const mcu_pin_obj_t *pin) {
44+
#ifdef CONFIG_IDF_TARGET_ESP32S2
4445
if (pin == &pin_GPIO17) {
4546
self->channel = DAC_CHANNEL_1;
4647
} else if (pin == &pin_GPIO18) {
@@ -49,25 +50,34 @@ void common_hal_analogio_analogout_construct(analogio_analogout_obj_t *self,
4950
mp_raise_ValueError(translate("Invalid DAC pin supplied"));
5051
}
5152
dac_output_enable(self->channel);
53+
#else
54+
mp_raise_NotImplementedError(NULL);
55+
#endif
5256
}
5357

5458
bool common_hal_analogio_analogout_deinited(analogio_analogout_obj_t *self) {
5559
return self->channel == DAC_CHANNEL_MAX;
5660
}
5761

5862
void common_hal_analogio_analogout_deinit(analogio_analogout_obj_t *self) {
63+
#ifdef CONFIG_IDF_TARGET_ESP32S2
5964
dac_output_disable(self->channel);
6065
self->channel = DAC_CHANNEL_MAX;
66+
#endif
6167
}
6268

6369
void common_hal_analogio_analogout_set_value(analogio_analogout_obj_t *self,
6470
uint16_t value) {
71+
#ifdef CONFIG_IDF_TARGET_ESP32S2
6572
uint8_t dac_value = (value * 255) / 65535;
6673
dac_output_enable(self->channel);
6774
dac_output_voltage(self->channel, dac_value);
75+
#endif
6876
}
6977

7078
void analogout_reset(void) {
79+
#ifdef CONFIG_IDF_TARGET_ESP32S2
7180
dac_output_disable(DAC_CHANNEL_1);
7281
dac_output_disable(DAC_CHANNEL_2);
82+
#endif
7383
}

ports/espressif/common-hal/frequencyio/FrequencyIn.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,15 @@ static void IRAM_ATTR timer_interrupt_handler(void *self_in) {
5656
// reset interrupt
5757
timg_dev_t *device = self->timer.group ? &(TIMERG1) : &(TIMERG0);
5858
if (self->timer.idx) {
59-
device->int_clr.t1 = 1;
59+
device->int_clr_timers.t1_int_clr = 1;
6060
} else {
61-
device->int_clr.t0 = 1;
61+
device->int_clr_timers.t0_int_clr = 1;
6262
}
63-
device->hw_timer[self->timer.idx].config.alarm_en = 1;
63+
#ifdef CONFIG_IDF_TARGET_ESP32S2
64+
device->hw_timer[self->timer.idx].config.tx_alarm_en = 1;
65+
#elif defined(CONFIG_IDF_TARGET_ESP32S3)
66+
device->hw_timer[self->timer.idx].config.tn_alarm_en = 1;
67+
#endif
6468
}
6569

6670
static void init_pcnt(frequencyio_frequencyin_obj_t *self) {

ports/espressif/common-hal/microcontroller/Processor.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,15 @@
4343

4444
float common_hal_mcu_processor_get_temperature(void) {
4545
float tsens_out;
46+
#ifdef CONFIG_IDF_TARGET_ESP32S3
47+
mp_raise_NotImplementedError(NULL);
48+
#else
4649
temp_sensor_config_t temp_sensor = TSENS_CONFIG_DEFAULT(); // DEFAULT: range:-10℃ ~ 80℃, error < 1℃.
4750
temp_sensor_set_config(temp_sensor);
4851
temp_sensor_start();
4952
temp_sensor_read_celsius(&tsens_out);
5053
temp_sensor_stop();
54+
#endif
5155
return tsens_out;
5256
}
5357

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,16 @@
4747

4848
#ifdef CONFIG_IDF_TARGET_ESP32C3
4949
#include "esp32c3/rom/rtc.h"
50-
#elif CONFIG_IDF_TARGET_ESP32S2
50+
#elif defined(CONFIG_IDF_TARGET_ESP32S2)
5151
#include "esp32s2/rom/rtc.h"
5252
#include "esp32s2/rom/usb/usb_persist.h"
5353
#include "esp32s2/rom/usb/chip_usb_dw_wrapper.h"
54+
#elif defined(CONFIG_IDF_TARGET_ESP32S3)
55+
#include "esp32s3/rom/rtc.h"
56+
#include "esp32s3/rom/usb/usb_persist.h"
57+
#include "esp32s3/rom/usb/chip_usb_dw_wrapper.h"
5458
#endif
5559

56-
5760
void common_hal_mcu_delay_us(uint32_t delay) {
5861
mp_hal_delay_us(delay);
5962
}

ports/espressif/esp-idf

Submodule esp-idf updated 4939 files

ports/espressif/mpconfigport.mk

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ CIRCUITPY_FRAMEBUFFERIO ?= 1
2626
CIRCUITPY_FREQUENCYIO ?= 1
2727
CIRCUITPY_IMAGECAPTURE ?= 1
2828
CIRCUITPY_I2CPERIPHERAL ?= 1
29-
CIRCUITPY_RGBMATRIX ?= 1
29+
CIRCUITPY_RGBMATRIX ?= 0
3030
CIRCUITPY_ROTARYIO ?= 1
3131
CIRCUITPY_NVM ?= 1
3232
CIRCUITPY_PS2IO ?= 1
@@ -43,17 +43,18 @@ CIRCUITPY_USB = 0
4343
CIRCUITPY_ALARM = 0
4444
CIRCUITPY_COUNTIO = 0
4545
CIRCUITPY_ROTARYIO = 0
46-
CIRCUITPY_ANALOGIO = 0
47-
CIRCUITPY_RGBMATRIX = 0
4846
CIRCUITPY_AUDIOBUSIO = 0
4947
CIRCUITPY_FREQUENCYIO = 0
5048
CIRCUITPY_IMAGECAPTURE = 0
5149
CIRCUITPY_PARALLELDISPLAY = 0
5250
CIRCUITPY_TOUCHIO ?= 1
5351
CIRCUITPY_TOUCHIO_USE_NATIVE = 0
52+
else ifeq ($(IDF_TARGET),esp32s3)
53+
CIRCUITPY_IMAGECAPTURE = 0
54+
CIRCUITPY_PARALLELDISPLAY = 0
5455
endif
5556

56-
# From the ESP32-S2 datasheet:
57+
# From ESP32-S2/S3 Technical Reference Manual:
5758
#
5859
# Endpoint number 0 always present (bi-directional, consisting of EP0 IN and EP0 OUT)
5960
# Six additional endpoints (endpoint numbers 1 to 6), configurable as IN or OUT

ports/espressif/mphalport.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,17 @@
2525
* THE SOFTWARE.
2626
*/
2727

28-
#include <string.h>
29-
3028
#include "py/mphal.h"
31-
#include "py/mpstate.h"
32-
#include "py/gc.h"
33-
34-
#include "esp_debug_helpers.h"
29+
#include "supervisor/cpu.h"
3530

3631
#ifdef CONFIG_IDF_TARGET_ESP32C3
3732
#include "components/esp_rom/include/esp32c3/rom/ets_sys.h"
38-
#elif CONFIG_IDF_TARGET_ESP32S2
33+
#elif defined(CONFIG_IDF_TARGET_ESP32S2)
3934
#include "components/esp_rom/include/esp32s2/rom/ets_sys.h"
35+
#elif defined(CONFIG_IDF_TARGET_ESP32S3)
36+
#include "components/esp_rom/include/esp32s3/rom/ets_sys.h"
4037
#endif
4138

42-
#include "supervisor/cpu.h"
43-
4439
void mp_hal_delay_us(mp_uint_t delay) {
4540
ets_delay_us(delay);
4641
}

0 commit comments

Comments
 (0)