1 #include "bootloader.h"
6 #ifdef STM32_BOOTLOADER_ADDRESS
10 /* This code should be checked whether it runs correctly on platforms */
11 #define SYMVAL(sym) (uint32_t)(((uint8_t *)&(sym)) - ((uint8_t *)0))
12 extern uint32_t __ram0_end__;
14 void bootloader_jump(void) {
15 *((unsigned long *)(SYMVAL(__ram0_end__) - 4)) = 0xDEADBEEF; // set magic flag => reset handler will jump into boot loader
19 #elif defined(STM32F3XX)
20 /* This code should be checked whether it runs correctly on platforms.
21 * It was added for clueboard60 BUT HAS NOT BEEN TESTED.
24 #define SYMVAL(sym) (uint32_t)(((uint8_t *)&(sym)) - ((uint8_t *)0))
25 extern uint32_t __ram0_end__;
27 void bootloader_jump(void) {
28 *((unsigned long *)(SYMVAL(__ram0_end__) - 4)) = 0xDEADBEEF; // set magic flag => reset handler will jump into boot loader
32 #else /* defined(STM32F0XX) */
33 #error Check that the bootloader code works on your platform and add it to bootloader.c!
34 #endif /* defined(STM32F0XX) */
36 #elif defined(KL2x) || defined(K20x) /* STM32_BOOTLOADER_ADDRESS */
39 #if defined(KIIBOHD_BOOTLOADER)
40 /* Kiibohd Bootloader (MCHCK and Infinity KB) */
41 #define SCB_AIRCR_VECTKEY_WRITEMAGIC 0x05FA0000
42 const uint8_t sys_reset_to_loader_magic[] = "\xff\x00\x7fRESET TO LOADER\x7f\x00\xff";
43 void bootloader_jump(void) {
44 __builtin_memcpy((void *)VBAT, (const void *)sys_reset_to_loader_magic, sizeof(sys_reset_to_loader_magic));
46 SCB->AIRCR = SCB_AIRCR_VECTKEY_WRITEMAGIC | SCB_AIRCR_SYSRESETREQ_Msk;
49 #else /* defined(KIIBOHD_BOOTLOADER) */
50 /* Default for Kinetis - expecting an ARM Teensy */
52 void bootloader_jump(void) {
56 #endif /* defined(KIIBOHD_BOOTLOADER) */
58 #else /* neither STM32 nor KINETIS */
60 void bootloader_jump(void) {}