diff --git a/bootloaders/riotboot_serial/Makefile.ci b/bootloaders/riotboot_serial/Makefile.ci index e2184eae00..f77aecd2a5 100644 --- a/bootloaders/riotboot_serial/Makefile.ci +++ b/bootloaders/riotboot_serial/Makefile.ci @@ -1,3 +1,6 @@ BOARD_INSUFFICIENT_MEMORY := \ + frdm-kw41z \ + pba-d-01-kw2x \ phynode-kw41z \ + usb-kw41z \ # diff --git a/sys/include/riotboot/bootloader_selection.h b/sys/include/riotboot/bootloader_selection.h index 81f089a4e5..52ba313307 100644 --- a/sys/include/riotboot/bootloader_selection.h +++ b/sys/include/riotboot/bootloader_selection.h @@ -68,6 +68,18 @@ extern "C" { #define BTN_BOOTLOADER_INVERTED true #endif +/** @brief LED pin for bootloader indication + * + * This pin (typically connected to a LED) will be toggled while the bootloader is active. + * It can be used to communicate the current bootloader state to the user. + */ +#if !defined(LED_BOOTLOADER_PIN) && defined(LED0_PIN) && !defined(LED_BOOTLOADER_NONE) || DOXYGEN +#define LED_BOOTLOADER_PIN LED0_PIN +#define LED_BOOTLOADER_ON LED0_ON /**< Turn the bootloader LED on */ +#define LED_BOOTLOADER_OFF LED0_OFF /**< Turn the bootloader LED off */ +#define LED_BOOTLOADER_TOGGLE LED0_TOGGLE /**< Toggle the bootloader LED */ +#endif + #ifdef __cplusplus } #endif diff --git a/sys/riotboot/serial.c b/sys/riotboot/serial.c index 454a27ab92..502f204e9d 100644 --- a/sys/riotboot/serial.c +++ b/sys/riotboot/serial.c @@ -69,6 +69,18 @@ static inline bool _boot_pin(void) #endif } +static inline void _boot_led_toggle(void) +{ +#ifdef LED_BOOTLOADER_PIN + static unsigned count = RIOTBOOT_DELAY / 10; + + if (--count == 0) { + count = RIOTBOOT_DELAY / 10; + LED_BOOTLOADER_TOGGLE; + } +#endif +} + /* send 'hello' byte until we get enter bootloader byte or timeout */ static bool _bootdelay(unsigned tries, volatile bool *boot_default) { @@ -88,6 +100,7 @@ static bool _bootdelay(unsigned tries, volatile bool *boot_default) if (_boot_pin()) { return false; } + _boot_led_toggle(); } return *boot_default; @@ -238,6 +251,10 @@ int riotboot_serial_loader(void) #ifdef BTN_BOOTLOADER_PIN gpio_init(BTN_BOOTLOADER_PIN, BTN_BOOTLOADER_MODE); #endif +#ifdef LED_BOOTLOADER_PIN + gpio_init(LED_BOOTLOADER_PIN, GPIO_OUT); + LED_BOOTLOADER_OFF; +#endif uart_init(RIOTBOOT_UART_DEV, RIOTBOOT_UART_BAUDRATE, _uart_rx_cmd, (void *)&reading); @@ -247,6 +264,10 @@ int riotboot_serial_loader(void) return -1; } +#ifdef LED_BOOTLOADER_ON + LED_BOOTLOADER_ON; +#endif + while (1) { /* we can't use mutex in riotboot */