Skip to content

Commit

Permalink
Merge pull request #4195 from askpatrickw/update-idf
Browse files Browse the repository at this point in the history
Update esp-idf to v4.3
  • Loading branch information
tannewt authored Jun 25, 2021
2 parents d67fb85 + e0eecd2 commit 5a4a803
Show file tree
Hide file tree
Showing 21 changed files with 237 additions and 401 deletions.
1 change: 1 addition & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@
[submodule "ports/esp32s2/esp-idf"]
path = ports/esp32s2/esp-idf
url = https://github.com/adafruit/esp-idf.git
branch = circuitpython-v4.3
[submodule "ports/esp32s2/certificates/nina-fw"]
path = ports/esp32s2/certificates/nina-fw
url = https://github.com/adafruit/nina-fw.git
Expand Down
4 changes: 4 additions & 0 deletions locale/circuitpython.pot
Original file line number Diff line number Diff line change
Expand Up @@ -2034,6 +2034,10 @@ msgstr ""
msgid "SPI Re-initialization error"
msgstr ""

#: ports/esp32s2/common-hal/busio/SPI.c
msgid "SPI configuration failed"
msgstr ""

#: ports/raspberrypi/common-hal/busio/SPI.c
msgid "SPI peripheral in use"
msgstr ""
Expand Down
128 changes: 73 additions & 55 deletions ports/esp32s2/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ PORT ?= /dev/tty.SLAB_USBtoUART
BUILD ?= build-$(BOARD)

include ../../py/mkenv.mk

# Board-specific
include boards/$(BOARD)/mpconfigboard.mk

# Port-specific
include mpconfigport.mk

Expand All @@ -64,51 +66,52 @@ CROSS_COMPILE = xtensa-esp32s2-elf-
#######################################

INC += -I.
INC += -I../..
INC += -I$(BUILD)
INC += -I$(BUILD)/genhdr
INC += -I./boards
INC += -I./boards/$(BOARD)
INC += -I./peripherals
INC += -I../..
INC += -I../../lib/mp-readline
INC += -I../../lib/tinyusb/src
INC += -I../../supervisor/shared/usb
INC += -I$(BUILD)
INC += -I$(BUILD)/genhdr
INC += -I$(BUILD)/esp-idf/config

INC += -isystem esp-idf
INC += -isystem esp-idf/components/app_update/include
INC += -isystem esp-idf/components/bootloader_support/include
INC += -isystem esp-idf/components/driver/esp32s2/include
INC += -isystem esp-idf/components/driver/include
INC += -isystem esp-idf/components/freertos/include/freertos
INC += -isystem esp-idf/components/freertos/xtensa/include
INC += -isystem esp-idf/components/esp32s2/include
INC += -isystem esp-idf/components/xtensa/esp32s2/include
INC += -isystem esp-idf/components/esp_common/include
INC += -isystem esp-idf/components/esp_event/include
INC += -isystem esp-idf/components/esp_hw_support/include
INC += -isystem esp-idf/components/esp_netif/include
INC += -isystem esp-idf/components/esp_pm/include
INC += -isystem esp-idf/components/esp_ringbuf/include
INC += -isystem esp-idf/components/esp_rom/include
INC += -isystem esp-idf/components/esp_wifi/include
INC += -isystem esp-idf/components/xtensa/include
INC += -isystem esp-idf/components/esp_system/include
INC += -isystem esp-idf/components/esp_timer/include
INC += -isystem esp-idf/components/mbedtls/mbedtls/include
INC += -isystem esp-idf/components/mbedtls/port/include/
INC += -isystem esp-idf/components/newlib/platform_include
INC += -isystem esp-idf/components/lwip/lwip/src/include
INC += -isystem esp-idf/components/lwip/port/esp32/include
INC += -isystem esp-idf/components/lwip/include/apps/sntp
INC += -isystem esp-idf/components/esp_wifi/include
INC += -isystem esp-idf/components/freertos/include
INC += -isystem esp-idf/components/freertos/include/freertos
INC += -isystem esp-idf/components/freertos/port/xtensa/include
INC += -isystem esp-idf/components/hal/include
INC += -isystem esp-idf/components/hal/esp32s2/include
INC += -isystem esp-idf/components/heap/include
INC += -isystem esp-idf/components/log/include/
INC += -isystem esp-idf/components/driver/esp32s2/include
INC += -isystem esp-idf/components/lwip/lwip/src/include
INC += -isystem esp-idf/components/lwip/port/esp32/include
INC += -isystem esp-idf/components/lwip/include/apps/sntp
INC += -isystem esp-idf/components/mbedtls/mbedtls/include
INC += -isystem esp-idf/components/mbedtls/port/include/
INC += -isystem esp-idf/components/newlib/platform_include
INC += -isystem esp-idf/components/nvs_flash/include
INC += -isystem esp-idf/components/soc/include
INC += -isystem esp-idf/components/soc/src/esp32s2/include
INC += -isystem esp-idf/components/soc/soc/include
INC += -isystem esp-idf/components/soc/soc/esp32s2/include
INC += -isystem esp-idf/components/heap/include
INC += -isystem esp-idf/components/esp_system/include
INC += -isystem esp-idf/components/soc/esp32s2/include
INC += -isystem esp-idf/components/spi_flash/include
INC += -isystem esp-idf/components/nvs_flash/include
INC += -isystem esp-idf/components/app_update/include
INC += -isystem esp-idf/components/bootloader_support/include
INC += -I$(BUILD)/esp-idf/config
INC += -isystem esp-idf/components/xtensa/esp32s2/include
INC += -isystem esp-idf/components/xtensa/include

