Skip to content

Commit

Permalink
Update to IDF 5.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
tannewt committed Mar 21, 2024
1 parent 50c504d commit 25ad46d
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 47 deletions.
2 changes: 1 addition & 1 deletion lib/tinyusb
12 changes: 10 additions & 2 deletions ports/espressif/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ INC += \
-isystem esp-idf/components/esp_adc/include \
-isystem esp-idf/components/esp_adc/$(IDF_TARGET)/include \
-isystem esp-idf/components/esp_app_format/include \
-isystem esp-idf/components/esp_bootloader_format/include \
-isystem esp-idf/components/esp_common/include \
-isystem esp-idf/components/esp_event/include \
-isystem esp-idf/components/esp_hw_support/include \
Expand All @@ -110,12 +111,15 @@ INC += \
-isystem esp-idf/components/esp_system/include \
-isystem esp-idf/components/esp_timer/include \
-isystem esp-idf/components/esp_wifi/include \
-isystem esp-idf/components/freertos/config/include \
-isystem esp-idf/components/freertos/config/include/freertos \
-isystem esp-idf/components/freertos/config/$(IDF_TARGET_ARCH)/include \
-isystem esp-idf/components/freertos/esp_additions/include \
-isystem esp-idf/components/freertos/esp_additions/include/freertos \
-isystem esp-idf/components/freertos/esp_additions/arch/$(IDF_TARGET_ARCH)/include \
-isystem esp-idf/components/freertos/FreeRTOS-Kernel/include \
-isystem esp-idf/components/freertos/FreeRTOS-Kernel/include/freertos \
-isystem esp-idf/components/freertos/FreeRTOS-Kernel/portable/$(IDF_TARGET_ARCH)/include \
-isystem esp-idf/components/freertos/FreeRTOS-Kernel/portable/$(IDF_TARGET_ARCH)/include/freertos \
-isystem esp-idf/components/hal/include \
-isystem esp-idf/components/hal/$(IDF_TARGET)/include \
-isystem esp-idf/components/hal/platform_port/include \
Expand All @@ -134,6 +138,7 @@ INC += \
-isystem esp-idf/components/soc/include \
-isystem esp-idf/components/soc/$(IDF_TARGET)/include \
-isystem esp-idf/components/spi_flash/include \
-isystem esp-idf/components/usb/include \
-isystem esp-idf/components/ulp/ulp_fsm/include \
-isystem esp-idf/components/ulp/ulp_riscv/include \
-isystem esp-idf/components/ulp/ulp_common/include \
Expand Down Expand Up @@ -498,6 +503,9 @@ endif
ifneq ($(CIRCUITPY_PARALLELDISPLAYBUS),0)
ESP_IDF_COMPONENTS_LINK += esp_lcd
endif
ifneq ($(CIRCUITPY_USB),0)
ESP_IDF_COMPONENTS_LINK += usb
endif

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

Expand Down Expand Up @@ -579,7 +587,7 @@ esp-idf-stamp: $(BUILD)/esp-idf/config/sdkconfig.h

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

$(BUILD)/circuitpython-firmware.bin: $(BUILD)/firmware.elf | tools/build_memory_info.py
$(STEPECHO) "Create $@"
Expand Down
6 changes: 3 additions & 3 deletions ports/espressif/common-hal/busio/UART.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,11 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
uart_config.flow_ctrl = UART_HW_FLOWCTRL_CTS;
}

