diff options
author | Fredrik Thulin <fredrik@thulin.net> | 2016-05-27 21:58:55 +0200 |
---|---|---|
committer | Fredrik Thulin <fredrik@thulin.net> | 2016-05-27 21:58:55 +0200 |
commit | 13d9bfb4bf1cfbb3d723c919763bc460c193ed3b (patch) | |
tree | 2454a8313689ce2ed92644bc4a449b7fa039f997 /projects/cli-test/cli-test.c | |
parent | 0009ba29bbb3d7ff911b343bafb9a005114ea2d8 (diff) | |
parent | 854a8ba169d64a16f5466c0cac9e1aeeff50659d (diff) |
Merge branch 'ft-dfu-code-loading'
Diffstat (limited to 'projects/cli-test/cli-test.c')
-rw-r--r-- | projects/cli-test/cli-test.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/projects/cli-test/cli-test.c b/projects/cli-test/cli-test.c index 41d7365..84c268b 100644 --- a/projects/cli-test/cli-test.c +++ b/projects/cli-test/cli-test.c @@ -39,6 +39,7 @@ #include "stm-keystore.h" #include "stm-sdram.h" #include "mgmt-cli.h" +#include "mgmt-dfu.h" #include "test_sdram.h" #include <string.h> @@ -396,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"); @@ -404,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); @@ -420,6 +442,7 @@ main() configure_cli_fpga(&cli); configure_cli_test(&cli); configure_cli_misc(&cli); + configure_cli_dfu(&cli); led_off(LED_RED); led_on(LED_GREEN); |