CFLAGS += -DHAVE_CONFIG_H \
-DMBEDTLS_CONFIG_FILE=\"mbedtls/esp_config.h\" \
Expand Down Expand Up @@ -136,27 +139,28 @@ CFLAGS += $(OPTIMIZATION_FLAGS)

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

LDFLAGS = $(CFLAGS) -Wl,-nostdlib -Wl,-Map=$@.map -Wl,-cref -Wl,--undefined=uxTopUsedPriority
LDFLAGS += -L$(BUILD)/esp-idf/esp-idf/esp32s2 \
-Tesp32s2_out.ld \
-L$(BUILD)/esp-idf/esp-idf/esp32s2/ld \
-Tesp32s2.project.ld \
-Lesp-idf/components/esp32s2/ld \
-Tesp32s2.peripherals.ld \
-Lesp-idf/components/esp_rom/esp32s2/ld \
-Tesp32s2.rom.ld \
-Tesp32s2.rom.libgcc.ld \
-Tesp32s2.rom.newlib-data.ld \
-Tesp32s2.rom.newlib-funcs.ld \
-Tesp32s2.rom.spiflash.ld
LIBS := -lgcc -lc -lstdc++
LDFLAGS = $(CFLAGS) -Wl,-nostdlib -Wl,-Map=$@.map -Wl,-cref -Wl,--undefined=uxTopUsedPriority

#
LDFLAGS += -L$(BUILD)/esp-idf/esp-idf/esp32s2 \
-L$(BUILD)/esp-idf/esp-idf/esp32s2/ld \
-Lesp-idf/components/esp32s2/ld \
-Lesp-idf/components/esp_rom/esp32s2/ld \
-Tesp32s2_out.ld \
-Tesp32s2.project.ld \
-Tesp32s2.peripherals.ld \
-Tesp32s2.rom.ld \
-Tesp32s2.rom.api.ld \
-Tesp32s2.rom.libgcc.ld \
-Tesp32s2.rom.newlib-data.ld \
-Tesp32s2.rom.newlib-funcs.ld \
-Tesp32s2.rom.spiflash.ld

LDFLAGS += -Wl,-Bstatic \
-Wl,--no-warn-mismatch \
-Wl,--build-id=none \
-fno-rtti

LDFLAGS += -Wl,-Bstatic \
-Wl,--no-warn-mismatch \
-Wl,--build-id=none \
-fno-rtti
LIBS := -lgcc -lc -lstdc++

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

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

ESP_IDF_COMPONENTS_INCLUDE = driver freertos log soc

INC += $(foreach component, $(ESP_IDF_COMPONENTS_INCLUDE), -isystem esp-idf/components/$(component)/include)
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

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

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

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

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

