diff --git a/board/early_init.h b/board/early_init.h index ae652aebced..60e6b622e23 100644 --- a/board/early_init.h +++ b/board/early_init.h @@ -6,10 +6,17 @@ extern void *g_pfnVectors; extern uint32_t enter_bootloader_mode; +typedef void (*bootloader_fcn)(void); +typedef bootloader_fcn *bootloader_fcn_ptr; + void jump_to_bootloader(void) { // do enter bootloader enter_bootloader_mode = 0; - void (*bootloader)(void) = (void (*)(void)) (*((uint32_t *)BOOTLOADER_ADDRESS)); + + // retrieve bootloader function pointer that is stored at BOOTLOADER_ADDRESS + bootloader_fcn_ptr bootloader_ptr = (bootloader_fcn_ptr)BOOTLOADER_ADDRESS; + // retrieve actual function address from bootloader pointer + bootloader_fcn bootloader = *bootloader_ptr; // jump to bootloader enable_interrupts();