Mike's bootloader sources + added as option, for Taranis only for now (not as clean as it could be, bootloader is always built even if not selected - didn't find how to nest ifs in makefile :\ ) (Issue #546)
This commit is contained in:
+24
-3
@@ -250,6 +250,10 @@ GVARS = NO
|
||||
# Values = NO, READONLY, NOMENUS
|
||||
MENUS_LOCK == NO
|
||||
|
||||
# Include bootloader, for now only for Taranis
|
||||
# Values = YES, NO
|
||||
BOOTLOADER = YES
|
||||
|
||||
#------- END BUILD OPTIONS ---------------------------
|
||||
|
||||
# Define programs and commands.
|
||||
@@ -257,6 +261,7 @@ SHELL = sh
|
||||
IMG2LBM = -python ../util/img2lbm.py
|
||||
TRANSLATE = -python ../util/translate.py
|
||||
SVNREV = $(shell sh -c "svnversion | egrep -o '[[:digit:]]+[[:alpha:]]*$$'")
|
||||
BIN2LBM = -python ../util/bin2lbm.py
|
||||
|
||||
SRC =
|
||||
CPPSRC =
|
||||
@@ -593,7 +598,11 @@ ifeq ($(PCB), TARANIS)
|
||||
else
|
||||
CPPDEFS = -DREV4
|
||||
endif
|
||||
LDSCRIPT = targets/taranis/stm32_flash.ld
|
||||
ifeq ($(BOOTLOADER), YES)
|
||||
LDSCRIPT = targets/taranis/stm32_flash_bl.ld
|
||||
else
|
||||
LDSCRIPT = targets/taranis/stm32_flash.ld
|
||||
endif
|
||||
TRGT = arm-none-eabi-
|
||||
MCU = cortex-m3
|
||||
OPT = 2
|
||||
@@ -614,7 +623,6 @@ ifeq ($(PCB), TARANIS)
|
||||
CPPSRC += audio_arm.cpp
|
||||
CPPSRC += targets/taranis/pwr_driver.cpp targets/taranis/pulses_driver.cpp targets/taranis/keys_driver.cpp targets/taranis/adc_driver.cpp targets/taranis/trainer_driver.cpp targets/taranis/audio_driver.cpp targets/taranis/delays.cpp targets/taranis/uart_driver.cpp targets/taranis/sport_driver.cpp
|
||||
CPPSRC += bmp.cpp gui/view_channels.cpp gui/view_about.cpp gui/view_text.cpp
|
||||
CPPSRC += loadboot.cpp
|
||||
SRC += targets/taranis/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/CMSIS/Device/ST/STM32F2xx/Source/Templates/system_stm32f2xx.c
|
||||
SRC += targets/taranis/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/src/misc.c
|
||||
SRC += targets/taranis/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_gpio.c
|
||||
@@ -664,6 +672,11 @@ ifeq ($(PCB), TARANIS)
|
||||
CPPSRC += protocols/hubsan.cpp
|
||||
CPPSRC += targets/taranis/a7105_driver.cpp
|
||||
endif
|
||||
|
||||
ifeq ($(BOOTLOADER), YES)
|
||||
CPPDEFS += -DBOOTLOADER
|
||||
CPPSRC += loadboot.cpp
|
||||
endif
|
||||
endif
|
||||
|
||||
CC = $(TRGT)gcc
|
||||
@@ -1044,9 +1057,15 @@ all: begin gccversion sizebefore build sizeafter end
|
||||
ifeq ($(ARCH), AVR)
|
||||
build: stamp_header tra lbm allsrc.cpp elf remallsrc hex
|
||||
else
|
||||
build: stamp_header tra lbm allsrc.cpp elf remallsrc bin
|
||||
build: stamp_header tra lbm bootloader allsrc.cpp elf remallsrc bin
|
||||
endif
|
||||
|
||||
# build bootloader
|
||||
.PHONY bootloader:
|
||||
@echo "Building bootloader..."
|
||||
$(MAKE) -C ../bootloader PCB=$(PCB)
|
||||
$(BIN2LBM) bootloader.lbm ../bootloader/bootloader_ramBoot.bin
|
||||
|
||||
tra: translations/cz.h translations/de.h translations/es.h translations/fr.h translations/it.h translations/pl.h translations/pt.h translations/se.h
|
||||
lbm: fonts bitmaps/sticks.lbm
|
||||
|
||||
@@ -1305,6 +1324,8 @@ clean_list :
|
||||
$(REMOVE) *.lst
|
||||
$(REMOVE) allsrc.cpp
|
||||
$(REMOVE) stamp-opentx.h
|
||||
$(REMOVE) `find . -name "*.lbm"`
|
||||
$(MAKE) -C ../bootloader clean
|
||||
|
||||
#### Install
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+27
-36
@@ -47,28 +47,32 @@
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
//#include "lcd.h"
|
||||
#ifdef PCBSKY
|
||||
#include "AT91SAM3S4.h"
|
||||
#endif
|
||||
|
||||
#ifdef PCBTARANIS
|
||||
#include "stm32f2xx.h"
|
||||
#include "stm32f2xx_gpio.h"
|
||||
#include "stm32f2xx.h"
|
||||
#include "stm32f2xx_gpio.h"
|
||||
#else
|
||||
#ifdef PCBX9D
|
||||
#include "x9d\stm32f2xx.h"
|
||||
#include "x9d\stm32f2xx_gpio.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(PCBX9D) || defined(PCBTARANIS)
|
||||
void bwdt_reset()
|
||||
{
|
||||
IWDG->KR = 0xAAAA ; // reload
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PCBTARANIS
|
||||
//#include "lcd.h"
|
||||
#if defined(PCBX9D) || defined(PCBTARANIS)
|
||||
|
||||
__attribute__ ((section(".bootrodata"), used))
|
||||
void _bootStart( void ) ;
|
||||
|
||||
|
||||
__attribute__ ((section(".isr_boot_vector"), used))
|
||||
const uint32_t BootVectors[] = {
|
||||
(uint32_t)&_estack,
|
||||
@@ -76,7 +80,7 @@ const uint32_t BootVectors[] = {
|
||||
} ;
|
||||
#endif
|
||||
|
||||
#ifdef PCBTARANIS
|
||||
#if defined(PCBX9D) || defined(PCBTARANIS)
|
||||
__attribute__ ((section(".bootrodata.*"), used))
|
||||
#endif
|
||||
|
||||
@@ -85,39 +89,13 @@ __attribute__ ((section(".bootrodata"), used))
|
||||
#endif
|
||||
|
||||
const uint8_t BootCode[] = {
|
||||
#ifdef PCBTARANIS
|
||||
#include "bootflashX.lbm"
|
||||
#else
|
||||
#ifdef REVX
|
||||
#include "bootflash8.lbm"
|
||||
#else
|
||||
#include "bootflash4.lbm"
|
||||
#endif
|
||||
#endif
|
||||
#include "bootloader.lbm"
|
||||
} ;
|
||||
|
||||
|
||||
#ifdef PCBTARANIS
|
||||
#if defined(PCBX9D) || defined(PCBTARANIS)
|
||||
|
||||
__attribute__ ((section(".bootrodata"), used))
|
||||
static void run_application( void ) ;
|
||||
|
||||
static void run_application()
|
||||
{
|
||||
asm(" mov.w r1, #134217728"); // 0x8000000
|
||||
asm(" add.w r1, #32768"); // 0x8000
|
||||
|
||||
asm(" movw r0, #60680"); // 0xED08
|
||||
asm(" movt r0, #57344"); // 0xE000
|
||||
asm(" str r1, [r0, #0]"); // Set the VTOR
|
||||
|
||||
asm("ldr r0, [r1, #0]"); // Stack pointer value
|
||||
asm("msr msp, r0"); // Set it
|
||||
asm("ldr r0, [r1, #4]"); // Reset address
|
||||
asm("mov.w r1, #1");
|
||||
asm("orr r0, r1"); // Set lsbit
|
||||
asm("bx r0"); // Execute application
|
||||
}
|
||||
|
||||
void _bootStart()
|
||||
{
|
||||
@@ -161,7 +139,20 @@ void _bootStart()
|
||||
|
||||
}
|
||||
}
|
||||
run_application() ;
|
||||
// run_application() ;
|
||||
asm(" mov.w r1, #134217728"); // 0x8000000
|
||||
asm(" add.w r1, #32768"); // 0x8000
|
||||
|
||||
asm(" movw r0, #60680"); // 0xED08
|
||||
asm(" movt r0, #57344"); // 0xE000
|
||||
asm(" str r1, [r0, #0]"); // Set the VTOR
|
||||
|
||||
asm("ldr r0, [r1, #0]"); // Stack pointer value
|
||||
asm("msr msp, r0"); // Set it
|
||||
asm("ldr r0, [r1, #4]"); // Reset address
|
||||
asm("mov.w r1, #1");
|
||||
asm("orr r0, r1"); // Set lsbit
|
||||
asm("bx r0"); // Execute application
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -71,9 +71,15 @@ SECTIONS
|
||||
*/
|
||||
.text :
|
||||
{
|
||||
_stext = .; /* Provide the name for the start of this section */
|
||||
FILL(0xFFFF)
|
||||
|
||||
CREATE_OBJECT_SYMBOLS
|
||||
CREATE_OBJECT_SYMBOLS
|
||||
|
||||
*(.bootrodata)
|
||||
*(.bootrodata.*)
|
||||
|
||||
. = ALIGN(32768); /* Align the start of the exidx part */
|
||||
_stext = .; /* Provide the name for the start of this section */
|
||||
KEEP(*(.vectors))
|
||||
|
||||
*(.text)
|
||||
@@ -129,11 +135,8 @@ SECTIONS
|
||||
|
||||
. = ALIGN(4); /* Align the end of the section */
|
||||
} > RAM
|
||||
_ebss = .; /* Provide the name for the end of this section */
|
||||
_ebss = .; /* Provide the name for the end of this section */
|
||||
|
||||
. = ALIGN(4); /* Align the end of the section */
|
||||
__end = .;
|
||||
_end = .;
|
||||
|
||||
/*
|
||||
* The ".stack" section is our stack.
|
||||
|
||||
+6
-3
@@ -232,9 +232,12 @@ void SystemInit(void)
|
||||
#ifdef VECT_TAB_SRAM
|
||||
SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */
|
||||
#else
|
||||
// SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */
|
||||
extern uint32_t g_pfnVectors ;
|
||||
SCB->VTOR = (uint32_t) &g_pfnVectors ; /* Vector Table Relocation in Internal FLASH */
|
||||
#if defined(BOOTLOADER)
|
||||
extern uint32_t g_pfnVectors ;
|
||||
SCB->VTOR = (uint32_t) &g_pfnVectors ; /* Vector Table Relocation in Internal FLASH */
|
||||
#else
|
||||
SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -32,9 +32,6 @@
|
||||
/* Entry Point */
|
||||
ENTRY(Reset_Handler)
|
||||
|
||||
/* Highest address of the user mode stack */
|
||||
_estack = 0x20020000; /* end of 128K SRAM */
|
||||
|
||||
/* Generate a link error if heap and stack don't fit into RAM */
|
||||
_Min_Heap_Size = 0; /* required amount of heap */
|
||||
_Min_Stack_Size = 0x200; /* required amount of stack */
|
||||
@@ -55,16 +52,6 @@ SECTIONS
|
||||
/* The program code and other data goes into FLASH */
|
||||
.text :
|
||||
{
|
||||
FILL(0xFFFF)
|
||||
|
||||
CREATE_OBJECT_SYMBOLS
|
||||
|
||||
KEEP(*(.isr_boot_vector)) /* Startup code */
|
||||
*(.bootrodata)
|
||||
*(.bootrodata.*)
|
||||
|
||||
. = ALIGN(32768); /* Align the start of the main program */
|
||||
_stext = .; /* Provide the name for the start of this section */
|
||||
. = ALIGN(4);
|
||||
KEEP(*(.isr_vector)) /* Startup code */
|
||||
*(.text) /* .text sections (code) */
|
||||
@@ -154,6 +141,8 @@ SECTIONS
|
||||
. = ALIGN(4);
|
||||
} >RAM
|
||||
|
||||
PROVIDE ( _estack = ORIGIN(RAM) + LENGTH(RAM) );
|
||||
|
||||
/* MEMORY_bank1 section, code must be located here explicitly */
|
||||
/* Example: extern int foo(void) __attribute__ ((section (".mb1text"))); */
|
||||
.memory_b1_text :
|
||||
|
||||
@@ -0,0 +1,176 @@
|
||||
/*
|
||||
*****************************************************************************
|
||||
**
|
||||
** File : stm32_flash.ld
|
||||
**
|
||||
** Abstract : Linker script for STM32F205 Device with
|
||||
** 0.5MByte FLASH, 128KByte SRAM
|
||||
**
|
||||
** Set heap size, stack size and stack location according
|
||||
** to application requirements.
|
||||
**
|
||||
** Set memory bank area and size if external memory is used.
|
||||
**
|
||||
** Target : STMicroelectronics STM32
|
||||
**
|
||||
** Environment : Atollic TrueSTUDIO(R)
|
||||
**
|
||||
** Distribution: The file is distributed “as is,” without any warranty
|
||||
** of any kind.
|
||||
**
|
||||
** (c)Copyright Atollic AB.
|
||||
** You may use this file as-is or modify it according to the needs of your
|
||||
** project. Distribution of this file (unmodified or modified) is not
|
||||
** permitted. Atollic AB permit registered Atollic TrueSTUDIO(R) users the
|
||||
** rights to distribute the assembled, compiled & linked contents of this
|
||||
** file as part of an application binary file, provided that it is built
|
||||
** using the Atollic TrueSTUDIO(R) toolchain.
|
||||
**
|
||||
*****************************************************************************
|
||||
*/
|
||||
|
||||
/* Entry Point */
|
||||
ENTRY(Reset_Handler)
|
||||
|
||||
/* Highest address of the user mode stack */
|
||||
_estack = 0x20020000; /* end of 128K SRAM */
|
||||
|
||||
/* Generate a link error if heap and stack don't fit into RAM */
|
||||
_Min_Heap_Size = 0; /* required amount of heap */
|
||||
_Min_Stack_Size = 0x200; /* required amount of stack */
|
||||
|
||||
/* Specify the memory areas */
|
||||
MEMORY
|
||||
{
|
||||
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K
|
||||
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
|
||||
MEMORY_B1 (rx) : ORIGIN = 0x60000000, LENGTH = 0K
|
||||
}
|
||||
|
||||
/* Define output sections */
|
||||
SECTIONS
|
||||
{
|
||||
/* The startup code goes first into FLASH */
|
||||
|
||||
/* The program code and other data goes into FLASH */
|
||||
.text :
|
||||
{
|
||||
FILL(0xFFFF)
|
||||
|
||||
CREATE_OBJECT_SYMBOLS
|
||||
|
||||
KEEP(*(.isr_boot_vector)) /* Startup code */
|
||||
*(.bootrodata)
|
||||
*(.bootrodata.*)
|
||||
|
||||
. = ALIGN(32768); /* Align the start of the main program */
|
||||
_stext = .; /* Provide the name for the start of this section */
|
||||
. = ALIGN(4);
|
||||
KEEP(*(.isr_vector)) /* Startup code */
|
||||
*(.text) /* .text sections (code) */
|
||||
*(.text*) /* .text* sections (code) */
|
||||
*(.rodata) /* .rodata sections (constants, strings, etc.) */
|
||||
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
|
||||
*(.glue_7) /* glue arm to thumb code */
|
||||
*(.glue_7t) /* glue thumb to arm code */
|
||||
*(.eh_frame)
|
||||
|
||||
KEEP (*(.init))
|
||||
KEEP (*(.fini))
|
||||
|
||||
. = ALIGN(4);
|
||||
_etext = .; /* define a global symbols at end of code */
|
||||
} >FLASH
|
||||
|
||||
|
||||
.ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
|
||||
.ARM : {
|
||||
__exidx_start = .;
|
||||
*(.ARM.exidx*)
|
||||
__exidx_end = .;
|
||||
} >FLASH
|
||||
|
||||
.preinit_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__preinit_array_start = .);
|
||||
KEEP (*(.preinit_array*))
|
||||
PROVIDE_HIDDEN (__preinit_array_end = .);
|
||||
} >FLASH
|
||||
.init_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__init_array_start = .);
|
||||
KEEP (*(SORT(.init_array.*)))
|
||||
KEEP (*(.init_array*))
|
||||
PROVIDE_HIDDEN (__init_array_end = .);
|
||||
} >FLASH
|
||||
.fini_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__fini_array_start = .);
|
||||
KEEP (*(.fini_array*))
|
||||
KEEP (*(SORT(.fini_array.*)))
|
||||
PROVIDE_HIDDEN (__fini_array_end = .);
|
||||
} >FLASH
|
||||
|
||||
/* used by the startup to initialize data */
|
||||
_sidata = .;
|
||||
|
||||
/* Initialized data sections goes into RAM, load LMA copy after code */
|
||||
.data : AT ( _sidata )
|
||||
{
|
||||
. = ALIGN(4);
|
||||
_sdata = .; /* create a global symbol at data start */
|
||||
*(.data) /* .data sections */
|
||||
*(.data*) /* .data* sections */
|
||||
|
||||
. = ALIGN(4);
|
||||
_edata = .; /* define a global symbol at data end */
|
||||
} >RAM
|
||||
|
||||
/* Uninitialized data section */
|
||||
. = ALIGN(4);
|
||||
.bss :
|
||||
{
|
||||
/* This is used by the startup in order to initialize the .bss secion */
|
||||
_sbss = .; /* define a global symbol at bss start */
|
||||
__bss_start__ = _sbss;
|
||||
*(.bss)
|
||||
*(.bss*)
|
||||
*(COMMON)
|
||||
|
||||
. = ALIGN(4);
|
||||
_ebss = .; /* define a global symbol at bss end */
|
||||
__bss_end__ = _ebss;
|
||||
} >RAM
|
||||
|
||||
PROVIDE ( end = _ebss );
|
||||
PROVIDE ( _end = _ebss );
|
||||
|
||||
/* User_heap_stack section, used to check that there is enough RAM left */
|
||||
._user_heap_stack :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
. = . + _Min_Heap_Size;
|
||||
. = . + _Min_Stack_Size;
|
||||
. = ALIGN(4);
|
||||
} >RAM
|
||||
|
||||
/* MEMORY_bank1 section, code must be located here explicitly */
|
||||
/* Example: extern int foo(void) __attribute__ ((section (".mb1text"))); */
|
||||
.memory_b1_text :
|
||||
{
|
||||
*(.mb1text) /* .mb1text sections (code) */
|
||||
*(.mb1text*) /* .mb1text* sections (code) */
|
||||
*(.mb1rodata) /* read-only data (constants) */
|
||||
*(.mb1rodata*)
|
||||
} >MEMORY_B1
|
||||
|
||||
/* Remove information from the standard libraries */
|
||||
/DISCARD/ :
|
||||
{
|
||||
libc.a ( * )
|
||||
libm.a ( * )
|
||||
libgcc.a ( * )
|
||||
}
|
||||
|
||||
.ARM.attributes 0 : { *(.ARM.attributes) }
|
||||
}
|
||||
Reference in New Issue
Block a user