FLASH_FLAGS = --flash_mode $(CIRCUITPY_ESP_FLASH_MODE) --flash_freq $(CIRCUITPY_ESP_FLASH_FREQ) --flash_size $(CIRCUITPY_ESP_FLASH_SIZE)
Expand All @@ -301,24 +301,42 @@ all: $(BUILD)/firmware.bin $(BUILD)/firmware.uf2
esp-idf-stamp: $(BUILD)/esp-idf/config/sdkconfig.h
$(Q)ninja -C $(BUILD)/esp-idf \
bootloader/bootloader.bin \
esp-idf/app_update/libapp_update.a \
esp-idf/bootloader_support/libbootloader_support.a \
esp-idf/esp-tls/libesp-tls.a \
esp-idf/driver/libdriver.a \
esp-idf/efuse/libefuse.a \
esp-idf/esp32s2/libesp32s2.a \
esp-idf/esp32s2/ld/esp32s2.project.ld \
esp-idf/esp_adc_cal/libesp_adc_cal.a \
esp-idf/esp_common/libesp_common.a \
esp-idf/esp_event/libesp_event.a \
esp-idf/esp_hw_support/libesp_hw_support.a \
esp-idf/esp_netif/libesp_netif.a \
esp-idf/esp_pm/libesp_pm.a \
esp-idf/esp_ringbuf/libesp_ringbuf.a \
esp-idf/esp_rom/libesp_rom.a \
esp-idf/esp_system/libesp_system.a \
esp-idf/esp_timer/libesp_timer.a \
esp-idf/esp-tls/libesp-tls.a \
esp-idf/esp_wifi/libesp_wifi.a \
esp-idf/freertos/libfreertos.a \
esp-idf/hal/libhal.a \
esp-idf/heap/libheap.a \
esp-idf/log/liblog.a \
esp-idf/lwip/liblwip.a \
esp-idf/mbedtls/libmbedtls.a \
esp-idf/newlib/libnewlib.a \
esp-idf/nvs_flash/libnvs_flash.a \
esp-idf/pthread/libpthread.a \
esp-idf/soc/libsoc.a \
esp-idf/spi_flash/libspi_flash.a \
esp-idf/vfs/libvfs.a \
esp-idf/wpa_supplicant/libwpa_supplicant.a \
esp-idf/mbedtls/libmbedtls.a \
esp-idf/freertos/libfreertos.a \
esp-idf/log/liblog.a \
esp-idf/xtensa/libxtensa.a

