diff --git a/flight/Bootloaders/BootloaderUpdater/Makefile b/flight/Bootloaders/BootloaderUpdater/Makefile index f2288c9b2..7da9d58d7 100644 --- a/flight/Bootloaders/BootloaderUpdater/Makefile +++ b/flight/Bootloaders/BootloaderUpdater/Makefile @@ -34,7 +34,7 @@ ENABLE_DEBUG_PINS ?= NO ENABLE_AUX_UART ?= NO # -USE_BOOTLOADER ?= NO +USE_BOOTLOADER ?= YES # Set to the source bootloader binary SOURCE_BL ?= NULL @@ -67,9 +67,9 @@ MCU = cortex-m3 CHIP = STM32F103CBT BOARD ?= NULL MODEL ?= NULL + ifeq ($(USE_BOOTLOADER), YES) BOOT_MODEL = $(MODEL)_BL - else BOOT_MODEL = $(MODEL)_NB endif @@ -320,7 +320,7 @@ LDFLAGS += $(MATH_LIB) LDFLAGS += -lc -lgcc # Set linker-script name depending on selected submodel name -LDFLAGS +=-T$(LINKERSCRIPTPATH)/link_stm32f10x_$(MODEL).ld +LDFLAGS +=-T$(LINKERSCRIPTPATH)/link_$(BOARD)_$(BOOT_MODEL).ld # Test if quotes are needed for the echo-command result = ${shell echo "test"} diff --git a/flight/Bootloaders/BootloaderUpdater/main.c b/flight/Bootloaders/BootloaderUpdater/main.c index 825d1c7b5..f2cd0495c 100644 --- a/flight/Bootloaders/BootloaderUpdater/main.c +++ b/flight/Bootloaders/BootloaderUpdater/main.c @@ -32,21 +32,22 @@ /* Prototype of PIOS_Board_Init() function */ extern void PIOS_Board_Init(void); extern void FLASH_Download(); -void error(); +void error(int); int main() { PIOS_SYS_Init(); PIOS_Board_Init(); PIOS_LED_On(LED1); - PIOS_DELAY_WaitmS(5000); + PIOS_DELAY_WaitmS(3000); PIOS_LED_Off(LED1); /// Self overwrite check uint32_t base_adress = SCB->VTOR; - if (0x08000000 + (sizeof(dataArray) * 4) > base_adress) - error(); + if (0x08000000 + (sizeof(dataArray)) > base_adress) + error(LED1); /// + FLASH_Unlock(); /// Bootloader memory space erase uint32_t pageAdress; @@ -69,13 +70,15 @@ int main() { } if (fail == TRUE) - error(); + error(LED1); + /// /// Bootloader programing - for (int x = 0; x < sizeof(dataArray); ++x) { + for (int x = 0; x < sizeof(dataArray)/sizeof(uint32_t); ++x) { int result = 0; + PIOS_LED_Toggle(LED1); for (int retry = 0; retry < MAX_WRI_RETRYS; ++retry) { if (result == 0) { result = (FLASH_ProgramWord(0x08000000 + (x * 4), dataArray[x]) @@ -83,18 +86,25 @@ int main() { } } if (result == 0) - error(); + error(LED1); } /// - PIOS_LED_On(LED1); - for (;;) {} + for (int x=0;x<3;++x) { + PIOS_LED_On(led); + PIOS_DELAY_WaitmS(1000); + PIOS_LED_Off(led); + PIOS_DELAY_WaitmS(1000); + } + for (;;) { + PIOS_DELAY_WaitmS(1000); + } } -void error() { +void error(int led) { for (;;) { - PIOS_LED_On(LED1); + PIOS_LED_On(led); PIOS_DELAY_WaitmS(500); - PIOS_LED_Off(LED1); + PIOS_LED_Off(led); PIOS_DELAY_WaitmS(500); } }