1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-18 03:52:11 +01:00

OP-917 bootloader updater for F4 targets. Initial commit

This commit is contained in:
Alessio Morale 2013-04-27 00:51:52 +02:00
parent fa8c2f239c
commit b21146b8e3
7 changed files with 47 additions and 20 deletions

View File

@ -197,7 +197,7 @@ export OPGCSSYNTHDIR := $(BUILD_DIR)/openpilotgcs-synthetics
# Define supported board lists
ALL_BOARDS := coptercontrol oplinkmini revolution osd revoproto simposix
ALL_BOARDS_BU := coptercontrol oplinkmini
ALL_BOARDS_BU := coptercontrol oplinkmini revolution osd revoproto
# Short names of each board (used to display board name in parallel builds)
coptercontrol_short := 'cc '

View File

@ -39,7 +39,6 @@ HWDEFSINC = ../../boards/$(BOARD_NAME)
# Use file-extension c for "c-only"-files
SRC += $(OPSYSTEM)/main.c
SRC += $(OPSYSTEM)/pios_board.c
## PIOS Hardware
ifeq ($(MCU),cortex-m3)
include $(PIOS)/stm32f10x/library.mk
@ -47,9 +46,19 @@ ifeq ($(MCU),cortex-m3)
# Set linker-script name depending on selected submodel name
LDFLAGS += -T$(LINKER_SCRIPTS_PATH)/link_$(BOARD)_memory.ld
LDFLAGS += -T$(LINKER_SCRIPTS_PATH)/link_$(BOARD)_sections.ld
else
ifeq ($(MCU),cortex-m4)
include $(PIOS)/stm32f4xx/library.mk
# Set linker-script name depending on selected submodel name
LDFLAGS += -T$(PIOS_DEVLIB)/link_stm32f4xx_fw_memory.ld
LDFLAGS += -T$(PIOS_DEVLIB)/link_stm32f4xx_sections.ld
SRC += $(HWDEFSINC)/firmware/cm3_fault_handlers.c
SRC += $(HWDEFSINC)/firmware/dcc_stdio.c
else
$(error Unsupported MCU for BootloaderUpdater: $(MCU))
endif
endif
# List any extra directories to look for include files here.
# Each directory must be seperated by a space.

View File

@ -34,7 +34,7 @@
#define PIOS_INCLUDE_DELAY
#define PIOS_INCLUDE_SYS
#define PIOS_INCLUDE_IRQ
#define PIOS_INCLUDE_GPIO
//#define PIOS_INCLUDE_GPIO
#define PIOS_INCLUDE_LED
#define PIOS_INCLUDE_BL_HELPER

View File

@ -35,7 +35,9 @@
extern void PIOS_Board_Init(void);
extern void FLASH_Download();
void error(int, int);
#ifdef STM32F4XX
#define FLASH_ErasePage(x) FLASH_EraseSector((x) > 0x08000000 ? FLASH_Sector_1 : FLASH_Sector_0, VoltageRange_3)
#endif
/* The ADDRESSES of the _binary_* symbols are the important
* data. This is non-intuitive for _binary_size where you
* might expect its value to hold the size but you'd be wrong.
@ -58,7 +60,7 @@ int main()
/// Self overwrite check
uint32_t base_address = SCB->VTOR;
if ((0x08000000 + embedded_image_size) > base_address)
if ((BL_BANK_BASE + embedded_image_size) > base_address)
error(PIOS_LED_HEARTBEAT, 1);
///
@ -71,7 +73,7 @@ int main()
*/
/* Calculate how far the board_info_blob is from the beginning of the bootloader */
uint32_t board_info_blob_offset = (uint32_t) &pios_board_info_blob - (uint32_t)0x08000000;
uint32_t board_info_blob_offset = (uint32_t) &pios_board_info_blob - (uint32_t)BL_BANK_BASE;
/* Use the same offset into our embedded bootloader image */
struct pios_board_info * new_board_info_blob = (struct pios_board_info *)
@ -90,9 +92,9 @@ int main()
/// Bootloader memory space erase
uint32_t pageAddress;
pageAddress = 0x08000000;
pageAddress = BL_BANK_BASE;
bool fail = false;
while ((pageAddress < base_address) && (fail == false)) {
while ((pageAddress < BL_BANK_BASE + BL_BANK_SIZE) && (fail == false)) {
for (int retry = 0; retry < MAX_DEL_RETRYS; ++retry) {
if (FLASH_ErasePage(pageAddress) == FLASH_COMPLETE) {
fail = false;
@ -105,6 +107,8 @@ int main()
pageAddress += 2048;
#elif defined (STM32F10X_MD)
pageAddress += 1024;
#elif defined (STM32F4XX)
pageAddress += 0x4000;
#endif
}
@ -157,4 +161,4 @@ void error(int led, int code)
}
PIOS_DELAY_WaitmS(3000);
}
}
}

