stm32f4-uart-bootloader

Simple UART bootloader for STM32F4 MCU's
git clone git://git.mdnr.space/stm32f4-uart-bootloader
Log | Files | Refs | Submodules | README | LICENSE

bootloader.c (990B)


      1 #include "bl/bl-packet.h"
      2 #include "shared/mem-blocks.h"
      3 #include "bl/update.h"
      4 #include "shared/drv-gpio.h"
      5 #include "shared/drv-rcc.h"
      6 #include "shared/drv-usart-dma.h"
      7 #include "bl/stimer.h"
      8 #include <string.h>
      9 
     10 static void jump_to_app(void) {
     11     typedef void (*void_fn)(void);
     12 
     13     uint32_t *reset_vector_entry = (uint32_t *)(MEM_APP_OFFSET + 4U);
     14     uint32_t *reset_vector = (uint32_t *)(*reset_vector_entry);
     15 #pragma GCC diagnostic push
     16 #pragma GCC diagnostic ignored "-Wpedantic"
     17     void_fn jump_fn = (void_fn)reset_vector;
     18 #pragma GCC diagnostic pop
     19 
     20     jump_fn();
     21 }
     22 
     23 int main(void) {
     24     res_rcc_setup();
     25     stimer_systick_init();
     26     res_gpio_setup();
     27     res_usart_init();
     28     res_usart_dma_gsm_setup();
     29     res_usart_dma_dbg_setup();
     30     usart_enable_idle_interrupt(gsm.port);
     31     usart_disable_rx_interrupt(gsm.port);
     32     usart_enable_idle_interrupt(dbg.port);
     33     usart_disable_rx_interrupt(dbg.port);
     34     packet_init();
     35     update_state_machine();
     36 
     37     jump_to_app();
     38 }