1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-01 09:24:10 +01:00

Merge branch 'next' into ins

Conflicts:
	flight/INS/Makefile
	flight/Project/OpenOCD/stm32f1x.cfg
	flight/Project/OpenOCD/stm32f2x.cfg
	make/firmware-defs.mk
This commit is contained in:
James Cotton 2011-09-27 00:59:46 -05:00
commit cf6a59468f
23 changed files with 75 additions and 180 deletions

View File

@ -202,8 +202,8 @@ arm_sdk_clean:
OPENOCD_DIR := $(TOOLS_DIR)/openocd
.PHONY: openocd_install
openocd_install: OPENOCD_URL := http://sourceforge.net/projects/openocd/files/openocd/0.4.0/openocd-0.4.0.tar.bz2/download
openocd_install: OPENOCD_FILE := openocd-0.4.0.tar.bz2
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
@ -218,8 +218,8 @@ openocd_install: openocd_clean
# build and install
$(V1) mkdir -p "$(OPENOCD_DIR)"
$(V1) ( \
cd $(DL_DIR)/openocd-build/openocd-0.4.0 ; \
./configure --prefix="$(OPENOCD_DIR)" --enable-ft2232_libftdi ; \
cd $(DL_DIR)/openocd-build/openocd-0.5.0 ; \
./configure --prefix="$(OPENOCD_DIR)" --enable-ft2232_libftdi --enable-buspirate; \
$(MAKE) ; \
$(MAKE) install ; \
)

View File

@ -355,7 +355,7 @@ $(OUTDIR)/$(TARGET).bin.o: $(OUTDIR)/$(TARGET).bin
$(eval $(call OPFW_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(BOARD_TYPE),$(BOARD_REVISION)))
# Add jtag targets (program and wipe)
$(eval $(call JTAG_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(FW_BANK_BASE),$(FW_BANK_SIZE)))
$(eval $(call JTAG_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(FW_BANK_BASE),$(FW_BANK_SIZE),$(OPENOCD_CONFIG)))
.PHONY: elf lss sym hex bin bino opfw
elf: $(OUTDIR)/$(TARGET).elf

View File

@ -258,7 +258,9 @@ CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) -I.
CFLAGS += -mapcs-frame
CFLAGS += -fomit-frame-pointer
ifeq ($(CODE_SOURCERY), YES)
CFLAGS += -fpromote-loop-indices
endif
CFLAGS += -Wall
CFLAGS += -Werror

View File

@ -300,7 +300,9 @@ CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) -I.
CFLAGS += -mapcs-frame
CFLAGS += -fomit-frame-pointer
ifeq ($(CODE_SOURCERY), YES)
CFLAGS += -fpromote-loop-indices
endif
CFLAGS += -Wall
CFLAGS += -Werror

View File

@ -306,7 +306,9 @@ CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) -I.
CFLAGS += -mapcs-frame
CFLAGS += -fomit-frame-pointer
ifeq ($(CODE_SOURCERY), YES)
CFLAGS += -fpromote-loop-indices
endif
CFLAGS += -Wall
CFLAGS += -Werror

View File

@ -301,7 +301,9 @@ CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) -I.
CFLAGS += -mapcs-frame
CFLAGS += -fomit-frame-pointer
ifeq ($(CODE_SOURCERY), YES)
CFLAGS += -fpromote-loop-indices
endif
CFLAGS += -Wall
CFLAGS += -Werror

View File

@ -443,7 +443,9 @@ CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) -I.
CFLAGS += -mapcs-frame
CFLAGS += -fomit-frame-pointer
ifeq ($(CODE_SOURCERY), YES)
CFLAGS += -fpromote-loop-indices
endif
CFLAGS += -Wall
CFLAGS += -Werror
@ -553,7 +555,7 @@ $(OUTDIR)/$(TARGET).bin.o: $(OUTDIR)/$(TARGET).bin
$(eval $(call OPFW_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(BOARD_TYPE),$(BOARD_REVISION)))
# Add jtag targets (program and wipe)
$(eval $(call JTAG_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(FW_BANK_BASE),$(FW_BANK_SIZE)))
$(eval $(call JTAG_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(FW_BANK_BASE),$(FW_BANK_SIZE),$(OPENOCD_CONFIG)))
.PHONY: elf lss sym hex bin bino opfw
elf: $(OUTDIR)/$(TARGET).elf

View File

@ -364,7 +364,7 @@ $(OUTDIR)/$(TARGET).bin.o: $(OUTDIR)/$(TARGET).bin
$(eval $(call OPFW_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(BOARD_TYPE),$(BOARD_REVISION)))
# Add jtag targets (program and wipe)
$(eval $(call JTAG_TEMPLATE_F2X,$(OUTDIR)/$(TARGET).bin,$(FW_BANK_BASE),$(FW_BANK_SIZE)))
$(eval $(call JTAG_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(FW_BANK_BASE),$(FW_BANK_SIZE),$(OPENOCD_CONFIG)))
.PHONY: elf lss sym hex bin bino opfw
elf: $(OUTDIR)/$(TARGET).elf

