Skip to content

fix espressif latest idf #3519

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,4 @@
url = https://github.com/adafruit/Adafruit_CircuitPython_RFM69.git
[submodule "ports/esp32s2/esp-idf"]
path = ports/esp32s2/esp-idf
url = https://github.com/hierophect/esp-idf.git
url = https://github.com/espressif/esp-idf.git
6 changes: 3 additions & 3 deletions ports/esp32s2/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ menuconfig: $(BUILD)/esp-idf/config
$(HEADER_BUILD)/qstr.i.last: | $(BUILD)/esp-idf/config/sdkconfig.h

# Order here matters
ESP_IDF_COMPONENTS_LINK = freertos log esp_system 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_rom esp-tls
ESP_IDF_COMPONENTS_LINK = freertos log hal esp_system 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_rom esp-tls

ESP_IDF_COMPONENTS_INCLUDE = driver freertos log soc

Expand All @@ -283,11 +283,11 @@ ESP_IDF_WIFI_COMPONENTS_EXPANDED = $(foreach component, $(ESP_IDF_WIFI_COMPONENT
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/xtensa/esp32s2/libhal.a
ESP_IDF_COMPONENTS_EXPANDED += $(BUILD)/esp-idf/esp-idf/soc/soc/esp32s2/libsoc_esp32s2.a 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 Down
2 changes: 1 addition & 1 deletion 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 Down
4 changes: 2 additions & 2 deletions ports/esp32s2/common-hal/busio/SPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
#include "common-hal/microcontroller/Pin.h"

#include "components/driver/include/driver/spi_common_internal.h"
#include "components/soc/include/hal/spi_hal.h"
#include "components/soc/include/hal/spi_types.h"
#include "components/hal/include/hal/spi_hal.h"
#include "components/hal/include/hal/spi_types.h"
#include "py/obj.h"

typedef struct {
Expand Down
2 changes: 1 addition & 1 deletion ports/esp32s2/common-hal/busio/UART.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/uart_types.h"
#include "components/hal/include/hal/uart_types.h"
#include "py/obj.h"

typedef struct {
Expand Down
2 changes: 1 addition & 1 deletion ports/esp32s2/common-hal/digitalio/DigitalInOut.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

#include "components/driver/include/driver/gpio.h"

#include "components/soc/include/hal/gpio_hal.h"
#include "components/hal/include/hal/gpio_hal.h"

void common_hal_digitalio_digitalinout_never_reset(
digitalio_digitalinout_obj_t *self) {
Expand Down
2 changes: 1 addition & 1 deletion ports/esp32s2/common-hal/microcontroller/Pin.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include "py/mphal.h"

#include "components/driver/include/driver/gpio.h"
#include "components/soc/include/hal/gpio_hal.h"
#include "components/hal/include/hal/gpio_hal.h"

#ifdef MICROPY_HW_NEOPIXEL
bool neopixel_in_use;
Expand Down
2 changes: 1 addition & 1 deletion ports/esp32s2/esp-idf
Submodule esp-idf updated 662 files
2 changes: 1 addition & 1 deletion ports/esp32s2/peripherals/pins.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

#include "esp32s2_peripherals_config.h"
#include "esp-idf/config/sdkconfig.h"
#include "components/soc/include/hal/gpio_types.h"
#include "components/hal/include/hal/gpio_types.h"

typedef struct {
PIN_PREFIX_FIELDS
Expand Down
34 changes: 30 additions & 4 deletions ports/esp32s2/supervisor/usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
#include "components/driver/include/driver/periph_ctrl.h"
#include "components/driver/include/driver/gpio.h"
#include "components/esp_rom/include/esp32s2/rom/gpio.h"
#include "components/esp_rom/include/esp_rom_gpio.h"
#include "components/hal/esp32s2/include/hal/gpio_ll.h"

#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
Expand Down Expand Up @@ -68,17 +70,41 @@ 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) ) {
esp_rom_gpio_pad_select_gpio(iopin->pin);
if ( iopin->is_output ) {
esp_rom_gpio_connect_out_signal(iopin->pin, iopin->func, false, false);
}
else {
esp_rom_gpio_connect_in_signal(iopin->pin, iopin->func, false);
if ( (iopin->pin != GPIO_FUNC_IN_LOW) && (iopin->pin != GPIO_FUNC_IN_HIGH) ) {
gpio_ll_input_enable(&GPIO, iopin->pin);
}
}
esp_rom_gpio_pad_unhold(iopin->pin);
}
}
if ( !usb->use_external_phy ) {
gpio_set_drive_capability(USBPHY_DM_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
};
usb_hal_init(&hal);

// Initialize the pin drive strength.
gpio_set_drive_capability(USBPHY_DM_NUM, GPIO_DRIVE_CAP_3);
gpio_set_drive_capability(USBPHY_DP_NUM, GPIO_DRIVE_CAP_3);
configure_pins(&hal);

(void) xTaskCreateStatic(usb_device_task,
"usbd",
Expand Down