Reindentation of loadboot.cpp
This commit is contained in:
+27
-25
@@ -45,8 +45,8 @@
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#ifdef PCBSKY
|
#ifdef PCBSKY
|
||||||
#include "AT91SAM3S4.h"
|
#include "AT91SAM3S4.h"
|
||||||
#endif
|
#endif
|
||||||
@@ -69,10 +69,8 @@ __attribute__ ((section(".bootrodata"), used))
|
|||||||
void _bootStart(void);
|
void _bootStart(void);
|
||||||
|
|
||||||
__attribute__ ((section(".isr_boot_vector"), used))
|
__attribute__ ((section(".isr_boot_vector"), used))
|
||||||
const uint32_t BootVectors[] = {
|
const uint32_t BootVectors[] = { (uint32_t) &_estack,
|
||||||
(uint32_t)&_estack,
|
(uint32_t) (void (*)(void)) ((unsigned long) &_bootStart) };
|
||||||
(uint32_t)(void (*)(void))((unsigned long)&_bootStart)
|
|
||||||
} ;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PCBTARANIS)
|
#if defined(PCBTARANIS)
|
||||||
@@ -87,7 +85,6 @@ const uint8_t BootCode[] = {
|
|||||||
#include "bootloader.lbm"
|
#include "bootloader.lbm"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#if defined(PCBTARANIS)
|
#if defined(PCBTARANIS)
|
||||||
|
|
||||||
__attribute__ ((section(".bootrodata"), used))
|
__attribute__ ((section(".bootrodata"), used))
|
||||||
@@ -101,15 +98,12 @@ void _bootStart()
|
|||||||
GPIOE->PUPDR = 0x00000040;
|
GPIOE->PUPDR = 0x00000040;
|
||||||
|
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
for ( i = 0 ; i < 50000 ; i += 1 )
|
for (i = 0; i < 50000; i += 1) {
|
||||||
{
|
|
||||||
bwdt_reset();
|
bwdt_reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (GPIOE->IDR & 0x00000008 ) == 0 )
|
if ((GPIOE->IDR & 0x00000008) == 0) {
|
||||||
{
|
if ((GPIOC->IDR & 0x00000002) == 0) {
|
||||||
if ( (GPIOC->IDR & 0x00000002 ) == 0 )
|
|
||||||
{
|
|
||||||
// Bootloader needed
|
// Bootloader needed
|
||||||
const uint8_t *src;
|
const uint8_t *src;
|
||||||
uint8_t *dest;
|
uint8_t *dest;
|
||||||
@@ -120,8 +114,7 @@ void _bootStart()
|
|||||||
src = BootCode;
|
src = BootCode;
|
||||||
dest = (uint8_t *) 0x20000000;
|
dest = (uint8_t *) 0x20000000;
|
||||||
|
|
||||||
for ( ; size ; size -= 1 )
|
for (; size; size -= 1) {
|
||||||
{
|
|
||||||
*dest++ = *src++;
|
*dest++ = *src++;
|
||||||
}
|
}
|
||||||
// Could check for a valid copy to RAM here
|
// Could check for a valid copy to RAM here
|
||||||
@@ -135,20 +128,29 @@ void _bootStart()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// run_application() ;
|
// run_application() ;
|
||||||
asm(" mov.w r1, #134217728"); // 0x8000000
|
asm(" mov.w r1, #134217728");
|
||||||
asm(" add.w r1, #32768"); // 0x8000
|
// 0x8000000
|
||||||
|
asm(" add.w r1, #32768");
|
||||||
|
// 0x8000
|
||||||
|
|
||||||
asm(" movw r0, #60680"); // 0xED08
|
asm(" movw r0, #60680");
|
||||||
asm(" movt r0, #57344"); // 0xE000
|
// 0xED08
|
||||||
asm(" str r1, [r0, #0]"); // Set the VTOR
|
asm(" movt r0, #57344");
|
||||||
|
// 0xE000
|
||||||
|
asm(" str r1, [r0, #0]");
|
||||||
|
// Set the VTOR
|
||||||
|
|
||||||
asm("ldr r0, [r1, #0]"); // Stack pointer value
|
asm("ldr r0, [r1, #0]");
|
||||||
asm("msr msp, r0"); // Set it
|
// Stack pointer value
|
||||||
asm("ldr r0, [r1, #4]"); // Reset address
|
asm("msr msp, r0");
|
||||||
|
// Set it
|
||||||
|
asm("ldr r0, [r1, #4]");
|
||||||
|
// Reset address
|
||||||
asm("mov.w r1, #1");
|
asm("mov.w r1, #1");
|
||||||
asm("orr r0, r1"); // Set lsbit
|
asm("orr r0, r1");
|
||||||
asm("bx r0"); // Execute application
|
// Set lsbit
|
||||||
|
asm("bx r0");
|
||||||
|
// Execute application
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user