View File

@ -514,7 +514,7 @@ $(OUTDIR)/$(TARGET).bin.o: $(OUTDIR)/$(TARGET).bin
$(eval $(call OPFW_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(BOARD_TYPE),$(BOARD_REVISION)))
# Add jtag targets (program and wipe)
$(eval $(call JTAG_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(FW_BANK_BASE),$(FW_BANK_SIZE)))
$(eval $(call JTAG_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(FW_BANK_BASE),$(FW_BANK_SIZE),$(OPENOCD_CONFIG)))
.PHONY: elf lss sym hex bin bino opfw
elf: $(OUTDIR)/$(TARGET).elf

View File

@ -394,7 +394,7 @@ $(OUTDIR)/$(TARGET).bin.o: $(OUTDIR)/$(TARGET).bin
$(eval $(call OPFW_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(BOARD_TYPE),$(BOARD_REVISION)))
# Add jtag targets (program and wipe)
$(eval $(call JTAG_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(FW_BANK_BASE),$(FW_BANK_SIZE)))
$(eval $(call JTAG_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(FW_BANK_BASE),$(FW_BANK_SIZE),$(OPENOCD_CONFIG)))
.PHONY: elf lss sym hex bin bino opfw
elf: $(OUTDIR)/$(TARGET).elf

View File

@ -62,7 +62,7 @@ jtag newtap $_CHIPNAME bs -irlen 5 -expected-id $_BSTAPID1 \
-expected-id $_BSTAPID6 -expected-id $_BSTAPID7
set _TARGETNAME $_CHIPNAME.cpu
target create $_TARGETNAME cortex_m3 -endian $_ENDIAN -chain-position $_TARGETNAME
target create $_TARGETNAME cortex_m3 -endian $_ENDIAN -chain-position $_TARGETNAME -rtos auto
$_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size $_WORKAREASIZE -work-area-backup 0

View File

