mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-18 08:54:15 +01:00
Flight/Bootloader - Bootloader updater, WORKING - tested with PipX only (should work for all boards though).
Led(LED1 different color on each board) Sequence: 1-Power On 2-Led ON for 3 seconds (you can disconnect during this time - safety measure) 3-Led flashes very quickly while the board is being programed (because the program is stored in memory this is very fast and looks like a led glitch) 4-If all good - LED flashes 3 times with a 1sec period and turns off - you may now reboot. 4-If an error ocurred - LED will keep flashing with a 500ms period until power off git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2804 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
50e78b4265
commit
56c195fa9a
@ -34,7 +34,7 @@ ENABLE_DEBUG_PINS ?= NO
|
|||||||
ENABLE_AUX_UART ?= NO
|
ENABLE_AUX_UART ?= NO
|
||||||
|
|
||||||
#
|
#
|
||||||
USE_BOOTLOADER ?= NO
|
USE_BOOTLOADER ?= YES
|
||||||
|
|
||||||
# Set to the source bootloader binary
|
# Set to the source bootloader binary
|
||||||
SOURCE_BL ?= NULL
|
SOURCE_BL ?= NULL
|
||||||
@ -67,9 +67,9 @@ MCU = cortex-m3
|
|||||||
CHIP = STM32F103CBT
|
CHIP = STM32F103CBT
|
||||||
BOARD ?= NULL
|
BOARD ?= NULL
|
||||||
MODEL ?= NULL
|
MODEL ?= NULL
|
||||||
|
|
||||||
ifeq ($(USE_BOOTLOADER), YES)
|
ifeq ($(USE_BOOTLOADER), YES)
|
||||||
BOOT_MODEL = $(MODEL)_BL
|
BOOT_MODEL = $(MODEL)_BL
|
||||||
|
|
||||||
else
|
else
|
||||||
BOOT_MODEL = $(MODEL)_NB
|
BOOT_MODEL = $(MODEL)_NB
|
||||||
endif
|
endif
|
||||||
@ -320,7 +320,7 @@ LDFLAGS += $(MATH_LIB)
|
|||||||
LDFLAGS += -lc -lgcc
|
LDFLAGS += -lc -lgcc
|
||||||
|
|
||||||
# Set linker-script name depending on selected submodel name
|
# 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
|
# Test if quotes are needed for the echo-command
|
||||||
result = ${shell echo "test"}
|
result = ${shell echo "test"}
|
||||||
|
@ -32,21 +32,22 @@
|
|||||||
/* Prototype of PIOS_Board_Init() function */
|
/* Prototype of PIOS_Board_Init() function */
|
||||||
extern void PIOS_Board_Init(void);
|
extern void PIOS_Board_Init(void);
|
||||||
extern void FLASH_Download();
|
extern void FLASH_Download();
|
||||||
void error();
|
void error(int);
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
|
||||||
PIOS_SYS_Init();
|
PIOS_SYS_Init();
|
||||||
PIOS_Board_Init();
|
PIOS_Board_Init();
|
||||||
PIOS_LED_On(LED1);
|
PIOS_LED_On(LED1);
|
||||||
PIOS_DELAY_WaitmS(5000);
|
PIOS_DELAY_WaitmS(3000);
|
||||||
PIOS_LED_Off(LED1);
|
PIOS_LED_Off(LED1);
|
||||||
|
|
||||||
/// Self overwrite check
|
/// Self overwrite check
|
||||||
uint32_t base_adress = SCB->VTOR;
|
uint32_t base_adress = SCB->VTOR;
|
||||||
if (0x08000000 + (sizeof(dataArray) * 4) > base_adress)
|
if (0x08000000 + (sizeof(dataArray)) > base_adress)
|
||||||
error();
|
error(LED1);
|
||||||
///
|
///
|
||||||
|
FLASH_Unlock();
|
||||||
|
|
||||||
/// Bootloader memory space erase
|
/// Bootloader memory space erase
|
||||||
uint32_t pageAdress;
|
uint32_t pageAdress;
|
||||||
@ -69,13 +70,15 @@ int main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (fail == TRUE)
|
if (fail == TRUE)
|
||||||
error();
|
error(LED1);
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
|
|
||||||
/// Bootloader programing
|
/// Bootloader programing
|
||||||
for (int x = 0; x < sizeof(dataArray); ++x) {
|
for (int x = 0; x < sizeof(dataArray)/sizeof(uint32_t); ++x) {
|
||||||
int result = 0;
|
int result = 0;
|
||||||
|
PIOS_LED_Toggle(LED1);
|
||||||
for (int retry = 0; retry < MAX_WRI_RETRYS; ++retry) {
|
for (int retry = 0; retry < MAX_WRI_RETRYS; ++retry) {
|
||||||
if (result == 0) {
|
if (result == 0) {
|
||||||
result = (FLASH_ProgramWord(0x08000000 + (x * 4), dataArray[x])
|
result = (FLASH_ProgramWord(0x08000000 + (x * 4), dataArray[x])
|
||||||
@ -83,18 +86,25 @@ int main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (result == 0)
|
if (result == 0)
|
||||||
error();
|
error(LED1);
|
||||||
}
|
}
|
||||||
///
|
///
|
||||||
PIOS_LED_On(LED1);
|
for (int x=0;x<3;++x) {
|
||||||
for (;;) {}
|
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 (;;) {
|
for (;;) {
|
||||||
PIOS_LED_On(LED1);
|
PIOS_LED_On(led);
|
||||||
PIOS_DELAY_WaitmS(500);
|
PIOS_DELAY_WaitmS(500);
|
||||||
PIOS_LED_Off(LED1);
|
PIOS_LED_Off(led);
|
||||||
PIOS_DELAY_WaitmS(500);
|
PIOS_DELAY_WaitmS(500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user