![](/media/cache/profiles/827ccb0eea8a706c4c34a16891f84e7b.jpg.50x50_q85.jpg)
Bootload from SD card to sector 0, and jump to sector 24 where new firmware resides
Fork of Panel-Controller-Bootloader by
Diff: main.cpp
- Revision:
- 2:0fa89ba8f6fe
- Parent:
- 0:c3a652eff606
--- a/main.cpp Tue Apr 21 09:32:51 2015 +0000 +++ b/main.cpp Wed Apr 22 10:18:55 2015 +0000 @@ -1,10 +1,10 @@ /* Includes */ #include <stddef.h> #include "stm32f10x.h" -#include "stm32f10x_usart.h" +#include "stm32f10x_usart.h" #include "main.h" -extern "C" +extern "C" { #include "flash.h" #include "usart.h" @@ -36,13 +36,13 @@ int main(void) { USART_Initialise(); - USART_SendString("Bootloader EMMA\r\n"); + USART_SendString("Bootloader EMMA\r\n"); RCC_Configuration(); NVIC_Configuration(); Timer2_Init(); Timer3_Init(); USART_SendString("Starting\r\n"); - + //If new firmware present on microSD card -> Flash to MCU flashResult = FlashFirmware(); USART_SendString("OK\r\n"); @@ -54,6 +54,7 @@ { USART_SendString("FLASH_OK or NO_FILE or NO_SD\r\n"); /* Test if user code is programmed starting from address "ApplicationAddress" */ + NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x6000); if (((*(__IO uint32_t*)ApplicationAddress) & 0x2FFE0000 ) == 0x20000000) { // Disable Timers @@ -62,6 +63,7 @@ /* Jump to user application */ JumpAddress = *(__IO uint32_t*) (ApplicationAddress + 4); + __disable_irq (); Jump_To_Application = (pFunction) JumpAddress; /* Initialise user application's Stack Pointer */ @@ -138,7 +140,7 @@ } void Timer3_Init(void) -{ +{ // Time base configuration Timer3 clock TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; TIM_TimeBaseStructure.TIM_Period = 10;