Bootload from SD card to sector 0, and jump to sector 24 where new firmware resides

Dependencies:   FatFS mbed

Fork of Panel-Controller-Bootloader by Emma

Files at this revision

API Documentation at this revision

Comitter:
bonchenko
Date:
Wed Apr 22 10:18:55 2015 +0000
Parent:
1:de82ae1cd814
Commit message:
Bootloader from SD card works perfectly. Compiled with offset in EmBlocks, ADE cannot print readings - but its happened without bootloader too. The problem is Emblocks compiler settings

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- 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;
--- a/mbed.bld	Tue Apr 21 09:32:51 2015 +0000
+++ b/mbed.bld	Wed Apr 22 10:18:55 2015 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/031413cf7a89
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/7e07b6fb45cf
\ No newline at end of file