if (receiver_buffer_size <= UART_FIFO_LEN) {
receiver_buffer_size = UART_FIFO_LEN + 8;
if (receiver_buffer_size <= UART_HW_FIFO_LEN(self->uart_num)) {
receiver_buffer_size = UART_HW_FIFO_LEN(self->uart_num) + 8;
}

uart_config.rx_flow_ctrl_thresh = UART_FIFO_LEN - 8;
uart_config.rx_flow_ctrl_thresh = UART_HW_FIFO_LEN(self->uart_num) - 8;
// Install the driver before we change the settings.
if (uart_driver_install(self->uart_num, receiver_buffer_size, 0, 20, &self->event_queue, 0) != ESP_OK ||
uart_set_mode(self->uart_num, mode) != ESP_OK) {
Expand Down
2 changes: 1 addition & 1 deletion ports/espressif/esp-idf
Submodule esp-idf updated 5967 files
28 changes: 18 additions & 10 deletions ports/espressif/mpconfigport.mk
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,19 @@ CIRCUITPY_USB = 0
else ifeq ($(IDF_TARGET),esp32c3)
# Modules
CIRCUITPY_ALARM = 0
CIRCUITPY_AUDIOBUSIO = 0
CIRCUITPY_BLEIO ?= 0
CIRCUITPY_COUNTIO = 0
CIRCUITPY_ESPCAMERA = 0
CIRCUITPY_ESPULP = 0
CIRCUITPY_FREQUENCYIO = 0
CIRCUITPY_MEMORYMAP = 0

# No I80 support from the IDF
CIRCUITPY_PARALLELDISPLAYBUS = 0

# No PCNT peripheral
CIRCUITPY_FREQUENCYIO = 0
CIRCUITPY_COUNTIO = 0
CIRCUITPY_ROTARYIO = 0

CIRCUITPY_TOUCHIO ?= 1
CIRCUITPY_TOUCHIO_USE_NATIVE = 0
# Features
Expand All @@ -74,13 +78,18 @@ CIRCUITPY_ESP_USB_SERIAL_JTAG ?= 1
else ifeq ($(IDF_TARGET),esp32c6)
# Modules
CIRCUITPY_ALARM = 0
CIRCUITPY_AUDIOBUSIO = 0
CIRCUITPY_BLEIO ?= 0
CIRCUITPY_ESPCAMERA = 0
CIRCUITPY_ESPULP = 0
CIRCUITPY_MEMORYMAP = 0
CIRCUITPY_PARALLELDISPLAYBUS = 0
CIRCUITPY_RGBMATRIX = 0

# No space for this
CIRCUITPY_AUDIOBUSIO = 0

# No I80 support from the IDF
CIRCUITPY_PARALLELDISPLAYBUS = 0

CIRCUITPY_TOUCHIO ?= 1
CIRCUITPY_TOUCHIO_USE_NATIVE = 0
# Features
Expand All @@ -90,16 +99,15 @@ CIRCUITPY_ESP_USB_SERIAL_JTAG ?= 1
else ifeq ($(IDF_TARGET),esp32h2)
# Modules
CIRCUITPY_ALARM = 0
# Turn off analogio because calibration is currently supported.
# https://github.com/espressif/esp-idf/issues/11038
CIRCUITPY_ANALOGIO = 0
CIRCUITPY_AUDIOBUSIO = 0
CIRCUITPY_BLEIO ?= 1
CIRCUITPY_ESPCAMERA = 0
CIRCUITPY_ESPULP = 0
CIRCUITPY_MEMORYMAP = 0
CIRCUITPY_PARALLELDISPLAYBUS = 0
CIRCUITPY_RGBMATRIX = 0

# No I80 support from the IDF
CIRCUITPY_PARALLELDISPLAYBUS = 0

CIRCUITPY_TOUCHIO ?= 1
CIRCUITPY_TOUCHIO_USE_NATIVE = 0
CIRCUITPY_HASHLIB_MBEDTLS_ONLY = 0
Expand Down
40 changes: 10 additions & 30 deletions ports/espressif/supervisor/usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
#include "shared/readline/readline.h"

#include "hal/gpio_ll.h"
#include "hal/usb_hal.h"

#include "esp_err.h"
#include "esp_private/usb_phy.h"
#include "soc/usb_periph.h"

#include "driver/gpio.h"
Expand Down Expand Up @@ -60,6 +62,8 @@
StackType_t usb_device_stack[USBD_STACK_SIZE];
StaticTask_t usb_device_taskdef;

static usb_phy_handle_t phy_hdl;

// USB Device Driver task
// This top level thread process all usb events and invoke callbacks
STATIC void usb_device_task(void *param) {
Expand All @@ -76,37 +80,13 @@ STATIC void usb_device_task(void *param) {
}
}

static void configure_pins(usb_hal_context_t *usb) {
/* usb_periph_iopins currently configures USB_OTG as USB Device.
* Introduce additional parameters in usb_hal_context_t when adding support
* for USB Host.
*/
for (const usb_iopin_dsc_t *iopin = usb_periph_iopins; iopin->pin != -1; ++iopin) {
if ((usb->use_external_phy) || (iopin->ext_phy_only == 0)) {
gpio_pad_select_gpio(iopin->pin);
if (iopin->is_output) {
gpio_matrix_out(iopin->pin, iopin->func, false, false);
} else {
gpio_matrix_in(iopin->pin, iopin->func, false);
gpio_pad_input_enable(iopin->pin);
}
gpio_pad_unhold(iopin->pin);
}
}
if (!usb->use_external_phy) {
gpio_set_drive_capability(USBPHY_DP_NUM, GPIO_DRIVE_CAP_3);
gpio_set_drive_capability(USBPHY_DP_NUM, GPIO_DRIVE_CAP_3);
}
}

void init_usb_hardware(void) {
periph_module_reset(PERIPH_USB_MODULE);
periph_module_enable(PERIPH_USB_MODULE);
usb_hal_context_t hal = {
.use_external_phy = false // use built-in PHY
// Configure USB PHY
usb_phy_config_t phy_conf = {
.controller = USB_PHY_CTRL_OTG,
.otg_mode = USB_OTG_MODE_DEVICE,
};
usb_hal_init(&hal);
configure_pins(&hal);
usb_new_phy(&phy_conf, &phy_hdl);

// Pin the USB task to the same core as CircuitPython. This way we leave
// the other core for networking.
Expand Down

0 comments on commit 25ad46d

Please sign in to comment.