1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-20 10:54:14 +01:00

Merge branch 'revolution' into revolution_overo

This commit is contained in:
James Cotton 2012-02-11 20:02:20 -06:00
commit d8f0494e57
13 changed files with 310 additions and 63 deletions

View File

@ -203,10 +203,9 @@ arm_sdk_clean:
OPENOCD_DIR := $(TOOLS_DIR)/openocd
.PHONY: openocd_install
openocd_install: | $(DL_DIR) $(TOOLS_DIR)
openocd_install: OPENOCD_URL := http://sourceforge.net/projects/openocd/files/openocd/0.5.0/openocd-0.5.0.tar.bz2/download
openocd_install: OPENOCD_FILE := openocd-0.5.0.tar.bz2
# order-only prereq on directory existance:
openocd_install: | $(DL_DIR) $(TOOLS_DIR)
openocd_install: openocd_clean
# download the source only if it's newer than what we already have
$(V1) wget -N -P "$(DL_DIR)" --trust-server-name "$(OPENOCD_URL)"
@ -221,6 +220,44 @@ openocd_install: openocd_clean
$(V1) ( \
cd $(DL_DIR)/openocd-build/openocd-0.5.0 ; \
./configure --prefix="$(OPENOCD_DIR)" --enable-ft2232_libftdi --enable-buspirate; \
$(MAKE) --silent ; \
$(MAKE) --silent install ; \
)
# delete the extracted source when we're done
$(V1) [ ! -d "$(DL_DIR)/openocd-build" ] || $(RM) -rf "$(DL_DIR)/openocd-build"
.PHONY: openocd_git_install
openocd_git_install: | $(DL_DIR) $(TOOLS_DIR)
openocd_git_install: OPENOCD_URL := git://openocd.git.sourceforge.net/gitroot/openocd/openocd
openocd_git_install: OPENOCD_REV := bce7009e31b23250d4325637c7b7cdbae0efed9a
openocd_git_install: openocd_clean
# download the source
$(V0) @echo " DOWNLOAD $(OPENOCD_URL) @ $(OPENOCD_REV)"
$(V1) [ ! -d "$(DL_DIR)/openocd-build" ] || $(RM) -rf "$(DL_DIR)/openocd-build"
$(V1) mkdir -p "$(DL_DIR)/openocd-build"
$(V1) git clone --depth 1 --no-checkout $(OPENOCD_URL) "$(DL_DIR)/openocd-build"
$(V1) ( \
cd $(DL_DIR)/openocd-build ; \
git checkout -q $(OPENOCD_REV) ; \
)
# apply patches
$(V0) @echo " PATCH $(OPENOCD_DIR)"
$(V1) ( \
cd $(DL_DIR)/openocd-build ; \
git apply < $(ROOT_DIR)/flight/Project/OpenOCD/0001-armv7m-remove-dummy-FP-regs-for-new-gdb.patch ; \
git apply < $(ROOT_DIR)/flight/Project/OpenOCD/0002-rtos-add-stm32_stlink-to-FreeRTOS-targets.patch ; \
)
# build and install
$(V0) @echo " BUILD $(OPENOCD_DIR)"
$(V1) mkdir -p "$(OPENOCD_DIR)"
$(V1) ( \
cd $(DL_DIR)/openocd-build ; \
./bootstrap ; \
./configure --enable-maintainer-mode --prefix="$(OPENOCD_DIR)" --enable-ft2232_libftdi --enable-buspirate --enable-stlink ; \
$(MAKE) ; \
$(MAKE) install ; \
)
@ -230,6 +267,7 @@ openocd_install: openocd_clean
.PHONY: openocd_clean
openocd_clean:
$(V0) @echo " CLEAN $(OPENOCD_DIR)"
$(V1) [ ! -d "$(OPENOCD_DIR)" ] || $(RM) -r "$(OPENOCD_DIR)"
STM32FLASH_DIR := $(TOOLS_DIR)/stm32flash
@ -452,17 +490,39 @@ bu_$(1)_clean:
$(V1) $(RM) -fr $(BUILD_DIR)/bu_$(1)
endef
# $(1) = Canonical board name all in lower case (e.g. coptercontrol)
define EF_TEMPLATE
.PHONY: ef_$(1)
ef_$(1): ef_$(1)_bin
ef_$(1)_%: bl_$(1)_bin fw_$(1)_bin
$(V1) mkdir -p $(BUILD_DIR)/ef_$(1)/dep
$(V1) cd $(ROOT_DIR)/flight/EntireFlash && \
$$(MAKE) -r --no-print-directory \
BOARD_NAME=$(1) \
TCHAIN_PREFIX="$(ARM_SDK_PREFIX)" \
DFU_CMD="$(DFUUTIL_DIR)/bin/dfu-util" \
$$*
.PHONY: ef_$(1)_clean
ef_$(1)_clean:
$(V0) @echo " CLEAN $$@"
$(V1) $(RM) -fr $(BUILD_DIR)/ef_$(1)
endef
# $(1) = Canonical board name all in lower case (e.g. coptercontrol)
define BOARD_PHONY_TEMPLATE
.PHONY: all_$(1)
all_$(1): $$(filter fw_$(1), $$(FW_TARGETS))
all_$(1): $$(filter bl_$(1), $$(BL_TARGETS))
all_$(1): $$(filter bu_$(1), $$(BU_TARGETS))
all_$(1): $$(filter ef_$(1), $$(EF_TARGETS))
.PHONY: all_$(1)_clean
all_$(1)_clean: $$(addsuffix _clean, $$(filter fw_$(1), $$(FW_TARGETS)))
all_$(1)_clean: $$(addsuffix _clean, $$(filter bl_$(1), $$(BL_TARGETS)))
all_$(1)_clean: $$(addsuffix _clean, $$(filter bu_$(1), $$(BU_TARGETS)))
all_$(1)_clean: $$(addsuffix _clean, $$(filter ef_$(1), $$(EF_TARGETS)))
endef
ALL_BOARDS := coptercontrol pipxtreme revolution
@ -476,6 +536,7 @@ revolution_friendly := Revolution
FW_BOARDS := $(ALL_BOARDS)
BL_BOARDS := $(ALL_BOARDS)
BU_BOARDS := $(ALL_BOARDS)
EF_BOARDS := $(ALL_BOARDS)
# FIXME: The INS build doesn't have a bootloader or bootloader
# updater yet so we need to filter them out to prevent errors.
@ -486,6 +547,7 @@ BU_BOARDS := $(filter-out ins, $(ALL_BOARDS))
FW_TARGETS := $(addprefix fw_, $(FW_BOARDS))
BL_TARGETS := $(addprefix bl_, $(BL_BOARDS))
BU_TARGETS := $(addprefix bu_, $(BU_BOARDS))
EF_TARGETS := $(addprefix ef_, $(EF_BOARDS))
.PHONY: all_fw all_fw_clean
all_fw: $(addsuffix _opfw, $(FW_TARGETS))
@ -499,9 +561,13 @@ all_bl_clean: $(addsuffix _clean, $(BL_TARGETS))
all_bu: $(addsuffix _opfw, $(BU_TARGETS))
all_bu_clean: $(addsuffix _clean, $(BU_TARGETS))
.PHONY: all_ef all_ef_clean
all_ef: $(EF_TARGETS))
all_ef_clean: $(addsuffix _clean, $(EF_TARGETS))
.PHONY: all_flight all_flight_clean
all_flight: all_fw all_bl all_bu
all_flight_clean: all_fw_clean all_bl_clean all_bu_clean
all_flight: all_fw all_bl all_bu all_ef
all_flight_clean: all_fw_clean all_bl_clean all_bu_clean all_ef_clean
# Expand the groups of targets for each board
$(foreach board, $(ALL_BOARDS), $(eval $(call BOARD_PHONY_TEMPLATE,$(board))))
@ -515,6 +581,9 @@ $(foreach board, $(ALL_BOARDS), $(eval $(call FW_TEMPLATE,$(board),$($(board)_fr
# Expand the bootloader rules
$(foreach board, $(ALL_BOARDS), $(eval $(call BL_TEMPLATE,$(board),$($(board)_friendly))))
# Expand the entire-flash rules
$(foreach board, $(ALL_BOARDS), $(eval $(call EF_TEMPLATE,$(board),$($(board)_friendly))))
.PHONY: sim_posix
sim_posix: sim_posix_elf

View File

@ -0,0 +1,49 @@
#####
# Makefile for Entire Flash (EF) images
#
# The OpenPilot Team, http://www.openpilot.org, Copyright (C) 2012.
#
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#####
WHEREAMI := $(dir $(lastword $(MAKEFILE_LIST)))
TOP := $(realpath $(WHEREAMI)/../../)
include $(TOP)/make/firmware-defs.mk
include $(TOP)/make/boards/$(BOARD_NAME)/board-info.mk
# Target file name (without extension).
TARGET := ef_$(BOARD_NAME)
# Directory for output files (lst, obj, dep, elf, sym, map, hex, bin etc.)
OUTDIR := $(TOP)/build/$(TARGET)
.PHONY: bin
bin: $(OUTDIR)/$(TARGET).bin
$(OUTDIR)/$(TARGET).bin: BL_BIN := $(TOP)/build/bl_$(BOARD_NAME)/bl_$(BOARD_NAME).bin
$(OUTDIR)/$(TARGET).bin: FW_BIN := $(TOP)/build/fw_$(BOARD_NAME)/fw_$(BOARD_NAME).bin
$(OUTDIR)/$(TARGET).bin: $(BL_BIN) $(FW_BIN)
$(V0) @echo " FLASH IMG $@"
$(V1) cat $(BL_BIN) $(FW_BIN) > $@
.PHONY: dfu
dfu: $(OUTDIR)/$(TARGET).bin
$(V0) @echo " DFU RESCUE $<"
$(V1) ( \
sudo $(DFU_CMD) -l && \
sudo $(DFU_CMD) -d 0483:df11 -c 1 -i 0 -a 0 -D $< -s $(BL_BANK_BASE) ; \
)

View File

@ -459,9 +459,9 @@ static int32_t updateSensorsCC3D(AccelsData * accelsData, GyrosData * gyrosData)
float accels[3] = {(float) -accel_accum[1] / accel_samples, (float) -accel_accum[0] / accel_samples, -(float) accel_accum[2] / accel_samples};
accelsData->x = accels[0] * accel_scaling - accelbias[0];
accelsData->y = accels[1] * accel_scaling - accelbias[1];
accelsData->z = accels[2] * accel_scaling - accelbias[2];
accelsData->x = (accels[0] - accelbias[0]) * accel_scaling;
accelsData->y = (accels[1] - accelbias[1]) * accel_scaling;
accelsData->z = (accels[2] - accelbias[2]) * accel_scaling;
lastSysTime = xTaskGetTickCount();

View File

@ -75,6 +75,7 @@ SECTIONS
{
. = ALIGN(4);
KEEP(*(.boardinfo))
. = ALIGN(ORIGIN(BD_INFO)+LENGTH(BD_INFO));
} > BD_INFO
/* Stabs debugging sections. */

View File

@ -68,6 +68,7 @@ SECTIONS
{
. = ALIGN(4);
KEEP(*(.boardinfo))
. = ALIGN(ORIGIN(BD_INFO)+LENGTH(BD_INFO));
} > BD_INFO
/*

View File

@ -68,19 +68,17 @@
*/
void PIOS_IAP_Init( void )
{
#if 0
/* Enable CRC clock */
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_CRC, ENABLE);
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_CRC, ENABLE);
/* Enable PWR and BKP clock */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE);
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_AHB1Periph_BKPSRAM, ENABLE);
/* Enable write access to Backup domain */
PWR_BackupAccessCmd(ENABLE);
/* Clear Tamper pin Event(TE) pending flag */
RTC_ClearFlag();
#endif
RTC_ClearFlag(RTC_FLAG_TAMP1F);
}
/*!
@ -93,8 +91,7 @@ void PIOS_IAP_Init( void )
*/
uint32_t PIOS_IAP_CheckRequest( void )
{
#if 0
uint32_t retval = FALSE;
uint32_t retval = false;
uint16_t reg1;
uint16_t reg2;
@ -103,13 +100,11 @@ uint32_t PIOS_IAP_CheckRequest( void )
if( reg1 == IAP_MAGIC_WORD_1 && reg2 == IAP_MAGIC_WORD_2 ) {
// We have a match.
retval = TRUE;
retval = true;
} else {
retval = FALSE;
retval = false;
}
return retval;
#endif
return 0;
}
@ -122,24 +117,18 @@ uint32_t PIOS_IAP_CheckRequest( void )
*/
void PIOS_IAP_SetRequest1(void)
{
#if 0
RTC_WriteBackupRegister( MAGIC_REG_1, IAP_MAGIC_WORD_1);
#endif
}
void PIOS_IAP_SetRequest2(void)
{
#if 0
RTC_WriteBackupRegister( MAGIC_REG_2, IAP_MAGIC_WORD_2);
#endif
}
void PIOS_IAP_ClearRequest(void)
{
#if 0
RTC_WriteBackupRegister( MAGIC_REG_1, 0);
RTC_WriteBackupRegister( MAGIC_REG_2, 0);
#endif
}
uint16_t PIOS_IAP_ReadBootCount(void)

