aboutsummaryrefslogtreecommitdiff
path: root/projects/cli-test/cli-test.c
diff options
context:
space:
mode:
Diffstat (limited to 'projects/cli-test/cli-test.c')
-rw-r--r--projects/cli-test/cli-test.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/projects/cli-test/cli-test.c b/projects/cli-test/cli-test.c
index 30623a4..84c268b 100644
--- a/projects/cli-test/cli-test.c
+++ b/projects/cli-test/cli-test.c
@@ -397,7 +397,7 @@ void configure_cli_test(struct cli_def *cli)
cli_command_node(test, sdram, "Run SDRAM tests");
}
-void configure_cli_misc(struct cli_def *cli)
+static void configure_cli_misc(struct cli_def *cli)
{
/* filetransfer */
cli_command_root_node(filetransfer, "Test file transfering");
@@ -405,11 +405,32 @@ void configure_cli_misc(struct cli_def *cli)
cli_command_root_node(reboot, "Reboot the STM32");
}
+typedef void (*pFunction)(void);
+
+/* This is it's own function to make it more convenient to set a breakpoint at it in gdb */
+void do_early_dfu_jump(void)
+{
+ pFunction loaded_app = (pFunction) *dfu_code_ptr;
+ /* Set the stack pointer to the correct one for the firmware */
+ __set_MSP(*dfu_msp_ptr);
+ /* Set the Vector Table Offset Register */
+ SCB->VTOR = (uint32_t) dfu_firmware;
+ loaded_app();
+ while (1);
+}
+
+
int
main()
{
static struct cli_def cli;
+ /* Check if we've just rebooted in order to jump to the firmware. */
+ if (*dfu_control == HARDWARE_EARLY_DFU_JUMP) {
+ *dfu_control = 0;
+ do_early_dfu_jump();
+ }
+
stm_init();
led_on(LED_RED);