View File

@ -34,6 +34,11 @@
* NOTE: THIS IS THE ONLY PLACE THAT SHOULD EVER INCLUDE THIS FILE
*/
#include <board_hw_defs.c>
#ifdef STM32F4XX
#define FLASH_ErasePage(x) FLASH_EraseSector(x,VoltageRange_3)
#define FLASH_PrefetchBuffer_Enable ENABLE
#endif
void PIOS_Board_Init(void) {
const struct pios_board_info * bdinfo = &pios_board_info_blob;
@ -42,7 +47,7 @@ void PIOS_Board_Init(void) {
FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);
/* Flash 2 wait state */
FLASH_SetLatency(FLASH_Latency_2);
//FLASH_SetLatency(FLASH_Latency_5);
/* Delay system */
PIOS_DELAY_Init();
@ -55,5 +60,8 @@ void PIOS_Board_Init(void) {
#endif /* PIOS_INCLUDE_LED */
/* Initialize the PiOS library */
#if defined(PIOS_INCLUDE_GPIO)
PIOS_GPIO_Init();
#endif /* PIOS_INCLUDE_GPIO */
}

View File

@ -107,17 +107,8 @@ EXTRA_LIBDIRS +=
# EXTRA_LIBS = newlib-lpc
EXTRA_LIBS +=
# Provide (only) the bootloader with board-specific defines
BLONLY_CDEFS += -DBOARD_TYPE=$(BOARD_TYPE)
BLONLY_CDEFS += -DBOARD_REVISION=$(BOARD_REVISION)
BLONLY_CDEFS += -DHW_TYPE=$(HW_TYPE)
BLONLY_CDEFS += -DBOOTLOADER_VERSION=$(BOOTLOADER_VERSION)
BLONLY_CDEFS += -DFW_BANK_BASE=$(FW_BANK_BASE)
BLONLY_CDEFS += -DFW_BANK_SIZE=$(FW_BANK_SIZE)
BLONLY_CDEFS += -DFW_DESC_SIZE=$(FW_DESC_SIZE)
# Compiler flags
CDEFS += $(BLONLY_CDEFS)
CDEFS +=
# Set linker-script name depending on selected submodel name
ifeq ($(MCU),cortex-m3)

View File

@ -122,6 +122,21 @@ CFLAGS += -Wall
CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) -I.
CFLAGS += -Wa,-adhlns=$(addprefix $(OUTDIR)/, $(notdir $(addsuffix .lst, $(basename $<))))
# Provides board-specific defines
BOARD_CDEFS += -DBOARD_TYPE=$(BOARD_TYPE)
BOARD_CDEFS += -DBOARD_REVISION=$(BOARD_REVISION)
BOARD_CDEFS += -DHW_TYPE=$(HW_TYPE)
BOARD_CDEFS += -DBOOTLOADER_VERSION=$(BOOTLOADER_VERSION)
BOARD_CDEFS += -DFW_BANK_BASE=$(FW_BANK_BASE)
BOARD_CDEFS += -DFW_BANK_SIZE=$(FW_BANK_SIZE)
BOARD_CDEFS += -DFW_DESC_SIZE=$(FW_DESC_SIZE)
BOARD_CDEFS += -DBL_BANK_BASE=$(BL_BANK_BASE)
BOARD_CDEFS += -DBL_BANK_SIZE=$(BL_BANK_SIZE)
BOARD_CDEFS += -DBL_DESC_SIZE=$(BL_DESC_SIZE)
CDEFS += $(BOARD_CDEFS)
# FIXME: stm32f4xx library raises strict aliasing and const qualifier warnings
ifneq ($(MCU),cortex-m4)
CFLAGS += -Werror