View File

@ -50,6 +50,7 @@
/* STM32 Std Perf Lib */
#if defined(STM32F4XX)
# include <stm32f4xx.h>
# include <stm32f4xx_rcc.h>
#elif defined(STM32F2XX)
#include <stm32f2xx.h>
#include <stm32f2xx_syscfg.h>

View File

@ -0,0 +1,79 @@
From 7a8a1dbf856a2183c91f441cfdd2eee5b3d9151b Mon Sep 17 00:00:00 2001
From: Stacey Sheldon <stac@solidgoldbomb.org>
Date: Thu, 2 Feb 2012 22:42:03 -0500
Subject: [PATCH 1/2] armv7m: remove dummy FP regs for new gdb
---
src/rtos/rtos_standard_stackings.c | 6 ++++++
src/target/armv7m.c | 16 ++++++++++++++++
2 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/src/rtos/rtos_standard_stackings.c b/src/rtos/rtos_standard_stackings.c
index 278d3ef..7ef4659 100644
--- a/src/rtos/rtos_standard_stackings.c
+++ b/src/rtos/rtos_standard_stackings.c
@@ -41,6 +41,7 @@ static const struct stack_register_offset rtos_standard_Cortex_M3_stack_offsets[
{ -2, 32 }, /* sp */
{ 0x34, 32 }, /* lr */
{ 0x38, 32 }, /* pc */
+#ifdef USE_DUMMY_FP_REGS
{ -1, 96 }, /* FPA1 */
{ -1, 96 }, /* FPA2 */
{ -1, 96 }, /* FPA3 */
@@ -50,6 +51,7 @@ static const struct stack_register_offset rtos_standard_Cortex_M3_stack_offsets[
{ -1, 96 }, /* FPA7 */
{ -1, 96 }, /* FPA8 */
{ -1, 32 }, /* FPS */
+#endif
{ 0x3c, 32 }, /* xPSR */
};
@@ -58,7 +60,11 @@ const struct rtos_register_stacking rtos_standard_Cortex_M3_stacking =
{
0x40, /* stack_registers_size */
-1, /* stack_growth_direction */
+#ifdef USE_DUMMY_FP_REGS
26, /* num_output_registers */
+#else
+ 17,
+#endif
8, /* stack_alignment */
rtos_standard_Cortex_M3_stack_offsets /* register_offsets */
};
diff --git a/src/target/armv7m.c b/src/target/armv7m.c
index 6c1732e..7bb53c7 100644
--- a/src/target/armv7m.c
+++ b/src/target/armv7m.c
@@ -272,6 +272,7 @@ int armv7m_get_gdb_reg_list(struct target *target, struct reg **reg_list[], int
struct armv7m_common *armv7m = target_to_armv7m(target);
int i;
+#ifdef USE_DUMMY_FP_REGS
*reg_list_size = 26;
*reg_list = malloc(sizeof(struct reg*) * (*reg_list_size));
@@ -302,6 +303,21 @@ int armv7m_get_gdb_reg_list(struct target *target, struct reg **reg_list[], int
(*reg_list)[25] = &armv7m->core_cache->reg_list[ARMV7M_xPSR];
#endif
+#else
+ *reg_list_size = 17;
+ *reg_list = malloc(sizeof(struct reg*) * (*reg_list_size));
+
+ /*
+ * GDB register packet format for ARM:
+ * - the first 16 registers are r0..r15
+ * - followed by xPSR
+ */
+ for (i = 0; i < *reg_list_size; i++)
+ {
+ (*reg_list)[i] = &armv7m->core_cache->reg_list[i];
+ }
+#endif
+
return ERROR_OK;
}
--
1.7.1

View File

@ -0,0 +1,34 @@
From fceb681b4421dd00eb47085990b77c0f0716517d Mon Sep 17 00:00:00 2001
From: Stacey Sheldon <stac@solidgoldbomb.org>
Date: Thu, 2 Feb 2012 22:42:26 -0500
Subject: [PATCH 2/2] rtos: add stm32_stlink to FreeRTOS targets
---
src/rtos/FreeRTOS.c | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/src/rtos/FreeRTOS.c b/src/rtos/FreeRTOS.c
index eeab134..e57806e 100644
--- a/src/rtos/FreeRTOS.c
+++ b/src/rtos/FreeRTOS.c
@@ -63,6 +63,17 @@ const struct FreeRTOS_params FreeRTOS_params_list[] =
0, // thread_stack_offset;
52, // thread_name_offset;
&rtos_standard_Cortex_M3_stacking, // stacking_info
+ },
+ { "stm32_stlink", // target_name
+ 4, // thread_count_width;
+ 4, // pointer_width;
+ 16, // list_next_offset;
+ 20, // list_width;
+ 8, // list_elem_next_offset;
+ 12, // list_elem_content_offset
+ 0, // thread_stack_offset;
+ 52, // thread_name_offset;
+ &rtos_standard_Cortex_M3_stacking, // stacking_info
}
};
--
1.7.1

