aboutsummaryrefslogtreecommitdiff
path: root/src/modules/systemlib
diff options
context:
space:
mode:
authorpx4dev <px4@purgatory.org>2013-08-03 22:35:18 -0700
committerpx4dev <px4@purgatory.org>2013-08-03 22:35:18 -0700
commite931d3b9cda723d63bf352ca866dc499d8df21f5 (patch)
tree181e4656d32ecacfb4c0b51b8611ce9efce38e4c /src/modules/systemlib
parentfbd5aae8c67ef7695cc31aa3c9d450a3e0ce46cb (diff)
downloadpx4-firmware-e931d3b9cda723d63bf352ca866dc499d8df21f5.tar.gz
px4-firmware-e931d3b9cda723d63bf352ca866dc499d8df21f5.tar.bz2
px4-firmware-e931d3b9cda723d63bf352ca866dc499d8df21f5.zip
Add an option to the systemreset() call and to the reboot command (-b) to reboot into the bootloader.
The system will remain in the bootloader until it's reset, or until an upload is completed.
Diffstat (limited to 'src/modules/systemlib')
-rw-r--r--src/modules/systemlib/systemlib.c12
-rw-r--r--src/modules/systemlib/systemlib.h2
2 files changed, 12 insertions, 2 deletions
diff --git a/src/modules/systemlib/systemlib.c b/src/modules/systemlib/systemlib.c
index 96276b56a..57a751e1c 100644
--- a/src/modules/systemlib/systemlib.c
+++ b/src/modules/systemlib/systemlib.c
@@ -50,9 +50,19 @@
#include <sys/stat.h>
#include <sys/types.h>
+#include <stm32_pwr.h>
+
#include "systemlib.h"
-__EXPORT extern void systemreset(void) {
+void
+systemreset(bool to_bootloader)
+{
+ if (to_bootloader) {
+ stm32_pwr_enablebkp();
+
+ /* XXX wow, this is evil - write a magic number into backup register zero */
+ *(uint32_t *)0x40002850 = 0xb007b007;
+ }
up_systemreset();
}
diff --git a/src/modules/systemlib/systemlib.h b/src/modules/systemlib/systemlib.h
index 77fdfe08a..3728f2067 100644
--- a/src/modules/systemlib/systemlib.h
+++ b/src/modules/systemlib/systemlib.h
@@ -45,7 +45,7 @@
__BEGIN_DECLS
/** Reboots the board */
-__EXPORT void systemreset(void) noreturn_function;
+__EXPORT void systemreset(bool to_bootloader) noreturn_function;
/** Sends SIGUSR1 to all processes */
__EXPORT void killall(void);