Browse Source

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.
sbg
José Roberto de Souza 8 years ago committed by Lorenz Meier
parent
commit
0b9e32ca3e
  1. 22
      src/drivers/boards/aerofc-v1/aerofc_init.c
  2. 2
      src/drivers/boards/aerofc-v1/board_config.h

22
src/drivers/boards/aerofc-v1/aerofc_init.c

@ -115,6 +115,19 @@ extern void led_on(int led); @@ -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 @@ -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) @@ -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 */

2
src/drivers/boards/aerofc-v1/board_config.h

@ -64,6 +64,8 @@ @@ -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
*

Loading…
Cancel
Save