$(BUILD)/firmware.elf: $(OBJ) | esp-idf-stamp
$(STEPECHO) "LINK $@"
$(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
$(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

$(BUILD)/circuitpython-firmware.bin: $(BUILD)/firmware.elf | tools/build_memory_info.py
$(STEPECHO) "Create $@"
Expand Down
23 changes: 0 additions & 23 deletions ports/esp32s2/boards/espressif_kaluga_1.3/sdkconfig
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
# CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE is not set
# CONFIG_COMPILER_OPTIMIZATION_SIZE is not set
# CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT is not set
# TWAI configuration
#
# CONFIG_TWAI_ISR_IN_IRAM is not set
# end of TWAI configuration

#
CONFIG_ESP32S2_SPIRAM_SUPPORT=y

#
Expand All @@ -27,7 +18,6 @@ CONFIG_DEFAULT_PSRAM_CS_IO=26

# CONFIG_SPIRAM_FETCH_INSTRUCTIONS is not set
# CONFIG_SPIRAM_RODATA is not set
# CONFIG_SPIRAM_USE_AHB_DBUS3 is not set
# CONFIG_SPIRAM_SPEED_80M is not set
CONFIG_SPIRAM_SPEED_40M=y
# CONFIG_SPIRAM_SPEED_26M is not set
Expand All @@ -41,16 +31,3 @@ CONFIG_SPIRAM_USE_MEMMAP=y
CONFIG_SPIRAM_MEMTEST=y
# CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set
# end of SPI RAM config

# CONFIG_ESP_CONSOLE_UART_NONE is not set
CONFIG_ESP_CONSOLE_UART_TX_GPIO=43
CONFIG_ESP_CONSOLE_UART_RX_GPIO=44
CONFIG_FREERTOS_TASK_FUNCTION_WRAPPER=y
CONFIG_LWIP_TCP_HIGH_SPEED_RETRANSMISSION=y
CONFIG_COMPILER_OPTIMIZATION_LEVEL_DEBUG=y
# CONFIG_COMPILER_OPTIMIZATION_LEVEL_RELEASE is not set
CONFIG_OPTIMIZATION_ASSERTIONS_ENABLED=y
# CONFIG_OPTIMIZATION_ASSERTIONS_SILENT is not set
# CONFIG_CONSOLE_UART_NONE is not set
CONFIG_CONSOLE_UART_TX_GPIO=43
CONFIG_CONSOLE_UART_RX_GPIO=44
2 changes: 1 addition & 1 deletion ports/esp32s2/common-hal/alarm/__init__.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

#include "esp_sleep.h"

#include "components/soc/soc/esp32s2/include/soc/rtc_cntl_reg.h"
#include "components/soc/esp32s2/include/soc/rtc_cntl_reg.h"
#include "components/driver/include/driver/uart.h"

// Singleton instance of SleepMemory.
Expand Down
10 changes: 5 additions & 5 deletions ports/esp32s2/common-hal/alarm/pin/PinAlarm.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@

#include "py/runtime.h"

#include "supervisor/esp_port.h"
#include "shared-bindings/alarm/pin/PinAlarm.h"
#include "shared-bindings/microcontroller/__init__.h"
#include "shared-bindings/microcontroller/Pin.h"
#include "supervisor/esp_port.h"
#include "shared-bindings/microcontroller/__init__.h"

#include "components/driver/include/driver/rtc_io.h"
#include "components/esp32s2/include/esp_sleep.h"
#include "components/freertos/include/freertos/FreeRTOS.h"
#include "components/soc/src/esp32s2/include/hal/gpio_ll.h"
#include "components/esp_system/include/esp_sleep.h"
#include "components/hal/esp32s2/include/hal/gpio_ll.h"
#include "components/xtensa/include/esp_debug_helpers.h"
#include "components/freertos/include/freertos/FreeRTOS.h"

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) {
if (edge) {
Expand Down
2 changes: 1 addition & 1 deletion ports/esp32s2/common-hal/analogio/AnalogIn.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

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

#include "components/soc/include/hal/adc_types.h"
#include "components/hal/include/hal/adc_types.h"
#include "FreeRTOS.h"
#include "freertos/semphr.h"
#include "py/obj.h"
Expand Down
8 changes: 4 additions & 4 deletions ports/esp32s2/common-hal/busio/I2C.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self,
}
#endif


if (xSemaphoreCreateMutexStatic(&self->semaphore) != &self->semaphore) {
self->xSemaphore = xSemaphoreCreateMutexStatic(&self->xSemaphoreBuffer);
if (self->xSemaphore == NULL) {
mp_raise_RuntimeError(translate("Unable to create lock"));
}
self->sda_pin = sda;
Expand Down Expand Up @@ -168,7 +168,7 @@ bool common_hal_busio_i2c_try_lock(busio_i2c_obj_t *self) {
if (self->has_lock) {
return false;
}
self->has_lock = xSemaphoreTake(&self->semaphore, 0) == pdTRUE;
self->has_lock = xSemaphoreTake(self->xSemaphore, 0) == pdTRUE;
return self->has_lock;
}

Expand All @@ -177,7 +177,7 @@ bool common_hal_busio_i2c_has_lock(busio_i2c_obj_t *self) {
}

void common_hal_busio_i2c_unlock(busio_i2c_obj_t *self) {
xSemaphoreGive(&self->semaphore);
xSemaphoreGive(self->xSemaphore);
self->has_lock = false;
}

Expand Down
5 changes: 3 additions & 2 deletions ports/esp32s2/common-hal/busio/I2C.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

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

#include "components/soc/include/hal/i2c_types.h"
#include "components/hal/include/hal/i2c_types.h"
#include "FreeRTOS.h"
#include "freertos/semphr.h"
#include "py/obj.h"
Expand All @@ -39,7 +39,8 @@ typedef struct {
const mcu_pin_obj_t *scl_pin;
const mcu_pin_obj_t *sda_pin;
i2c_port_t i2c_num;
StaticSemaphore_t semaphore;
SemaphoreHandle_t xSemaphore;
StaticSemaphore_t xSemaphoreBuffer;
bool has_lock;
} busio_i2c_obj_t;

Expand Down
Loading

0 comments on commit 5a4a803

Please sign in to comment.