Skip to content

esp32: Remove support for ESP-IDF <5.2 #16128

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 3 commits into from
Dec 10, 2024
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
10 changes: 0 additions & 10 deletions ports/esp32/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
# needs to be duplicated for out-of-tree builds, and can easily get out of date.
cmake_minimum_required(VERSION 3.12)

# Retrieve IDF version
include($ENV{IDF_PATH}/tools/cmake/version.cmake)
set(IDF_VERSION "${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}.${IDF_VERSION_PATCH}")

# Set the board if it's not already set.
if(NOT MICROPY_BOARD)
set(MICROPY_BOARD ESP32_GENERIC)
Expand All @@ -35,12 +31,6 @@ set(SDKCONFIG ${CMAKE_BINARY_DIR}/sdkconfig)
# Save the manifest file set from the cmake command line.
set(MICROPY_USER_FROZEN_MANIFEST ${MICROPY_FROZEN_MANIFEST})

# Specific options for IDF v5.2 and later
set(SDKCONFIG_IDF_VERSION_SPECIFIC "")
if (IDF_VERSION VERSION_GREATER_EQUAL "5.2.0")
set(SDKCONFIG_IDF_VERSION_SPECIFIC boards/sdkconfig.idf52)
endif()

# Include board config; this is expected to set (among other options):
# - SDKCONFIG_DEFAULTS
# - IDF_TARGET
Expand Down
2 changes: 1 addition & 1 deletion ports/esp32/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ manage the ESP32 microcontroller, as well as a way to manage the required
build environment and toolchains needed to build the firmware.

The ESP-IDF changes quickly and MicroPython only supports certain versions.
Currently MicroPython supports v5.0.4, v5.0.5, v5.1.2, v5.2.0, v5.2.2, v5.3.
Currently MicroPython supports v5.2, v5.2.2, and v5.3.

