Skip to content

Commit

Permalink
update esp-idf to v5.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
hathach committed Jan 17, 2025
1 parent ea0963a commit d9c5bd1
Show file tree
Hide file tree
Showing 65 changed files with 53 additions and 41,554 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ jobs:
boards: ${{ toJSON(fromJSON(needs.set-matrix.outputs.json)['espressif'].board) }}
build-system: 'make'
toolchain: 'esp-idf'
toolchain_version: 'v5.1.4'
toolchain_version: 'v5.3.2'

# ---------------------------------------
# Build RISC-V
Expand Down
1 change: 1 addition & 0 deletions ports/espressif/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ set(SDKCONFIG_DEFAULTS ${CMAKE_CURRENT_LIST_DIR}/sdkconfig.defaults ${CMAKE_CURR
set(SDKCONFIG ${CMAKE_BINARY_DIR}/sdkconfig)

include($ENV{IDF_PATH}/tools/cmake/project.cmake)
idf_build_set_property(EXTRA_CMAKE_ARGS -DBOARD=${BOARD}) # Pass BOARD to bootloader

execute_process(COMMAND git describe --dirty --always --tags
OUTPUT_VARIABLE GIT_VERSION)
Expand Down
2 changes: 1 addition & 1 deletion ports/espressif/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

The project is composed of customizing the 2nd stage bootloader from IDF and UF2 factory application as 3rd stage bootloader.

**Note**: IDF is actively developed and change very often, TinyUF2 is developed and tested with IDF v5.1.4. Should you have a problem please try to change your IDF version.
**Note**: IDF is actively developed and change very often, TinyUF2 is developed and tested with IDF v5.3.2. Should you have a problem please try to change your IDF version.

Following boards are supported:

Expand Down
3 changes: 2 additions & 1 deletion ports/espressif/boards/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
idf_component_register(SRCS boards.c board_flash.c ${BOARD_SOURCES}
INCLUDE_DIRS "." "${BOARD}" ${BOARD_INCLUDES} ${TOP}/src
REQUIRES driver esp_timer app_update spi_flash led_strip lcd ssd1306 XPowersLib tinyusb_src)
PRIV_REQUIRES driver usb
REQUIRES esp_timer app_update spi_flash led_strip lcd ssd1306 XPowersLib tinyusb_src)
57 changes: 16 additions & 41 deletions ports/espressif/boards/boards.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@
#include "freertos/semphr.h"

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

#include "esp_private/usb_phy.h"
#include "soc/usb_pins.h"

#include "soc/usb_periph.h"
#include "esp_private/periph_ctrl.h"

Expand Down Expand Up @@ -89,7 +92,6 @@ extern bool board_init_extension();
#endif

extern int main(void);
static void configure_pins(usb_hal_context_t* usb);
static void internal_timer_cb(void* arg);

//--------------------------------------------------------------------+
Expand Down Expand Up @@ -257,16 +259,19 @@ void board_init(void) {
esp_timer_create(&periodic_timer_args, &timer_hdl);
}

void board_dfu_init(void) {
// USB Controller Hal init
periph_module_reset(PERIPH_USB_MODULE);
periph_module_enable(PERIPH_USB_MODULE);
static usb_phy_handle_t phy_hdl;

usb_hal_context_t hal = {
.use_external_phy = false // use built-in PHY
void board_dfu_init(void) {
// Configure USB PHY
usb_phy_config_t phy_conf = {
.controller = USB_PHY_CTRL_OTG,
.target = USB_PHY_TARGET_INT,
.otg_mode = USB_OTG_MODE_DEVICE,
// .otg_speed = (CFG_TUSB_MCU == OPT_MCU_ESP32P4 ? USB_PHY_SPEED_HIGH : USB_PHY_SPEED_FULL),
.otg_speed = USB_PHY_SPEED_FULL,
};
usb_hal_init(&hal);
configure_pins(&hal);

usb_new_phy(&phy_conf, &phy_hdl);
}

void board_reset(void) {
Expand Down Expand Up @@ -345,7 +350,6 @@ void board_timer_stop(void) {

#if CONFIG_IDF_TARGET_ESP32S3
#include "hal/usb_serial_jtag_ll.h"
#include "hal/usb_fsls_phy_ll.h"

static void hw_cdc_reset_handler(void *arg) {
portBASE_TYPE xTaskWoken = 0;
Expand Down Expand Up @@ -389,7 +393,7 @@ static void usb_switch_to_cdc_jtag(void) {
gpio_set_level((gpio_num_t)USBPHY_DP_NUM, 0);

// Initialize CDC+JTAG ISR to listen for BUS_RESET
usb_fsls_phy_ll_int_jtag_enable(&USB_SERIAL_JTAG);
usb_serial_jtag_ll_phy_enable_external(false);
usb_serial_jtag_ll_disable_intr_mask(USB_SERIAL_JTAG_LL_INTR_MASK);
usb_serial_jtag_ll_clr_intsts_mask(USB_SERIAL_JTAG_LL_INTR_MASK);
usb_serial_jtag_ll_ena_intr_mask(USB_SERIAL_JTAG_INTR_BUS_RESET);
Expand Down Expand Up @@ -579,32 +583,3 @@ void dotstar_write(uint8_t const rgb[]) {
}

#endif

//--------------------------------------------------------------------+
// Helper
//--------------------------------------------------------------------+
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_MATRIX_CONST_ZERO_INPUT) && (iopin->pin != GPIO_MATRIX_CONST_ONE_INPUT)) {
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);
}
}
20 changes: 20 additions & 0 deletions ports/espressif/bootloader_components/main/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
idf_component_register(SRCS "bootloader_start.c"
INCLUDE_DIRS "../../boards/${BOARD}"
REQUIRES bootloader bootloader_support hal)

idf_build_get_property(target IDF_TARGET)

# TODO: [ESP32C5] IDF-9197 remove this when beta3 is removed
if(CONFIG_IDF_TARGET_ESP32C5_MP_VERSION)
set(target_folder "esp32c5/mp")
elseif(CONFIG_IDF_TARGET_ESP32C5_BETA3_VERSION)
set(target_folder "esp32c5/beta3")
else()
set(target_folder "${target}")
endif()

# Use the linker script files from the actual bootloader
set(scripts "${IDF_PATH}/components/bootloader/subproject/main/ld/${target_folder}/bootloader.ld"
"${IDF_PATH}/components/bootloader/subproject/main/ld/${target_folder}/bootloader.rom.ld")

target_linker_script(${COMPONENT_LIB} INTERFACE "${scripts}")
Original file line number Diff line number Diff line change
Expand Up @@ -219,14 +219,15 @@ static int selected_boot_partition(const bootloader_state_t *bs) {
#endif

if (boot_index != FACTORY_INDEX) {
if (UF2_DETECTION_DELAY_MS > 0){
#if CONFIG_IDF_TARGET_ESP32S3
// S3 startup with USB JTAG, while delaying here, USB JTAG will be enumerated which can cause confusion when
// switching to OTG in application. Switch to OTG PHY here to avoid this.
SET_PERI_REG_MASK(RTC_CNTL_USB_CONF_REG,
RTC_CNTL_SW_HW_USB_PHY_SEL | RTC_CNTL_SW_USB_PHY_SEL | RTC_CNTL_USB_PAD_ENABLE);
#endif
#if SOC_USB_SERIAL_JTAG_SUPPORTED
// startup with USB JTAG, while delaying here, USB JTAG will be enumerated which can cause confusion when
// switching to OTG in application. Switch to OTG PHY here to avoid this.
uint32_t const rtc_cntl_usb_conf = READ_PERI_REG(RTC_CNTL_USB_CONF_REG);
SET_PERI_REG_MASK(RTC_CNTL_USB_CONF_REG,
RTC_CNTL_SW_HW_USB_PHY_SEL | RTC_CNTL_SW_USB_PHY_SEL | RTC_CNTL_USB_PAD_ENABLE);
#endif

if (UF2_DETECTION_DELAY_MS > 0){
board_led_on();
}

Expand All @@ -245,13 +246,12 @@ static int selected_boot_partition(const bootloader_state_t *bs) {
} while (UF2_DETECTION_DELAY_MS > (esp_log_early_timestamp() - tm_start) );

if (UF2_DETECTION_DELAY_MS > 0){
#if CONFIG_IDF_TARGET_ESP32S3
CLEAR_PERI_REG_MASK(RTC_CNTL_USB_CONF_REG,
RTC_CNTL_SW_HW_USB_PHY_SEL | RTC_CNTL_SW_USB_PHY_SEL | RTC_CNTL_USB_PAD_ENABLE);
#endif

board_led_off();
}

#if SOC_USB_SERIAL_JTAG_SUPPORTED
WRITE_PERI_REG(RTC_CNTL_USB_CONF_REG, rtc_cntl_usb_conf);
#endif
}

#if PIN_DOUBLE_RESET_RC
Expand Down
32 changes: 0 additions & 32 deletions ports/espressif/components/bootloader/CMakeLists.txt

This file was deleted.

Loading

0 comments on commit d9c5bd1

Please sign in to comment.