@ -52,7 +52,7 @@ if { [info exists BSTAPID ] } {
jtag newtap $_CHIPNAME bs -irlen 5 -expected-id $_BSTAPID
set _TARGETNAME $_CHIPNAME.cpu
target create $_TARGETNAME cortex_m3 -endian $_ENDIAN -chain-position $_TARGETNAME
target create $_TARGETNAME cortex_m3 -endian $_ENDIAN -chain-position $_TARGETNAME -rtos auto
$_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size $_WORKAREASIZE -work-area-backup 0

View File

@ -1,99 +0,0 @@
#!/usr/bin/env python
# Generate a version blob for
# the OpenPilot firmware.
#
# By E. Lafargue (c) 2011 E. Lafargue & the OpenPilot team
# Licence: GPLv3
#
###
# Usage:
# versionblob.py --append --firmware=<Firmware file name> --boardid=<Board code>
#
# append: if present, then append blob to firmware file directly, otherwise create "blob.bin"
# firmware: the filename of the firmware binary
# boardid: as a string, the board code, for example "0401" for CC board version 1.
# should match the codes in firmware description files.
#
# We have 100 bytes for the whole description.
#
# Only the first 40 are visible on the FirmwareIAP uavobject, the remaining
# 60 are ok to use for packaging and will be saved in the flash
#
# Structure is:
# 4 bytes: header: "OpFw"
# 4 bytes: GIT commit tag (short version of SHA1)
# 4 bytes: Unix timestamp of compile time
# 2 bytes: target platform. Should follow same rule as BOARD_TYPE and BOARD_REVISION in board define files.
# 26 bytes: commit tag if it is there, otherwise branch name. Zero-padded
# ---- 40 bytes limit ---
# 20 bytes: SHA1 sum of the firmware.
# 40 bytes: free for now.
import binascii
import os
from time import time
import argparse
# Do the argument parsing:
parser = argparse.ArgumentParser(description='Generate firmware desciption blob')
parser.add_argument('--append', action='store_true')
parser.add_argument('--firmware', help='name of firmware binary file' , required=True)
parser.add_argument('--boardid', help='ID of board model, for example 0401 for CopterControl', required=True)
args = parser.parse_args()
print args
if args.append == True:
print 'Appending description blob directly to ' + args.firmware
filename = args.firmware
file = open(filename,"ab")
else:
filename = 'blob.bin'
file = open(filename,"wb")
# Write the magic value:
file.write("OpFw")
# Get the short commit tag of the current git repository.
# Strip it to 8 characters for a 4 byte (int32) value.
# We have no full guarantee of unicity, but it is good enough
# with the rest of the information in the structure.
hs= os.popen('git rev-parse --short=8 HEAD').read().strip()
print "Version: " + hs
hb=binascii.a2b_hex(hs)
file.write(hb)
# Then the Unix time into a 32 bit integer:
print "Date: " + hex(int(time())).lstrip('0x')
hb = binascii.a2b_hex(hex(int(time())).lstrip('0x'))
file.write(hb)
# Then write board type and board revision
hb = binascii.a2b_hex(args.boardid)
file.write(hb)
# Last: a user-friendly description if it exists in GIT, otherwise
# just "unreleased"
hs = os.popen('git describe --exact-match').read()
if len(hs) == 0 :
print "Unreleased: get branch name instead"
hs = os.popen('git branch --contains HEAD').read()
file.write(hs[0:26])
file.write("\0"*(26-len(hs)))
## Now we are at the 40 bytes mark.
## Add the 20 byte SHA1 hash of the firmware:
import hashlib
sha1 = hashlib.sha1()
with open('build/coptercontrol/CopterControl.bin','rb') as f:
for chunk in iter(lambda: f.read(8192), ''):
sha1.update(chunk)
file.write(sha1.digest())
# Pad will null bytes:
file.write('\0'*40)
file.close()

View File

@ -949,6 +949,27 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Min</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Neutral (slowest for motor)</string>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Max</string>
</property>
</widget>
</item>
</layout>
</item>
<item>

View File

@ -117,7 +117,7 @@ void USBMonitor::removeDevice(IOHIDDeviceRef dev) {
*/
void USBMonitor::detach_callback(void *context, IOReturn r, void *hid_mgr, IOHIDDeviceRef dev)
{
qDebug() << "USBMonitor: Device detached event";
instance()->removeDevice(dev);
}
@ -136,6 +136,8 @@ void USBMonitor::attach_callback(void *context, IOReturn r, void *hid_mgr, IOHID
deviceInfo.dev_handle = dev;
qDebug() << "USBMonitor: Device attached event";
// Populate the device info structure
got_properties &= HID_GetIntProperty(dev, CFSTR( kIOHIDVendorIDKey ), &deviceInfo.vendorID);
got_properties &= HID_GetIntProperty(dev, CFSTR( kIOHIDProductIDKey ), &deviceInfo.productID);
@ -149,6 +151,7 @@ void USBMonitor::attach_callback(void *context, IOReturn r, void *hid_mgr, IOHID
// Currently only enumerating objects that have the complete list of properties
if(got_properties) {
qDebug() << "USBMonitor: Adding device";
instance()->addDevice(deviceInfo);
}
}

View File

@ -80,29 +80,26 @@ DFUObject::DFUObject(bool _debug,bool _use_serial,QString portname):
}
else
{
send_delay=10;
use_delay=true;
// int numDevices=0;
QList<USBPortInfo> devices;
int count=0;
while((devices.length()==0) && count < 10)
{
if (debug)
qDebug() << ".";
delay::msleep(500);
// processEvents enables XP to process the system
// plug/unplug events, otherwise it will not process
// those events before the end of the call!
QApplication::processEvents();
devices = USBMonitor::instance()->availableDevices(0x20a0,-1,-1,USBMonitor::Bootloader);
count++;
}
if (devices.length()==1) {
devices = USBMonitor::instance()->availableDevices(0x20a0,-1,-1,USBMonitor::Bootloader);
if (devices.length()==1) {
hidHandle.open(1,devices.first().vendorID,devices.first().productID,0,0);
} else {
qDebug() << devices.length() << " device(s) detected, don't know what to do!";
mready = false;
}
// Wait for the board to appear on the USB bus:
QEventLoop m_eventloop;
connect(USBMonitor::instance(), SIGNAL(deviceDiscovered(USBPortInfo)),&m_eventloop, SLOT(quit()));
QTimer::singleShot(5000,&m_eventloop, SLOT(quit()));
m_eventloop.exec();
devices = USBMonitor::instance()->availableDevices(0x20a0,-1,-1,USBMonitor::Bootloader);
if (devices.length()==1) {
delay::msleep(2000); // Let the USB Subsystem settle (especially important on Mac!)
hidHandle.open(1,devices.first().vendorID,devices.first().productID,0,0);
}
else {
qDebug() << devices.length() << " device(s) detected, don't know what to do!";
mready = false;
}
}
}
}

View File

@ -17,6 +17,7 @@
#include "delay.h"
#include <qextserialport/src/qextserialport.h>
#include <QTime>
#include <QTimer>
#include "SSP/qssp.h"
#include "SSP/port.h"
#include "SSP/qsspt.h"

View File

@ -235,9 +235,7 @@ void UploaderGadgetWidget::goToBootloader(UAVObject* callerObj, bool success)
currentStep = IAP_STATE_BOOTLOADER;
// Tell the mainboard to get into bootloader state:
log("Detecting devices, please wait 5 seconds...");
this->repaint();
delay::msleep(5100); // Required to let the board(s) settle
log("Detecting devices, please wait a few seconds...");
if (!dfu) {
if (dlj.startsWith("USB"))
dfu = new DFUObject(DFU_DEBUG, false, QString());

View File

@ -9,6 +9,8 @@ BOARD := STM32103CB_AHRS
MODEL := MD
MODEL_SUFFIX :=
OPENOCD_CONFIG := stm32f1x.cfg
# Note: These must match the values in link_$(BOARD)_memory.ld
BL_BANK_BASE := 0x08000000 # Start of bootloader flash
BL_BANK_SIZE := 0x00002000 # Should include BD_INFO region

View File

@ -9,6 +9,8 @@ BOARD := STM32103CB_CC_Rev1
MODEL := MD
MODEL_SUFFIX := _CC
OPENOCD_CONFIG := stm32f1x.cfg
# Note: These must match the values in link_$(BOARD)_memory.ld
BL_BANK_BASE := 0x08000000 # Start of bootloader flash
BL_BANK_SIZE := 0x00003000 # Should include BD_INFO region

View File

@ -9,6 +9,8 @@ BOARD := STM32F2xx_INS
MODEL := HD
MODEL_SUFFIX :=
OPENOCD_CONFIG := stm32f1x.cfg
# Note: These must match the values in link_$(BOARD)_memory.ld
BL_BANK_BASE := 0x08000000 # Start of bootloader flash
BL_BANK_SIZE := 0x00008000 # Should include BD_INFO region

View File

@ -9,6 +9,8 @@ BOARD := STM3210E_OP
MODEL := HD
MODEL_SUFFIX := _OP
OPENOCD_CONFIG := stm32f1x.cfg
# Note: These must match the values in link_$(BOARD)_memory.ld
BL_BANK_BASE := 0x08000000 # Start of bootloader flash
BL_BANK_SIZE := 0x00005000 # Should include BD_INFO region

View File

@ -201,6 +201,7 @@ endef
# $(1) = Name of binary image to write
# $(2) = Base of flash region to write/wipe
# $(3) = Size of flash region to write/wipe
# $(4) = OpenOCD configuration file to use
define JTAG_TEMPLATE
# ---------------------------------------------------------------------------
# Options for OpenOCD flash-programming
@ -213,7 +214,7 @@ OOCD_EXE ?= openocd
OOCD_JTAG_SETUP = -d0
# interface and board/target settings (using the OOCD target-library here)
OOCD_JTAG_SETUP += -s $(TOP)/flight/Project/OpenOCD
OOCD_JTAG_SETUP += -f foss-jtag.revb.cfg -f stm32f1x.cfg
OOCD_JTAG_SETUP += -f foss-jtag.revb.cfg -f $(4)
# initialize
OOCD_BOARD_RESET = -c init
@ -244,48 +245,3 @@ wipe:
-c "shutdown"
endef
# $(1) = Name of binary image to write
# $(2) = Base of flash region to write/wipe
# $(3) = Size of flash region to write/wipe
define JTAG_TEMPLATE_F2X
# ---------------------------------------------------------------------------
# Options for OpenOCD flash-programming
# see openocd.pdf/openocd.texi for further information
# if OpenOCD is in the $PATH just set OPENOCDEXE=openocd
OOCD_EXE ?= openocd
# debug level
OOCD_JTAG_SETUP = -d0
# interface and board/target settings (using the OOCD target-library here)
OOCD_JTAG_SETUP += -s $(TOP)/flight/Project/OpenOCD
OOCD_JTAG_SETUP += -f foss-jtag.revb.cfg -f stm32f2x.cfg
# initialize
OOCD_BOARD_RESET = -c init
# show the targets
#OOCD_BOARD_RESET += -c targets
# commands to prepare flash-write
OOCD_BOARD_RESET += -c "reset halt"
.PHONY: program
program: $(1)
@echo $(MSG_JTAG_PROGRAM) $$(call toprel, $$<)
$(V1) $(OOCD_EXE) \
$$(OOCD_JTAG_SETUP) \
$$(OOCD_BOARD_RESET) \
-c "flash write_image erase $$< $(2) bin" \
-c "verify_image $$< $(2) bin" \
-c "reset run" \
-c "shutdown"
.PHONY: wipe
wipe:
@echo $(MSG_JTAG_WIPE) wiping $(3) bytes starting from $(2)
$(V1) $(OOCD_EXE) \
$$(OOCD_JTAG_SETUP) \
$$(OOCD_BOARD_RESET) \
-c "flash erase_address pad $(2) $(3)" \
-c "reset run" \
-c "shutdown"
endef