aerofc: Reboot board when force bootloader pin is set

This can help "unbrick" AeroFC when a bad firmware is loaded
and it keeps rebooting or it spinning in some loop.

No need to request to stay in booloader as it will stay
in bootloader because the pin is set.
This commit is contained in:
José Roberto de Souza 2017-07-24 14:15:44 -07:00 committed by Lorenz Meier
parent 0109154c43
commit 0b9e32ca3e
2 changed files with 22 additions and 2 deletions

View File

@ -115,6 +115,19 @@ extern void led_on(int led);
extern void led_off(int led);
__END_DECLS
/****************************************************************************
* Private Functions
****************************************************************************/
static int _bootloader_force_pin_callback(int irq, void *context)
{
if (stm32_gpioread(GPIO_FORCE_BOOTLOADER)) {
board_reset(0);
}
return 0;
}
/****************************************************************************
* Protected Functions
****************************************************************************/
@ -128,15 +141,17 @@ __END_DECLS
*
* Description:
* All STM32 architectures must provide the following entry point. This entry point
* is called early in the intitialization -- after all memory has been configured
* is called early in the initialization -- after all memory has been configured
* and mapped but before any devices have been initialized.
*
************************************************************************************/
__EXPORT void stm32_boardinitialize(void)
{
/* configure LEDs */
stm32_configgpio(GPIO_FORCE_BOOTLOADER);
_bootloader_force_pin_callback(0, NULL);
/* configure LEDs */
board_autoled_initialize();
/* turn sensors on */
@ -159,6 +174,9 @@ __EXPORT int board_app_initialize(uintptr_t arg)
{
int result;
/* the interruption subsystem is not initialized when stm32_boardinitialize() is called */
stm32_gpiosetevent(GPIO_FORCE_BOOTLOADER, true, false, false, _bootloader_force_pin_callback);
#if defined(CONFIG_HAVE_CXX) && defined(CONFIG_HAVE_CXXINITIALIZE)
/* run C++ ctors before we go any further */

View File

@ -64,6 +64,8 @@
#define GPIO_VDD_5V_SENSORS_EN (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|GPIO_OUTPUT_SET|GPIO_PORTD|GPIO_PIN13)
#define GPIO_FORCE_BOOTLOADER (GPIO_INPUT|GPIO_PULLDOWN|GPIO_SPEED_50MHz|GPIO_PORTA|GPIO_PIN11|GPIO_EXTI)
/*
* I2C busses
*