diff --git a/ports/espressif/components/bootloader/subproject/main/bootloader_start.c b/ports/espressif/components/bootloader/subproject/main/bootloader_start.c index 9976f6cd..20773f09 100644 --- a/ports/espressif/components/bootloader/subproject/main/bootloader_start.c +++ b/ports/espressif/components/bootloader/subproject/main/bootloader_start.c @@ -232,7 +232,24 @@ static int selected_boot_partition(const bootloader_state_t *bs) { esp_rom_gpio_pad_select_gpio(PIN_BUTTON_UF2); PIN_INPUT_ENABLE(GPIO_PIN_MUX_REG[PIN_BUTTON_UF2]); - esp_rom_gpio_pad_pullup_only(PIN_BUTTON_UF2); + #ifdef BUTTON_ACTIVE_HIGH + gpio_pad_pulldown(PIN_BUTTON_UF2); + #else + gpio_pad_pullup(PIN_BUTTON_UF2); + #endif + for(volatile uint16_t i = 0; i < 100; i++){} //Add small delay +#ifndef FASTBOOT + uint32_t tm_start = esp_log_early_timestamp(); + while (UF2_DETECTION_DELAY_MS > (esp_log_early_timestamp() - tm_start) ) + { +#endif + #ifdef BUTTON_ACTIVE_HIGH + if ( gpio_ll_get_level(&GPIO, PIN_BUTTON_UF2) == 1 ) + #else + if ( gpio_ll_get_level(&GPIO, PIN_BUTTON_UF2) == 0 ) + #endif + { + ESP_LOGI(TAG, "Detect GPIO %d active to enter UF2 bootloader", PIN_BUTTON_UF2); // run the GPIO detection at least once even if UF2_DETECTION_DELAY_MS is set to zero uint32_t tm_start = esp_log_early_timestamp(); diff --git a/workspace.code-workspace b/workspace.code-workspace index 6ae52b01..3f0c6736 100644 --- a/workspace.code-workspace +++ b/workspace.code-workspace @@ -8,7 +8,7 @@ "terminal.integrated.shell.windows" : "cmd.exe", "terminal.integrated.shellArgs.windows" : [ "/k", - "lib\\esp-idf\\export.bat" + "C:\\Espressif\\frameworks\\esp-idf-v4.4\\export.bat" ], "files.associations": { "*.mk": "makefile",