View File

@ -0,0 +1,17 @@
#
# STMicroelectronics ST-LINK/V2 in-circuit debugger/programmer
#
interface stlink
stlink_layout usb
stlink_device_desc "ST-LINK/V2"
stlink_vid_pid 0x0483 0x3748
#
# dummy values, not really needed
#
adapter_khz 1
reset_config trst_and_srst
gdb_port 3333
tcl_port 6666
telnet_port 4444

View File

@ -0,0 +1,34 @@
#
#
#
if { [info exists CHIPNAME] } {
set _CHIPNAME $CHIPNAME
} else {
set _CHIPNAME stm32f4x
}
# Work-area is a space in RAM used for flash programming
# By default use 64kB
if { [info exists WORKAREASIZE] } {
set _WORKAREASIZE $WORKAREASIZE
} else {
set _WORKAREASIZE 0x10000
}
if { [info exists CPUTAPID] } {
set _CPUTAPID $CPUTAPID
} else {
set _CPUTAPID 0x2ba01477
}
transport select stlink_swd
stlink newtap $_CHIPNAME cpu -expected-id $_CPUTAPID
set _TARGETNAME $_CHIPNAME.cpu
target create $_TARGETNAME stm32_stlink -chain-position $_TARGETNAME -rtos auto
$_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size $_WORKAREASIZE -work-area-backup 0
set _FLASHNAME $_CHIPNAME.flash
flash bank $_FLASHNAME stm32f2x 0x08000000 0 0 0 $_TARGETNAME

