Keyboard firmwares for Atmel AVR and Cortex-M
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

bootloader.c 864B

123456789101112131415161718192021222324252627282930313233
  1. #include "bootloader.h"
  2. #include "ch.h"
  3. #include "hal.h"
  4. #ifdef STM32_BOOTLOADER_ADDRESS
  5. /* STM32 */
  6. #if defined(STM32F0XX)
  7. /* This code should be checked whether it runs correctly on platforms */
  8. #define SYMVAL(sym) (uint32_t)(((uint8_t *)&(sym)) - ((uint8_t *)0))
  9. extern uint32_t __ram0_end__;
  10. void bootloader_jump(void) {
  11. *((unsigned long *)(SYMVAL(__ram0_end__) - 4)) = 0xDEADBEEF; // set magic flag => reset handler will jump into boot loader
  12. NVIC_SystemReset();
  13. }
  14. #else /* defined(STM32F0XX) */
  15. #error Check that the bootloader code works on your platform and add it to bootloader.c!
  16. #endif /* defined(STM32F0XX) */
  17. #elif defined(KL2x) || defined(K20x) /* STM32_BOOTLOADER_ADDRESS */
  18. /* Kinetis */
  19. void bootloader_jump(void) {
  20. chThdSleepMilliseconds(100);
  21. __BKPT(0);
  22. }
  23. #else /* neither STM32 nor KINETIS */
  24. void bootloader_jump(void) {}
  25. #endif