From ad44fd660fe9845bed5b475f62be855baf3c35c7 Mon Sep 17 00:00:00 2001 From: sukuwc Date: Mon, 19 Oct 2026 14:47:02 +0200 Subject: [PATCH 1/2] espressif: fix bootloader build when UF2_DETECTION_DELAY_MS is 0 The detection loop compared the delay macro with an unsigned elapsed time: `UF2_DETECTION_DELAY_MS > (esp_log_early_timestamp() - tm_start)`. With the macro set to 0, as the intechstudio_grid and intechstudio_knot boards do, that is `0 > unsigned`, which the ESP-IDF v6.1 toolchain rejects: bootloader_start.c:246:45: error: comparison of unsigned expression in '< 0' is always false [-Werror=type-limits] Compare against a variable, so a zero delay still runs the detection once and every other value behaves as before. Co-Authored-By: Claude Sonnet 5.5 --- ports/espressif/bootloader_components/main/bootloader_start.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ports/espressif/bootloader_components/main/bootloader_start.c b/ports/espressif/bootloader_components/main/bootloader_start.c index c17921960..7d76aa78e 100644 --- a/ports/espressif/bootloader_components/main/bootloader_start.c +++ b/ports/espressif/bootloader_components/main/bootloader_start.c @@ -236,6 +236,7 @@ static int selected_boot_partition(const bootloader_state_t *bs) { esp_rom_gpio_pad_pullup_only(PIN_BUTTON_UF2); // run the GPIO detection at least once even if UF2_DETECTION_DELAY_MS is set to zero + uint32_t const detection_delay_ms = UF2_DETECTION_DELAY_MS; uint32_t tm_start = esp_log_early_timestamp(); do { if ( gpio_ll_get_level(&GPIO, PIN_BUTTON_UF2) == 0 ) { @@ -243,7 +244,7 @@ static int selected_boot_partition(const bootloader_state_t *bs) { boot_index = FACTORY_INDEX; break; } - } while (UF2_DETECTION_DELAY_MS > (esp_log_early_timestamp() - tm_start) ); + } while ((esp_log_early_timestamp() - tm_start) < detection_delay_ms); if (UF2_DETECTION_DELAY_MS > 0){ board_led_off(); From cfaac180f29205d7f7a07ac0db8a8a9bf07a3b73 Mon Sep 17 00:00:00 2001 From: sukuwc Date: Mon, 19 Oct 2026 14:50:44 +0200 Subject: [PATCH 2/2] espressif: keep the original operand order in the detection loop The variable alone fixes the type-limits error, flipping the comparison was not needed. Restore `delay > elapsed` so the change to the loop is just the macro replaced by the variable. Co-Authored-By: Claude Sonnet 5.5 --- ports/espressif/bootloader_components/main/bootloader_start.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/espressif/bootloader_components/main/bootloader_start.c b/ports/espressif/bootloader_components/main/bootloader_start.c index 7d76aa78e..210f5ab48 100644 --- a/ports/espressif/bootloader_components/main/bootloader_start.c +++ b/ports/espressif/bootloader_components/main/bootloader_start.c @@ -244,7 +244,7 @@ static int selected_boot_partition(const bootloader_state_t *bs) { boot_index = FACTORY_INDEX; break; } - } while ((esp_log_early_timestamp() - tm_start) < detection_delay_ms); + } while (detection_delay_ms > (esp_log_early_timestamp() - tm_start) ); if (UF2_DETECTION_DELAY_MS > 0){ board_led_off();