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
|
// bad firmware CRC, don't try and boot
|
||||||
timeout = 0;
|
timeout = 0;
|
||||||
try_boot = false;
|
try_boot = false;
|
||||||
|
led_set(LED_BAD_FW);
|
||||||
}
|
}
|
||||||
#ifndef BOOTLOADER_DEV_LIST
|
#ifndef BOOTLOADER_DEV_LIST
|
||||||
else if (timeout != 0) {
|
else if (timeout != 0) {
|
||||||
|
@ -131,6 +132,7 @@ int main(void)
|
||||||
// bad firmware, don't try and boot
|
// bad firmware, don't try and boot
|
||||||
timeout = 0;
|
timeout = 0;
|
||||||
try_boot = false;
|
try_boot = false;
|
||||||
|
led_set(LED_BAD_FW);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -141,7 +141,7 @@ static virtual_timer_t systick_vt;
|
||||||
#define TIMER_BL_WAIT 0
|
#define TIMER_BL_WAIT 0
|
||||||
#define TIMER_LED 1
|
#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];
|
volatile unsigned timer[NTIMERS];
|
||||||
|
|
||||||
|
@ -176,6 +176,11 @@ static void sys_tick_handler(void *ctx)
|
||||||
led_toggle(LED_BOOTLOADER);
|
led_toggle(LED_BOOTLOADER);
|
||||||
timer[TIMER_LED] = 50;
|
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)
|
static void delay(unsigned msec)
|
||||||
|
@ -183,7 +188,7 @@ static void delay(unsigned msec)
|
||||||
chThdSleep(chTimeMS2I(msec));
|
chThdSleep(chTimeMS2I(msec));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
void
|
||||||
led_set(enum led_state state)
|
led_set(enum led_state state)
|
||||||
{
|
{
|
||||||
led_state = state;
|
led_state = state;
|
||||||
|
@ -201,6 +206,10 @@ led_set(enum led_state state)
|
||||||
/* restart the blink state machine ASAP */
|
/* restart the blink state machine ASAP */
|
||||||
timer[TIMER_LED] = 0;
|
timer[TIMER_LED] = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case LED_BAD_FW:
|
||||||
|
timer[TIMER_LED] = 0;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,6 +247,7 @@ jump_to_app()
|
||||||
const auto ok = check_good_firmware();
|
const auto ok = check_good_firmware();
|
||||||
if (ok != check_fw_result_t::CHECK_FW_OK) {
|
if (ok != check_fw_result_t::CHECK_FW_OK) {
|
||||||
// bad firmware, don't try and boot
|
// bad firmware, don't try and boot
|
||||||
|
led_set(LED_BAD_FW);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -467,7 +477,10 @@ bootloader(unsigned timeout)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* make the LED blink while we are idle */
|
/* 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) {
|
while (true) {
|
||||||
volatile int c;
|
volatile int c;
|
||||||
|
|
|
@ -16,3 +16,6 @@ void bootloader(unsigned timeout);
|
||||||
#define MAX_DES_LENGTH 20
|
#define MAX_DES_LENGTH 20
|
||||||
|
|
||||||
#define arraySize(a) (sizeof((a))/sizeof(((a)[0])))
|
#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