aboutsummaryrefslogtreecommitdiff
path: root/projects/bootloader/bootloader.c
diff options
context:
space:
mode:
authorFredrik Thulin <fredrik@thulin.net>2016-06-08 09:29:45 +0200
committerFredrik Thulin <fredrik@thulin.net>2016-06-08 09:29:45 +0200
commit9abe50042629ac64443738d4f4b66da95b116686 (patch)
tree55cb03618ac1d7c58ab60717e606ca554b190e57 /projects/bootloader/bootloader.c
parent3277ffbfe960da93c6f617005cc619958ed419d8 (diff)
parent8c345a87ef4d72d3aef2af9fc4114599d7ee0e56 (diff)
Merge branch 'master' of git.cryptech.is.:sw/stm32
Diffstat (limited to 'projects/bootloader/bootloader.c')
-rw-r--r--projects/bootloader/bootloader.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/projects/bootloader/bootloader.c b/projects/bootloader/bootloader.c
index ab3c1d9..30cd120 100644
--- a/projects/bootloader/bootloader.c
+++ b/projects/bootloader/bootloader.c
@@ -37,6 +37,8 @@
#include "stm-uart.h"
#include "dfu.h"
+#undef HAL_Delay
+
/* Linker symbols are strange in C. Make regular pointers for sanity. */
__IO uint32_t *dfu_control = &CRYPTECH_DFU_CONTROL;
__IO uint32_t *dfu_firmware = &CRYPTECH_FIRMWARE_START;
@@ -49,16 +51,20 @@ __IO uint32_t *dfu_code_ptr = &CRYPTECH_FIRMWARE_START + 1;
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)
+/* called from Reset_Handler */
+void check_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);
+ /* Check if we've just rebooted in order to jump to the firmware. */
+ if (*dfu_control == HARDWARE_EARLY_DFU_JUMP) {
+ *dfu_control = 0;
+ 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 should_dfu()
@@ -86,12 +92,6 @@ main()
{
int status;
- /* 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();
uart_send_string2(STM_UART_MGMT, (char *) "\r\n\r\nThis is the bootloader speaking...");