diff options
Diffstat (limited to 'projects/bootloader/bootloader.c')
-rw-r--r-- | projects/bootloader/bootloader.c | 30 |
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..."); |