View File

@ -1,41 +1,4 @@
define connect
target remote localhost:3334
monitor cortex_m3 vector_catch all
target remote localhost:3333
file ./build/fw_revolution/fw_revolution.elf
# file ./build/bl_ins/bl_ins.elf
end
source CortexM3
#monitor reset halt
define hook-step
monitor cortex_m3 maskisr on
end
define hookpost-step
monitor cortex_m3 maskisr off
end
define hook-stepi
monitor cortex_m3 maskisr on
end
define hookpost-stepi
monitor cortex_m3 maskisr off
end
define hook-next
monitor cortex_m3 maskisr on
end
define hookpost-next
monitor cortex_m3 maskisr off
end
define hook-finish
monitor cortex_m3 maskisr on
end
define hookpost-finish
monitor cortex_m3 maskisr off
end

View File

@ -312,7 +312,17 @@ void PIOS_Board_Init(void) {
PIOS_TIM_InitClock(&tim_11_cfg);
/* IAP System Setup */
//PIOS_IAP_Init();
PIOS_IAP_Init();
uint16_t boot_count = PIOS_IAP_ReadBootCount();
if (boot_count < 3) {
PIOS_IAP_WriteBootCount(++boot_count);
AlarmsClear(SYSTEMALARMS_ALARM_BOOTFAULT);
} else {
/* Too many failed boot attempts, force hwsettings to defaults */
HwSettingsSetDefaults(HwSettingsHandle(), 0);
AlarmsSet(SYSTEMALARMS_ALARM_BOOTFAULT, SYSTEMALARMS_ALARM_CRITICAL);
}
#if defined(PIOS_INCLUDE_COM)
#if defined(PIOS_INCLUDE_GPS)