To install the ESP-IDF the full instructions can be found at the
[Espressif Getting Started guide](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/index.html#installation-step-by-step).
Expand Down
1 change: 0 additions & 1 deletion ports/esp32/boards/ARDUINO_NANO_ESP32/mpconfigboard.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ set(IDF_TARGET esp32s3)

set(SDKCONFIG_DEFAULTS
boards/sdkconfig.base
${SDKCONFIG_IDF_VERSION_SPECIFIC}
boards/sdkconfig.usb
boards/sdkconfig.ble
boards/sdkconfig.240mhz
Expand Down
1 change: 0 additions & 1 deletion ports/esp32/boards/ESP32_GENERIC/mpconfigboard.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
set(SDKCONFIG_DEFAULTS
boards/sdkconfig.base
${SDKCONFIG_IDF_VERSION_SPECIFIC}
boards/sdkconfig.ble
)
1 change: 0 additions & 1 deletion ports/esp32/boards/ESP32_GENERIC_C3/mpconfigboard.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ set(IDF_TARGET esp32c3)

set(SDKCONFIG_DEFAULTS
boards/sdkconfig.base
${SDKCONFIG_IDF_VERSION_SPECIFIC}
boards/sdkconfig.ble
boards/ESP32_GENERIC_C3/sdkconfig.c3usb
)
1 change: 0 additions & 1 deletion ports/esp32/boards/ESP32_GENERIC_C6/mpconfigboard.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ set(IDF_TARGET esp32c6)

set(SDKCONFIG_DEFAULTS
boards/sdkconfig.base
${SDKCONFIG_IDF_VERSION_SPECIFIC}
boards/sdkconfig.c6
boards/sdkconfig.ble
)
1 change: 0 additions & 1 deletion ports/esp32/boards/ESP32_GENERIC_S2/mpconfigboard.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ set(IDF_TARGET esp32s2)

set(SDKCONFIG_DEFAULTS
boards/sdkconfig.base
${SDKCONFIG_IDF_VERSION_SPECIFIC}
boards/sdkconfig.usb
boards/sdkconfig.spiram_sx
)
1 change: 0 additions & 1 deletion ports/esp32/boards/ESP32_GENERIC_S3/mpconfigboard.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ set(IDF_TARGET esp32s3)

set(SDKCONFIG_DEFAULTS
boards/sdkconfig.base
${SDKCONFIG_IDF_VERSION_SPECIFIC}
boards/sdkconfig.usb
boards/sdkconfig.ble
boards/sdkconfig.spiram_sx
Expand Down
1 change: 0 additions & 1 deletion ports/esp32/boards/LILYGO_TTGO_LORA32/mpconfigboard.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
set(SDKCONFIG_DEFAULTS
boards/sdkconfig.base
${SDKCONFIG_IDF_VERSION_SPECIFIC}
boards/sdkconfig.ble
)

Expand Down
1 change: 0 additions & 1 deletion ports/esp32/boards/LOLIN_C3_MINI/mpconfigboard.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ set(IDF_TARGET esp32c3)

set(SDKCONFIG_DEFAULTS
boards/sdkconfig.base
${SDKCONFIG_IDF_VERSION_SPECIFIC}
boards/sdkconfig.ble
boards/LOLIN_C3_MINI/sdkconfig.board
)
Expand Down
1 change: 0 additions & 1 deletion ports/esp32/boards/LOLIN_S2_MINI/mpconfigboard.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ set(IDF_TARGET esp32s2)

set(SDKCONFIG_DEFAULTS
boards/sdkconfig.base
${SDKCONFIG_IDF_VERSION_SPECIFIC}
boards/sdkconfig.spiram_sx
boards/sdkconfig.usb
)
Expand Down
1 change: 0 additions & 1 deletion ports/esp32/boards/LOLIN_S2_PICO/mpconfigboard.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ set(IDF_TARGET esp32s2)

set(SDKCONFIG_DEFAULTS
boards/sdkconfig.base
${SDKCONFIG_IDF_VERSION_SPECIFIC}
boards/sdkconfig.spiram_sx
boards/sdkconfig.usb
)
Expand Down
1 change: 0 additions & 1 deletion ports/esp32/boards/M5STACK_ATOM/mpconfigboard.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
set(SDKCONFIG_DEFAULTS
boards/sdkconfig.base
${SDKCONFIG_IDF_VERSION_SPECIFIC}
boards/sdkconfig.ble
boards/sdkconfig.240mhz
boards/M5STACK_ATOM/sdkconfig.board
Expand Down
1 change: 0 additions & 1 deletion ports/esp32/boards/M5STACK_NANOC6/mpconfigboard.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ set(IDF_TARGET esp32c6)

set(SDKCONFIG_DEFAULTS
boards/sdkconfig.base
${SDKCONFIG_IDF_VERSION_SPECIFIC}
boards/sdkconfig.c6
boards/sdkconfig.ble
)
1 change: 0 additions & 1 deletion ports/esp32/boards/OLIMEX_ESP32_EVB/mpconfigboard.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
set(SDKCONFIG_DEFAULTS
boards/sdkconfig.base
${SDKCONFIG_IDF_VERSION_SPECIFIC}
boards/sdkconfig.ble
boards/OLIMEX_ESP32_EVB/sdkconfig.board
)
1 change: 0 additions & 1 deletion ports/esp32/boards/OLIMEX_ESP32_POE/mpconfigboard.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
set(SDKCONFIG_DEFAULTS
boards/sdkconfig.base
${SDKCONFIG_IDF_VERSION_SPECIFIC}
boards/sdkconfig.ble
boards/OLIMEX_ESP32_POE/sdkconfig.board
)
1 change: 0 additions & 1 deletion ports/esp32/boards/SIL_WESP32/mpconfigboard.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
set(SDKCONFIG_DEFAULTS
boards/sdkconfig.base
${SDKCONFIG_IDF_VERSION_SPECIFIC}
boards/sdkconfig.ble
boards/sdkconfig.240mhz
boards/SIL_WESP32/sdkconfig.board
Expand Down
1 change: 0 additions & 1 deletion ports/esp32/boards/UM_FEATHERS2/mpconfigboard.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
set(IDF_TARGET esp32s2)
set(SDKCONFIG_DEFAULTS
boards/sdkconfig.base
${SDKCONFIG_IDF_VERSION_SPECIFIC}
boards/sdkconfig.spiram_sx
boards/sdkconfig.usb
boards/UM_FEATHERS2/sdkconfig.board
Expand Down
1 change: 0 additions & 1 deletion ports/esp32/boards/UM_FEATHERS2NEO/mpconfigboard.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
set(IDF_TARGET esp32s2)
set(SDKCONFIG_DEFAULTS
boards/sdkconfig.base
${SDKCONFIG_IDF_VERSION_SPECIFIC}
boards/sdkconfig.spiram_sx
boards/sdkconfig.usb
boards/UM_FEATHERS2NEO/sdkconfig.board
Expand Down
1 change: 0 additions & 1 deletion ports/esp32/boards/UM_FEATHERS3/mpconfigboard.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ set(IDF_TARGET esp32s3)

set(SDKCONFIG_DEFAULTS
boards/sdkconfig.base
${SDKCONFIG_IDF_VERSION_SPECIFIC}
boards/sdkconfig.usb
boards/sdkconfig.ble
boards/sdkconfig.240mhz
Expand Down
1 change: 0 additions & 1 deletion ports/esp32/boards/UM_FEATHERS3NEO/mpconfigboard.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ set(IDF_TARGET esp32s3)

set(SDKCONFIG_DEFAULTS
boards/sdkconfig.base
${SDKCONFIG_IDF_VERSION_SPECIFIC}
boards/sdkconfig.usb
boards/sdkconfig.ble
boards/sdkconfig.240mhz
Expand Down
1 change: 0 additions & 1 deletion ports/esp32/boards/UM_NANOS3/mpconfigboard.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ set(IDF_TARGET esp32s3)

set(SDKCONFIG_DEFAULTS
boards/sdkconfig.base
${SDKCONFIG_IDF_VERSION_SPECIFIC}
boards/sdkconfig.usb
boards/sdkconfig.ble
boards/sdkconfig.240mhz
Expand Down
1 change: 0 additions & 1 deletion ports/esp32/boards/UM_OMGS3/mpconfigboard.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ set(IDF_TARGET esp32s3)

set(SDKCONFIG_DEFAULTS
boards/sdkconfig.base
${SDKCONFIG_IDF_VERSION_SPECIFIC}
boards/sdkconfig.usb
boards/sdkconfig.ble
boards/sdkconfig.240mhz
Expand Down
1 change: 0 additions & 1 deletion ports/esp32/boards/UM_PROS3/mpconfigboard.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ set(IDF_TARGET esp32s3)

set(SDKCONFIG_DEFAULTS
boards/sdkconfig.base
${SDKCONFIG_IDF_VERSION_SPECIFIC}
boards/sdkconfig.usb
boards/sdkconfig.ble
boards/sdkconfig.240mhz
Expand Down
1 change: 0 additions & 1 deletion ports/esp32/boards/UM_RGBTOUCH_MINI/mpconfigboard.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ set(IDF_TARGET esp32s3)

set(SDKCONFIG_DEFAULTS
boards/sdkconfig.base
${SDKCONFIG_IDF_VERSION_SPECIFIC}
boards/sdkconfig.usb
boards/sdkconfig.ble
boards/sdkconfig.240mhz
Expand Down
1 change: 0 additions & 1 deletion ports/esp32/boards/UM_TINYC6/mpconfigboard.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ set(IDF_TARGET esp32c6)

set(SDKCONFIG_DEFAULTS
boards/sdkconfig.base
${SDKCONFIG_IDF_VERSION_SPECIFIC}
boards/sdkconfig.c6
boards/sdkconfig.ble
boards/UM_TINYC6/sdkconfig.board
Expand Down
1 change: 0 additions & 1 deletion ports/esp32/boards/UM_TINYPICO/mpconfigboard.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
set(SDKCONFIG_DEFAULTS
boards/sdkconfig.base
${SDKCONFIG_IDF_VERSION_SPECIFIC}
boards/sdkconfig.ble
boards/sdkconfig.240mhz
boards/sdkconfig.spiram
Expand Down
1 change: 0 additions & 1 deletion ports/esp32/boards/UM_TINYS2/mpconfigboard.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
set(IDF_TARGET esp32s2)
set(SDKCONFIG_DEFAULTS
boards/sdkconfig.base
${SDKCONFIG_IDF_VERSION_SPECIFIC}
boards/sdkconfig.spiram_sx
boards/sdkconfig.usb
boards/UM_TINYS2/sdkconfig.board
Expand Down
1 change: 0 additions & 1 deletion ports/esp32/boards/UM_TINYS3/mpconfigboard.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ set(IDF_TARGET esp32s3)

set(SDKCONFIG_DEFAULTS
boards/sdkconfig.base
${SDKCONFIG_IDF_VERSION_SPECIFIC}
boards/sdkconfig.usb
boards/sdkconfig.ble
boards/sdkconfig.240mhz
Expand Down
1 change: 0 additions & 1 deletion ports/esp32/boards/UM_TINYWATCHS3/mpconfigboard.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ set(IDF_TARGET esp32s3)

set(SDKCONFIG_DEFAULTS
boards/sdkconfig.base
${SDKCONFIG_IDF_VERSION_SPECIFIC}
boards/sdkconfig.usb
boards/sdkconfig.ble
boards/sdkconfig.240mhz
Expand Down
3 changes: 2 additions & 1 deletion ports/esp32/boards/sdkconfig.base
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ CONFIG_ESP_SYSTEM_MEMPROT_FEATURE=n
# FreeRTOS
CONFIG_FREERTOS_THREAD_LOCAL_STORAGE_POINTERS=2
CONFIG_FREERTOS_SUPPORT_STATIC_ALLOCATION=y
CONFIG_FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP=y
CONFIG_FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP=n
CONFIG_FREERTOS_TASK_PRE_DELETION_HOOK=y

# UDP
CONFIG_LWIP_PPP_SUPPORT=y
Expand Down
2 changes: 0 additions & 2 deletions ports/esp32/boards/sdkconfig.idf52

This file was deleted.

27 changes: 0 additions & 27 deletions ports/esp32/machine_dac.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,13 @@
#if MICROPY_PY_MACHINE_DAC

#include "driver/gpio.h"
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 0)
#include "driver/dac_oneshot.h"
#else
#include "driver/dac.h"
#define DAC_CHAN_0 DAC_CHANNEL_1
#define DAC_CHAN_1 DAC_CHANNEL_2
#endif

typedef struct _mdac_obj_t {
mp_obj_base_t base;
gpio_num_t gpio_id;
dac_channel_t dac_id;
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 0)
dac_oneshot_handle_t dac_oneshot_handle;
#endif
} mdac_obj_t;

static mdac_obj_t mdac_obj[] = {
Expand Down Expand Up @@ -77,21 +69,10 @@ static mp_obj_t mdac_make_new(const mp_obj_type_t *type, size_t n_args, size_t n
mp_raise_ValueError(MP_ERROR_TEXT("invalid Pin for DAC"));
}

#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 0)
dac_oneshot_config_t dac_oneshot_config = {.chan_id = self->dac_id};
check_esp_err(dac_oneshot_new_channel(&dac_oneshot_config, (dac_oneshot_handle_t *)&self->dac_oneshot_handle));
check_esp_err(dac_oneshot_output_voltage(self->dac_oneshot_handle, 0));
return MP_OBJ_FROM_PTR(self);
#else
esp_err_t err = dac_output_enable(self->dac_id);
if (err == ESP_OK) {
err = dac_output_voltage(self->dac_id, 0);
}
if (err == ESP_OK) {
return MP_OBJ_FROM_PTR(self);
}
mp_raise_ValueError(MP_ERROR_TEXT("parameter error"));
#endif
}

static void mdac_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
Expand All @@ -106,16 +87,8 @@ static mp_obj_t mdac_write(mp_obj_t self_in, mp_obj_t value_in) {
mp_raise_ValueError(MP_ERROR_TEXT("value out of range"));
}

#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 0)
check_esp_err(dac_oneshot_output_voltage(self->dac_oneshot_handle, value));
return mp_const_none;
#else
esp_err_t err = dac_output_voltage(self->dac_id, value);
if (err == ESP_OK) {
return mp_const_none;
}
mp_raise_ValueError(MP_ERROR_TEXT("parameter error"));
#endif
}
MP_DEFINE_CONST_FUN_OBJ_2(mdac_write_obj, mdac_write);

Expand Down
43 changes: 0 additions & 43 deletions ports/esp32/machine_pwm.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,39 +211,6 @@ static void configure_channel(machine_pwm_obj_t *self) {
}
}

// Temporary workaround for ledc_find_suitable_duty_resolution function only being added in IDF V5.2
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 2, 0)
static uint32_t ledc_find_suitable_duty_resolution(uint32_t src_clk_freq, uint32_t timer_freq) {
// This implementation is based on the one used in Micropython v1.23

// Find the highest bit resolution for the requested frequency
unsigned int freq = src_clk_freq;

int divider = (freq + timer_freq / 2) / timer_freq; // rounded
if (divider == 0) {
divider = 1;
}
float f = (float)freq / divider; // actual frequency
if (f <= 1.0) {
f = 1.0;
}
freq = (unsigned int)roundf((float)freq / f);

unsigned int res = 0;
for (; freq > 1; freq >>= 1) {
++res;
}
if (res == 0) {
res = 1;
} else if (res > HIGHEST_PWM_RES) {
// Limit resolution to HIGHEST_PWM_RES to match units of our duty
res = HIGHEST_PWM_RES;
}

return res;
}
#endif

static void set_freq(machine_pwm_obj_t *self, unsigned int freq, ledc_timer_config_t *timer) {
esp_err_t err;
if (freq != timer->freq_hz) {
Expand All @@ -265,20 +232,10 @@ static void set_freq(machine_pwm_obj_t *self, unsigned int freq, ledc_timer_conf
}
#endif
uint32_t src_clk_freq = 0;
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1, 0)
err = esp_clk_tree_src_get_freq_hz(timer->clk_cfg, ESP_CLK_TREE_SRC_FREQ_PRECISION_CACHED, &src_clk_freq);
if (err != ESP_OK) {
mp_raise_msg_varg(&mp_type_ValueError, MP_ERROR_TEXT("unable to query source clock frequency %d"), (int)timer->clk_cfg);
}
#else
// Simplified fallback logic for IDF V5.0.x, for targets with APB only.
src_clk_freq = APB_CLK_FREQ; // 80 MHz
#if SOC_LEDC_SUPPORT_REF_TICK
if (timer->clk_cfg == LEDC_USE_REF_TICK) {
src_clk_freq = REF_CLK_FREQ; // 1 MHz
}
#endif // SOC_LEDC_SUPPORT_REF_TICK
#endif // ESP_IDF_VERSION

timer->duty_resolution = ledc_find_suitable_duty_resolution(src_clk_freq, timer->freq_hz);

Expand Down
4 changes: 0 additions & 4 deletions ports/esp32/machine_uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -399,11 +399,7 @@ static void mp_machine_uart_init_helper(machine_uart_obj_t *self, size_t n_args,
}
self->flowcontrol = args[ARG_flow].u_int;
}
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 2, 0)
uint8_t uart_fifo_len = UART_HW_FIFO_LEN(self->uart_num);
#else
uint8_t uart_fifo_len = UART_FIFO_LEN;
#endif
check_esp_err(uart_set_hw_flow_ctrl(self->uart_num, self->flowcontrol, uart_fifo_len - uart_fifo_len / 4));
}

Expand Down
Loading
Loading