mirror of https://github.com/ArduPilot/ardupilot
Tools: add LED notification for bad firmware
This commit is contained in:
parent
40d11540ac
commit
5cd0105971
|
@ -109,6 +109,7 @@ int main(void)
|
|||
// bad firmware CRC, don't try and boot
|
||||
timeout = 0;
|
||||
try_boot = false;
|
||||
led_set(LED_BAD_FW);
|
||||
}
|
||||
#ifndef BOOTLOADER_DEV_LIST
|
||||
else if (timeout != 0) {
|
||||
|
@ -131,6 +132,7 @@ int main(void)
|
|||
// bad firmware, don't try and boot
|
||||
timeout = 0;
|
||||
try_boot = false;
|
||||
led_set(LED_BAD_FW);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -141,7 +141,7 @@ static virtual_timer_t systick_vt;
|
|||
#define TIMER_BL_WAIT 0
|
||||
#define TIMER_LED 1
|
||||
|
||||
static enum led_state {LED_BLINK, LED_ON, LED_OFF} led_state;
|
||||
static enum led_state led_state;
|
||||
|
||||
volatile unsigned timer[NTIMERS];
|
||||
|
||||
|
@ -176,6 +176,11 @@ static void sys_tick_handler(void *ctx)
|
|||
led_toggle(LED_BOOTLOADER);
|
||||
timer[TIMER_LED] = 50;
|
||||
}
|
||||
|
||||
if ((led_state == LED_BAD_FW) && (timer[TIMER_LED] == 0)) {
|
||||
led_toggle(LED_BOOTLOADER);
|
||||
timer[TIMER_LED] = 1000;
|
||||
}
|
||||
}
|
||||
|
||||
static void delay(unsigned msec)
|
||||
|
@ -183,7 +188,7 @@ static void delay(unsigned msec)
|
|||
chThdSleep(chTimeMS2I(msec));
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
led_set(enum led_state state)
|
||||
{
|
||||
led_state = state;
|
||||
|
@ -201,6 +206,10 @@ led_set(enum led_state state)
|
|||
/* restart the blink state machine ASAP */
|
||||
timer[TIMER_LED] = 0;
|
||||
break;
|
||||
|
||||
case LED_BAD_FW:
|
||||
timer[TIMER_LED] = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -238,6 +247,7 @@ jump_to_app()
|
|||
const auto ok = check_good_firmware();
|
||||
if (ok != check_fw_result_t::CHECK_FW_OK) {
|
||||
// bad firmware, don't try and boot
|
||||
led_set(LED_BAD_FW);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
@ -467,7 +477,10 @@ bootloader(unsigned timeout)
|
|||
}
|
||||
|
||||
/* make the LED blink while we are idle */
|
||||
led_set(LED_BLINK);
|
||||
// ensure we don't override BAD FW LED
|
||||
if (led_state != LED_BAD_FW) {
|
||||
led_set(LED_BLINK);
|
||||
}
|
||||
|
||||
while (true) {
|
||||
volatile int c;
|
||||
|
|
|
@ -16,3 +16,6 @@ void bootloader(unsigned timeout);
|
|||
#define MAX_DES_LENGTH 20
|
||||
|
||||
#define arraySize(a) (sizeof((a))/sizeof(((a)[0])))
|
||||
|
||||
enum led_state {LED_BLINK, LED_ON, LED_OFF, LED_BAD_FW};
|
||||
void led_set(enum led_state state);
|
||||
|
|
Loading…
Reference in New Issue