Skip to content
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

Update idf 5.3.2 #426

Merged
merged 5 commits into from
Jan 21, 2025
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
3 changes: 1 addition & 2 deletions .github/actions/setup_toolchain/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ runs:
if: inputs.toolchain == 'arm-gcc'
uses: carlosperate/arm-none-eabi-gcc-action@v1
with:
# release: '12.3.Rel1'
release: '11.2-2022.02'
release: '13.3.Rel1'

- name: Pull ESP-IDF docker
if: inputs.toolchain == 'esp-idf'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
# ---------------------------------------
# Build ESP
# ---------------------------------------
esp:
espressif:
needs: set-matrix
uses: ./.github/workflows/build_util.yml
secrets: inherit
Expand All @@ -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
25 changes: 24 additions & 1 deletion .idea/cmake.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/tinyusb
Submodule tinyusb updated 1030 files
7 changes: 5 additions & 2 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 All @@ -23,8 +24,10 @@ string(REPLACE ../ "" GIT_SUBMODULE_VERSIONS ${GIT_SUBMODULE_VERSIONS})
string(REPLACE lib/ "" GIT_SUBMODULE_VERSIONS ${GIT_SUBMODULE_VERSIONS})
string(STRIP ${GIT_SUBMODULE_VERSIONS} GIT_SUBMODULE_VERSIONS)

add_compile_definitions(UF2_VERSION_BASE="${GIT_VERSION}")
add_compile_definitions(UF2_VERSION="${GIT_VERSION} - ${GIT_SUBMODULE_VERSIONS}")
add_compile_definitions(
UF2_VERSION_BASE="${GIT_VERSION}"
UF2_VERSION="${GIT_VERSION} - ${GIT_SUBMODULE_VERSIONS}"
)

cmake_print_variables(GIT_VERSION GIT_SUBMODULE_VERSIONS)

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);
}

static usb_phy_handle_t phy_hdl;
void board_dfu_init(void) {
// USB Controller Hal init
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,
.target = USB_PHY_TARGET_INT,
.otg_mode = USB_OTG_MODE_DEVICE,
// https://github.com/hathach/tinyusb/issues/2943#issuecomment-2601888322
// Set speed to undefined (auto-detect) to avoid timinng/racing issue with S3 with host such as macOS
.otg_speed = USB_PHY_SPEED_UNDEFINED,
};
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
25 changes: 0 additions & 25 deletions ports/espressif/components/bootloader/CMakeLists.txt

This file was deleted.

Loading
Loading