diff --git a/.gitignore b/.gitignore index 5f12c3dfd..06eca8f32 100644 --- a/.gitignore +++ b/.gitignore @@ -1,88 +1,54 @@ -# Exclude temporary and system files -.DS_Store +# Ignore artifacts of top-level Makefile +/downloads +/tools +/build -# /flight/ +# Exclude temporary and system files +Thumbs.db +.DS_Store +GPATH +GRTAGS +GSYMS +GTAGS + +# flight /flight/*.pnproj /flight/*.pnps /flight/.cproject /flight/.metadata /flight/.project /flight/.settings -/flight/Build - -# /flight/AHRS/ -/flight/AHRS/Build - -# /flight/Bootloaders/OpenPilot.old/ -/flight/Bootloaders/OpenPilot.old/Build - -# /flight/OpenPilot/ -/flight/OpenPilot/Build -/flight/OpenPilot/Build.win32 - -#flight/Project/OpenPilotOSX -flight/Project/OpenPilotOSX/build - -# /flight/PipBee/ -/flight/PipBee/Build - -# /flight/Project/OpenPilotOSX/ -/flight/Project/OpenPilotOSX/build/ - -# /ground/ -/ground/Build - -/ground/openpilotgcs/share/openpilotgcs/models/Easystar/Thumbs.db - -/ground/openpilotgcs/share/openpilotgcs/sounds/normalize.exe - -/ground/openpilotgcs/share/openpilotgcs/sounds/default/normalize.exe - -/ground/openpilotgcs/share/openpilotgcs/translations/extract-mimetypes.xq - -/ground/openpilotgcs/src/experimental/OPMapWidget/core/header.h - -/ground/openpilotgcs/src/experimental/tools/DocumentationHelper/ui_mainwindow.h - -/ground/openpilotgcs/src/libs/qextserialport/.hg -/ground/openpilotgcs/src/libs/qextserialport/.hgtags - -/ground/openpilotgcs/src/libs/qwt/qwt.prf -/ground/openpilotgcs/src/libs/qwt/designer - -/ground/openpilotgcs/src/plugins/ipconnection/ui_ipconnectionoptionspage.h - -# Ignore artifacts of top-level Makefile -/downloads -/tools -/build +/flight/Project/OpenPilotOSX/OpenPilotOSX.xcodeproj/*.mode1v3 +/flight/Project/OpenPilotOSX/OpenPilotOSX.xcodeproj/*.pbxuser +# ground openpilotgcs-build-desktop -flight/Project/OpenPilotOSX/OpenPilotOSX.xcodeproj/*.mode1v3 -flight/Project/OpenPilotOSX/OpenPilotOSX.xcodeproj/*.pbxuser # Ignore some of the .pro.user files -ground/openpilotgcs/openpilotgcs.pro.user -ground/uavobjgenerator/uavobjgenerator.pro.user -ground/uavobjects/uavobjects.pro.user -ground/ground.pro.user +/ground/openpilotgcs/openpilotgcs.pro.user +/ground/uavobjgenerator/uavobjgenerator.pro.user +/ground/uavobjects/uavobjects.pro.user +/ground/ground.pro.user -GPATH -GRTAGS -GSYMS -GTAGS - -plane -quad +# Misc artifacts +/ground/openpilotgcs/share/openpilotgcs/sounds/normalize.exe +/ground/openpilotgcs/share/openpilotgcs/sounds/default/normalize.exe +/ground/openpilotgcs/share/openpilotgcs/translations/extract-mimetypes.xq +/ground/openpilotgcs/src/experimental/tools/DocumentationHelper/ui_mainwindow.h +/ground/openpilotgcs/src/libs/qextserialport/.hg +/ground/openpilotgcs/src/libs/qextserialport/.hgtags +/ground/openpilotgcs/src/libs/qwt/qwt.prf +/ground/openpilotgcs/src/libs/qwt/designer +/ground/openpilotgcs/src/plugins/ipconnection/ui_ipconnectionoptionspage.h # Ignore intermediate files generated by command-line android builds # Couldn't figure out how to force these files into the ./build directory -androidgcs/build.xml -androidgcs/local.properties -androidgcs/proguard-project.txt +/androidgcs/build.xml +/androidgcs/local.properties +/androidgcs/proguard-project.txt # Ignore build output from Eclipse android builds -androidgcs/bin/ -androidgcs/gen/ +/androidgcs/bin/ +/androidgcs/gen/ /.cproject /.project diff --git a/HISTORY.txt b/HISTORY.txt index aa6bc6ef4..23cf292fe 100644 --- a/HISTORY.txt +++ b/HISTORY.txt @@ -172,7 +172,7 @@ By default a lot of diagnostic objects that were enabled by default are now disabled in the build. This include TaskInfo (and all the FreeRTOS options that provide that debugging information). Also MixerStatus, I2CStatus, WatchdogStatus and RateDesired. These can be reenabled for debugging with --DDIAGNOSTICS. +-DDIAG_ALL. 2011-08-04 Fixed packaging aesthetic issues. Also avoid runtime issues on OSX Lion by diff --git a/Makefile b/Makefile index 9605e7194..f7cca5298 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,44 @@ +# +# Top level Makefile for the OpenPilot project build system. +# Copyright (c) 2010-2013, The OpenPilot Team, http://www.openpilot.org +# +# 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 +# + +# This top level Makefile passes down some variables to sub-makes through +# the environment. They are explicitly exported using the export keyword. +# Lower level makefiles assume that these variables are defined. To ensure +# that a special magic variable is exported here. It must be checked for +# existance by each sub-make. +export OPENPILOT_IS_COOL := Fuck Yeah! + # Set up a default goal .DEFAULT_GOAL := help # Set up some macros for common directories within the tree -ROOT_DIR=$(CURDIR) -TOOLS_DIR=$(ROOT_DIR)/tools -BUILD_DIR=$(ROOT_DIR)/build -DL_DIR=$(ROOT_DIR)/downloads +export ROOT_DIR := $(realpath $(dir $(lastword $(MAKEFILE_LIST)))) +export TOOLS_DIR := $(ROOT_DIR)/tools +export BUILD_DIR := $(ROOT_DIR)/build +export DL_DIR := $(ROOT_DIR)/downloads +export PACKAGE_DIR := $(ROOT_DIR)/build/package + +# Set up default build configurations (debug | release) +GCS_BUILD_CONF := release +UAVOGEN_BUILD_CONF := debug +ANDROIDGCS_BUILD_CONF := debug +GOOGLE_API_VERSION := 14 # Function for converting an absolute path to one relative # to the top of the source tree. @@ -15,10 +48,10 @@ toprel = $(subst $(realpath $(ROOT_DIR))/,,$(abspath $(1))) # to remove the chance that they will cause problems with our build define SANITIZE_VAR $(if $(filter-out undefined,$(origin $(1))), - $(info *NOTE* Sanitized $(2) variable '$(1)' from $(origin $(1))) - MAKEOVERRIDES = $(filter-out $(1)=%,$(MAKEOVERRIDES)) - override $(1) := - unexport $(1) + $(info *NOTE* Sanitized $(2) variable '$(1)' from $(origin $(1))) + MAKEOVERRIDES = $(filter-out $(1)=%,$(MAKEOVERRIDES)) + override $(1) := + unexport $(1) ) endef @@ -31,144 +64,117 @@ $(foreach var, $(SANITIZE_GCC_VARS), $(eval $(call SANITIZE_VAR,$(var),disallowe SANITIZE_DEPRECATED_VARS := USE_BOOTLOADER $(foreach var, $(SANITIZE_DEPRECATED_VARS), $(eval $(call SANITIZE_VAR,$(var),deprecated))) -# Deal with unreasonable requests -# See: http://xkcd.com/149/ -ifeq ($(MAKECMDGOALS),me a sandwich) - ifeq ($(shell whoami),root) - $(error Okay) - else - $(error What? Make it yourself) - endif -endif - -# Make sure this isn't being run as root -ifeq ($(shell whoami),root) -$(error You should not be running this as root) +# Make sure this isn't being run as root (no whoami on Windows, but that is ok here) +ifeq ($(shell whoami 2>/dev/null),root) + $(error You should not be running this as root) endif # Decide on a verbosity level based on the V= parameter export AT := @ - ifndef V -export V0 := -export V1 := $(AT) + export V0 := + export V1 := $(AT) else ifeq ($(V), 0) -export V0 := $(AT) -export V1 := $(AT) + export V0 := $(AT) + export V1 := $(AT) else ifeq ($(V), 1) endif -# Make sure we know a few things about the architecture before including +# Make sure we know few things about the architecture before including # the tools.mk to ensure that we download/install the right tools. UNAME := $(shell uname) -ARCH := $(shell uname -m) - -include $(ROOT_DIR)/make/tools.mk - -# We almost need to consider autoconf/automake instead of this -# I don't know if windows supports uname :-( -QT_SPEC=win32-g++ -UAVOBJGENERATOR="$(BUILD_DIR)/ground/uavobjgenerator/debug/uavobjgenerator.exe" -ifeq ($(UNAME), Linux) - QT_SPEC=linux-g++ - UAVOBJGENERATOR="$(BUILD_DIR)/ground/uavobjgenerator/uavobjgenerator" +ARCH := $(shell uname -m) +# Here and everywhere if not Linux or OSX then assume Windows +ifeq ($(filter Linux Darwin, $(UNAME)), ) + UNAME := Windows endif -ifeq ($(UNAME), Darwin) - QT_SPEC=macx-g++ - UAVOBJGENERATOR="$(BUILD_DIR)/ground/uavobjgenerator/uavobjgenerator" -endif - -# OpenPilot GCS build configuration (debug | release) -GCS_BUILD_CONF ?= debug # Set up misc host tools -RM=rm +export ECHO := echo +export MKDIR := mkdir +export CP := cp +export RM := rm +export LN := ln +export CAT := cat +export SED := sed +export TAR := tar +export ANT := ant +export JAVAC := javac +export JAR := jar +export GIT := git +export PYTHON := python +export INSTALL := install -.PHONY: help -help: - @echo - @echo " This Makefile is known to work on Linux and Mac in a standard shell environment." - @echo " It also works on Windows by following the instructions in make/winx86/README.txt." - @echo - @echo " Here is a summary of the available targets:" - @echo - @echo " [Tool Installers]" - @echo " qt_sdk_install - Install the QT v4.7.3 tools" - @echo " arm_sdk_install - Install the GNU ARM gcc toolchain" - @echo " openocd_install - Install the OpenOCD JTAG daemon" - @echo " stm32flash_install - Install the stm32flash tool for unbricking boards" - @echo " dfuutil_install - Install the dfu-util tool for unbricking F4-based boards" - @echo " android_sdk_install - Install the Android SDK tools" - @echo - @echo " [Big Hammer]" - @echo " all - Generate UAVObjects, build openpilot firmware and gcs" - @echo " all_flight - Build all firmware, bootloaders and bootloader updaters" - @echo " all_fw - Build only firmware for all boards" - @echo " all_bl - Build only bootloaders for all boards" - @echo " all_bu - Build only bootloader updaters for all boards" - @echo - @echo " all_clean - Remove your build directory ($(BUILD_DIR))" - @echo " all_flight_clean - Remove all firmware, bootloaders and bootloader updaters" - @echo " all_fw_clean - Remove firmware for all boards" - @echo " all_bl_clean - Remove bootlaoders for all boards" - @echo " all_bu_clean - Remove bootloader updaters for all boards" - @echo - @echo " all_ - Build all available images for " - @echo " all__clean - Remove all available images for " - @echo - @echo " all_ut - Build all unit tests" - @echo " all_ut_tap - Run all unit tests and capture all TAP output to files" - @echo " all_ut_run - Run all unit tests and dump TAP output to console" - @echo - @echo " [Firmware]" - @echo " - Build firmware for " - @echo " supported boards are ($(ALL_BOARDS))" - @echo " fw_ - Build firmware for " - @echo " supported boards are ($(FW_BOARDS))" - @echo " fw__clean - Remove firmware for " - @echo " fw__program - Use OpenOCD + JTAG to write firmware to " - @echo - @echo " [Bootloader]" - @echo " bl_ - Build bootloader for " - @echo " supported boards are ($(BL_BOARDS))" - @echo " bl__clean - Remove bootloader for " - @echo " bl__program - Use OpenOCD + JTAG to write bootloader to " - @echo - @echo " [Bootloader Updater]" - @echo " bu_ - Build bootloader updater for " - @echo " supported boards are ($(BU_BOARDS))" - @echo " bu__clean - Remove bootloader updater for " - @echo - @echo " [Unbrick a board]" - @echo " unbrick_ - Use the STM32's built in boot ROM to write a bootloader to " - @echo " supported boards are ($(BL_BOARDS))" - @echo " [Unittests]" - @echo " ut_ - Build unit test " - @echo " ut__tap - Run test and capture TAP output into a file" - @echo " ut__run - Run test and dump TAP output to console" - @echo - @echo " [Simulation]" - @echo " sim_osx - Build OpenPilot simulation firmware for OSX" - @echo " sim_osx_clean - Delete all build output for the osx simulation" - @echo " sim_win32 - Build OpenPilot simulation firmware for" - @echo " Windows using mingw and msys" - @echo " sim_win32_clean - Delete all build output for the win32 simulation" - @echo - @echo " [GCS]" - @echo " gcs - Build the Ground Control System (GCS) application" - @echo " gcs_clean - Remove the Ground Control System (GCS) application" - @echo - @echo " [UAVObjects]" - @echo " uavobjects - Generate source files from the UAVObject definition XML files" - @echo " uavobjects_test - parse xml-files - check for valid, duplicate ObjId's, ... " - @echo " uavobjects_ - Generate source files from a subset of the UAVObject definition XML files" - @echo " supported groups are ($(UAVOBJ_TARGETS))" - @echo - @echo " Hint: Add V=1 to your command line to see verbose build output." - @echo - @echo " Note: All tools will be installed into $(TOOLS_DIR)" - @echo " All build output will be placed in $(BUILD_DIR)" - @echo +# Command to extract version info data from the repository and source tree +export VERSION_INFO := $(PYTHON) "$(ROOT_DIR)/make/scripts/version-info.py" --path="$(ROOT_DIR)" + +# Test if quotes are needed for the echo-command +ifeq (${shell $(ECHO) "test"}, test) + export QUOTE := ' +# This line is just to clear out the single quote above ' +else + export QUOTE := +endif + +# The tools.mk uses wget to fetch tarballs or packages +ifeq ($(shell [ -x "$(TOOLS_DIR)/bin/wget" ] && $(ECHO) "exists"), exists) + WGET := $(TOOLS_DIR)/bin/wget +else + # not installed, hope it's in the path... + WGET ?= wget +endif + +# Include tools installers +include $(ROOT_DIR)/make/tools.mk + +# Set up paths to tools +ifeq ($(shell [ -d "$(QT_SDK_DIR)" ] && $(ECHO) "exists"), exists) + QMAKE := $(QT_SDK_QMAKE_PATH) +else + # not installed, hope it's in the path... + QMAKE ?= qmake +endif + +ifeq ($(shell [ -d "$(ARM_SDK_DIR)" ] && $(ECHO) "exists"), exists) + export ARM_SDK_PREFIX := $(ARM_SDK_DIR)/bin/arm-none-eabi- +else + # not installed, hope it's in the path... + export ARM_SDK_PREFIX ?= arm-none-eabi- +endif + +ifeq ($(shell [ -d "$(OPENOCD_DIR)" ] && $(ECHO) "exists"), exists) + export OPENOCD := $(OPENOCD_DIR)/bin/openocd +else + # not installed, hope it's in the path... + export OPENOCD ?= openocd +endif + +ifeq ($(shell [ -d "$(ANDROID_SDK_DIR)" ] && $(ECHO) "exists"), exists) + ANDROID := $(ANDROID_SDK_DIR)/tools/android + ANDROID_DX := $(ANDROID_SDK_DIR)/platform-tools/dx +else + # not installed, hope it's in the path... + ANDROID ?= android + ANDROID_DX ?= dx +endif + +# We almost need to consider autoconf/automake instead of this +ifeq ($(UNAME), Linux) + QT_SPEC = linux-g++ + UAVOBJGENERATOR = "$(BUILD_DIR)/ground/uavobjgenerator/uavobjgenerator" +else ifeq ($(UNAME), Darwin) + QT_SPEC = macx-g++ + UAVOBJGENERATOR = "$(BUILD_DIR)/ground/uavobjgenerator/uavobjgenerator" +else + QT_SPEC = win32-g++ + UAVOBJGENERATOR = "$(BUILD_DIR)/ground/uavobjgenerator/$(UAVOGEN_BUILD_CONF)/uavobjgenerator.exe" +endif + +############################## +# +# All targets +# +############################## .PHONY: all all: uavobjects all_ground all_flight @@ -178,268 +184,57 @@ all_clean: [ ! -d "$(BUILD_DIR)" ] || $(RM) -rf "$(BUILD_DIR)" $(DL_DIR): - mkdir -p $@ + $(MKDIR) -p $@ $(TOOLS_DIR): - mkdir -p $@ + $(MKDIR) -p $@ $(BUILD_DIR): - mkdir -p $@ + $(MKDIR) -p $@ ############################## # -# Set up paths to tools +# UAVObjects # ############################## -ifeq ($(shell [ -d "$(QT_SDK_DIR)" ] && echo "exists"), exists) - QMAKE = $(QT_SDK_QMAKE_PATH) -else - # not installed, hope it's in the path... - QMAKE = qmake -endif - -ifeq ($(shell [ -d "$(ARM_SDK_DIR)" ] && echo "exists"), exists) - ARM_SDK_PREFIX := $(ARM_SDK_DIR)/bin/arm-none-eabi- -else - # not installed, hope it's in the path... - ARM_SDK_PREFIX ?= arm-none-eabi- -endif - -ifeq ($(shell [ -d "$(OPENOCD_DIR)" ] && echo "exists"), exists) - OPENOCD := $(OPENOCD_DIR)/bin/openocd -else - # not installed, hope it's in the path... - OPENOCD ?= openocd -endif - -ifeq ($(shell [ -d "$(ANDROID_SDK_DIR)" ] && echo "exists"), exists) - ANDROID := $(ANDROID_SDK_DIR)/tools/android - ANDROID_DX := $(ANDROID_SDK_DIR)/platform-tools/dx -else - # not installed, hope it's in the path... - ANDROID ?= android - ANDROID_DX ?= dx -endif - -############################## -# -# GCS related components -# -############################## - -.PHONY: all_ground -all_ground: openpilotgcs - -# Convenience target for the GCS -.PHONY: gcs gcs_clean -gcs: openpilotgcs -gcs_clean: openpilotgcs_clean - ifeq ($(V), 1) -GCS_SILENT := + UAVOGEN_SILENT := else -GCS_SILENT := silent -endif - -.PHONY: openpilotgcs -openpilotgcs: uavobjects_gcs - $(V1) mkdir -p $(BUILD_DIR)/ground/$@ - $(V1) ( cd $(BUILD_DIR)/ground/$@ && \ - $(QMAKE) $(ROOT_DIR)/ground/openpilotgcs/openpilotgcs.pro -spec $(QT_SPEC) -r CONFIG+="$(GCS_BUILD_CONF) $(GCS_SILENT)" $(GCS_QMAKE_OPTS) && \ - $(MAKE) -w ; \ - ) - -.PHONY: openpilotgcs_clean -openpilotgcs_clean: - $(V0) @echo " CLEAN $@" - $(V1) [ ! -d "$(BUILD_DIR)/ground/openpilotgcs" ] || $(RM) -r "$(BUILD_DIR)/ground/openpilotgcs" - -ifeq ($(V), 1) -UAVOGEN_SILENT := -else -UAVOGEN_SILENT := silent + UAVOGEN_SILENT := silent endif .PHONY: uavobjgenerator uavobjgenerator: - $(V1) mkdir -p $(BUILD_DIR)/ground/$@ + $(V1) $(MKDIR) -p $(BUILD_DIR)/ground/$@ $(V1) ( cd $(BUILD_DIR)/ground/$@ && \ - $(QMAKE) $(ROOT_DIR)/ground/uavobjgenerator/uavobjgenerator.pro -spec $(QT_SPEC) -r CONFIG+="debug $(UAVOGEN_SILENT)" && \ - $(MAKE) --no-print-directory -w ; \ + $(QMAKE) $(ROOT_DIR)/ground/uavobjgenerator/uavobjgenerator.pro -spec $(QT_SPEC) -r CONFIG+="$(UAVOGEN_BUILD_CONF) $(UAVOGEN_SILENT)" && \ + $(MAKE) --no-print-directory -w ; \ ) UAVOBJ_TARGETS := gcs flight python matlab java wireshark -.PHONY:uavobjects + +.PHONY: uavobjects uavobjects: $(addprefix uavobjects_, $(UAVOBJ_TARGETS)) UAVOBJ_XML_DIR := $(ROOT_DIR)/shared/uavobjectdefinition UAVOBJ_OUT_DIR := $(BUILD_DIR)/uavobject-synthetics $(UAVOBJ_OUT_DIR): - $(V1) mkdir -p $@ + $(V1) $(MKDIR) -p $@ uavobjects_%: $(UAVOBJ_OUT_DIR) uavobjgenerator $(V1) ( cd $(UAVOBJ_OUT_DIR) && \ - $(UAVOBJGENERATOR) -$* $(UAVOBJ_XML_DIR) $(ROOT_DIR) ; \ + $(UAVOBJGENERATOR) -$* $(UAVOBJ_XML_DIR) $(ROOT_DIR) ; \ ) uavobjects_test: $(UAVOBJ_OUT_DIR) uavobjgenerator $(V1) $(UAVOBJGENERATOR) -v -none $(UAVOBJ_XML_DIR) $(ROOT_DIR) uavobjects_clean: - $(V0) @echo " CLEAN $@" + $(V0) @$(ECHO) " CLEAN $@" $(V1) [ ! -d "$(UAVOBJ_OUT_DIR)" ] || $(RM) -r "$(UAVOBJ_OUT_DIR)" -################################ -# -# Android GCS related components -# -################################ - -ANDROIDGCS_BUILD_CONF ?= debug - -# Build the output directory for the Android GCS build -ANDROIDGCS_OUT_DIR := $(BUILD_DIR)/androidgcs -$(ANDROIDGCS_OUT_DIR): - $(V1) mkdir -p $@ - -# Build the asset directory for the android assets -ANDROIDGCS_ASSETS_DIR := $(ANDROIDGCS_OUT_DIR)/assets -$(ANDROIDGCS_ASSETS_DIR)/uavos: - $(V1) mkdir -p $@ - -ifeq ($(V), 1) -ANT_QUIET := -ANDROID_SILENT := -else -ANT_QUIET := -q -ANDROID_SILENT := -s -endif -.PHONY: androidgcs -androidgcs: uavo-collections_java - $(V0) @echo " ANDROID $(call toprel, $(ANDROIDGCS_OUT_DIR))" - $(V1) mkdir -p $(ANDROIDGCS_OUT_DIR) - $(V1) $(ANDROID) $(ANDROID_SILENT) update project --target 'Google Inc.:Google APIs:14' --name androidgcs --path ./androidgcs - $(V1) ant -f ./androidgcs/build.xml \ - $(ANT_QUIET) \ - -Dout.dir="../$(call toprel, $(ANDROIDGCS_OUT_DIR)/bin)" \ - -Dgen.absolute.dir="$(ANDROIDGCS_OUT_DIR)/gen" \ - $(ANDROIDGCS_BUILD_CONF) - -.PHONY: androidgcs_clean -androidgcs_clean: - $(V0) @echo " CLEAN $@" - $(V1) [ ! -d "$(ANDROIDGCS_OUT_DIR)" ] || $(RM) -r "$(ANDROIDGCS_OUT_DIR)" - -# We want to take snapshots of the UAVOs at each point that they change -# to allow the GCS to be compatible with as many versions as possible. -# -# Find the git hashes of each commit that changes uavobjects with: -# git log --format=%h -- shared/uavobjectdefinition/ | head -n 2 -UAVO_GIT_VERSIONS := 5e14f53 - -# All versions includes a pseudo collection called "working" which represents -# the UAVOs in the source tree -UAVO_ALL_VERSIONS := $(UAVO_GIT_VERSIONS) srctree - -# This is where the UAVO collections are stored -UAVO_COLLECTION_DIR := $(BUILD_DIR)/uavo-collections - -# $(1) git hash of a UAVO snapshot -define UAVO_COLLECTION_GIT_TEMPLATE - -# Make the output directory that will contain all of the synthetics for the -# uavo collection referenced by the git hash $(1) -$$(UAVO_COLLECTION_DIR)/$(1): - $$(V1) mkdir -p $$(UAVO_COLLECTION_DIR)/$(1) - -# Extract the snapshot of shared/uavobjectdefinition from git hash $(1) -$$(UAVO_COLLECTION_DIR)/$(1)/uavo-xml.tar: | $$(UAVO_COLLECTION_DIR)/$(1) -$$(UAVO_COLLECTION_DIR)/$(1)/uavo-xml.tar: - $$(V0) @echo " UAVOTAR $(1)" - $$(V1) git archive $(1) -o $$@ -- shared/uavobjectdefinition/ - -# Extract the uavo xml files from our snapshot -$$(UAVO_COLLECTION_DIR)/$(1)/uavo-xml: $$(UAVO_COLLECTION_DIR)/$(1)/uavo-xml.tar - $$(V0) @echo " UAVOUNTAR $(1)" - $$(V1) rm -rf $$@ - $$(V1) mkdir -p $$@ - $$(V1) tar -C $$(call toprel, $$@) -xf $$(call toprel, $$<) || rm -rf $$@ -endef - -# Map the current working directory into the set of UAVO collections -$(UAVO_COLLECTION_DIR)/srctree: - $(V1) mkdir -p $@ - -$(UAVO_COLLECTION_DIR)/srctree/uavo-xml: | $(UAVO_COLLECTION_DIR)/srctree -$(UAVO_COLLECTION_DIR)/srctree/uavo-xml: $(UAVOBJ_XML_DIR) - $(V1) ln -sf $(ROOT_DIR) $(UAVO_COLLECTION_DIR)/srctree/uavo-xml - -# $(1) git hash (or symbolic name) of a UAVO snapshot -define UAVO_COLLECTION_BUILD_TEMPLATE - -# This leaves us with a (broken) symlink that points to the full sha1sum of the collection -$$(UAVO_COLLECTION_DIR)/$(1)/uavohash: $$(UAVO_COLLECTION_DIR)/$(1)/uavo-xml - # Compute the sha1 hash for this UAVO collection - # The sed bit truncates the UAVO hash to 16 hex digits - $$(V1) python $$(ROOT_DIR)/make/scripts/version-info.py \ - --path=$$(ROOT_DIR) \ - --uavodir=$$(UAVO_COLLECTION_DIR)/$(1)/uavo-xml/shared/uavobjectdefinition \ - --format='$$$${UAVOSHA1TXT}' | \ - sed -e 's|\(................\).*|\1|' > $$@ - - $$(V0) @echo " UAVOHASH $(1) ->" $$$$(cat $$(UAVO_COLLECTION_DIR)/$(1)/uavohash) - -# Generate the java uavobjects for this UAVO collection -$$(UAVO_COLLECTION_DIR)/$(1)/java-build/java: $$(UAVO_COLLECTION_DIR)/$(1)/uavohash - $$(V0) @echo " UAVOJAVA $(1) " $$$$(cat $$(UAVO_COLLECTION_DIR)/$(1)/uavohash) - $$(V1) mkdir -p $$@ - $$(V1) ( \ - cd $$(UAVO_COLLECTION_DIR)/$(1)/java-build && \ - $$(UAVOBJGENERATOR) -java $$(UAVO_COLLECTION_DIR)/$(1)/uavo-xml/shared/uavobjectdefinition $$(ROOT_DIR) ; \ - ) - -# Build a jar file for this UAVO collection -$$(UAVO_COLLECTION_DIR)/$(1)/java-build/uavobjects.jar: | $$(ANDROIDGCS_ASSETS_DIR)/uavos -$$(UAVO_COLLECTION_DIR)/$(1)/java-build/uavobjects.jar: $$(UAVO_COLLECTION_DIR)/$(1)/java-build/java - $$(V0) @echo " UAVOJAR $(1) " $$$$(cat $$(UAVO_COLLECTION_DIR)/$(1)/uavohash) - $$(V1) ( \ - HASH=$$$$(cat $$(UAVO_COLLECTION_DIR)/$(1)/uavohash) && \ - cd $$(UAVO_COLLECTION_DIR)/$(1)/java-build && \ - javac java/*.java \ - $$(ROOT_DIR)/androidgcs/src/org/openpilot/uavtalk/UAVDataObject.java \ - $$(ROOT_DIR)/androidgcs/src/org/openpilot/uavtalk/UAVObject*.java \ - $$(ROOT_DIR)/androidgcs/src/org/openpilot/uavtalk/UAVMetaObject.java \ - -d . && \ - find ./org/openpilot/uavtalk/uavobjects -type f -name '*.class' > classlist.txt && \ - jar cf tmp_uavobjects.jar @classlist.txt && \ - $$(ANDROID_DX) \ - --dex \ - --output $$(ANDROIDGCS_ASSETS_DIR)/uavos/$$$${HASH}.jar \ - tmp_uavobjects.jar && \ - ln -sf $$(ANDROIDGCS_ASSETS_DIR)/uavos/$$$${HASH}.jar uavobjects.jar \ - ) - -endef - -# One of these for each element of UAVO_GIT_VERSIONS so we can extract the UAVOs from git -$(foreach githash, $(UAVO_GIT_VERSIONS), $(eval $(call UAVO_COLLECTION_GIT_TEMPLATE,$(githash)))) - -# One of these for each UAVO_ALL_VERSIONS which includes the ones in the srctree -$(foreach githash, $(UAVO_ALL_VERSIONS), $(eval $(call UAVO_COLLECTION_BUILD_TEMPLATE,$(githash)))) - -.PHONY: uavo-collections_java -uavo-collections_java: $(foreach githash, $(UAVO_ALL_VERSIONS), $(UAVO_COLLECTION_DIR)/$(githash)/java-build/uavobjects.jar) - -.PHONY: uavo-collections -uavo-collections: uavo-collections_java - -.PHONY: uavo-collections_clean -uavo-collections_clean: - $(V0) @echo " CLEAN $(UAVO_COLLECTION_DIR)" - $(V1) [ ! -d "$(UAVO_COLLECTION_DIR)" ] || $(RM) -r $(UAVO_COLLECTION_DIR) - ############################## # # Flight related components @@ -448,14 +243,75 @@ uavo-collections_clean: # Define some pointers to the various important pieces of the flight code # to prevent these being repeated in every sub makefile -PIOS := $(ROOT_DIR)/flight/PiOS -FLIGHTLIB := $(ROOT_DIR)/flight/Libraries -OPMODULEDIR := $(ROOT_DIR)/flight/Modules -OPUAVOBJ := $(ROOT_DIR)/flight/targets/UAVObjects -OPUAVTALK := $(ROOT_DIR)/flight/targets/UAVTalk -HWDEFS := $(ROOT_DIR)/flight/targets/board_hw_defs -DOXYGENDIR := $(ROOT_DIR)/flight/Doc/Doxygen -OPUAVSYNTHDIR := $(BUILD_DIR)/uavobject-synthetics/flight +export PIOS := $(ROOT_DIR)/flight/PiOS +export FLIGHTLIB := $(ROOT_DIR)/flight/Libraries +export OPMODULEDIR := $(ROOT_DIR)/flight/Modules +export OPUAVOBJ := $(ROOT_DIR)/flight/targets/UAVObjects +export OPUAVTALK := $(ROOT_DIR)/flight/targets/UAVTalk +export HWDEFS := $(ROOT_DIR)/flight/targets/board_hw_defs +export DOXYGENDIR := $(ROOT_DIR)/flight/Doc/Doxygen +export OPUAVSYNTHDIR := $(BUILD_DIR)/uavobject-synthetics/flight + +# Define supported board lists +ALL_BOARDS := coptercontrol pipxtreme revolution revomini osd simposix +ALL_BOARDS_BU := coptercontrol pipxtreme simposix + +# Friendly names of each board (used to find source tree) +coptercontrol_friendly := CopterControl +pipxtreme_friendly := PipXtreme +revolution_friendly := Revolution +revomini_friendly := RevoMini +osd_friendly := OSD +simposix_friendly := SimPosix + +# Short names of each board (used to display board name in parallel builds) +coptercontrol_short := 'cc ' +pipxtreme_short := 'pipx' +revolution_short := 'revo' +revomini_short := 'rm ' +osd_short := 'osd ' +simposix_short := 'posx' + +# SimPosix only builds on Linux so drop it from the list for +# all other platforms. +ifneq ($(UNAME), Linux) + ALL_BOARDS := $(filter-out simposix, $(ALL_BOARDS)) + ALL_BOARDS_BU := $(filter-out simposix, $(ALL_BOARDS_BU)) +endif + +# Start out assuming that we'll build fw, bl and bu for all boards +FW_BOARDS := $(ALL_BOARDS) +BL_BOARDS := $(ALL_BOARDS) +BU_BOARDS := $(ALL_BOARDS_BU) +EF_BOARDS := $(ALL_BOARDS) + +# SimPosix doesn't have a BL, BU or EF target so we need to +# filter them out to prevent errors on the all_flight target. +BL_BOARDS := $(filter-out simposix, $(BL_BOARDS)) +BU_BOARDS := $(filter-out simposix, $(BU_BOARDS)) +EF_BOARDS := $(filter-out simposix, $(EF_BOARDS)) + +# Generate the targets for whatever boards are left in each list +FW_TARGETS := $(addprefix fw_, $(FW_BOARDS)) +BL_TARGETS := $(addprefix bl_, $(BL_BOARDS)) +BU_TARGETS := $(addprefix bu_, $(BU_BOARDS)) +EF_TARGETS := $(addprefix ef_, $(EF_BOARDS)) + +# When building any of the "all_*" targets, tell all sub makefiles to display +# additional details on each line of output to describe which build and target +# that each line applies to. The same applies also to all, opfw_resource, +# package and clean_package targets +ifneq ($(strip $(filter all_% all opfw_resource package clean_package,$(MAKECMDGOALS))),) + export ENABLE_MSG_EXTRA := yes +endif + +# When building more than one goal in a single make invocation, also +# enable the extra context for each output line +ifneq ($(word 2,$(MAKECMDGOALS)),) + export ENABLE_MSG_EXTRA := yes +endif + +# TEMPLATES (used to generate build rules) # $(1) = Canonical board name all in lower case (e.g. coptercontrol) # $(2) = Name of board used in source tree (e.g. CopterControl) @@ -466,33 +322,22 @@ $(1): fw_$(1)_opfw fw_$(1): fw_$(1)_opfw fw_$(1)_%: uavobjects_flight - $(V1) mkdir -p $(BUILD_DIR)/fw_$(1)/dep + $(V1) $(MKDIR) -p $(BUILD_DIR)/fw_$(1)/dep $(V1) cd $(ROOT_DIR)/flight/targets/$(2) && \ $$(MAKE) -r --no-print-directory \ BOARD_NAME=$(1) \ BOARD_SHORT_NAME=$(3) \ BUILD_TYPE=fw \ - TCHAIN_PREFIX="$(ARM_SDK_PREFIX)" \ - REMOVE_CMD="$(RM)" OOCD_EXE="$(OPENOCD)" \ - \ - TARGET=fw_$(1) \ - OUTDIR=$(BUILD_DIR)/fw_$(1) \ - \ - PIOS=$(PIOS) \ - FLIGHTLIB=$(FLIGHTLIB) \ - OPMODULEDIR=$(OPMODULEDIR) \ - OPUAVOBJ=$(OPUAVOBJ) \ - OPUAVTALK=$(OPUAVTALK) \ HWDEFSINC=$(HWDEFS)/$(1) \ - DOXYGENDIR=$(DOXYGENDIR) \ - OPUAVSYNTHDIR=$(OPUAVSYNTHDIR) \ - \ + TOPDIR=$(ROOT_DIR)/flight/targets/$(2) \ + OUTDIR=$(BUILD_DIR)/fw_$(1) \ + TARGET=fw_$(1) \ $$* .PHONY: $(1)_clean $(1)_clean: fw_$(1)_clean fw_$(1)_clean: - $(V0) @echo " CLEAN $$@" + $(V0) @$(ECHO) " CLEAN $$@" $(V1) $(RM) -fr $(BUILD_DIR)/fw_$(1) endef @@ -504,46 +349,35 @@ bl_$(1): bl_$(1)_bin bl_$(1)_bino: bl_$(1)_bin bl_$(1)_%: - $(V1) mkdir -p $(BUILD_DIR)/bl_$(1)/dep + $(V1) $(MKDIR) -p $(BUILD_DIR)/bl_$(1)/dep $(V1) cd $(ROOT_DIR)/flight/targets/Bootloaders/$(2) && \ $$(MAKE) -r --no-print-directory \ BOARD_NAME=$(1) \ BOARD_SHORT_NAME=$(3) \ BUILD_TYPE=bl \ - TCHAIN_PREFIX="$(ARM_SDK_PREFIX)" \ - REMOVE_CMD="$(RM)" OOCD_EXE="$(OPENOCD)" \ - \ - TARGET=bl_$(1) \ - OUTDIR=$(BUILD_DIR)/bl_$(1) \ - \ - PIOS=$(PIOS) \ - FLIGHTLIB=$(FLIGHTLIB) \ - OPMODULEDIR=$(OPMODULEDIR) \ - OPUAVOBJ=$(OPUAVOBJ) \ - OPUAVTALK=$(OPUAVTALK) \ HWDEFSINC=$(HWDEFS)/$(1) \ - OPUAVSYNTHDIR=$(OPUAVSYNTHDIR) \ - DOXYGENDIR=$(DOXYGENDIR) \ - \ + TOPDIR=$(ROOT_DIR)/flight/targets/Bootloaders/$(2) \ + OUTDIR=$(BUILD_DIR)/bl_$(1) \ + TARGET=bl_$(1) \ $$* .PHONY: unbrick_$(1) unbrick_$(1): bl_$(1)_hex $(if $(filter-out undefined,$(origin UNBRICK_TTY)), - $(V0) @echo " UNBRICK $(1) via $$(UNBRICK_TTY)" + $(V0) @$(ECHO) " UNBRICK $(1) via $$(UNBRICK_TTY)" $(V1) $(STM32FLASH_DIR)/stm32flash \ -w $(BUILD_DIR)/bl_$(1)/bl_$(1).hex \ -g 0x0 \ $$(UNBRICK_TTY) , - $(V0) @echo - $(V0) @echo "ERROR: You must specify UNBRICK_TTY= to use for unbricking." - $(V0) @echo " eg. $$(MAKE) $$@ UNBRICK_TTY=/dev/ttyUSB0" + $(V0) @$(ECHO) + $(V0) @$(ECHO) "ERROR: You must specify UNBRICK_TTY= to use for unbricking." + $(V0) @$(ECHO) " eg. $$(MAKE) $$@ UNBRICK_TTY=/dev/ttyUSB0" ) .PHONY: bl_$(1)_clean bl_$(1)_clean: - $(V0) @echo " CLEAN $$@" + $(V0) @$(ECHO) " CLEAN $$@" $(V1) $(RM) -fr $(BUILD_DIR)/bl_$(1) endef @@ -553,32 +387,21 @@ define BU_TEMPLATE bu_$(1): bu_$(1)_opfw bu_$(1)_%: bl_$(1)_bino - $(V1) mkdir -p $(BUILD_DIR)/bu_$(1)/dep - $(V1) cd $(ROOT_DIR)/flight/targets/Bootloaders/BootloaderUpdater && \ + $(V1) $(MKDIR) -p $(BUILD_DIR)/bu_$(1)/dep + $(V1) cd $(ROOT_DIR)/flight/targets/BootloaderUpdater && \ $$(MAKE) -r --no-print-directory \ BOARD_NAME=$(1) \ BOARD_SHORT_NAME=$(3) \ BUILD_TYPE=bu \ - TCHAIN_PREFIX="$(ARM_SDK_PREFIX)" \ - REMOVE_CMD="$(RM)" OOCD_EXE="$(OPENOCD)" \ - \ - TARGET=bu_$(1) \ - OUTDIR=$(BUILD_DIR)/bu_$(1) \ - \ - PIOS=$(PIOS) \ - FLIGHTLIB=$(FLIGHTLIB) \ - OPMODULEDIR=$(OPMODULEDIR) \ - OPUAVOBJ=$(OPUAVOBJ) \ - OPUAVTALK=$(OPUAVTALK) \ HWDEFSINC=$(HWDEFS)/$(1) \ - OPUAVSYNTHDIR=$(OPUAVSYNTHDIR) \ - DOXYGENDIR=$(DOXYGENDIR) \ - \ + TOPDIR=$(ROOT_DIR)/flight/targets/BootloaderUpdater \ + OUTDIR=$(BUILD_DIR)/bu_$(1) \ + TARGET=bu_$(1) \ $$* .PHONY: bu_$(1)_clean bu_$(1)_clean: - $(V0) @echo " CLEAN $$@" + $(V0) @$(ECHO) " CLEAN $$@" $(V1) $(RM) -fr $(BUILD_DIR)/bu_$(1) endef @@ -588,39 +411,24 @@ define EF_TEMPLATE ef_$(1): ef_$(1)_bin ef_$(1)_%: bl_$(1)_bin fw_$(1)_opfw - $(V1) mkdir -p $(BUILD_DIR)/ef_$(1)/dep + $(V1) $(MKDIR) -p $(BUILD_DIR)/ef_$(1) $(V1) cd $(ROOT_DIR)/flight/targets/EntireFlash && \ $$(MAKE) -r --no-print-directory \ BOARD_NAME=$(1) \ BOARD_SHORT_NAME=$(3) \ BUILD_TYPE=ef \ - TCHAIN_PREFIX="$(ARM_SDK_PREFIX)" \ DFU_CMD="$(DFUUTIL_DIR)/bin/dfu-util" \ - \ - TARGET=ef_$(1) \ + TOPDIR=$(ROOT_DIR)/flight/targets/EntireFlash \ OUTDIR=$(BUILD_DIR)/ef_$(1) \ - \ + TARGET=ef_$(1) \ $$* .PHONY: ef_$(1)_clean ef_$(1)_clean: - $(V0) @echo " CLEAN $$@" + $(V0) @$(ECHO) " CLEAN $$@" $(V1) $(RM) -fr $(BUILD_DIR)/ef_$(1) endef -# When building any of the "all_*" targets, tell all sub makefiles to display -# additional details on each line of output to describe which build and target -# that each line applies to. -ifneq ($(strip $(filter all_%,$(MAKECMDGOALS))),) -export ENABLE_MSG_EXTRA := yes -endif - -# When building more than one goal in a single make invocation, also -# enable the extra context for each output line -ifneq ($(word 2,$(MAKECMDGOALS)),) -export ENABLE_MSG_EXTRA := yes -endif - # $(1) = Canonical board name all in lower case (e.g. coptercontrol) define BOARD_PHONY_TEMPLATE .PHONY: all_$(1) @@ -636,54 +444,7 @@ 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 revomini simposix osd -ALL_BOARDS_BU := coptercontrol pipxtreme simposix - -# SimPosix only builds on Linux so drop it from the list for -# all other platforms. -ifneq ($(UNAME), Linux) -ALL_BOARDS := $(filter-out simposix, $(ALL_BOARDS)) -ALL_BOARDS_BU := $(filter-out simposix, $(ALL_BOARDS_BU)) -endif - -# Friendly names of each board (used to find source tree) -coptercontrol_friendly := CopterControl -pipxtreme_friendly := PipXtreme -revolution_friendly := Revolution -revomini_friendly := RevoMini -simposix_friendly := SimPosix -osd_friendly := OSD - -# Short names of each board (used to display board name in parallel builds) -coptercontrol_short := 'cc ' -pipxtreme_short := 'pipx' -revolution_short := 'revo' -revomini_short := 'rm ' -simposix_short := 'posx' -osd_short := 'osd ' - -# Start out assuming that we'll build fw, bl and bu for all boards -FW_BOARDS := $(ALL_BOARDS) -BL_BOARDS := $(ALL_BOARDS) -BU_BOARDS := $(ALL_BOARDS_BU) -EF_BOARDS := $(ALL_BOARDS) - -# FIXME: The BU image doesn't work for F4 boards so we need to -# filter them out to prevent errors. -BU_BOARDS := $(filter-out revolution osd, $(BU_BOARDS)) - -# SimPosix doesn't have a BL, BU or EF target so we need to -# filter them out to prevent errors on the all_flight target. -BL_BOARDS := $(filter-out simposix, $(BL_BOARDS)) -BU_BOARDS := $(filter-out simposix, $(BU_BOARDS)) -EF_BOARDS := $(filter-out simposix, $(EF_BOARDS)) - -# Generate the targets for whatever boards are left in each list -FW_TARGETS := $(addprefix fw_, $(FW_BOARDS)) -BL_TARGETS := $(addprefix bl_, $(BL_BOARDS)) -BU_TARGETS := $(addprefix bu_, $(BU_BOARDS)) -EF_TARGETS := $(addprefix ef_, $(EF_BOARDS)) - +# Generate flight build rules .PHONY: all_fw all_fw_clean all_fw: $(addsuffix _opfw, $(FW_TARGETS)) all_fw_clean: $(addsuffix _clean, $(FW_TARGETS)) @@ -707,15 +468,15 @@ 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)))) -# Expand the bootloader updater rules -$(foreach board, $(ALL_BOARDS), $(eval $(call BU_TEMPLATE,$(board),$($(board)_friendly),$($(board)_short)))) - # Expand the firmware rules $(foreach board, $(ALL_BOARDS), $(eval $(call FW_TEMPLATE,$(board),$($(board)_friendly),$($(board)_short)))) # Expand the bootloader rules $(foreach board, $(ALL_BOARDS), $(eval $(call BL_TEMPLATE,$(board),$($(board)_friendly),$($(board)_short)))) +# Expand the bootloader updater rules +$(foreach board, $(ALL_BOARDS), $(eval $(call BU_TEMPLATE,$(board),$($(board)_friendly),$($(board)_short)))) + # Expand the entire-flash rules $(foreach board, $(ALL_BOARDS), $(eval $(call EF_TEMPLATE,$(board),$($(board)_friendly),$($(board)_short)))) @@ -723,7 +484,7 @@ $(foreach board, $(ALL_BOARDS), $(eval $(call EF_TEMPLATE,$(board),$($(board)_fr sim_win32: sim_win32_exe sim_win32_%: uavobjects_flight - $(V1) mkdir -p $(BUILD_DIR)/sitl_win32 + $(V1) $(MKDIR) -p $(BUILD_DIR)/sitl_win32 $(V1) $(MAKE) --no-print-directory \ -C $(ROOT_DIR)/flight/targets/OpenPilot --file=$(ROOT_DIR)/flight/targets/OpenPilot/Makefile.win32 $* @@ -731,10 +492,202 @@ sim_win32_%: uavobjects_flight sim_osx: sim_osx_elf sim_osx_%: uavobjects_flight - $(V1) mkdir -p $(BUILD_DIR)/sim_osx + $(V1) $(MKDIR) -p $(BUILD_DIR)/sim_osx $(V1) $(MAKE) --no-print-directory \ -C $(ROOT_DIR)/flight/targets/Revolution --file=$(ROOT_DIR)/flight/targets/Revolution/Makefile.osx $* +############################## +# +# GCS related components +# +############################## + +.PHONY: all_ground +all_ground: openpilotgcs + +# Convenience target for the GCS +.PHONY: gcs gcs_clean gcs_all_clean +gcs: openpilotgcs +gcs_clean: openpilotgcs_clean +gcs_all_clean: openpilotgcs_all_clean + +ifeq ($(V), 1) + GCS_SILENT := +else + GCS_SILENT := silent +endif + +.PHONY: openpilotgcs +openpilotgcs: uavobjects_gcs + $(V1) $(MKDIR) -p $(BUILD_DIR)/ground/$@/$(GCS_BUILD_CONF) + $(V1) ( cd $(BUILD_DIR)/ground/$@/$(GCS_BUILD_CONF) && \ + $(QMAKE) $(ROOT_DIR)/ground/openpilotgcs/openpilotgcs.pro -spec $(QT_SPEC) -r CONFIG+="$(GCS_BUILD_CONF) $(GCS_SILENT)" $(GCS_QMAKE_OPTS) && \ + $(MAKE) -w ; \ + ) + +.PHONY: openpilotgcs_clean +openpilotgcs_clean: + $(V0) @$(ECHO) " CLEAN $@" + $(V1) [ ! -d "$(BUILD_DIR)/ground/openpilotgcs/$(GCS_BUILD_CONF)" ] || $(RM) -r "$(BUILD_DIR)/ground/openpilotgcs/$(GCS_BUILD_CONF)" + +.PHONY: openpilotgcs_all_clean +openpilotgcs_all_clean: + $(V0) @$(ECHO) " CLEAN $@" + $(V1) [ ! -d "$(BUILD_DIR)/ground/openpilotgcs" ] || $(RM) -r "$(BUILD_DIR)/ground/openpilotgcs" + +################################ +# +# Android GCS related components +# +################################ + +# Build the output directory for the Android GCS build +ANDROIDGCS_OUT_DIR := $(BUILD_DIR)/androidgcs +$(ANDROIDGCS_OUT_DIR): + $(V1) $(MKDIR) -p $@ + +# Build the asset directory for the android assets +ANDROIDGCS_ASSETS_DIR := $(ANDROIDGCS_OUT_DIR)/assets +$(ANDROIDGCS_ASSETS_DIR)/uavos: + $(V1) $(MKDIR) -p $@ + +ifeq ($(V), 1) + ANT_QUIET := + ANDROID_SILENT := +else + ANT_QUIET := -q + ANDROID_SILENT := -s +endif + +.PHONY: androidgcs +androidgcs: uavo-collections_java + $(V0) @$(ECHO) " ANDROID $(call toprel, $(ANDROIDGCS_OUT_DIR))" + $(V1) $(MKDIR) -p $(ANDROIDGCS_OUT_DIR) + $(V1) $(ANDROID) $(ANDROID_SILENT) update project \ + --target "Google Inc.:Google APIs:$(GOOGLE_API_VERSION)" \ + --name androidgcs \ + --path ./androidgcs + $(V1) $(ANT) -f ./androidgcs/build.xml \ + $(ANT_QUIET) \ + -Dout.dir="../$(call toprel, $(ANDROIDGCS_OUT_DIR)/bin)" \ + -Dgen.absolute.dir="$(ANDROIDGCS_OUT_DIR)/gen" \ + $(ANDROIDGCS_BUILD_CONF) + +.PHONY: androidgcs_clean +androidgcs_clean: + $(V0) @$(ECHO) " CLEAN $@" + $(V1) [ ! -d "$(ANDROIDGCS_OUT_DIR)" ] || $(RM) -r "$(ANDROIDGCS_OUT_DIR)" + +# We want to take snapshots of the UAVOs at each point that they change +# to allow the GCS to be compatible with as many versions as possible. +# We always include a pseudo collection called "srctree" which represents +# the UAVOs in the source tree. So not necessary to add current tree UAVO +# hash here, it is always included. + +# Find the git hashes of each commit that changes uavobjects with: +# git log --format=%h -- shared/uavobjectdefinition/ | head -n 2 +# List only UAVO hashes of past releases, do not list current hash. +# Past compatible versions are so far: RELEASE-12.10.2 +UAVO_GIT_VERSIONS := 5e14f53 + +# All versions includes also the current source tree UAVO hash +UAVO_ALL_VERSIONS := $(UAVO_GIT_VERSIONS) srctree + +# This is where the UAVO collections are stored +UAVO_COLLECTION_DIR := $(BUILD_DIR)/uavo-collections + +# $(1) git hash of a UAVO snapshot +define UAVO_COLLECTION_GIT_TEMPLATE + +# Make the output directory that will contain all of the synthetics for the +# uavo collection referenced by the git hash $(1) +$$(UAVO_COLLECTION_DIR)/$(1): + $$(V1) $(MKDIR) -p $$(UAVO_COLLECTION_DIR)/$(1) + +# Extract the snapshot of shared/uavobjectdefinition from git hash $(1) +$$(UAVO_COLLECTION_DIR)/$(1)/uavo-xml.tar: | $$(UAVO_COLLECTION_DIR)/$(1) +$$(UAVO_COLLECTION_DIR)/$(1)/uavo-xml.tar: + $$(V0) @$(ECHO) " UAVOTAR $(1)" + $$(V1) $(GIT) archive $(1) -o $$@ -- shared/uavobjectdefinition/ + +# Extract the uavo xml files from our snapshot +$$(UAVO_COLLECTION_DIR)/$(1)/uavo-xml: $$(UAVO_COLLECTION_DIR)/$(1)/uavo-xml.tar + $$(V0) @$(ECHO) " UAVOUNTAR $(1)" + $$(V1) $(RM) -rf $$@ + $$(V1) $(MKDIR) -p $$@ + $$(V1) $(TAR) -C $$(call toprel, $$@) -xf $$(call toprel, $$<) || $(RM) -rf $$@ +endef + +# Map the current working directory into the set of UAVO collections +$(UAVO_COLLECTION_DIR)/srctree: + $(V1) $(MKDIR) -p $@ + +$(UAVO_COLLECTION_DIR)/srctree/uavo-xml: | $(UAVO_COLLECTION_DIR)/srctree +$(UAVO_COLLECTION_DIR)/srctree/uavo-xml: $(UAVOBJ_XML_DIR) + $(V1) $(LN) -sf $(ROOT_DIR) $(UAVO_COLLECTION_DIR)/srctree/uavo-xml + +# $(1) git hash (or symbolic name) of a UAVO snapshot +define UAVO_COLLECTION_BUILD_TEMPLATE + +# This leaves us with a (broken) symlink that points to the full sha1sum of the collection +$$(UAVO_COLLECTION_DIR)/$(1)/uavohash: $$(UAVO_COLLECTION_DIR)/$(1)/uavo-xml + # Compute the sha1 hash for this UAVO collection + # The sed bit truncates the UAVO hash to 16 hex digits + $$(V1) $$(VERSION_INFO) \ + --uavodir=$$(UAVO_COLLECTION_DIR)/$(1)/uavo-xml/shared/uavobjectdefinition \ + --format='$$$${UAVOSHA1TXT}' | \ + $(SED) -e 's|\(................\).*|\1|' > $$@ + + $$(V0) @$(ECHO) " UAVOHASH $(1) ->" $$$$(cat $$(UAVO_COLLECTION_DIR)/$(1)/uavohash) + +# Generate the java uavobjects for this UAVO collection +$$(UAVO_COLLECTION_DIR)/$(1)/java-build/java: $$(UAVO_COLLECTION_DIR)/$(1)/uavohash + $$(V0) @$(ECHO) " UAVOJAVA $(1) " $$$$(cat $$(UAVO_COLLECTION_DIR)/$(1)/uavohash) + $$(V1) $(MKDIR) -p $$@ + $$(V1) ( \ + cd $$(UAVO_COLLECTION_DIR)/$(1)/java-build && \ + $$(UAVOBJGENERATOR) -java $$(UAVO_COLLECTION_DIR)/$(1)/uavo-xml/shared/uavobjectdefinition $$(ROOT_DIR) ; \ + ) + +# Build a jar file for this UAVO collection +$$(UAVO_COLLECTION_DIR)/$(1)/java-build/uavobjects.jar: | $$(ANDROIDGCS_ASSETS_DIR)/uavos +$$(UAVO_COLLECTION_DIR)/$(1)/java-build/uavobjects.jar: $$(UAVO_COLLECTION_DIR)/$(1)/java-build/java + $$(V0) @$(ECHO) " UAVOJAR $(1) " $$$$(cat $$(UAVO_COLLECTION_DIR)/$(1)/uavohash) + $$(V1) ( \ + HASH=$$$$(cat $$(UAVO_COLLECTION_DIR)/$(1)/uavohash) && \ + cd $$(UAVO_COLLECTION_DIR)/$(1)/java-build && \ + $(JAVAC) java/*.java \ + $$(ROOT_DIR)/androidgcs/src/org/openpilot/uavtalk/UAVDataObject.java \ + $$(ROOT_DIR)/androidgcs/src/org/openpilot/uavtalk/UAVObject*.java \ + $$(ROOT_DIR)/androidgcs/src/org/openpilot/uavtalk/UAVMetaObject.java \ + -d . && \ + find ./org/openpilot/uavtalk/uavobjects -type f -name '*.class' > classlist.txt && \ + $(JAR) cf tmp_uavobjects.jar @classlist.txt && \ + $$(ANDROID_DX) \ + --dex \ + --output $$(ANDROIDGCS_ASSETS_DIR)/uavos/$$$${HASH}.jar \ + tmp_uavobjects.jar && \ + $(LN) -sf $$(ANDROIDGCS_ASSETS_DIR)/uavos/$$$${HASH}.jar uavobjects.jar \ + ) + +endef + +# One of these for each element of UAVO_GIT_VERSIONS so we can extract the UAVOs from git +$(foreach githash, $(UAVO_GIT_VERSIONS), $(eval $(call UAVO_COLLECTION_GIT_TEMPLATE,$(githash)))) + +# One of these for each UAVO_ALL_VERSIONS which includes the ones in the srctree +$(foreach githash, $(UAVO_ALL_VERSIONS), $(eval $(call UAVO_COLLECTION_BUILD_TEMPLATE,$(githash)))) + +.PHONY: uavo-collections_java +uavo-collections_java: $(foreach githash, $(UAVO_ALL_VERSIONS), $(UAVO_COLLECTION_DIR)/$(githash)/java-build/uavobjects.jar) + +.PHONY: uavo-collections +uavo-collections: uavo-collections_java + +.PHONY: uavo-collections_clean +uavo-collections_clean: + $(V0) @$(ECHO) " CLEAN $(UAVO_COLLECTION_DIR)" + $(V1) [ ! -d "$(UAVO_COLLECTION_DIR)" ] || $(RM) -r $(UAVO_COLLECTION_DIR) ############################## # @@ -744,10 +697,10 @@ sim_osx_%: uavobjects_flight ALL_UNITTESTS := logfs +# Build the directory for the unit tests UT_OUT_DIR := $(BUILD_DIR)/unit_tests - $(UT_OUT_DIR): - $(V1) mkdir -p $@ + $(V1) $(MKDIR) -p $@ .PHONY: all_ut all_ut: $(addsuffix _elf, $(addprefix ut_, $(ALL_UNITTESTS))) @@ -760,7 +713,7 @@ all_ut_run: $(addsuffix _run, $(addprefix ut_, $(ALL_UNITTESTS))) .PHONY: all_ut_clean all_ut_clean: - $(V0) @echo " CLEAN $@" + $(V0) @$(ECHO) " CLEAN $@" $(V1) [ ! -d "$(UT_OUT_DIR)" ] || $(RM) -r "$(UT_OUT_DIR)" # $(1) = Unit test name @@ -769,7 +722,7 @@ define UT_TEMPLATE ut_$(1): ut_$(1)_run ut_$(1)_%: $$(UT_OUT_DIR) - $(V1) mkdir -p $(UT_OUT_DIR)/$(1) + $(V1) $(MKDIR) -p $(UT_OUT_DIR)/$(1) $(V1) cd $(ROOT_DIR)/flight/tests/$(1) && \ $$(MAKE) -r --no-print-directory \ BUILD_TYPE=ut \ @@ -791,9 +744,8 @@ ut_$(1)_%: $$(UT_OUT_DIR) .PHONY: ut_$(1)_clean ut_$(1)_clean: - $(V0) @echo " CLEAN $(1)" + $(V0) @$(ECHO) " CLEAN $(1)" $(V1) [ ! -d "$(UT_OUT_DIR)/$(1)" ] || $(RM) -r "$(UT_OUT_DIR)/$(1)" - endef # Expand the unittest rules @@ -803,7 +755,7 @@ $(foreach ut, $(ALL_UNITTESTS), $(eval $(call UT_TEMPLATE,$(ut)))) # output is interleaved with the rest of the make output. ifneq ($(strip $(filter all_ut_run,$(MAKECMDGOALS))),) .NOTPARALLEL: -$(info *NOTE* Parallel make disabled by all_ut_run target so we have sane console output) + $(info *NOTE* Parallel make disabled by all_ut_run target so we have sane console output) endif ############################## @@ -812,19 +764,213 @@ endif # ############################## -.PHONY: package -package: - $(V1) cd $@ && $(MAKE) --no-print-directory $@ +# Firmware files to package +PACKAGE_FW_TARGETS := $(filter-out fw_simposix, $(FW_TARGETS)) +PACKAGE_ELF_TARGETS := $(filter fw_simposix, $(FW_TARGETS)) -.PHONY: package_resources -package_resources: - $(V1) cd package && $(MAKE) --no-print-directory opfw_resource +# Rules to generate GCS resources used to embed firmware binaries into the GCS. +# They are used later by the vehicle setup wizard to update board firmware. +# To open a firmware image use ":/firmware/fw_coptercontrol.opfw" +OPFW_RESOURCE := $(BUILD_DIR)/ground/opfw_resource/opfw_resource.qrc +OPFW_RESOURCE_PREFIX := ../../../ +OPFW_FILES := $(foreach fw_targ, $(PACKAGE_FW_TARGETS), $(call toprel, $(BUILD_DIR)/$(fw_targ)/$(fw_targ).opfw)) +OPFW_CONTENTS := \ + \ + \ + $(foreach fw_file, $(OPFW_FILES), $(OPFW_RESOURCE_PREFIX)$(fw_file)) \ + \ + + +.PHONY: opfw_resource +opfw_resource: $(OPFW_RESOURCE) + +$(OPFW_RESOURCE): $(FW_TARGETS) + @$(ECHO) Generating OPFW resource file $(call toprel, $@) + $(V1) $(MKDIR) -p $(dir $@) + $(V1) $(ECHO) $(QUOTE)$(OPFW_CONTENTS)$(QUOTE) > $@ + +# If opfw_resource is requested, GCS should depend on it +ifneq ($(strip $(filter opfw_resource,$(MAKECMDGOALS))),) + $(eval openpilotgcs: | opfw_resource) +endif + +# Packaging targets: package, clean_package +# - removes build directory (clean_package only) +# - builds all firmware, opfw_resource, gcs +# - copies firmware into a package directory +# - calls paltform-specific packaging script + +# Do some checks and define some values if package is requested +ifneq ($(strip $(filter package clean_package,$(MAKECMDGOALS))),) + # Define some variables + export PACKAGE_LBL := $(shell $(VERSION_INFO) --format=\$${LABEL}) + export PACKAGE_NAME := OpenPilot + export PACKAGE_SEP := - + + # We can only package release builds + ifneq ($(GCS_BUILD_CONF),release) + $(error Packaging is currently supported for release builds only) + endif + + # Packaged GCS should depend on opfw_resource + ifneq ($(strip $(filter package clean_package,$(MAKECMDGOALS))),) + $(eval openpilotgcs: | opfw_resource) + endif + + # Clean the build directory if clean_package is requested + ifneq ($(strip $(filter clean_package,$(MAKECMDGOALS))),) + $(info Cleaning build directory before packaging...) + ifneq ($(shell $(MAKE) all_clean >/dev/null 2>&1 && $(ECHO) "clean"), clean) + $(error Cannot clean build directory) + endif + + .PHONY: clean_package + clean_package: package + endif +endif + +# Copy file template. Empty line before the endef is required, do not remove +# $(1) = copy file name without extension +# $(2) = source file extension +# $(3) = destination file extension +define COPY_FW_FILES + $(V1) $(CP) "$(BUILD_DIR)/$(1)/$(1)$(2)" "$(PACKAGE_DIR)/firmware/$(1)$(PACKAGE_SEP)$(PACKAGE_LBL)$(3)" + +endef + +# Build and copy package files into the package directory +# and call platform-specific packaging script +.PHONY: package +package: all_fw all_ground uavobjects_matlab + @$(ECHO) "Packaging for $(UNAME) $(ARCH) into $(call toprel, $(PACKAGE_DIR)) directory" + $(V1) [ ! -d "$(PACKAGE_DIR)" ] || $(RM) -rf "$(PACKAGE_DIR)" + $(V1) $(MKDIR) -p "$(PACKAGE_DIR)/firmware" + $(foreach fw_targ, $(PACKAGE_FW_TARGETS), $(call COPY_FW_FILES,$(fw_targ),.opfw,.opfw)) + $(foreach fw_targ, $(PACKAGE_ELF_TARGETS), $(call COPY_FW_FILES,$(fw_targ),.elf,)) + $(MAKE) --no-print-directory -C $(ROOT_DIR)/package --file=$(UNAME).mk $@ + +############################## +# +# Build info +# +############################## .PHONY: build-info build-info: - $(V1) mkdir -p $(BUILD_DIR) - $(V1) python $(ROOT_DIR)/make/scripts/version-info.py \ - --path=$(ROOT_DIR) \ + $(V1) $(MKDIR) -p $(BUILD_DIR) + $(V1) $(VERSION_INFO) \ --uavodir=$(ROOT_DIR)/shared/uavobjectdefinition \ --template="make/templates/$@.txt" \ --outfile="$(BUILD_DIR)/$@.txt" + +############################## +# +# Help message, the default Makefile goal +# +############################## + +.PHONY: help +help: + @$(ECHO) + @$(ECHO) " This Makefile is known to work on Linux and Mac in a standard shell environment." + @$(ECHO) " It also works on Windows by following the instructions in make/winx86/README.txt." + @$(ECHO) + @$(ECHO) " Here is a summary of the available targets:" + @$(ECHO) + @$(ECHO) " [Tool Installers]" + @$(ECHO) " qt_sdk_install - Install the QT development tools" + @$(ECHO) " arm_sdk_install - Install the GNU ARM gcc toolchain" + @$(ECHO) " openocd_install - Install the OpenOCD JTAG daemon" + @$(ECHO) " stm32flash_install - Install the stm32flash tool for unbricking F1-based boards" + @$(ECHO) " dfuutil_install - Install the dfu-util tool for unbricking F4-based boards" + @$(ECHO) " android_sdk_install - Install the Android SDK tools" + @$(ECHO) + @$(ECHO) " [Big Hammer]" + @$(ECHO) " all - Generate UAVObjects, build openpilot firmware and gcs" + @$(ECHO) " all_flight - Build all firmware, bootloaders and bootloader updaters" + @$(ECHO) " all_fw - Build only firmware for all boards" + @$(ECHO) " all_bl - Build only bootloaders for all boards" + @$(ECHO) " all_bu - Build only bootloader updaters for all boards" + @$(ECHO) + @$(ECHO) " all_clean - Remove your build directory ($(BUILD_DIR))" + @$(ECHO) " all_flight_clean - Remove all firmware, bootloaders and bootloader updaters" + @$(ECHO) " all_fw_clean - Remove firmware for all boards" + @$(ECHO) " all_bl_clean - Remove bootlaoders for all boards" + @$(ECHO) " all_bu_clean - Remove bootloader updaters for all boards" + @$(ECHO) + @$(ECHO) " all_ - Build all available images for " + @$(ECHO) " all__clean - Remove all available images for " + @$(ECHO) + @$(ECHO) " all_ut - Build all unit tests" + @$(ECHO) " all_ut_tap - Run all unit tests and capture all TAP output to files" + @$(ECHO) " all_ut_run - Run all unit tests and dump TAP output to console" + @$(ECHO) + @$(ECHO) " [Firmware]" + @$(ECHO) " - Build firmware for " + @$(ECHO) " supported boards are ($(ALL_BOARDS))" + @$(ECHO) " fw_ - Build firmware for " + @$(ECHO) " supported boards are ($(FW_BOARDS))" + @$(ECHO) " fw__clean - Remove firmware for " + @$(ECHO) " fw__program - Use OpenOCD + JTAG to write firmware to " + @$(ECHO) + @$(ECHO) " [Bootloader]" + @$(ECHO) " bl_ - Build bootloader for " + @$(ECHO) " supported boards are ($(BL_BOARDS))" + @$(ECHO) " bl__clean - Remove bootloader for " + @$(ECHO) " bl__program - Use OpenOCD + JTAG to write bootloader to " + @$(ECHO) + @$(ECHO) " [Entire Flash]" + @$(ECHO) " ef_ - Build entire flash image for " + @$(ECHO) " supported boards are ($(EF_BOARDS))" + @$(ECHO) " ef__clean - Remove entire flash image for " + @$(ECHO) " ef__program - Use OpenOCD + JTAG to write entire flash image to " + @$(ECHO) + @$(ECHO) " [Bootloader Updater]" + @$(ECHO) " bu_ - Build bootloader updater for " + @$(ECHO) " supported boards are ($(BU_BOARDS))" + @$(ECHO) " bu__clean - Remove bootloader updater for " + @$(ECHO) + @$(ECHO) " [Unbrick a board]" + @$(ECHO) " unbrick_ - Use the STM32's built in boot ROM to write a bootloader to " + @$(ECHO) " supported boards are ($(BL_BOARDS))" + @$(ECHO) " [Unittests]" + @$(ECHO) " ut_ - Build unit test " + @$(ECHO) " ut__xml - Run test and capture XML output into a file" + @$(ECHO) " ut__run - Run test and dump output to console" + @$(ECHO) + @$(ECHO) " [Simulation]" + @$(ECHO) " sim_osx - Build OpenPilot simulation firmware for OSX" + @$(ECHO) " sim_osx_clean - Delete all build output for the osx simulation" + @$(ECHO) " sim_win32 - Build OpenPilot simulation firmware for" + @$(ECHO) " Windows using mingw and msys" + @$(ECHO) " sim_win32_clean - Delete all build output for the win32 simulation" + @$(ECHO) + @$(ECHO) " [GCS]" + @$(ECHO) " gcs - Build the Ground Control System (GCS) application (debug|release)" + @$(ECHO) " gcs_clean - Remove the Ground Control System (GCS) application (debug|release)" + @$(ECHO) " supported build configurations: GCS_BUILD_CONF=debug|release (default is $(GCS_BUILD_CONF))" + @$(ECHO) " gcs_all_clean - Remove the Ground Control System (GCS) application (all build confgurations)" + @$(ECHO) + @$(ECHO) " [AndroidGCS]" + @$(ECHO) " androidgcs - Build the Android Ground Control System (GCS) application" + @$(ECHO) " androidgcs_install - Use ADB to install the Android GCS application" + @$(ECHO) " androidgcs_run - Run the Android GCS application" + @$(ECHO) " androidgcs_clean - Remove the Android GCS application" + @$(ECHO) + @$(ECHO) " [UAVObjects]" + @$(ECHO) " uavobjects - Generate source files from the UAVObject definition XML files" + @$(ECHO) " uavobjects_test - parse xml-files - check for valid, duplicate ObjId's, ... " + @$(ECHO) " uavobjects_ - Generate source files from a subset of the UAVObject definition XML files" + @$(ECHO) " supported groups are ($(UAVOBJ_TARGETS))" + @$(ECHO) + @$(ECHO) " [Packaging]" + @$(ECHO) " opfw_resource - Generate resources to embed firmware binaries into the GCS" + @$(ECHO) " clean_package - Clean, build and package the OpenPilot platform-dependent package" + @$(ECHO) " package - Build and package the OpenPilot platform-dependent package" + @$(ECHO) + @$(ECHO) " Hint: Add V=1 to your command line to see verbose build output." + @$(ECHO) + @$(ECHO) " Note: All tools will be installed into $(TOOLS_DIR)" + @$(ECHO) " All build output will be placed in $(BUILD_DIR)" + @$(ECHO) " Package will be placed into $(PACKAGE_DIR)" + @$(ECHO) diff --git a/flight/Doc/Architecture/ahrs_spi_link_fsm.dot b/flight/Doc/Architecture/ahrs_spi_link_fsm.dot deleted file mode 100644 index c53a748fb..000000000 --- a/flight/Doc/Architecture/ahrs_spi_link_fsm.dot +++ /dev/null @@ -1,90 +0,0 @@ -// Regenerate using graphviz/dotty with this command -// dot -Tjpg ./flight/Doc/Architecture/ahrs_spi_link_fsm.dot > ./flight/Doc/Architecture/ahrs_spi_link_fsm.jpg - -digraph ahrs_spi_protocol { - label="AHRS SPI Link State Machine" - labelloc=t - labeljust = l - - // Stopped -- Undefined Wire State - { - node [ style=filled,color=lightgray ] - - stopped [ shape="doublecircle" ] - stopping - } - - // Wire State Inactive - { - node [ style=filled,color=lightblue ] - - inactive - } - - // Wire State Busy - { - node [ style=filled,color=red ] - - user_busy - user_busy_tx_pending - user_busy_rx_pending - user_busy_rxtx_pending - } - { - node [ style=filled,color=yellow ] - - user_tx_pending - user_rx_pending - user_rxtx_pending - } - - // Wire State Ready - { - node [ style=filled,color=green ] - - user_rx_active - user_tx_active - user_rxtx_active - } - - // - // State transitions driven by the user - // - stopped -> inactive [ label="init link" ] - - inactive -> stopping [ label="stop" ] - inactive -> user_busy_rx_pending [ label="user set rx" ] - inactive -> user_busy_tx_pending [ label="user set tx" ] - - user_busy -> user_busy_tx_pending [ label="user set tx" ] - user_busy -> user_busy_rx_pending [ label="user set rx" ] - user_busy -> inactive [ label="user done" ] - user_busy -> stopping [ label="stop" ] - - user_busy_tx_pending -> user_busy_rxtx_pending [ label="user set rx" ] - user_busy_tx_pending -> user_tx_pending [ label="user done" ] - - user_busy_rx_pending -> user_busy_rxtx_pending [ label="user set tx" ] - user_busy_rx_pending -> user_rx_pending [ label="user done" ] - - user_busy_rxtx_pending -> user_rxtx_pending [ label="user done" ] - - // - // State transitions driven by messaging from the OP board - // - stopping -> stopped [ label="rx any" ] - - user_tx_pending -> user_tx_active [ label="rx any" ] - user_rx_pending -> user_rx_active [ label="rx any" ] - - user_rxtx_pending -> user_rxtx_active [ label="rx any" ] - - // Active -> Busy - user_rx_active -> user_busy [ label="rx user" ] - - user_tx_active -> inactive [ label="rx any" ] - - user_rxtx_active -> user_busy [ label="rx user" ] - user_rxtx_active -> user_rx_active [ label="rx link" ] - user_rxtx_active -> user_rx_active [ label="rx unknown" ] -} diff --git a/flight/Doc/Architecture/ahrs_spi_link_fsm.jpg b/flight/Doc/Architecture/ahrs_spi_link_fsm.jpg deleted file mode 100644 index 4f5eaae27..000000000 Binary files a/flight/Doc/Architecture/ahrs_spi_link_fsm.jpg and /dev/null differ diff --git a/flight/Libraries/PyMite/pymite.mk b/flight/Libraries/PyMite/pymite.mk index 02da15a5d..c009d416f 100644 --- a/flight/Libraries/PyMite/pymite.mk +++ b/flight/Libraries/PyMite/pymite.mk @@ -1,41 +1,75 @@ # -# Rules to add PYMite to a PiOS target +# Rules to add PyMite flight plan interpreter # -PYMITE = $(FLIGHTLIB)/PyMite -PYMITELIB = $(PYMITE)/lib -PYMITEPLAT = $(PYMITE)/platform/openpilot -PYMITETOOLS = $(PYMITE)/tools -PYMITEVM = $(PYMITE)/vm -PYMITEINC = $(PYMITEVM) -PYMITEINC += $(PYMITEPLAT) -PYMITEINC += $(OUTDIR) +# Paths +PYMITE := $(FLIGHTLIB)/PyMite +PYMITELIB := $(PYMITE)/lib +PYMITEPLAT := $(PYMITE)/platform/openpilot +PYMITETOOLS := $(PYMITE)/tools +PYMITEVM := $(PYMITE)/vm +PYMITEINC := $(PYMITEVM) +PYMITEINC += $(PYMITEPLAT) +PYMITEINC += $(OUTDIR) -# List C source files here. (C dependencies are automatically generated.) -# use file-extension c for "c-only"-files +# Flight plans +FLIGHTPLANLIB ?= $(OPMODULEDIR)/FlightPlan/lib +FLIGHTPLANS ?= $(OPMODULEDIR)/FlightPlan/flightplans -## PyMite files and modules -SRC += $(OUTDIR)/pmlib_img.c -SRC += $(OUTDIR)/pmlib_nat.c -SRC += $(OUTDIR)/pmlibusr_img.c -SRC += $(OUTDIR)/pmlibusr_nat.c -PYSRC += $(wildcard ${PYMITEVM}/*.c) -PYSRC += $(wildcard ${PYMITEPLAT}/*.c) -PYSRC += ${foreach MOD, ${PYMODULES}, ${wildcard ${OPMODULEDIR}/${MOD}/*.c}} -SRC += $(PYSRC) +# Extra modules +PYMODULES ?= FlightPlan -EXTRAINCDIRS += $(PYMITEINC) +# Modules +PYSRC += $(foreach mod, $(PYMODULES), $(wildcard $(OPMODULEDIR)/$(mod)/*.c)) -# Generate intermediate code -gencode: ${OUTDIR}/pmlib_img.c ${OUTDIR}/pmlib_nat.c ${OUTDIR}/pmlibusr_img.c ${OUTDIR}/pmlibusr_nat.c ${OUTDIR}/pmfeatures.h +# PyMite virtual machine and platform files +PYSRC += $(wildcard $(PYMITEVM)/*.c) +PYSRC += $(wildcard $(PYMITEPLAT)/*.c) -$(PYSRC): gencode +# Autogenerated files +PYLIB += $(addprefix $(OUTDIR)/, pmlib_img.c pmlib_nat.c) +PYLIB += $(addprefix $(OUTDIR)/, pmlibusr_img.c pmlibusr_nat.c) -PYTHON = python +# Scripts +PYSCRIPTS += $(wildcard $(PYMITELIB)/*.py) +PYSCRIPTS += $(wildcard $(PYMITEPLAT)/*.py) +PYSCRIPTS += $(wildcard $(FLIGHTPLANLIB)/*.py) +PYSCRIPTS += $(wildcard $(FLIGHTPLANS)/*.py) # Generate code for PyMite -${OUTDIR}/pmlib_img.c ${OUTDIR}/pmlib_nat.c ${OUTDIR}/pmlibusr_img.c ${OUTDIR}/pmlibusr_nat.c ${OUTDIR}/pmfeatures.h: $(wildcard ${PYMITELIB}/*.py) $(wildcard ${PYMITEPLAT}/*.py) $(wildcard ${FLIGHTPLANLIB}/*.py) $(wildcard ${FLIGHTPLANS}/*.py) - @echo $(MSG_PYMITEINIT) $(call toprel, $@) - @$(PYTHON) $(PYMITETOOLS)/pmImgCreator.py -f $(PYMITEPLAT)/pmfeatures.py -c -s --memspace=flash -o $(OUTDIR)/pmlib_img.c --native-file=$(OUTDIR)/pmlib_nat.c $(PYMITELIB)/list.py $(PYMITELIB)/dict.py $(PYMITELIB)/__bi.py $(PYMITELIB)/sys.py $(PYMITELIB)/string.py $(wildcard $(FLIGHTPLANLIB)/*.py) - @$(PYTHON) $(PYMITETOOLS)/pmGenPmFeatures.py $(PYMITEPLAT)/pmfeatures.py > $(OUTDIR)/pmfeatures.h - @$(PYTHON) $(PYMITETOOLS)/pmImgCreator.py -f $(PYMITEPLAT)/pmfeatures.py -c -u -o $(OUTDIR)/pmlibusr_img.c --native-file=$(OUTDIR)/pmlibusr_nat.c $(FLIGHTPLANS)/test.py +$(PYSRC): | $(PYLIB) $(OUTDIR)/pmfeatures.h + +$(OUTDIR)/pmfeatures.h: $(PYSCRIPTS) + @$(ECHO) $(MSG_PYMITEINIT) $(call toprel, $@) + $(V1) $(PYTHON) $(PYMITETOOLS)/pmGenPmFeatures.py $(PYMITEPLAT)/pmfeatures.py > $@ + +$(OUTDIR)/pmlib_img.c: | $(OUTDIR)/pmlib_nat.c + +$(OUTDIR)/pmlib_nat.c: $(PYSCRIPTS) + @$(ECHO) $(MSG_PYMITEINIT) $(call toprel, $@) + $(V1) $(PYTHON) $(PYMITETOOLS)/pmImgCreator.py -c -s --memspace=flash \ + -f $(PYMITEPLAT)/pmfeatures.py \ + -o $(OUTDIR)/pmlib_img.c \ + --native-file=$(OUTDIR)/pmlib_nat.c \ + $(PYMITELIB)/list.py \ + $(PYMITELIB)/dict.py \ + $(PYMITELIB)/__bi.py \ + $(PYMITELIB)/sys.py \ + $(PYMITELIB)/string.py \ + $(wildcard $(FLIGHTPLANLIB)/*.py) + +$(OUTDIR)/pmlibusr_img.c: | $(OUTDIR)/pmlibusr_nat.c + +$(OUTDIR)/pmlibusr_nat.c: $(PYSCRIPTS) + @$(ECHO) $(MSG_PYMITEINIT) $(call toprel, $@) + $(V1) $(PYTHON) $(PYMITETOOLS)/pmImgCreator.py -c -u \ + -f $(PYMITEPLAT)/pmfeatures.py \ + -o $(OUTDIR)/pmlibusr_img.c \ + --native-file=$(OUTDIR)/pmlibusr_nat.c \ + $(FLIGHTPLANS)/test.py + +# Add to the source and include lists +SRC += $(PYSRC) +SRC += $(PYLIB) +EXTRAINCDIRS += $(PYMITEINC) +EXTRAINCDIRS += $(foreach mod, $(PYMODULES), $(OPMODULEDIR)/$(mod)/inc) diff --git a/flight/Libraries/ahrs_comm_objects.c b/flight/Libraries/ahrs_comm_objects.c deleted file mode 100644 index 3bc3bff3c..000000000 --- a/flight/Libraries/ahrs_comm_objects.c +++ /dev/null @@ -1,164 +0,0 @@ -/** - ****************************************************************************** - * - * @file ahrs_comm_objects.c - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief AHRS comms AUVObjects. This file defined teh objects to be used. - * - * @see The GNU Public License (GPL) Version 3 - * - *****************************************************************************/ -/* - * 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 - */ - -#include "pios.h" -#include "ahrs_spi_comm.h" -#include "pios_debug.h" - -static AttitudeRawData AttitudeRaw; -static AttitudeActualData AttitudeActual; -static BaroAltitudeData BaroAltitude; -static GPSPositionData GPSPosition; -static HomeLocationData HomeLocation; -static InsStatusData InsStatus; -static InsSettingsData InsSettings; -static FirmwareIAPObjData FirmwareIAPObj; -static PositionActualData PositionActual; -static VelocityActualData VelocityActual; -static GPSSatellitesData GPSSatellites; -static GPSTimeData GPSTime; - -AhrsSharedObject objectHandles[MAX_AHRS_OBJECTS]; - -#ifndef NULL -#define NULL ((void *)0) -#endif - -#ifdef IN_AHRS - -//slightly hacky - implement our own version of the xxxHandle() functions -#define CREATEHANDLE(n,obj) \ - void * obj##Handle() {return (&objectHandles[n]);} - -CREATEHANDLE(0, AttitudeRaw); -CREATEHANDLE(1, AttitudeActual); -CREATEHANDLE(2, InsSettings); -CREATEHANDLE(3, InsStatus); -CREATEHANDLE(4, BaroAltitude); -CREATEHANDLE(5, GPSPosition); -CREATEHANDLE(6, PositionActual); -CREATEHANDLE(7, VelocityActual); -CREATEHANDLE(8, HomeLocation); -CREATEHANDLE(9, FirmwareIAPObj); -CREATEHANDLE(10, GPSSatellites); -CREATEHANDLE(11, GPSTime); - -#if 12 != MAX_AHRS_OBJECTS //sanity check -#error We did not create the correct number of xxxHandle() functions -#endif - -#define ADDHANDLE(idx,obj) {\ - int n = idx;\ - objectHandles[n].data = &obj;\ - objectHandles[n].size = sizeof(obj);\ - objectHandles[n].index = n;\ - } - -#else - -static void ObjectUpdatedCb(UAVObjEvent * ev); - -#define ADDHANDLE(idx,obj) {\ - obj##Initialize();\ - int n = idx;\ - objectHandles[n].data = &obj;\ - objectHandles[n].uavHandle = obj##Handle();\ - objectHandles[n].size = sizeof(obj);\ - objectHandles[n].index = n;\ - } - -#endif - -void AhrsInitHandles(void) -{ - int idx = 0; -//Note: the first item in this list has the highest priority -//the last has the lowest priority - ADDHANDLE(idx++, AttitudeRaw); - ADDHANDLE(idx++, AttitudeActual); - ADDHANDLE(idx++, InsSettings); - ADDHANDLE(idx++, InsStatus); - ADDHANDLE(idx++, BaroAltitude); - ADDHANDLE(idx++, GPSPosition); - ADDHANDLE(idx++, PositionActual); - ADDHANDLE(idx++, VelocityActual); - ADDHANDLE(idx++, HomeLocation); - ADDHANDLE(idx++, FirmwareIAPObj); - ADDHANDLE(idx++, GPSSatellites); - ADDHANDLE(idx++, GPSTime); - - if (idx != MAX_AHRS_OBJECTS) { - PIOS_DEBUG_Assert(0); - } -//Note: Only connect objects that the AHRS needs to read -//When the AHRS writes to these the data does a round trip -//AHRS->OP->AHRS due to these events -#ifndef IN_AHRS - InsSettingsConnectCallback(ObjectUpdatedCb); - HomeLocationConnectCallback(ObjectUpdatedCb); - FirmwareIAPObjConnectCallback(ObjectUpdatedCb); -#endif -} - -AhrsObjHandle AhrsFromIndex(uint8_t index) -{ - if (index >= MAX_AHRS_OBJECTS) { - return (NULL); - } - return (&objectHandles[index]); -} - -#ifndef IN_AHRS - -AhrsObjHandle AhrsFromUAV(UAVObjHandle obj) -{ - if (objectHandles[0].uavHandle == NULL) { //Oops - we haven't been initialised! - PIOS_DEBUG_Assert(0); - } - for (int ct = 0; ct < MAX_AHRS_OBJECTS; ct++) { - if (objectHandles[ct].uavHandle == obj) { - return (&objectHandles[ct]); - } - } - return (NULL); -} - -/** Callback to update AHRS from UAVObjects -*/ -static void ObjectUpdatedCb(UAVObjEvent * ev) -{ - if (!(ev->event & EV_MASK_ALL_UPDATES)) { - return; - } - AhrsObjHandle hdl = AhrsFromUAV(ev->obj); - if (hdl) { - AhrsSharedData data; //this is guaranteed to be big enough - UAVObjGetData(ev->obj, &data); - AhrsSetData(hdl, &data); - } -} - -#endif diff --git a/flight/Libraries/ahrs_spi_comm.c b/flight/Libraries/ahrs_spi_comm.c deleted file mode 100644 index 9c6f65d70..000000000 --- a/flight/Libraries/ahrs_spi_comm.c +++ /dev/null @@ -1,452 +0,0 @@ -/** - ****************************************************************************** - * - * @file ahrs_spi_comm.c - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief AHRS SPI communications. - * - * @see The GNU Public License (GPL) Version 3 - * - *****************************************************************************/ -/* - * 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 - */ -#include -#include "ahrs_spi_comm.h" -#include "ahrs_spi_program.h" - -#ifdef IN_AHRS -#include -#include "pios_debug.h" -#include "pios_spi.h" -#include "pios_irq.h" -#include "ahrs_spi_program_slave.h" -//#include "STM32103CB_AHRS.h" -#endif - -/*transmit and receive packet magic numbers. -These numbers are chosen to be very unlikely to occur due to noise. -CRC8 does not always catch noise from cross-coupling between data lines. -*/ -#ifdef IN_AHRS -#define TXMAGIC 0xA55AF0C3 -#define RXMAGIC 0x3C5AA50F -#else -#define RXMAGIC 0xA55AF0C3 -#define TXMAGIC 0x3C5AA50F -#endif - -//packet types -typedef enum { COMMS_NULL, COMMS_OBJECT } COMMSCOMMAND; - -//The maximum number of objects that can be updated in one cycle. -//Currently the link is capable of sending 3 packets per cycle but 2 is enough -#define MAX_UPDATE_OBJECTS 2 - -//Number of transmissions + 1 before we expect to see the data acknowledge -//This is controlled by the SPI hardware. -#define ACK_LATENCY 4 - -/** All data for one object -*/ -typedef struct { - uint8_t done; - uint8_t index; - AhrsSharedData object; -} ObjectPacketData; - -/** One complete packet. -Other packet types are allowed for. The frame size will be the size of this -structure. -*/ -typedef struct { - uint32_t magicNumber; - COMMSCOMMAND command; - AhrsEndStatus status; - union { //allow for expansion to other packet types. - ObjectPacketData objects[MAX_UPDATE_OBJECTS]; - }; - uint8_t dummy; //For some reason comms trashes the last byte -} CommsDataPacket; - -static void FillObjectPacket(); -static void CommsCallback(uint8_t crc_ok, uint8_t crc_val); -static void SetObjectDirty(const int idx); -static void HandleObjectPacket(); -static void HandleRxPacket(); -static void PollEvents(); -#ifndef IN_AHRS -static void SendPacket(void); -static void AhrsUpdatedCb(AhrsObjHandle handle); -#endif - -/** Receive data buffer -*/ -static CommsDataPacket rxPacket; - -/** Transmit data buffer -*/ - -static CommsDataPacket txPacket; -/** Objects that have changed and so should be transmitted -*/ -static unsigned int dirtyObjects[MAX_AHRS_OBJECTS]; - -/** Objects that have been updated at startup -*/ -static bool readyObjects[MAX_AHRS_OBJECTS]; - -/** List of event callbacks -*/ -static AhrsEventCallback objCallbacks[MAX_AHRS_OBJECTS]; - -/** True for objects for which new data is received and callback needs to be called -*/ -static bool callbackPending[MAX_AHRS_OBJECTS]; - -//More than this number of errors in a row will indicate the link is down -#define MAX_CRC_ERRORS 50 -//At least this number of good frames are needed to indicate the link is up. -#define MIN_OK_FRAMES 50 -//At least this number of empty objects are needed before the initial flood of events is over. -#define MIN_EMPTY_OBJECTS 10 - -static uint8_t linkOk = false; -static int okCount = MIN_OK_FRAMES; -static int emptyCount = MIN_EMPTY_OBJECTS; -static bool programReceive = false; - -void AhrsInitComms(void) -{ - programReceive = false; - AhrsInitHandles(); - memset(objCallbacks, 0, sizeof(AhrsEventCallback) * MAX_AHRS_OBJECTS); - memset(callbackPending, 0, sizeof(bool) * MAX_AHRS_OBJECTS); - memset(dirtyObjects, 0, sizeof(unsigned int) * MAX_AHRS_OBJECTS); - memset(&txPacket, 0, sizeof(txPacket)); - memset(&rxPacket, 0, sizeof(rxPacket)); - memset(&readyObjects, 0, sizeof(bool) * MAX_AHRS_OBJECTS); - txPacket.command = COMMS_NULL; - rxPacket.command = COMMS_NULL; -} - -static uint32_t opahrs_spi_id; -void AhrsConnect(uint32_t spi_id) -{ - /* Bind this comms layer to the appropriate SPI id */ - opahrs_spi_id = spi_id; -#ifndef IN_AHRS - /* Comms already init in OP code */ - for (int ct = 0; ct < MAX_AHRS_OBJECTS; ct++) { - AhrsObjHandle hdl = AhrsFromIndex(ct); - if (hdl) { - AhrsConnectCallBack(hdl, AhrsUpdatedCb); - } - } -#endif -} - -int32_t AhrsSetData(AhrsObjHandle obj, const void *dataIn) -{ - if (obj == NULL || dataIn == NULL || obj->data == NULL) { - return (-1); - } - if (memcmp(obj->data, dataIn, obj->size) == 0) { //nothing to do, don't generate an event - return (0); - } - memcpy(obj->data, dataIn, obj->size); - SetObjectDirty(obj->index); - return (0); -} - -int32_t AhrsGetData(AhrsObjHandle obj, void *dataOut) -{ - - if (obj == NULL || dataOut == NULL || obj->data == NULL) { - return (-1); - } - memcpy(dataOut, obj->data, obj->size); - return (0); -} - -/** Mark an object to be sent -*/ -void SetObjectDirty(const int idx) -{ - if (idx < 0 || idx >= MAX_AHRS_OBJECTS) { - return; - } - dirtyObjects[idx] = ACK_LATENCY; -} -/** Work out what data needs to be sent. - If an object was not sent it will be retried 4 frames later -*/ -static void FillObjectPacket() -{ - txPacket.command = COMMS_OBJECT; - txPacket.magicNumber = TXMAGIC; - int idx = 0; - for (int ct = 0; ct < MAX_UPDATE_OBJECTS; ct++) { - txPacket.objects[ct].index = AHRS_NO_OBJECT; - for (; idx < MAX_AHRS_OBJECTS; idx++) { - if (dirtyObjects[idx] > 0) { - if (dirtyObjects[idx] == ACK_LATENCY) { - dirtyObjects[idx]--; - txPacket.objects[ct].index = idx; - AhrsObjHandle hdl = AhrsFromIndex(idx); - if (hdl) { - memcpy(&txPacket.objects[ct].object, hdl->data, hdl->size); - break; - } - } else { - dirtyObjects[idx]--; - if (dirtyObjects[idx] == 0) { //timed out - dirtyObjects[idx] = ACK_LATENCY; - txPacket.status.retries++; - } - } - } - } - } - for (; idx < MAX_AHRS_OBJECTS; idx++) { - if (dirtyObjects[idx] > 0 && dirtyObjects[idx] != ACK_LATENCY) { - dirtyObjects[idx]--; - if (dirtyObjects[idx] == 0) { //timed out - dirtyObjects[idx] = ACK_LATENCY; - txPacket.status.retries++; - } - } - } -} - -/** Process a received packet -*/ -static void HandleRxPacket() -{ - switch (rxPacket.command) { - case COMMS_NULL: - // Empty packet, nothing to do - break; - - case COMMS_OBJECT: - HandleObjectPacket(); - break; - - default: - txPacket.status.invalidPacket++; - } -} - -/** Process a received UAVObject packet -*/ -static void HandleObjectPacket() -{ - for (int ct = 0; ct < MAX_UPDATE_OBJECTS; ct++) { - uint8_t idx; - - // Flag objects that have been successfully received at the other end - idx = rxPacket.objects[ct].done; - txPacket.objects[ct].done = AHRS_NO_OBJECT; - if (idx < MAX_AHRS_OBJECTS) { - - if (dirtyObjects[idx] == 1) { //this ack is the correct one for the last send - dirtyObjects[idx] = 0; - } - } - - // Handle received object if there is one in this packet - idx = rxPacket.objects[ct].index; - if (idx == AHRS_NO_OBJECT) { - if (emptyCount > 0) { - emptyCount--; - } - continue; - } - AhrsObjHandle obj = AhrsFromIndex(idx); - if (obj) { - memcpy(obj->data, &rxPacket.objects[ct].object, obj->size); - txPacket.objects[ct].done = idx; - callbackPending[idx] = true; // New data available, call callback - readyObjects[idx] = true; - } else { - txPacket.status.invalidPacket++; - } - } -#ifdef IN_AHRS - FillObjectPacket(); //ready for the next frame -#endif -} - -int32_t AhrsConnectCallBack(AhrsObjHandle obj, AhrsEventCallback cb) -{ - if (obj == NULL || obj->data == NULL) { - return (-1); - } - objCallbacks[obj->index] = cb; - return (0); -} - -void AhrsGetStatus(AhrsCommStatus * status) -{ - status->remote = rxPacket.status; - status->local = txPacket.status; - status->linkOk = linkOk; -} - - -/** Function called after an SPI transfer - */ -static void CommsCallback(uint8_t crc_ok, uint8_t crc_val) -{ -#ifndef IN_AHRS - PIOS_SPI_RC_PinSet(opahrs_spi_id, 1); //signal the end of the transfer -#endif - txPacket.command = COMMS_NULL; //we must send something so default to null - - // While the crc is ok, there is a magic value in the received data for extra security - if (rxPacket.magicNumber != RXMAGIC) { - crc_ok = false; - } - - - if (crc_ok) { - // The received data is OK, update link state and handle data - if (!linkOk && okCount > 0) { - okCount--; - if (okCount == 0) { - linkOk = true; - okCount = MAX_CRC_ERRORS; - emptyCount = MIN_EMPTY_OBJECTS; - } - } - HandleRxPacket(); - } else { - // The received data is incorrect, update state -#ifdef IN_AHRS //AHRS - do we neeed to enter program mode? - if (memcmp(&rxPacket, SPI_PROGRAM_REQUEST, SPI_PROGRAM_REQUEST_LENGTH) == 0) - { - rxPacket.magicNumber = 0; - programReceive = true; //flag it to be executed in program space - return; - } -#endif - txPacket.status.crcErrors++; - if (linkOk && okCount > 0) { - okCount--; - if (okCount == 0) { - linkOk = false; - okCount = MIN_OK_FRAMES; - } - } - } - rxPacket.magicNumber = 0; -#ifdef IN_AHRS - /*queue next frame - If PIOS_SPI_TransferBlock() fails for any reason, comms will stop working. - In that case, AhrsPoll() should kick start things again. - */ - PIOS_SPI_TransferBlock(opahrs_spi_id, (uint8_t *) & txPacket, (uint8_t *) & rxPacket, sizeof(CommsDataPacket), &CommsCallback); -#endif -} - -/** Call callbacks for object where new data is received - */ -static void PollEvents(void) -{ - for (int idx = 0; idx < MAX_AHRS_OBJECTS; idx++) { - if (objCallbacks[idx]) { - PIOS_IRQ_Disable(); - if (callbackPending[idx]) { - callbackPending[idx] = false; - PIOS_IRQ_Enable(); - objCallbacks[idx] (AhrsFromIndex(idx)); - } else { - PIOS_IRQ_Enable(); - } - } - } -} - -#ifdef IN_AHRS -void AhrsPoll() -{ - if(programReceive) - { - AhrsProgramReceive(opahrs_spi_id); - programReceive = false; - } - PollEvents(); - if (PIOS_SPI_Busy(opahrs_spi_id) != 0) { //Everything is working correctly - return; - } - txPacket.status.kickStarts++; -//comms have broken down - try kick starting it. - txPacket.command = COMMS_NULL; //we must send something so default to null - PIOS_SPI_TransferBlock(opahrs_spi_id, (uint8_t *) & txPacket, (uint8_t *) & rxPacket, sizeof(CommsDataPacket), &CommsCallback); -} - -bool AhrsLinkReady(void) -{ - - for (int ct = 0; ct < MAX_AHRS_OBJECTS; ct++) { - if (!readyObjects[ct]) { - return (false); - } - } - return (linkOk); -} - -#else - -void AhrsSendObjects(void) -{ - static bool oldLink = false; - - PollEvents(); - - if (oldLink != linkOk) { - oldLink = linkOk; - if (linkOk) { - for (int ct = 0; ct < MAX_AHRS_OBJECTS; ct++) { - AhrsObjHandle hdl = AhrsFromIndex(ct); - if (!hdl) { //paranoid - shouldn't ever happen - continue; - } - AhrsSharedData data; - UAVObjGetData(hdl->uavHandle, &data); - AhrsSetData(hdl, &data); - SetObjectDirty(ct); //force even unchanged data to be sent - } - } - } - FillObjectPacket(); - SendPacket(); -} - -void SendPacket(void) -{ -#ifndef IN_AHRS - PIOS_SPI_RC_PinSet(opahrs_spi_id, 0); -#endif - //no point checking if this failed. There isn't much we could do about it if it did fail - PIOS_SPI_TransferBlock(opahrs_spi_id, (uint8_t *) & txPacket, (uint8_t *) & rxPacket, sizeof(CommsDataPacket), &CommsCallback); -} - -static void AhrsUpdatedCb(AhrsObjHandle handle) -{ - UAVObjSetData(handle->uavHandle, handle->data); - return; -} -#endif diff --git a/flight/Libraries/inc/ahrs_comm_objects.h b/flight/Libraries/inc/ahrs_comm_objects.h deleted file mode 100644 index f6c0cb380..000000000 --- a/flight/Libraries/inc/ahrs_comm_objects.h +++ /dev/null @@ -1,95 +0,0 @@ -/** - ****************************************************************************** - * - * @file ahrs_comm_objects.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief AHRS SPI comms UAVObject definitions. - * - * @see The GNU Public License (GPL) Version 3 - * - *****************************************************************************/ -/* - * 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 - */ - - #ifndef AHRS_COMM_OBJECTS_H -#define AHRS_COMM_OBJECTS_H - -#include "attitudeactual.h" -#include "attituderaw.h" -#include "baroaltitude.h" -#include "gpsposition.h" -#include "homelocation.h" -#include "insstatus.h" -#include "inssettings.h" -#include "positionactual.h" -#include "velocityactual.h" -#include "firmwareiapobj.h" -#include "gpsposition.h" -#include "gpssatellites.h" -#include "gpstime.h" -/** union that will fit any UAVObject. -*/ - -typedef union { - AttitudeRawData AttitudeRaw; - AttitudeActualData AttitudeActual; - InsStatusData AhrsStatus; - BaroAltitudeData BaroAltitude; - GPSPositionData GPSPosition; - PositionActualData PositionActual; - VelocityActualData VelocityActual; - HomeLocationData HomeLocation; - InsSettingsData InsSettings; - FirmwareIAPObjData FirmwareIAPObj; - GPSSatellitesData GPSSatellites; - GPSTimeData GPSTime; -} __attribute__ ((packed)) AhrsSharedData; - -/** The number of UAVObjects we will be dealing with. -*/ -#define MAX_AHRS_OBJECTS 12 - -/** Our own version of a UAVObject. -*/ -typedef struct { - void *data; - int size; - uint8_t index; -#ifndef IN_AHRS - UAVObjHandle uavHandle; -#endif -} AhrsSharedObject; - -typedef AhrsSharedObject *AhrsObjHandle; - -/** Initialise the object mapping. -It is important that this is called before any of the following functions. -*/ -void AhrsInitHandles(void); - -/** the AHRS object related to the given index. -Returns the AHRS object or NULL if not found -*/ -AhrsObjHandle AhrsFromIndex(uint8_t index); - -#ifndef IN_AHRS -/** Get the AHRS object associated with the UAVObject. -Returns the AHRS object or NULL if not found -*/ -AhrsObjHandle AhrsFromUAV(UAVObjHandle obj); -#endif - -#endif //#ifndef AHRS_COMMS_OBJECTS_H diff --git a/flight/Libraries/inc/ahrs_spi_comm.h b/flight/Libraries/inc/ahrs_spi_comm.h deleted file mode 100644 index e86a1bb46..000000000 --- a/flight/Libraries/inc/ahrs_spi_comm.h +++ /dev/null @@ -1,136 +0,0 @@ -/** - ****************************************************************************** - * - * @file ahrs_spi_comm.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief Include file of the AHRS SPI comms exposed functionality. - * - * @see The GNU Public License (GPL) Version 3 - * - *****************************************************************************/ -/* - * 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 - */ - -#ifndef AHRS_SPI_COMM_H_INCLUDED -#define AHRS_SPI_COMM_H_INCLUDED - -#ifdef IN_AHRS //AHRS only -#include -#include - -/** Redirect UAVObjGetData call -*/ -#define UAVObjGetData(obj, data) AhrsGetData(obj, data) - -/** Redirect UAVObjSetData call -*/ -#define UAVObjSetData(obj, data) AhrsSetData(obj, data) - -/** Redirect UAVObjConnectCallback call -Note: in AHRS, mask is unused because there is only one event type -*/ -#define UAVObjConnectCallback(obj, callback, mask) AhrsConnectCallBack(obj,callback) - -/** define our own UAVObjHandle -*/ -typedef void *UAVObjHandle; - -#else - -#include "openpilot.h" -#include "uavobjectmanager.h" - -#endif - -#define AHRS_NO_OBJECT 0xff - -#include "ahrs_comm_objects.h" - -/** Status of each end of the link -*/ -typedef struct { //try to keep this short and in multiples of 4 bytes - uint8_t kickStarts; //AHRS end only - uint8_t crcErrors; - uint8_t retries; - uint8_t invalidPacket; -} AhrsEndStatus; - -/** AHRS comms status -*/ -typedef struct { - uint8_t linkOk; - AhrsEndStatus remote; - AhrsEndStatus local; -} AhrsCommStatus; - -/** Event callback, this function is called when an object changes. - */ -typedef void (*AhrsEventCallback) (AhrsObjHandle obj); - -/** Initialise comms. -Note: this must be called before you do anything else. -Comms will not start until the first call to AhrsPoll() or -AhrsSendObjects() - */ -void AhrsInitComms(void); - -/** Connect Comms to a specific SPI interface instance. - */ -void AhrsConnect(uint32_t spi_id); - -/** AHRS version of UAVObject xxxSetData. -Returns: 0 if ok, -1 if an error - */ -int32_t AhrsSetData(AhrsObjHandle obj, const void *dataIn); - -/** AHRS version of UAVObject xxxGetData. -Returns: 0 if ok, -1 if an error - */ -int32_t AhrsGetData(AhrsObjHandle obj, void *dataOut); - -/** Connect a callback for any changes to AHRS data. -Returns: 0 if ok, -1 if an error - */ -int32_t AhrsConnectCallBack(AhrsObjHandle obj, AhrsEventCallback cb); - -/** Get the current link status. -Returns: the status. -Note: the remote status will only be valid if the link is up and running - */ -void AhrsGetStatus(AhrsCommStatus * status); - -#ifdef IN_AHRS //slave only -/** Send the latest objects to the OP -This also polls any pending events and kick starts the DMA -if needed -*/ -void AhrsPoll(); - -/** Check if the link is up and we have received the first batch of updates -Returns: True if the link is up and all objects are up to date -*/ -bool AhrsLinkReady(); - -#else //master only - -/** Send the latest objects to the AHRS -This also polls any pending events -*/ -void AhrsSendObjects(void); - -#endif - -#endif //#ifndef AHRS_SPI_COMM_H_INCLUDED diff --git a/flight/Libraries/inc/insgps.h b/flight/Libraries/inc/insgps.h index 1ff6c4de7..562937c75 100644 --- a/flight/Libraries/inc/insgps.h +++ b/flight/Libraries/inc/insgps.h @@ -80,7 +80,7 @@ void VelBaroCorrection(float Vel[3], float BaroAlt); uint16_t ins_get_num_states(); // Nav structure containing current solution -struct NavStruct { +extern struct NavStruct { float Pos[3]; // Position in meters and relative to a local NED frame float Vel[3]; // Velocity in meters and in NED float q[4]; // unit quaternion rotation relative to NED diff --git a/flight/Libraries/insgps13state.c b/flight/Libraries/insgps13state.c index 8748ef4c9..051338572 100644 --- a/flight/Libraries/insgps13state.c +++ b/flight/Libraries/insgps13state.c @@ -66,6 +66,9 @@ float P[NUMX][NUMX], X[NUMX]; // covariance matrix and state vector float Q[NUMW], R[NUMV]; // input noise and measurement noise variances float K[NUMX][NUMV]; // feedback gain matrix +// Global variables +struct NavStruct Nav; + // ************* Exposed Functions **************** // ************************************************* diff --git a/flight/PiOS/Common/printf-stdarg.c b/flight/Libraries/printf-stdarg.c similarity index 97% rename from flight/PiOS/Common/printf-stdarg.c rename to flight/Libraries/printf-stdarg.c index 5f057ee89..b579b9d53 100644 --- a/flight/PiOS/Common/printf-stdarg.c +++ b/flight/Libraries/printf-stdarg.c @@ -3,26 +3,26 @@ * @addtogroup PIOS PIOS Core hardware abstraction layer * @{ * - * @file printf-stdarg.c + * @file printf-stdarg.c * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. * Parts by Thorsten Klose (tk@midibox.org) * @brief Formatted print functions * @see The GNU Public License (GPL) Version 3 * *****************************************************************************/ -/* - * 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 +/* + * 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 + * + * 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., + * + * 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 */ diff --git a/flight/PiOS/Common/printf2.c b/flight/Libraries/printf2.c similarity index 100% rename from flight/PiOS/Common/printf2.c rename to flight/Libraries/printf2.c diff --git a/flight/Libraries/rscode/library.mk b/flight/Libraries/rscode/library.mk new file mode 100644 index 000000000..8805495c4 --- /dev/null +++ b/flight/Libraries/rscode/library.mk @@ -0,0 +1,9 @@ +# +# Rules to add RSCODE to a PiOS target +# + +RSCODE_DIR := $(dir $(lastword $(MAKEFILE_LIST))) +RSCODE_SRC := berlekamp.c crcgen.c galois.c rs.c + +SRC += $(addprefix $(RSCODE_DIR),$(RSCODE_SRC)) +EXTRAINCDIRS += $(RSCODE_DIR) diff --git a/flight/Libraries/taskmonitor.c b/flight/Libraries/taskmonitor.c index f64d0e1b9..332e94cbf 100644 --- a/flight/Libraries/taskmonitor.c +++ b/flight/Libraries/taskmonitor.c @@ -47,7 +47,7 @@ int32_t TaskMonitorInitialize(void) lock = xSemaphoreCreateRecursiveMutex(); memset(handles, 0, sizeof(xTaskHandle)*TASKINFO_RUNNING_NUMELEM); lastMonitorTime = 0; -#if defined(DIAG_TASKS) +#ifdef DIAG_TASKS lastMonitorTime = portGET_RUN_TIME_COUNTER_VALUE(); #endif return 0; @@ -104,7 +104,7 @@ bool TaskMonitorQueryRunning(TaskInfoRunningElem task) */ void TaskMonitorUpdateAll(void) { -#if defined(DIAG_TASKS) +#ifdef DIAG_TASKS TaskInfoData data; int n; diff --git a/flight/Modules/AHRSComms/ahrs_comms.c b/flight/Modules/AHRSComms/ahrs_comms.c deleted file mode 100644 index abda58ee0..000000000 --- a/flight/Modules/AHRSComms/ahrs_comms.c +++ /dev/null @@ -1,143 +0,0 @@ -/** - ****************************************************************************** - * @addtogroup OpenPilotModules OpenPilot Modules - * @{ - * @addtogroup AHRSCommsModule AHRSComms Module - * @brief Handles communication with AHRS and updating position - * Specifically updates the the @ref AttitudeActual "AttitudeActual" and @ref AttitudeRaw "AttitudeRaw" settings objects - * @{ - * - * @file ahrs_comms.c - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief Module to handle all comms to the AHRS on a periodic basis. - * - * @see The GNU Public License (GPL) Version 3 - * - ******************************************************************************/ -/* - * 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 - */ - -/** - * Input objects: As defined in PiOS/inc/pios_ahrs_comms.h - * Output objects: As defined in PiOS/inc/pios_ahrs_comms.h - * - * This module will periodically update the values of latest attitude solution - * and other objects that are transferred to and from the AHRS - * The module settings can configure how often AHRS is polled for a new solution. - * - * The module executes in its own thread. - * - * UAVObjects are automatically generated by the UAVObjectGenerator from - * the object definition XML file. - * - * Modules have no API, all communication to other modules is done through UAVObjects. - * However modules may use the API exposed by shared libraries. - * See the OpenPilot wiki for more details. - * http://www.openpilot.org/OpenPilot_Application_Architecture - * - */ - -#include "ahrs_comms.h" -#include "ahrs_spi_comm.h" -#include "insstatus.h" - -// Private constants -#define STACK_SIZE configMINIMAL_STACK_SIZE -#define TASK_PRIORITY (tskIDLE_PRIORITY+4) - -// Private types - -// Private variables -static xTaskHandle taskHandle; - -// Private functions -static void ahrscommsTask(void *parameters); - -/** - * Initialise the module, called on startup - * \returns 0 on success or -1 if initialisation failed - */ -int32_t AHRSCommsStart(void) -{ - // Start main task - xTaskCreate(ahrscommsTask, (signed char *)"AHRSComms", STACK_SIZE, NULL, TASK_PRIORITY, &taskHandle); - TaskMonitorAdd(TASKINFO_RUNNING_AHRSCOMMS, taskHandle); - PIOS_WDG_RegisterFlag(PIOS_WDG_AHRS); - - return 0; -} - -/** - * Initialise the module, called on startup - * \returns 0 on success or -1 if initialisation failed - */ -int32_t AHRSCommsInitialize(void) -{ - InsStatusInitialize(); - InsSettingsInitialize(); - AttitudeRawInitialize(); - AttitudeActualInitialize(); - VelocityActualInitialize(); - PositionActualInitialize(); - - return 0; -} -MODULE_INITCALL(AHRSCommsInitialize, AHRSCommsStart) - -/** - * Module thread, should not return. - */ -static void ahrscommsTask(void *parameters) -{ - portTickType lastSysTime; - - AlarmsSet(SYSTEMALARMS_ALARM_AHRSCOMMS, SYSTEMALARMS_ALARM_CRITICAL); - - // Main task loop - while (1) { - PIOS_WDG_UpdateFlag(PIOS_WDG_AHRS); - AhrsCommStatus stat; - - AhrsSendObjects(); - AhrsGetStatus(&stat); - if (stat.linkOk) { - AlarmsClear(SYSTEMALARMS_ALARM_AHRSCOMMS); - } else { - AlarmsSet(SYSTEMALARMS_ALARM_AHRSCOMMS, SYSTEMALARMS_ALARM_WARNING); - } - InsStatusData sData; - InsStatusGet(&sData); - - sData.LinkRunning = stat.linkOk; - sData.AhrsKickstarts = stat.remote.kickStarts; - sData.AhrsCrcErrors = stat.remote.crcErrors; - sData.AhrsRetries = stat.remote.retries; - sData.AhrsInvalidPackets = stat.remote.invalidPacket; - sData.OpCrcErrors = stat.local.crcErrors; - sData.OpRetries = stat.local.retries; - sData.OpInvalidPackets = stat.local.invalidPacket; - - InsStatusSet(&sData); - /* Wait for the next update interval */ - vTaskDelayUntil(&lastSysTime, 2 / portTICK_RATE_MS); - - } -} - -/** - * @} - * @} - */ diff --git a/flight/Modules/AHRSComms/inc/ahrs_comms.h b/flight/Modules/AHRSComms/inc/ahrs_comms.h deleted file mode 100644 index 6dd6c2a1a..000000000 --- a/flight/Modules/AHRSComms/inc/ahrs_comms.h +++ /dev/null @@ -1,37 +0,0 @@ -/** - ****************************************************************************** - * @addtogroup OpenPilotModules OpenPilot Modules - * @{ - * @addtogroup AHRSCommsModule AHRSComms Module - * @{ - * - * @file ahrs_comms.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief Module to handle all comms to the AHRS on a periodic basis. - * - * @see The GNU Public License (GPL) Version 3 - * - *****************************************************************************/ -/* - * 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 - */ -#ifndef AHRS_COMMS_H -#define AHRS_COMMS_H - -#include "openpilot.h" - -int32_t AHRSCommsInitialize(void); - -#endif // AHRS_COMMS_H diff --git a/flight/Modules/Actuator/actuator.c b/flight/Modules/Actuator/actuator.c index 4f341d936..b01a753eb 100644 --- a/flight/Modules/Actuator/actuator.c +++ b/flight/Modules/Actuator/actuator.c @@ -128,7 +128,7 @@ int32_t ActuatorInitialize() // Primary output of this module ActuatorCommandInitialize(); -#if defined(MIXERSTATUS_DIAGNOSTICS) +#ifdef DIAG_MIXERSTATUS // UAVO only used for inspecting the internal status of the mixer during debug MixerStatusInitialize(); #endif @@ -218,7 +218,7 @@ static void actuatorTask(void* parameters) ActuatorDesiredGet(&desired); ActuatorCommandGet(&command); -#if defined(MIXERSTATUS_DIAGNOSTICS) +#ifdef DIAG_MIXERSTATUS MixerStatusGet(&mixerStatus); #endif int nMixers = 0; @@ -379,7 +379,7 @@ static void actuatorTask(void* parameters) // Update in case read only (eg. during servo configuration) ActuatorCommandGet(&command); -#if defined(MIXERSTATUS_DIAGNOSTICS) +#ifdef DIAG_MIXERSTATUS MixerStatusSet(&mixerStatus); #endif diff --git a/flight/Modules/Altitude/altitude.c b/flight/Modules/Altitude/altitude.c index 4898829b0..4e11848e7 100644 --- a/flight/Modules/Altitude/altitude.c +++ b/flight/Modules/Altitude/altitude.c @@ -92,7 +92,7 @@ int32_t AltitudeStart() */ int32_t AltitudeInitialize() { -#ifdef MODULE_Altitude_BUILTIN +#ifdef MODULE_ALTITUDE_BUILTIN altitudeEnabled = 1; #else HwSettingsInitialize(); diff --git a/flight/Modules/CameraStab/camerastab.c b/flight/Modules/CameraStab/camerastab.c index 12915be68..89f41e821 100644 --- a/flight/Modules/CameraStab/camerastab.c +++ b/flight/Modules/CameraStab/camerastab.c @@ -94,7 +94,7 @@ int32_t CameraStabInitialize(void) { bool cameraStabEnabled; -#ifdef MODULE_CameraStab_BUILTIN +#ifdef MODULE_CAMERASTAB_BUILTIN cameraStabEnabled = true; #else uint8_t optionalModules[HWSETTINGS_OPTIONALMODULES_NUMELEM]; diff --git a/flight/Modules/ComUsbBridge/ComUsbBridge.c b/flight/Modules/ComUsbBridge/ComUsbBridge.c index 678e7039d..13c9f6ee4 100644 --- a/flight/Modules/ComUsbBridge/ComUsbBridge.c +++ b/flight/Modules/ComUsbBridge/ComUsbBridge.c @@ -94,7 +94,7 @@ static int32_t comUsbBridgeInitialize(void) usart_port = PIOS_COM_BRIDGE; vcp_port = PIOS_COM_VCP; -#ifdef MODULE_ComUsbBridge_BUILTIN +#ifdef MODULE_COMUSBBRIDGE_BUILTIN bridge_enabled = true; #else HwSettingsInitialize(); diff --git a/flight/Modules/Extensions/MagBaro/magbaro.c b/flight/Modules/Extensions/MagBaro/magbaro.c index e4db11261..ab02a902f 100644 --- a/flight/Modules/Extensions/MagBaro/magbaro.c +++ b/flight/Modules/Extensions/MagBaro/magbaro.c @@ -87,7 +87,7 @@ int32_t MagBaroStart() */ int32_t MagBaroInitialize() { -#ifdef MODULE_MagBaro_BUILTIN +#ifdef MODULE_MAGBARO_BUILTIN magbaroEnabled = 1; #else HwSettingsInitialize(); diff --git a/flight/Modules/Fault/Fault.c b/flight/Modules/Fault/Fault.c index 868330739..b707ed5a5 100644 --- a/flight/Modules/Fault/Fault.c +++ b/flight/Modules/Fault/Fault.c @@ -40,7 +40,7 @@ static uint8_t active_fault; static int32_t fault_initialize(void) { -#ifdef MODULE_Fault_BUILTIN +#ifdef MODULE_FAULT_BUILTIN module_enabled = true; #else HwSettingsInitialize(); diff --git a/flight/Modules/OveroSync/overosync.c b/flight/Modules/OveroSync/overosync.c index 1fb4d1920..639082fce 100644 --- a/flight/Modules/OveroSync/overosync.c +++ b/flight/Modules/OveroSync/overosync.c @@ -75,7 +75,7 @@ struct overosync *overosync; int32_t OveroSyncInitialize(void) { -#ifdef MODULE_OVERO_BUILTIN +#ifdef MODULE_OVEROSYNC_BUILTIN overoEnabled = true; #else diff --git a/flight/Modules/Stabilization/stabilization.c b/flight/Modules/Stabilization/stabilization.c index 06cf27e3c..52ccc8f29 100644 --- a/flight/Modules/Stabilization/stabilization.c +++ b/flight/Modules/Stabilization/stabilization.c @@ -120,7 +120,7 @@ int32_t StabilizationInitialize() // Initialize variables StabilizationSettingsInitialize(); ActuatorDesiredInitialize(); -#if defined(RATEDESIRED_DIAGNOSTICS) +#ifdef DIAG_RATEDESIRED RateDesiredInitialize(); #endif @@ -173,7 +173,7 @@ static void stabilizationTask(void* parameters) StabilizationDesiredGet(&stabDesired); AttitudeActualGet(&attitudeActual); GyrosGet(&gyrosData); -#if defined(RATEDESIRED_DIAGNOSTICS) +#ifdef DIAG_RATEDESIRED RateDesiredGet(&rateDesired); #endif @@ -350,7 +350,7 @@ static void stabilizationTask(void* parameters) if (settings.VbarPiroComp == STABILIZATIONSETTINGS_VBARPIROCOMP_TRUE) stabilization_virtual_flybar_pirocomp(gyro_filtered[2], dT); -#if defined(RATEDESIRED_DIAGNOSTICS) +#ifdef DIAG_RATEDESIRED RateDesiredSet(&rateDesired); #endif diff --git a/flight/Modules/System/systemmod.c b/flight/Modules/System/systemmod.c index 5ac170608..8d6e88508 100644 --- a/flight/Modules/System/systemmod.c +++ b/flight/Modules/System/systemmod.c @@ -92,7 +92,7 @@ static void hwSettingsUpdatedCb(UAVObjEvent * ev); static void updateStats(); static void updateSystemAlarms(); static void systemTask(void *parameters); -#if defined(I2C_WDG_STATS_DIAGNOSTICS) +#ifdef DIAG_I2C_WDG_STATS static void updateI2Cstats(); static void updateWDGstats(); #endif @@ -125,10 +125,10 @@ int32_t SystemModInitialize(void) SystemStatsInitialize(); FlightStatusInitialize(); ObjectPersistenceInitialize(); -#if defined(DIAG_TASKS) +#ifdef DIAG_TASKS TaskInfoInitialize(); #endif -#if defined(I2C_WDG_STATS_DIAGNOSTICS) +#ifdef DIAG_I2C_WDG_STATS I2CStatsInitialize(); WatchdogStatusInitialize(); #endif @@ -181,12 +181,12 @@ static void systemTask(void *parameters) // Update the system alarms updateSystemAlarms(); -#if defined(I2C_WDG_STATS_DIAGNOSTICS) +#ifdef DIAG_I2C_WDG_STATS updateI2Cstats(); updateWDGstats(); #endif -#if defined(DIAG_TASKS) +#ifdef DIAG_TASKS // Update the task status object TaskMonitorUpdateAll(); #endif @@ -334,7 +334,7 @@ static void hwSettingsUpdatedCb(UAVObjEvent * ev) /** * Called periodically to update the I2C statistics */ -#if defined(I2C_WDG_STATS_DIAGNOSTICS) +#ifdef DIAG_I2C_WDG_STATS static void updateI2Cstats() { #if defined(PIOS_INCLUDE_I2C) diff --git a/flight/PiOS/Boards/STM32103CB_AHRS.h b/flight/PiOS/Boards/STM32103CB_AHRS.h deleted file mode 100644 index 1852d60fb..000000000 --- a/flight/PiOS/Boards/STM32103CB_AHRS.h +++ /dev/null @@ -1,243 +0,0 @@ - /** - ****************************************************************************** - * - * @file pios_board.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief Defines board hardware for the OpenPilot Version 1.1 hardware. - * @see The GNU Public License (GPL) Version 3 - * - *****************************************************************************/ -/* - * 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 - */ - - -#ifndef STM32103CB_AHRS_H_ -#define STM32103CB_AHRS_H_ - -//------------------------ -// Timers and Channels Used -//------------------------ -/* -Timer | Channel 1 | Channel 2 | Channel 3 | Channel 4 -------+-----------+-----------+-----------+---------- -TIM1 | | | | -TIM2 | --------------- PIOS_DELAY ----------------- -TIM3 | | | | -TIM4 | | | | -TIM5 | | | | -TIM6 | | | | -TIM7 | | | | -TIM8 | | | | -------+-----------+-----------+-----------+---------- -*/ - -//------------------------ -// DMA Channels Used -//------------------------ -/* Channel 1 - */ -/* Channel 2 - */ -/* Channel 3 - */ -/* Channel 4 - */ -/* Channel 5 - */ -/* Channel 6 - */ -/* Channel 7 - */ -/* Channel 8 - */ -/* Channel 9 - */ -/* Channel 10 - */ -/* Channel 11 - */ -/* Channel 12 - */ - - -//------------------------ -// BOOTLOADER_SETTINGS -//------------------------ -#define BOARD_READABLE TRUE -#define BOARD_WRITABLE TRUE -#define MAX_DEL_RETRYS 3 - -//------------------------ -// PIOS_LED -//------------------------ -#define PIOS_LED_HEARTBEAT 0 - -//------------------------- -// System Settings -//------------------------- -#define PIOS_MASTER_CLOCK 72000000 -#define PIOS_PERIPHERAL_CLOCK (PIOS_MASTER_CLOCK / 2) - -//------------------------- -// Interrupt Priorities -//------------------------- -#define PIOS_IRQ_PRIO_LOW 12 // lower than RTOS -#define PIOS_IRQ_PRIO_MID 8 // higher than RTOS -#define PIOS_IRQ_PRIO_HIGH 5 // for SPI, ADC, I2C etc... -#define PIOS_IRQ_PRIO_HIGHEST 4 // for USART etc... - -//------------------------ -// PIOS_I2C -// See also pios_board.c -//------------------------ -#define PIOS_I2C_MAX_DEVS 1 -extern uint32_t pios_i2c_main_adapter_id; -#define PIOS_I2C_MAIN_ADAPTER (pios_i2c_main_adapter_id) - -//------------------------- -// SPI -// -// See also pios_board.c -//------------------------- -#define PIOS_SPI_MAX_DEVS 1 - -//------------------------- -// PIOS_USART -//------------------------- -#define PIOS_USART_MAX_DEVS 2 - -//------------------------- -// PIOS_COM -// -// See also pios_board.c -//------------------------- -#define PIOS_COM_MAX_DEVS 2 - -extern uint32_t pios_com_aux_id; -#define PIOS_COM_AUX (pios_com_aux_id) -#define PIOS_COM_DEBUG PIOS_COM_AUX - -//------------------------- -// ADC -// PIOS_ADC_PinGet(0) = Accel Z -// PIOS_ADC_PinGet(2) = Accel Y -// PIOS_ADC_PinGet(4) = Accel X -// PIOS_ADC_PinGet(1) = Gyro X -// PIOS_ADC_PinGet(3) = Gyro Y -// PIOS_ADC_PinGet(5) = Gyro Z -// PIOS_ADC_PinGet(6) = XY Temp -// PIOS_ADC_PinGet(7) = Z Temp -//------------------------- -//#define PIOS_ADC_OVERSAMPLING_RATE 1 -#define PIOS_ADC_USE_TEMP_SENSOR 0 -#define PIOS_ADC_TEMP_SENSOR_ADC ADC1 -#define PIOS_ADC_TEMP_SENSOR_ADC_CHANNEL 1 - -#define PIOS_ADC_PIN1_GPIO_PORT GPIOA // PA2 (Accel X) -#define PIOS_ADC_PIN1_GPIO_PIN GPIO_Pin_2 // ADC12_IN2 -#define PIOS_ADC_PIN1_GPIO_CHANNEL ADC_Channel_2 -#define PIOS_ADC_PIN1_ADC ADC1 -#define PIOS_ADC_PIN1_ADC_NUMBER 1 - -#define PIOS_ADC_PIN2_GPIO_PORT GPIOA // PA1 (Accel Y) -#define PIOS_ADC_PIN2_GPIO_PIN GPIO_Pin_1 // ADC123_IN1 -#define PIOS_ADC_PIN2_GPIO_CHANNEL ADC_Channel_1 -#define PIOS_ADC_PIN2_ADC ADC1 -#define PIOS_ADC_PIN2_ADC_NUMBER 2 - -#define PIOS_ADC_PIN3_GPIO_PORT GPIOA // PA0 (Accel Z) -#define PIOS_ADC_PIN3_GPIO_PIN GPIO_Pin_0 // ADC12_IN0 -#define PIOS_ADC_PIN3_GPIO_CHANNEL ADC_Channel_0 -#define PIOS_ADC_PIN3_ADC ADC1 -#define PIOS_ADC_PIN3_ADC_NUMBER 3 - -#define PIOS_ADC_PIN4_GPIO_PORT GPIOA // PA6 (Temp_XY) -#define PIOS_ADC_PIN4_GPIO_PIN GPIO_Pin_6 // ADC12_IN6 -#define PIOS_ADC_PIN4_GPIO_CHANNEL ADC_Channel_6 -#define PIOS_ADC_PIN4_ADC ADC1 -#define PIOS_ADC_PIN4_ADC_NUMBER 4 - -#define PIOS_ADC_PIN5_GPIO_PORT GPIOA // PA4 (Gyro X) -#define PIOS_ADC_PIN5_GPIO_PIN GPIO_Pin_4 // ADC12_IN4 -#define PIOS_ADC_PIN5_GPIO_CHANNEL ADC_Channel_4 -#define PIOS_ADC_PIN5_ADC ADC2 -#define PIOS_ADC_PIN5_ADC_NUMBER 1 - -#define PIOS_ADC_PIN6_GPIO_PORT GPIOA // PA5 (Gyro Y) -#define PIOS_ADC_PIN6_GPIO_PIN GPIO_Pin_5 // ADC12_IN5 -#define PIOS_ADC_PIN6_GPIO_CHANNEL ADC_Channel_5 -#define PIOS_ADC_PIN6_ADC ADC2 -#define PIOS_ADC_PIN6_ADC_NUMBER 2 - -#define PIOS_ADC_PIN7_GPIO_PORT GPIOA // PA7 (Gyro Z) -#define PIOS_ADC_PIN7_GPIO_PIN GPIO_Pin_7 // ADC12_IN7 -#define PIOS_ADC_PIN7_GPIO_CHANNEL ADC_Channel_7 -#define PIOS_ADC_PIN7_ADC ADC2 -#define PIOS_ADC_PIN7_ADC_NUMBER 3 - -#define PIOS_ADC_PIN8_GPIO_PORT GPIOB // PB1 (Z Temp) -#define PIOS_ADC_PIN8_GPIO_PIN GPIO_Pin_1 // ADC12_IN9 -#define PIOS_ADC_PIN8_GPIO_CHANNEL ADC_Channel_9 -#define PIOS_ADC_PIN8_ADC ADC2 -#define PIOS_ADC_PIN8_ADC_NUMBER 4 - -#define PIOS_ADC_NUM_PINS 8 - -#define PIOS_ADC_PORTS { PIOS_ADC_PIN1_GPIO_PORT, PIOS_ADC_PIN2_GPIO_PORT, PIOS_ADC_PIN3_GPIO_PORT, PIOS_ADC_PIN4_GPIO_PORT, PIOS_ADC_PIN5_GPIO_PORT, PIOS_ADC_PIN6_GPIO_PORT, PIOS_ADC_PIN7_GPIO_PORT, PIOS_ADC_PIN8_GPIO_PORT } -#define PIOS_ADC_PINS { PIOS_ADC_PIN1_GPIO_PIN, PIOS_ADC_PIN2_GPIO_PIN, PIOS_ADC_PIN3_GPIO_PIN, PIOS_ADC_PIN4_GPIO_PIN, PIOS_ADC_PIN5_GPIO_PIN, PIOS_ADC_PIN6_GPIO_PIN, PIOS_ADC_PIN7_GPIO_PIN, PIOS_ADC_PIN8_GPIO_PIN } -#define PIOS_ADC_CHANNELS { PIOS_ADC_PIN1_GPIO_CHANNEL, PIOS_ADC_PIN2_GPIO_CHANNEL, PIOS_ADC_PIN3_GPIO_CHANNEL, PIOS_ADC_PIN4_GPIO_CHANNEL, PIOS_ADC_PIN5_GPIO_CHANNEL, PIOS_ADC_PIN6_GPIO_CHANNEL, PIOS_ADC_PIN7_GPIO_CHANNEL, PIOS_ADC_PIN8_GPIO_CHANNEL } -#define PIOS_ADC_MAPPING { PIOS_ADC_PIN1_ADC, PIOS_ADC_PIN2_ADC, PIOS_ADC_PIN3_ADC, PIOS_ADC_PIN4_ADC, PIOS_ADC_PIN5_ADC, PIOS_ADC_PIN6_ADC, PIOS_ADC_PIN7_ADC, PIOS_ADC_PIN8_ADC } -#define PIOS_ADC_CHANNEL_MAPPING { PIOS_ADC_PIN1_ADC_NUMBER, PIOS_ADC_PIN2_ADC_NUMBER, PIOS_ADC_PIN3_ADC_NUMBER, PIOS_ADC_PIN4_ADC_NUMBER, PIOS_ADC_PIN5_ADC_NUMBER, PIOS_ADC_PIN6_ADC_NUMBER, PIOS_ADC_PIN7_ADC_NUMBER, PIOS_ADC_PIN8_ADC_NUMBER } -#define PIOS_ADC_NUM_CHANNELS (PIOS_ADC_NUM_PINS + PIOS_ADC_USE_TEMP_SENSOR) -#define PIOS_ADC_NUM_ADC_CHANNELS 2 -#define PIOS_ADC_USE_ADC2 1 -#define PIOS_ADC_ADCCLK RCC_PCLK2_Div2 -#define PIOS_ADC_PCLK2 RCC_HCLK_Div16 -#define PIOS_ADC_CLOCK_FUNCTION RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1 | RCC_APB2Periph_ADC2, ENABLE); RCC_PCLK2Config(PIOS_ADC_PCLK2); -/* RCC_PCLK2_Div2: ADC clock = PCLK2/2 */ -/* RCC_PCLK2_Div4: ADC clock = PCLK2/4 */ -/* RCC_PCLK2_Div6: ADC clock = PCLK2/6 */ -/* RCC_PCLK2_Div8: ADC clock = PCLK2/8 */ -#define PIOS_ADC_SAMPLE_TIME ADC_SampleTime_239Cycles5 -/* Sample time: */ -/* With an ADCCLK = 14 MHz and a sampling time of 239.5 cycles: */ -/* Tconv = 239.5 + 12.5 = 252 cycles = 18�s */ -/* (1 / (ADCCLK / CYCLES)) = Sample Time (�S) */ -#define PIOS_ADC_IRQ_PRIO PIOS_IRQ_PRIO_LOW - -// Currently analog acquistion hard coded at 480 Hz -// PCKL2 = HCLK / 16 -// ADCCLK = PCLK2 / 2 -#define PIOS_ADC_RATE (72.0e6 / 16 / 2 / 252 / (PIOS_ADC_NUM_PINS / 2)) -#define EKF_RATE (PIOS_ADC_RATE / adc_oversampling / 2) -#define PIOS_ADC_MAX_OVERSAMPLING 50 - -//------------------------- -// GPIO -//------------------------- -#define PIOS_GPIO_1_PORT GPIOB -#define PIOS_GPIO_1_PIN GPIO_Pin_9 -#define PIOS_GPIO_1_GPIO_CLK RCC_APB2Periph_GPIOB -#define PIOS_GPIO_PORTS { PIOS_GPIO_1_PORT } -#define PIOS_GPIO_PINS { PIOS_GPIO_1_PIN } -#define PIOS_GPIO_CLKS { PIOS_GPIO_1_GPIO_CLK } -#define PIOS_GPIO_NUM 1 -#define SET_ACCEL_2G PIOS_GPIO_On(0); -#define SET_ACCEL_6G PIOS_GPIO_Off(0) - -//------------------------ -// PIOS_HMC5843 -//------------------------ -#define PIOS_HMC5843_DRDY_GPIO_PORT GPIOB -#define PIOS_HMC5843_DRDY_GPIO_PIN GPIO_Pin_8 -#define PIOS_HMC5843_DRDY_PORT_SOURCE GPIO_PortSourceGPIOB -#define PIOS_HMC5843_DRDY_PIN_SOURCE GPIO_PinSource8 -#define PIOS_HMC5843_DRDY_CLK RCC_APB2Periph_GPIOB -#define PIOS_HMC5843_DRDY_EXTI_LINE EXTI_Line8 -#define PIOS_HMC5843_DRDY_IRQn EXTI9_5_IRQn -#define PIOS_HMC5843_DRDY_PRIO PIOS_IRQ_PRIO_HIGH - - - -#endif /* STM32103CB_AHRS_H_ */ diff --git a/flight/PiOS/Boards/STM32103CB_CC_Rev1.h b/flight/PiOS/Boards/STM32103CB_CC_Rev1.h index 292594ee9..f5ba3b067 100644 --- a/flight/PiOS/Boards/STM32103CB_CC_Rev1.h +++ b/flight/PiOS/Boards/STM32103CB_CC_Rev1.h @@ -275,4 +275,4 @@ extern uint32_t pios_com_debug_id; #define PIOS_USB_DETECT_GPIO_PORT GPIOC #define PIOS_USB_MAX_DEVS 1 #define PIOS_USB_DETECT_GPIO_PIN GPIO_Pin_15 -#endif /* STM32103CB_AHRS_H_ */ +#endif /* STM32103CB_CC_H_ */ diff --git a/flight/PiOS/Boards/STM32103CB_PIPXTREME_Rev1.h b/flight/PiOS/Boards/STM32103CB_PIPXTREME_Rev1.h index 88ce43312..d2a901bfb 100755 --- a/flight/PiOS/Boards/STM32103CB_PIPXTREME_Rev1.h +++ b/flight/PiOS/Boards/STM32103CB_PIPXTREME_Rev1.h @@ -191,12 +191,6 @@ extern uint32_t pios_ppm_out_id; #define PIOS_PPM_RECEIVER (pios_ppm_rcvr_id) #define PIOS_PPM_OUTPUT (pios_ppm_out_id) -#define DEBUG_LEVEL 2 -#if DEBUG_LEVEL > 1000 -#define DEBUG_PRINTF(level, ...) {if(level <= DEBUG_LEVEL && PIOS_COM_DEBUG > 0) { PIOS_COM_SendFormattedStringNonBlocking(PIOS_COM_DEBUG, __VA_ARGS__); }} -#else -#define DEBUG_PRINTF(...) -#endif #define RFM22_DEBUG 1 //------------------------- @@ -294,26 +288,12 @@ extern uint32_t pios_rfm22b_id; //------------------------- // Packet Handler //------------------------- -#if defined(PIOS_INCLUDE_PACKET_HANDLER) extern uint32_t pios_packet_handler; #define PIOS_PACKET_HANDLER (pios_packet_handler) #define PIOS_PH_MAX_PACKET 255 #define PIOS_PH_WIN_SIZE 3 #define PIOS_PH_MAX_CONNECTIONS 1 #define RS_ECC_NPARITY 4 -#endif /* PIOS_INCLUDE_PACKET_HANDLER */ - -//------------------------- -// Packet Handler -//------------------------- - -#if defined(PIOS_INCLUDE_PACKET_HANDLER) -uint32_t pios_packet_handler; -#define PIOS_PACKET_HANDLER (pios_packet_handler) -#define PIOS_PH_MAX_PACKET 255 -#define PIOS_PH_WIN_SIZE 3 -#define PIOS_PH_MAX_CONNECTIONS 1 -#endif /* PIOS_INCLUDE_PACKET_HANDLER */ //------------------------- // Reed-Solomon ECC diff --git a/flight/PiOS/Boards/STM32F4xx_OSD.h b/flight/PiOS/Boards/STM32F4xx_OSD.h index 722c76d34..5628571a0 100644 --- a/flight/PiOS/Boards/STM32F4xx_OSD.h +++ b/flight/PiOS/Boards/STM32F4xx_OSD.h @@ -186,7 +186,7 @@ extern uint32_t pios_com_telem_usb_id; #define PIOS_COM_GPS (pios_com_gps_id) #define PIOS_COM_TELEM_USB (pios_com_telem_usb_id) #define PIOS_COM_TELEM_RF (pios_com_telem_rf_id) -#define PIOS_COM_DEBUG PIOS_COM_AUX +#define PIOS_COM_DEBUG (PIOS_COM_AUX) #define PIOS_COM_OSD (pios_com_aux_id) //extern uint32_t pios_com_serial_id; @@ -202,13 +202,6 @@ extern uint32_t pios_com_telem_usb_id; #define PIOS_COM_TELEM_USB (pios_com_telem_usb_id) #endif -#if defined(PIOS_COM_DEBUG) -// #define DEBUG_PRINTF(...) PIOS_COM_SendFormattedString(PIOS_COM_DEBUG, __VA_ARGS__) - #define DEBUG_PRINTF(...) PIOS_COM_SendFormattedStringNonBlocking(PIOS_COM_DEBUG, __VA_ARGS__) -#else - #define DEBUG_PRINTF(...) -#endif - // ***************************************************************** // ADC diff --git a/flight/PiOS/Boards/STM32F4xx_RevoMini.h b/flight/PiOS/Boards/STM32F4xx_RevoMini.h index 49c0d1c96..0f8fb38d3 100644 --- a/flight/PiOS/Boards/STM32F4xx_RevoMini.h +++ b/flight/PiOS/Boards/STM32F4xx_RevoMini.h @@ -31,13 +31,6 @@ #include -#if defined(PIOS_INCLUDE_DEBUG_CONSOLE) -#define DEBUG_LEVEL 0 -#define DEBUG_PRINTF(level, ...) {if(level <= DEBUG_LEVEL && pios_com_debug_id > 0) { PIOS_COM_SendFormattedStringNonBlocking(pios_com_debug_id, __VA_ARGS__); }} -#else -#define DEBUG_PRINTF(level, ...) -#endif /* PIOS_INCLUDE_DEBUG_CONSOLE */ - //------------------------ // Timers and Channels Used //------------------------ diff --git a/flight/PiOS/Boards/pios_board.h b/flight/PiOS/Boards/pios_board.h index aced5f898..9a2340e2e 100644 --- a/flight/PiOS/Boards/pios_board.h +++ b/flight/PiOS/Boards/pios_board.h @@ -1,9 +1,7 @@ #ifndef PIOS_BOARD_H_ #define PIOS_BOARD_H_ -#ifdef USE_STM32103CB_AHRS -#include "STM32103CB_AHRS.h" -#elif USE_STM3210E_OP +#ifdef USE_STM3210E_OP #include "STM3210E_OP.h" #elif USE_STM32103CB_PIPXTREME #include "STM32103CB_PIPXTREME_Rev1.h" diff --git a/flight/PiOS/Common/Libraries/CMSIS2/library.mk b/flight/PiOS/Common/Libraries/CMSIS2/library.mk index d965c1b63..fd9410ad0 100644 --- a/flight/PiOS/Common/Libraries/CMSIS2/library.mk +++ b/flight/PiOS/Common/Libraries/CMSIS2/library.mk @@ -2,28 +2,26 @@ # Rules to add CMSIS2 to a PiOS target # -CMSIS2_DIR := $(dir $(lastword $(MAKEFILE_LIST))) -EXTRAINCDIRS += $(CMSIS2_DIR)/Include +CMSIS2_DIR := $(dir $(lastword $(MAKEFILE_LIST))) +EXTRAINCDIRS += $(CMSIS2_DIR)Include # Rules to build the ARM DSP library ifeq ($(USE_DSP_LIB), YES) + DSPLIB_NAME := dsp + CMSIS_DSPLIB := $(CMSIS2_DIR)DSP_Lib/Source -DSPLIB_NAME := dsp -CMSIS_DSPLIB := $(CMSIS2_DIR)/DSP_Lib/Source + # Compile all files into output directory + DSPLIB_SRC := $(wildcard $(CMSIS_DSPLIB)/*/*.c) + DSPLIB_SRCBASE := $(notdir $(basename $(DSPLIB_SRC))) + $(foreach src, $(DSPLIB_SRC), $(eval $(call COMPILE_C_TEMPLATE, $(src)))) -# Compile all files into output directory -DSPLIB_SRC := $(wildcard $(CMSIS_DSPLIB)/*/*.c) -DSPLIB_SRCBASE := $(notdir $(basename $(DSPLIB_SRC))) -$(foreach src, $(DSPLIB_SRC), $(eval $(call COMPILE_C_TEMPLATE, $(src)))) + # Define the object files directory and a list of object files for the library + DSPLIB_OBJDIR = $(OUTDIR) + DSPLIB_OBJ = $(addprefix $(DSPLIB_OBJDIR)/, $(addsuffix .o, $(DSPLIB_SRCBASE))) -# Define the object files directory and a list of object files for the library -DSPLIB_OBJDIR = $(OUTDIR) -DSPLIB_OBJ = $(addprefix $(DSPLIB_OBJDIR)/, $(addsuffix .o, $(DSPLIB_SRCBASE))) - -# Create a library file -$(eval $(call ARCHIVE_TEMPLATE, $(OUTDIR)/lib$(DSPLIB_NAME).a, $(DSPLIB_OBJ), $(DSPLIB_OBJDIR))) - -# Add library to the list of linked objects -ALLLIB += $(OUTDIR)/lib$(DSPLIB_NAME).a + # Create a library file + $(eval $(call ARCHIVE_TEMPLATE, $(OUTDIR)/lib$(DSPLIB_NAME).a, $(DSPLIB_OBJ), $(DSPLIB_OBJDIR))) + # Add library to the list of linked objects + ALLLIB += $(OUTDIR)/lib$(DSPLIB_NAME).a endif diff --git a/flight/PiOS/Common/Libraries/FreeRTOS/library.mk b/flight/PiOS/Common/Libraries/FreeRTOS/library.mk index ae65aff82..9e101b273 100644 --- a/flight/PiOS/Common/Libraries/FreeRTOS/library.mk +++ b/flight/PiOS/Common/Libraries/FreeRTOS/library.mk @@ -5,7 +5,6 @@ # has been defined and add in the target-specific pieces separately. # -FREERTOS_DIR := $(dir $(lastword $(MAKEFILE_LIST)))/Source -SRC += $(wildcard $(FREERTOS_DIR)/*.c) -EXTRAINCDIRS += $(FREERTOS_DIR)/include - +FREERTOS_DIR := $(dir $(lastword $(MAKEFILE_LIST)))/Source +SRC += $(wildcard $(FREERTOS_DIR)/*.c) +EXTRAINCDIRS += $(FREERTOS_DIR)/include diff --git a/flight/PiOS/Common/Libraries/dosfs/library.mk b/flight/PiOS/Common/Libraries/dosfs/library.mk index d3bf6e16b..0e6fa982e 100644 --- a/flight/PiOS/Common/Libraries/dosfs/library.mk +++ b/flight/PiOS/Common/Libraries/dosfs/library.mk @@ -2,7 +2,6 @@ # Rules to add DOSFS to a PiOS target # -DOSFS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) -SRC += $(wildcard $(DOSFS_DIR)*.c) -EXTRAINCDIRS += $(DOSFS_DIR) - +DOSFS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) +SRC += $(wildcard $(DOSFS_DIR)*.c) +EXTRAINCDIRS += $(DOSFS_DIR) diff --git a/flight/PiOS/Common/Libraries/msheap/library.mk b/flight/PiOS/Common/Libraries/msheap/library.mk index de7ca06f6..84a796e62 100644 --- a/flight/PiOS/Common/Libraries/msheap/library.mk +++ b/flight/PiOS/Common/Libraries/msheap/library.mk @@ -2,7 +2,6 @@ # Rules to add the MSHeap allocator to a PiOS target # -MSHEAP_DIR := $(dir $(lastword $(MAKEFILE_LIST))) -SRC += $(wildcard $(MSHEAP_DIR)*.c) -EXTRAINCDIRS += $(MSHEAP_DIR) - +MSHEAP_DIR := $(dir $(lastword $(MAKEFILE_LIST))) +SRC += $(wildcard $(MSHEAP_DIR)*.c) +EXTRAINCDIRS += $(MSHEAP_DIR) diff --git a/flight/PiOS/Common/pios_adxl345.c b/flight/PiOS/Common/pios_adxl345.c index 248c985b2..3f3ba88f8 100644 --- a/flight/PiOS/Common/pios_adxl345.c +++ b/flight/PiOS/Common/pios_adxl345.c @@ -30,6 +30,8 @@ #include "pios.h" +#ifdef PIOS_INCLUDE_ADXL345 + enum pios_adxl345_dev_magic { PIOS_ADXL345_DEV_MAGIC = 0xcb55aa55, }; @@ -306,3 +308,5 @@ uint8_t PIOS_ADXL345_Read(struct pios_adxl345_data * data) return rec[8] & 0x7F; // return number of remaining entries } + +#endif /* PIOS_INCLUDE_ADXL345 */ diff --git a/flight/PiOS/Common/pios_bma180.c b/flight/PiOS/Common/pios_bma180.c index 3a2e32d95..a5f64a121 100644 --- a/flight/PiOS/Common/pios_bma180.c +++ b/flight/PiOS/Common/pios_bma180.c @@ -31,7 +31,7 @@ #include "pios.h" -#if defined(PIOS_INCLUDE_BMA180) +#ifdef PIOS_INCLUDE_BMA180 #include "fifo_buffer.h" @@ -475,6 +475,7 @@ bool PIOS_BMA180_IRQHandler(void) } #endif /* PIOS_INCLUDE_BMA180 */ + /** * @} * @} diff --git a/flight/PiOS/Common/pios_bmp085.c b/flight/PiOS/Common/pios_bmp085.c index c12174d0f..0b1201caf 100644 --- a/flight/PiOS/Common/pios_bmp085.c +++ b/flight/PiOS/Common/pios_bmp085.c @@ -28,15 +28,13 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include "pios.h" -#if defined(PIOS_INCLUDE_BMP085) -#if !defined(PIOS_INCLUDE_EXTI) -#error PIOS_EXTI Must be included in the project! -#endif /* PIOS_INCLUDE_EXTI */ +#ifdef PIOS_INCLUDE_BMP085 -#include +#ifndef PIOS_INCLUDE_EXTI +#error PIOS_EXTI must be included in the project +#endif /* PIOS_INCLUDE_EXTI */ /* Glocal Variables */ ConversionTypeTypeDef CurrentRead; diff --git a/flight/PiOS/Common/pios_board_info.c b/flight/PiOS/Common/pios_board_info.c index 8905a5c08..c3a5a4dfb 100644 --- a/flight/PiOS/Common/pios_board_info.c +++ b/flight/PiOS/Common/pios_board_info.c @@ -1,6 +1,5 @@ #include #include - #include "pios_board_info.h" const struct pios_board_info __attribute__((__used__)) __attribute__((__section__(".boardinfo"))) pios_board_info_blob = { diff --git a/flight/PiOS/Common/pios_com.c b/flight/PiOS/Common/pios_com.c index 422f3ecc9..b15a176ef 100644 --- a/flight/PiOS/Common/pios_com.c +++ b/flight/PiOS/Common/pios_com.c @@ -28,15 +28,14 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include "pios.h" -#if defined(PIOS_INCLUDE_COM) +#ifdef PIOS_INCLUDE_COM #include "fifo_buffer.h" #include -#if !defined(PIOS_INCLUDE_FREERTOS) +#ifndef PIOS_INCLUDE_FREERTOS #include "pios_delay.h" /* PIOS_DELAY_WaitmS */ #endif @@ -524,7 +523,7 @@ bool PIOS_COM_Available(uint32_t com_id) return (com_dev->driver->available)(com_dev->lower_id); } -#endif +#endif /* PIOS_INCLUDE_COM */ /** * @} diff --git a/flight/PiOS/Common/pios_com_msg.c b/flight/PiOS/Common/pios_com_msg.c index c1cebe1d9..afc68c1ec 100644 --- a/flight/PiOS/Common/pios_com_msg.c +++ b/flight/PiOS/Common/pios_com_msg.c @@ -28,10 +28,9 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include "pios.h" -#if defined(PIOS_INCLUDE_COM_MSG) +#ifdef PIOS_INCLUDE_COM_MSG #include "pios_com.h" diff --git a/flight/PiOS/Common/pios_etasv3.c b/flight/PiOS/Common/pios_etasv3.c index 2a0ca9b52..33090ba5e 100644 --- a/flight/PiOS/Common/pios_etasv3.c +++ b/flight/PiOS/Common/pios_etasv3.c @@ -28,12 +28,9 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include "pios.h" -#if defined(PIOS_INCLUDE_ETASV3) - -#include "pios_etasv3.h" +#ifdef PIOS_INCLUDE_ETASV3 static bool PIOS_ETASV3_Read(uint8_t * buffer, uint8_t len) { diff --git a/flight/PiOS/Common/pios_flash_jedec.c b/flight/PiOS/Common/pios_flash_jedec.c index 6d382a1c1..2294b598d 100644 --- a/flight/PiOS/Common/pios_flash_jedec.c +++ b/flight/PiOS/Common/pios_flash_jedec.c @@ -28,7 +28,11 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + #include "pios.h" + +#ifdef PIOS_INCLUDE_FLASH + #include "pios_flash_jedec_priv.h" #define JEDEC_WRITE_ENABLE 0x06 @@ -562,3 +566,4 @@ const struct pios_flash_driver pios_jedec_flash_driver = { .read_data = PIOS_Flash_Jedec_ReadData, }; +#endif /* PIOS_INCLUDE_FLASH */ diff --git a/flight/PiOS/Common/pios_flashfs_logfs.c b/flight/PiOS/Common/pios_flashfs_logfs.c index 5bad06383..0873e5987 100644 --- a/flight/PiOS/Common/pios_flashfs_logfs.c +++ b/flight/PiOS/Common/pios_flashfs_logfs.c @@ -24,6 +24,11 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#include "pios.h" + +#ifdef PIOS_INCLUDE_FLASH + #include "openpilot.h" #include "pios_flashfs_logfs_priv.h" @@ -1020,6 +1025,8 @@ out_exit: return rc; } +#endif /* PIOS_INCLUDE_FLASH */ + /** * @} * @} diff --git a/flight/PiOS/Common/pios_gcsrcvr.c b/flight/PiOS/Common/pios_gcsrcvr.c index d5451157e..674a88481 100644 --- a/flight/PiOS/Common/pios_gcsrcvr.c +++ b/flight/PiOS/Common/pios_gcsrcvr.c @@ -28,12 +28,11 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include "pios.h" -#include "uavobjectmanager.h" +#ifdef PIOS_INCLUDE_GCSRCVR -#if defined(PIOS_INCLUDE_GCSRCVR) +#include "uavobjectmanager.h" #include "pios_gcsrcvr_priv.h" @@ -168,7 +167,7 @@ static void PIOS_gcsrcvr_Supervisor(uint32_t gcsrcvr_id) { gcsrcvr_dev->Fresh = false; } -#endif /* PIOS_INCLUDE_GCSRCVR */ +#endif /* PIOS_INCLUDE_GCSRCVR */ /** * @} diff --git a/flight/PiOS/Common/pios_hcsr04.c b/flight/PiOS/Common/pios_hcsr04.c index cbdb31e7e..02177fac0 100644 --- a/flight/PiOS/Common/pios_hcsr04.c +++ b/flight/PiOS/Common/pios_hcsr04.c @@ -28,12 +28,12 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include "pios.h" -#if defined(PIOS_INCLUDE_HCSR04) +#ifdef PIOS_INCLUDE_HCSR04 + #if !(defined(PIOS_INCLUDE_DSM) || defined(PIOS_INCLUDE_SBUS)) -#error Only supported with Spektrum/JR DSM or S.Bus interface! +#error Only supported with Spektrum/JR DSM or S.Bus interface #endif /* Local Variables */ @@ -206,5 +206,5 @@ void TIM3_IRQHandler(void) } } +#endif /* PIOS_INCLUDE_HCSR04 */ -#endif diff --git a/flight/PiOS/Common/pios_hmc5843.c b/flight/PiOS/Common/pios_hmc5843.c index 4f6b562d6..83dcc07bf 100644 --- a/flight/PiOS/Common/pios_hmc5843.c +++ b/flight/PiOS/Common/pios_hmc5843.c @@ -29,10 +29,9 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include "pios.h" -#if defined(PIOS_INCLUDE_HMC5843) +#ifdef PIOS_INCLUDE_HMC5843 #include @@ -376,7 +375,7 @@ static bool PIOS_HMC5843_Write(uint8_t address, uint8_t buffer) return PIOS_I2C_Transfer(PIOS_I2C_MAIN_ADAPTER, txn_list, NELEMENTS(txn_list)); } -#endif +#endif /* PIOS_INCLUDE_HMC5843 */ /** * @} diff --git a/flight/PiOS/Common/pios_hmc5883.c b/flight/PiOS/Common/pios_hmc5883.c index 0eb14e28a..1e676fbcb 100644 --- a/flight/PiOS/Common/pios_hmc5883.c +++ b/flight/PiOS/Common/pios_hmc5883.c @@ -28,10 +28,9 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include "pios.h" -#if defined(PIOS_INCLUDE_HMC5883) +#ifdef PIOS_INCLUDE_HMC5883 /* Global Variables */ diff --git a/flight/PiOS/Common/pios_i2c_esc.c b/flight/PiOS/Common/pios_i2c_esc.c index d440bfa48..9409b9a68 100644 --- a/flight/PiOS/Common/pios_i2c_esc.c +++ b/flight/PiOS/Common/pios_i2c_esc.c @@ -29,12 +29,11 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include "pios.h" -#if defined(PIOS_INCLUDE_I2C_ESC) +#ifdef PIOS_INCLUDE_I2C_ESC -/* HMC5843 Addresses */ +/* Known i2c ESC addresses */ #define MK_I2C_ADDR 0x29 #define ASTEC4_I2C_ADDR 0x02 @@ -164,7 +163,7 @@ bool PIOS_SetAstec4Speed(uint8_t motornum, uint8_t speed) { return PIOS_I2C_Transfer(PIOS_I2C_ESC_ADAPTER, txn_list, NELEMENTS(txn_list)); } -#endif +#endif /* PIOS_INCLUDE_I2C_ESC */ /** * @} diff --git a/flight/PiOS/Common/pios_l3gd20.c b/flight/PiOS/Common/pios_l3gd20.c index 6876db16d..399eaa785 100644 --- a/flight/PiOS/Common/pios_l3gd20.c +++ b/flight/PiOS/Common/pios_l3gd20.c @@ -29,10 +29,9 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include "pios.h" -#if defined(PIOS_INCLUDE_L3GD20) +#ifdef PIOS_INCLUDE_L3GD20 #include "fifo_buffer.h" @@ -381,7 +380,7 @@ bool PIOS_L3GD20_IRQHandler(void) return xHigherPriorityTaskWoken == pdTRUE; } -#endif /* L3GD20 */ +#endif /* PIOS_INCLUDE_L3GD20 */ /** * @} diff --git a/flight/PiOS/Common/pios_mpu6000.c b/flight/PiOS/Common/pios_mpu6000.c index 973332fae..7820efe62 100644 --- a/flight/PiOS/Common/pios_mpu6000.c +++ b/flight/PiOS/Common/pios_mpu6000.c @@ -29,9 +29,9 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include "pios.h" -#if defined(PIOS_INCLUDE_MPU6000) + +#ifdef PIOS_INCLUDE_MPU6000 #include "fifo_buffer.h" @@ -551,7 +551,7 @@ bool PIOS_MPU6000_IRQHandler(void) return xHigherPriorityTaskWoken == pdTRUE; } -#endif +#endif /* PIOS_INCLUDE_MPU6000 */ /** * @} diff --git a/flight/PiOS/Common/pios_mpxv.c b/flight/PiOS/Common/pios_mpxv.c index ff02a0266..80e0b648d 100644 --- a/flight/PiOS/Common/pios_mpxv.c +++ b/flight/PiOS/Common/pios_mpxv.c @@ -30,10 +30,9 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include "pios.h" -#if defined(PIOS_INCLUDE_MPXV) +#ifdef PIOS_INCLUDE_MPXV #define A0 340.27f //speed of sound at standard sea level in [m/s] #define P0 101.325f //static air pressure at standard sea level in kPa diff --git a/flight/PiOS/Common/pios_ms5611.c b/flight/PiOS/Common/pios_ms5611.c index 41bf7c80e..7e4358b35 100644 --- a/flight/PiOS/Common/pios_ms5611.c +++ b/flight/PiOS/Common/pios_ms5611.c @@ -28,13 +28,14 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ +#include "pios.h" + +#ifdef PIOS_INCLUDE_MS5611 + + // TODO: Clean this up. Getting around old constant. #define PIOS_MS5611_OVERSAMPLING oversampling -#include "pios.h" - -#if defined(PIOS_INCLUDE_MS5611) /* Glocal Variables */ ConversionTypeTypeDef CurrentRead; @@ -261,7 +262,7 @@ int32_t PIOS_MS5611_Test() return 0; } -#endif +#endif /* PIOS_INCLUDE_MS5611 */ /** * @} diff --git a/flight/PiOS/Common/pios_opahrs.c b/flight/PiOS/Common/pios_opahrs.c deleted file mode 100644 index c97691aec..000000000 --- a/flight/PiOS/Common/pios_opahrs.c +++ /dev/null @@ -1,343 +0,0 @@ -/** - ****************************************************************************** - * @addtogroup PIOS PIOS Core hardware abstraction layer - * @{ - * @addtogroup PIOS_OPAHRS OPAHRS Functions - * @brief HAL code to interface to the OpenPilot AHRS module - * @{ - * - * @file pios_opahrs.c - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief Hardware commands to communicate with the AHRS - * @see The GNU Public License (GPL) Version 3 - * - *****************************************************************************/ -/* - * 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 - */ - -/* Project Includes */ -#include "pios.h" - -#if defined(PIOS_INCLUDE_OPAHRS) - -#include "pios_opahrs_proto.h" -#include "pios_opahrs.h" - -/** - * Initialise the OpenPilot AHRS - */ -void PIOS_OPAHRS_Init(void) -{ - PIOS_SPI_SetClockSpeed(PIOS_OPAHRS_SPI, PIOS_SPI_PRESCALER_8); -} - -static int32_t opahrs_msg_txrx(const uint8_t * tx, uint8_t * rx, uint32_t len) -{ - int32_t rc; - - PIOS_SPI_RC_PinSet(PIOS_OPAHRS_SPI, 0); -#ifdef PIOS_INCLUDE_FREERTOS - vTaskDelay(1 / portTICK_RATE_MS); -#else - PIOS_DELAY_WaitmS(20); -#endif - rc = PIOS_SPI_TransferBlock(PIOS_OPAHRS_SPI, tx, rx, len, NULL); - PIOS_SPI_RC_PinSet(PIOS_OPAHRS_SPI, 1); - return (rc); -} - -static enum opahrs_result opahrs_msg_v1_send_req(const struct opahrs_msg_v1 *req) -{ - int32_t rc; - struct opahrs_msg_v1 link_rx; - - for (uint8_t retries = 0; retries < 20; retries++) { - struct opahrs_msg_v1 *rsp = &link_rx; - - if ((rc = opahrs_msg_txrx((const uint8_t *)req, (uint8_t *) rsp, sizeof(*rsp))) < 0) { - return OPAHRS_RESULT_FAILED; - } - - /* Make sure we got a sane response by checking the magic */ - if ((rsp->head.magic != OPAHRS_MSG_MAGIC_HEAD) || (rsp->tail.magic != OPAHRS_MSG_MAGIC_TAIL)) { - return OPAHRS_RESULT_FAILED; - } - - switch (rsp->head.type) { - case OPAHRS_MSG_TYPE_LINK: - switch (rsp->payload.link.state) { - case OPAHRS_MSG_LINK_STATE_BUSY: - case OPAHRS_MSG_LINK_STATE_INACTIVE: - /* Wait for a small delay and retry */ -#ifdef PIOS_INCLUDE_FREERTOS - vTaskDelay(1 / portTICK_RATE_MS); -#else - PIOS_DELAY_WaitmS(20); -#endif - continue; - case OPAHRS_MSG_LINK_STATE_READY: - /* Peer was ready when we Tx'd so they have now Rx'd our message */ - return OPAHRS_RESULT_OK; - } - break; - case OPAHRS_MSG_TYPE_USER_V0: - case OPAHRS_MSG_TYPE_USER_V1: - /* Wait for a small delay and retry */ -#ifdef PIOS_INCLUDE_FREERTOS - vTaskDelay(1 / portTICK_RATE_MS); -#else - PIOS_DELAY_WaitmS(50); -#endif - continue; - } - } - - return OPAHRS_RESULT_TIMEOUT; -} - -static enum opahrs_result opahrs_msg_v1_recv_rsp(enum opahrs_msg_v1_tag tag, struct opahrs_msg_v1 *rsp) -{ - struct opahrs_msg_v1 link_tx; - - opahrs_msg_v1_init_link_tx(&link_tx, OPAHRS_MSG_LINK_TAG_NOP); - - for (uint8_t retries = 0; retries < 20; retries++) { - if (opahrs_msg_txrx((const uint8_t *)&link_tx, (uint8_t *) rsp, sizeof(*rsp)) < 0) { - return OPAHRS_RESULT_FAILED; - } - - /* Make sure we got a sane response by checking the magic */ - if ((rsp->head.magic != OPAHRS_MSG_MAGIC_HEAD) || (rsp->tail.magic != OPAHRS_MSG_MAGIC_TAIL)) { - return OPAHRS_RESULT_FAILED; - } - - switch (rsp->head.type) { - case OPAHRS_MSG_TYPE_LINK: - switch (rsp->payload.link.state) { - case OPAHRS_MSG_LINK_STATE_BUSY: - /* Wait for a small delay and retry */ -#ifdef PIOS_INCLUDE_FREERTOS - vTaskDelay(1 / portTICK_RATE_MS); -#else - PIOS_DELAY_WaitmS(20); -#endif - continue; - case OPAHRS_MSG_LINK_STATE_INACTIVE: - case OPAHRS_MSG_LINK_STATE_READY: - /* somehow, we've missed our response */ - return OPAHRS_RESULT_FAILED; - } - break; - case OPAHRS_MSG_TYPE_USER_V0: - /* This isn't the type we expected */ - return OPAHRS_RESULT_FAILED; - break; - case OPAHRS_MSG_TYPE_USER_V1: - if (rsp->payload.user.t == tag) { - return OPAHRS_RESULT_OK; - } else { - return OPAHRS_RESULT_FAILED; - } - break; - } - } - - return OPAHRS_RESULT_TIMEOUT; -} - -static enum opahrs_result PIOS_OPAHRS_v1_simple_req(enum opahrs_msg_v1_tag req_type, struct opahrs_msg_v1 *rsp, enum opahrs_msg_v1_tag rsp_type) -{ - struct opahrs_msg_v1 req; - enum opahrs_result rc; - - /* Make up an empty request */ - opahrs_msg_v1_init_user_tx(&req, req_type); - - /* Send the message until it is received */ - rc = opahrs_msg_v1_send_req(&req); - if ((rc == OPAHRS_RESULT_OK) && rsp) { - /* We need a specific kind of reply, go get it */ - return opahrs_msg_v1_recv_rsp(rsp_type, rsp); - } - - return rc; -} - -enum opahrs_result PIOS_OPAHRS_GetSerial(struct opahrs_msg_v1 *rsp) -{ - if (!rsp) - return OPAHRS_RESULT_FAILED; - - return (PIOS_OPAHRS_v1_simple_req(OPAHRS_MSG_V1_REQ_SERIAL, rsp, OPAHRS_MSG_V1_RSP_SERIAL)); -} - -enum opahrs_result PIOS_OPAHRS_resync(void) -{ - struct opahrs_msg_v1 req; - struct opahrs_msg_v1 rsp; - - enum opahrs_result rc = OPAHRS_RESULT_FAILED; - - opahrs_msg_v1_init_link_tx(&req, OPAHRS_MSG_LINK_TAG_NOP); - - PIOS_SPI_RC_PinSet(PIOS_OPAHRS_SPI, 0); -#ifdef PIOS_INCLUDE_FREERTOS - vTaskDelay(1 / portTICK_RATE_MS); -#else - PIOS_DELAY_WaitmS(20); -#endif - - for (uint32_t i = 0; i < sizeof(req); i++) { - /* Tx a shortened (by one byte) message to walk through all byte positions */ - opahrs_msg_v1_init_rx(&rsp); - PIOS_SPI_TransferBlock(PIOS_OPAHRS_SPI, (uint8_t *) & req, (uint8_t *) & rsp, sizeof(req) - 1, NULL); - - /* Good magic means we're sync'd */ - if ((rsp.head.magic == OPAHRS_MSG_MAGIC_HEAD) && (rsp.tail.magic == OPAHRS_MSG_MAGIC_TAIL)) { - /* We need to shift out one more byte to compensate for the short tx */ - PIOS_SPI_TransferByte(PIOS_OPAHRS_SPI, 0x00); - rc = OPAHRS_RESULT_OK; - break; - } -#ifdef PIOS_INCLUDE_FREERTOS - vTaskDelay(1 / portTICK_RATE_MS); -#else - PIOS_DELAY_WaitmS(10); -#endif - } - - PIOS_SPI_RC_PinSet(PIOS_OPAHRS_SPI, 1); - //vTaskDelay(5 / portTICK_RATE_MS); - - return rc; -} - -enum opahrs_result PIOS_OPAHRS_GetAttitudeRaw(struct opahrs_msg_v1 *rsp) -{ - if (!rsp) - return OPAHRS_RESULT_FAILED; - - return (PIOS_OPAHRS_v1_simple_req(OPAHRS_MSG_V1_REQ_ATTITUDERAW, rsp, OPAHRS_MSG_V1_RSP_ATTITUDERAW)); -} - -extern enum opahrs_result PIOS_OPAHRS_SetAlgorithm(struct opahrs_msg_v1 *req) -{ - struct opahrs_msg_v1 rsp; - enum opahrs_result rc; - - if (!req) - return OPAHRS_RESULT_FAILED; - - /* Make up an attituderaw request */ - opahrs_msg_v1_init_user_tx(req, OPAHRS_MSG_V1_REQ_ALGORITHM); - - /* Send the message until it is received */ - rc = opahrs_msg_v1_send_req(req); - if (rc != OPAHRS_RESULT_OK) { - /* Failed to send the request, bail out */ - return rc; - } - - return opahrs_msg_v1_recv_rsp(OPAHRS_MSG_V1_RSP_ALGORITHM, &rsp); -} - -enum opahrs_result PIOS_OPAHRS_SetMagNorth(struct opahrs_msg_v1 *req) -{ - struct opahrs_msg_v1 rsp; - enum opahrs_result rc; - - if (!req) - return OPAHRS_RESULT_FAILED; - - /* Make up an attituderaw request */ - opahrs_msg_v1_init_user_tx(req, OPAHRS_MSG_V1_REQ_NORTH); - - /* Send the message until it is received */ - rc = opahrs_msg_v1_send_req(req); - if (rc != OPAHRS_RESULT_OK) { - /* Failed to send the request, bail out */ - return rc; - } - - return opahrs_msg_v1_recv_rsp(OPAHRS_MSG_V1_RSP_NORTH, &rsp); -} - -enum opahrs_result PIOS_OPAHRS_SetGetUpdate(struct opahrs_msg_v1 *req, struct opahrs_msg_v1 *rsp) -{ - enum opahrs_result rc; - - if (!req) - return OPAHRS_RESULT_FAILED; - - /* Make up an attituderaw request */ - opahrs_msg_v1_init_user_tx(req, OPAHRS_MSG_V1_REQ_UPDATE); - - /* Send the message until it is received */ - rc = opahrs_msg_v1_send_req(req); - if (rc != OPAHRS_RESULT_OK) { - /* Failed to send the request, bail out */ - return rc; - } - - return opahrs_msg_v1_recv_rsp(OPAHRS_MSG_V1_RSP_UPDATE, rsp); -} - -enum opahrs_result PIOS_OPAHRS_SetGetCalibration(struct opahrs_msg_v1 *req, struct opahrs_msg_v1 *rsp) -{ - enum opahrs_result rc; - - if (!req) - return OPAHRS_RESULT_FAILED; - - /* Make up an attituderaw request */ - opahrs_msg_v1_init_user_tx(req, OPAHRS_MSG_V1_REQ_CALIBRATION); - - /* Send the message until it is received */ - rc = opahrs_msg_v1_send_req(req); - if (rc != OPAHRS_RESULT_OK) { - /* Failed to send the request, bail out */ - return rc; - } - - return opahrs_msg_v1_recv_rsp(OPAHRS_MSG_V1_RSP_CALIBRATION, rsp); -} - -enum opahrs_result PIOS_OPAHRS_SetGetInitialized(struct opahrs_msg_v1 *req, struct opahrs_msg_v1 *rsp) -{ - enum opahrs_result rc; - - if (!req) - return OPAHRS_RESULT_FAILED; - - /* Make up an attituderaw request */ - opahrs_msg_v1_init_user_tx(req, OPAHRS_MSG_V1_REQ_INITIALIZED); - - /* Send the message until it is received */ - rc = opahrs_msg_v1_send_req(req); - if (rc != OPAHRS_RESULT_OK) { - /* Failed to send the request, bail out */ - return rc; - } - - return opahrs_msg_v1_recv_rsp(OPAHRS_MSG_V1_RSP_INITIALIZED, rsp); -} - -#endif /* PIOS_INCLUDE_OPAHRS */ - -/** - * @} - * @} - */ diff --git a/flight/PiOS/Common/pios_opahrs_proto.c b/flight/PiOS/Common/pios_opahrs_proto.c deleted file mode 100644 index b4c7f822c..000000000 --- a/flight/PiOS/Common/pios_opahrs_proto.c +++ /dev/null @@ -1,76 +0,0 @@ -/** - * @addtogroup PIOS PIOS Core hardware abstraction layer - * @{ - * @addtogroup PIOS_OPAHRS OPAHRS Functions - * @{ - * - * @file pios_opahrs_proto.c - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief PPM Input functions - * @see The GNU Public License (GPL) Version 3 - * - */ - -#include "pios_opahrs_proto.h" -#include /* memset */ - -void opahrs_msg_v0_init_rx(struct opahrs_msg_v0 *msg) -{ - /* Make sure we start with bad magic in the rx buffer */ - msg->head.magic = 0; - msg->head.type = 0; - msg->tail.magic = 0; -} - -void opahrs_msg_v0_init_user_tx(struct opahrs_msg_v0 *msg, enum opahrs_msg_v0_tag tag) -{ - msg->head.magic = OPAHRS_MSG_MAGIC_HEAD; - msg->head.type = OPAHRS_MSG_TYPE_USER_V0; - - msg->payload.user.t = tag; - - msg->tail.magic = OPAHRS_MSG_MAGIC_TAIL; -} - -void opahrs_msg_v0_init_link_tx(struct opahrs_msg_v0 *msg, enum opahrs_msg_link_tag tag) -{ - msg->head.magic = OPAHRS_MSG_MAGIC_HEAD; - msg->head.type = OPAHRS_MSG_TYPE_LINK; - - msg->payload.link.t = tag; - - msg->tail.magic = OPAHRS_MSG_MAGIC_TAIL; -} - -void opahrs_msg_v1_init_rx(struct opahrs_msg_v1 *msg) -{ - /* Make sure we start with bad magic in the rx buffer */ - msg->head.magic = 0; - msg->head.type = 0; - msg->tail.magic = 0; -} - -void opahrs_msg_v1_init_user_tx(struct opahrs_msg_v1 *msg, enum opahrs_msg_v1_tag tag) -{ - msg->head.magic = OPAHRS_MSG_MAGIC_HEAD; - msg->head.type = OPAHRS_MSG_TYPE_USER_V1; - - msg->payload.user.t = tag; - - msg->tail.magic = OPAHRS_MSG_MAGIC_TAIL; -} - -void opahrs_msg_v1_init_link_tx(struct opahrs_msg_v1 *msg, enum opahrs_msg_link_tag tag) -{ - msg->head.magic = OPAHRS_MSG_MAGIC_HEAD; - msg->head.type = OPAHRS_MSG_TYPE_LINK; - - msg->payload.link.t = tag; - - msg->tail.magic = OPAHRS_MSG_MAGIC_TAIL; -} - -/** - * @} - * @} - */ diff --git a/flight/PiOS/Common/pios_opahrs_v0.c b/flight/PiOS/Common/pios_opahrs_v0.c deleted file mode 100644 index 3dbc71a1d..000000000 --- a/flight/PiOS/Common/pios_opahrs_v0.c +++ /dev/null @@ -1,330 +0,0 @@ -/** - ****************************************************************************** - * @addtogroup PIOS PIOS Core hardware abstraction layer - * @{ - * @addtogroup PIOS_OPAHRS OPAHRS Functions - * @brief HAL code to interface to the OpenPilot AHRS module's bootloader - * @{ - * - * @file pios_opahrs_download.c - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief Hardware commands to communicate with the AHRS bootloader - * @see The GNU Public License (GPL) Version 3 - * - *****************************************************************************/ -/* - * 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 - */ - -/* Project Includes */ -#include "pios.h" - -#if defined(PIOS_INCLUDE_OPAHRS) - -#include "pios_opahrs_proto.h" -#include "pios_opahrs.h" - -static uint32_t PIOS_OPAHRS_SPI; - -void PIOS_OPAHRS_Attach(uint32_t spi_id) -{ - PIOS_OPAHRS_SPI = spi_id; -} - -void PIOS_OPAHRS_ForceSlaveSelected(bool selected) -{ - if (selected) { - PIOS_SPI_RC_PinSet(PIOS_OPAHRS_SPI, 0); - } else { - PIOS_SPI_RC_PinSet(PIOS_OPAHRS_SPI, 1); - } -} - -static int32_t opahrs_msg_txrx(const uint8_t * tx, uint8_t * rx, uint32_t len) -{ - int32_t rc; - - PIOS_SPI_RC_PinSet(PIOS_OPAHRS_SPI, 0); -#ifdef PIOS_INCLUDE_FREERTOS - vTaskDelay(20 / portTICK_RATE_MS); -#else - PIOS_DELAY_WaitmS(1); -#endif - rc = PIOS_SPI_TransferBlock(PIOS_OPAHRS_SPI, tx, rx, len, NULL); - PIOS_SPI_RC_PinSet(PIOS_OPAHRS_SPI, 1); - return (rc); -} - -static enum opahrs_result opahrs_msg_v0_send_req(const struct opahrs_msg_v0 *req) -{ - int32_t rc; - struct opahrs_msg_v0 link_rx; - - for (uint8_t retries = 0; retries < 20; retries++) { - struct opahrs_msg_v0 *rsp = &link_rx; - - if ((rc = opahrs_msg_txrx((const uint8_t *)req, (uint8_t *) rsp, sizeof(*rsp))) < 0) { - return OPAHRS_RESULT_FAILED; - } - - /* Make sure we got a sane response by checking the magic */ - if ((rsp->head.magic != OPAHRS_MSG_MAGIC_HEAD) || (rsp->tail.magic != OPAHRS_MSG_MAGIC_TAIL)) { - return OPAHRS_RESULT_FAILED; - } - - switch (rsp->head.type) { - case OPAHRS_MSG_TYPE_LINK: - switch (rsp->payload.link.state) { - case OPAHRS_MSG_LINK_STATE_BUSY: - case OPAHRS_MSG_LINK_STATE_INACTIVE: - /* Wait for a small delay and retry */ -#ifdef PIOS_INCLUDE_FREERTOS - vTaskDelay(20 / portTICK_RATE_MS); -#else - //PIOS_DELAY_WaitmS(1); -#endif - continue; - case OPAHRS_MSG_LINK_STATE_READY: - /* Peer was ready when we Tx'd so they have now Rx'd our message */ - return OPAHRS_RESULT_OK; - } - break; - case OPAHRS_MSG_TYPE_USER_V0: - case OPAHRS_MSG_TYPE_USER_V1: - /* Wait for a small delay and retry */ -#ifdef PIOS_INCLUDE_FREERTOS - vTaskDelay(50 / portTICK_RATE_MS); -#else - //PIOS_DELAY_WaitmS(1); -#endif - continue; - } - } - - return OPAHRS_RESULT_TIMEOUT; -} - -static enum opahrs_result opahrs_msg_v0_recv_rsp(enum opahrs_msg_v0_tag tag, struct opahrs_msg_v0 *rsp) -{ - struct opahrs_msg_v0 link_tx; - - opahrs_msg_v0_init_link_tx(&link_tx, OPAHRS_MSG_LINK_TAG_NOP); - - for (uint8_t retries = 0; retries < 20; retries++) { - if (opahrs_msg_txrx((const uint8_t *)&link_tx, (uint8_t *) rsp, sizeof(*rsp)) < 0) { - return OPAHRS_RESULT_FAILED; - } - - /* Make sure we got a sane response by checking the magic */ - if ((rsp->head.magic != OPAHRS_MSG_MAGIC_HEAD) || (rsp->tail.magic != OPAHRS_MSG_MAGIC_TAIL)) { - return OPAHRS_RESULT_FAILED; - } - - switch (rsp->head.type) { - case OPAHRS_MSG_TYPE_LINK: - switch (rsp->payload.link.state) { - case OPAHRS_MSG_LINK_STATE_BUSY: - /* Wait for a small delay and retry */ -#ifdef PIOS_INCLUDE_FREERTOS - vTaskDelay(20 / portTICK_RATE_MS); -#else - PIOS_DELAY_WaitmS(1); -#endif - continue; - case OPAHRS_MSG_LINK_STATE_INACTIVE: - case OPAHRS_MSG_LINK_STATE_READY: - /* somehow, we've missed our response */ - return OPAHRS_RESULT_FAILED; - } - break; - case OPAHRS_MSG_TYPE_USER_V0: - if (rsp->payload.user.t == tag) { - return OPAHRS_RESULT_OK; - } else { - return OPAHRS_RESULT_FAILED; - } - break; - case OPAHRS_MSG_TYPE_USER_V1: - /* This isn't the type we expected */ - return OPAHRS_RESULT_FAILED; - break; - } - } - - return OPAHRS_RESULT_TIMEOUT; -} - -static enum opahrs_result PIOS_OPAHRS_v0_simple_req(enum opahrs_msg_v0_tag req_type, struct opahrs_msg_v0 *rsp, enum opahrs_msg_v0_tag rsp_type) -{ - struct opahrs_msg_v0 req; - enum opahrs_result rc; - - /* Make up an empty request */ - opahrs_msg_v0_init_user_tx(&req, req_type); - - /* Send the message until it is received */ - - rc = opahrs_msg_v0_send_req(&req); - if ((rc == OPAHRS_RESULT_OK) && rsp) { - /* We need a specific kind of reply, go get it */ - return opahrs_msg_v0_recv_rsp(rsp_type, rsp); - } - - return rc; -} - -enum opahrs_result PIOS_OPAHRS_bl_GetVersions(struct opahrs_msg_v0 *rsp) -{ - if (!rsp) - return OPAHRS_RESULT_FAILED; - - return (PIOS_OPAHRS_v0_simple_req(OPAHRS_MSG_V0_REQ_VERSIONS, rsp, OPAHRS_MSG_V0_RSP_VERSIONS)); -} - -enum opahrs_result PIOS_OPAHRS_bl_GetMemMap(struct opahrs_msg_v0 *rsp) -{ - if (!rsp) - return OPAHRS_RESULT_FAILED; - - return (PIOS_OPAHRS_v0_simple_req(OPAHRS_MSG_V0_REQ_MEM_MAP, rsp, OPAHRS_MSG_V0_RSP_MEM_MAP)); -} - -enum opahrs_result PIOS_OPAHRS_bl_GetSerial(struct opahrs_msg_v0 *rsp) -{ - if (!rsp) - return OPAHRS_RESULT_FAILED; - - return (PIOS_OPAHRS_v0_simple_req(OPAHRS_MSG_V0_REQ_SERIAL, rsp, OPAHRS_MSG_V0_RSP_SERIAL)); -} - -enum opahrs_result PIOS_OPAHRS_bl_FwupStart(struct opahrs_msg_v0 *rsp) -{ - if (!rsp) - return OPAHRS_RESULT_FAILED; - return (PIOS_OPAHRS_v0_simple_req(OPAHRS_MSG_V0_REQ_FWUP_START, rsp, OPAHRS_MSG_V0_RSP_FWUP_STATUS)); -} - -enum opahrs_result PIOS_OPAHRS_bl_FwupStatus(struct opahrs_msg_v0 *rsp) -{ - if (!rsp) - return OPAHRS_RESULT_FAILED; - return (PIOS_OPAHRS_v0_simple_req(OPAHRS_MSG_V0_REQ_FWUP_STATUS, rsp, OPAHRS_MSG_V0_RSP_FWUP_STATUS)); -} - -enum opahrs_result PIOS_OPAHRS_bl_FwupData(struct opahrs_msg_v0 *req, struct opahrs_msg_v0 *rsp) -{ - if (!req || !rsp) - return OPAHRS_RESULT_FAILED; - - /* Make up an attituderaw request */ - opahrs_msg_v0_init_user_tx(req, OPAHRS_MSG_V0_REQ_FWUP_DATA); - enum opahrs_result rc; - /* Send the message until it is received */ - rc = opahrs_msg_v0_send_req(req); - if (rc != OPAHRS_RESULT_OK) { - /* Failed to send the request, bail out */ - return rc; - } - - return opahrs_msg_v0_recv_rsp(OPAHRS_MSG_V0_RSP_FWUP_STATUS, rsp); -} - -enum opahrs_result PIOS_OPAHRS_bl_FwDlData(struct opahrs_msg_v0 *req, struct opahrs_msg_v0 *rsp) -{ - if (!req || !rsp) - return OPAHRS_RESULT_FAILED; - - /* Make up an attituderaw request */ - opahrs_msg_v0_init_user_tx(req, OPAHRS_MSG_V0_REQ_FWDN_DATA); - enum opahrs_result rc; - /* Send the message until it is received */ - rc = opahrs_msg_v0_send_req(req); - if (rc != OPAHRS_RESULT_OK) { - /* Failed to send the request, bail out */ - return rc; - } - - return opahrs_msg_v0_recv_rsp(OPAHRS_MSG_V0_RSP_FWDN_DATA, rsp); -} - -enum opahrs_result PIOS_OPAHRS_bl_FwupVerify(struct opahrs_msg_v0 *rsp) -{ - if (!rsp) - return OPAHRS_RESULT_FAILED; - - return (PIOS_OPAHRS_v0_simple_req(OPAHRS_MSG_V0_REQ_FWUP_VERIFY, rsp, OPAHRS_MSG_V0_RSP_FWUP_STATUS)); -} - -enum opahrs_result PIOS_OPAHRS_bl_resync(void) -{ - struct opahrs_msg_v0 req; - struct opahrs_msg_v0 rsp; - - enum opahrs_result rc = OPAHRS_RESULT_FAILED; - - opahrs_msg_v0_init_link_tx(&req, OPAHRS_MSG_LINK_TAG_NOP); - - PIOS_SPI_RC_PinSet(PIOS_OPAHRS_SPI, 0); -#ifdef PIOS_INCLUDE_FREERTOS - vTaskDelay(20 / portTICK_RATE_MS); -#else - //PIOS_DELAY_WaitmS(1); -#endif - - for (uint32_t i = 0; i < sizeof(req); i++) { - /* Tx a shortened (by one byte) message to walk through all byte positions */ - opahrs_msg_v0_init_rx(&rsp); - PIOS_SPI_TransferBlock(PIOS_OPAHRS_SPI, (uint8_t *) & req, (uint8_t *) & rsp, sizeof(req) - 1, NULL); - - /* Good magic means we're sync'd */ - if ((rsp.head.magic == OPAHRS_MSG_MAGIC_HEAD) && (rsp.tail.magic == OPAHRS_MSG_MAGIC_TAIL)) { - /* We need to shift out one more byte to compensate for the short tx */ - PIOS_SPI_TransferByte(PIOS_OPAHRS_SPI, 0x00); - rc = OPAHRS_RESULT_OK; - break; - } -#ifdef PIOS_INCLUDE_FREERTOS - vTaskDelay(10 / portTICK_RATE_MS); -#else - PIOS_DELAY_WaitmS(1); -#endif - } - - PIOS_SPI_RC_PinSet(PIOS_OPAHRS_SPI, 1); - //vTaskDelay(5 / portTICK_RATE_MS); - - return rc; -} - -enum opahrs_result PIOS_OPAHRS_bl_reset(uint32_t delay) -{ - struct opahrs_msg_v0 req; - /* Make up an attituderaw request */ - opahrs_msg_v0_init_user_tx(&req, OPAHRS_MSG_V0_REQ_RESET); - req.payload.user.v.req.reset.reset_delay_in_ms = delay; - /* Send the message until it is received */ - return opahrs_msg_v0_send_req(&req); -} - -enum opahrs_result PIOS_OPAHRS_bl_boot(uint32_t delay) -{ - struct opahrs_msg_v0 req; - /* Make up an attituderaw request */ - opahrs_msg_v0_init_user_tx(&req, OPAHRS_MSG_V0_REQ_BOOT); - req.payload.user.v.req.boot.boot_delay_in_ms = delay; - /* Send the message until it is received */ - return opahrs_msg_v0_send_req(&req); -} -#endif /* PIOS_INCLUDE_OPAHRS */ diff --git a/flight/PiOS/Common/pios_rcvr.c b/flight/PiOS/Common/pios_rcvr.c index 0f3988d7f..4533d874b 100644 --- a/flight/PiOS/Common/pios_rcvr.c +++ b/flight/PiOS/Common/pios_rcvr.c @@ -1,7 +1,6 @@ -/* Project Includes */ #include "pios.h" -#if defined(PIOS_INCLUDE_RCVR) +#ifdef PIOS_INCLUDE_RCVR #include @@ -108,7 +107,7 @@ int32_t PIOS_RCVR_Read(uint32_t rcvr_id, uint8_t channel) return rcvr_dev->driver->read(rcvr_dev->lower_id, channel); } -#endif +#endif /* PIOS_INCLUDE_RCVR */ /** * @} diff --git a/flight/PiOS/Common/pios_rfm22b.c b/flight/PiOS/Common/pios_rfm22b.c index 306e96062..20eecc112 100644 --- a/flight/PiOS/Common/pios_rfm22b.c +++ b/flight/PiOS/Common/pios_rfm22b.c @@ -46,10 +46,9 @@ // // ***************************************************************** -/* Project Includes */ #include "pios.h" -#if defined(PIOS_INCLUDE_RFM22B) +#ifdef PIOS_INCLUDE_RFM22B #include #include @@ -2455,7 +2454,7 @@ static enum pios_rfm22b_event rfm22_fatal_error(struct pios_rfm22b_dev *rfm22b_d // ************************************ -#endif +#endif /* PIOS_INCLUDE_RFM22B */ /** * @} diff --git a/flight/PiOS/Common/pios_rfm22b_com.c b/flight/PiOS/Common/pios_rfm22b_com.c index e8fb4a6db..868671653 100644 --- a/flight/PiOS/Common/pios_rfm22b_com.c +++ b/flight/PiOS/Common/pios_rfm22b_com.c @@ -28,9 +28,10 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include +#ifdef PIOS_INCLUDE_RFM22B_COM + #include /* Provide a COM driver */ @@ -128,3 +129,5 @@ static bool PIOS_RFM22B_COM_Available(uint32_t rfm22b_id) { return PIOS_RFM22B_LinkStatus(rfm22b_id); } + +#endif /* PIOS_INCLUDE_RFM22B_COM */ diff --git a/flight/PiOS/Common/pios_rfm22b_rcvr.c b/flight/PiOS/Common/pios_rfm22b_rcvr.c index 0878da0f1..889615cb4 100644 --- a/flight/PiOS/Common/pios_rfm22b_rcvr.c +++ b/flight/PiOS/Common/pios_rfm22b_rcvr.c @@ -28,10 +28,9 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include "pios.h" -#if defined(PIOS_INCLUDE_RFM22B_RCVR) +#ifdef PIOS_INCLUDE_RFM22B_RCVR #include "pios_rfm22b_priv.h" @@ -91,7 +90,7 @@ static void PIOS_RFM22B_RCVR_Supervisor(uint32_t rcvr_id) { rfm22b_dev->ppm_fresh = false; } -#endif /* PIOS_INCLUDE_GCSRCVR */ +#endif /* PIOS_INCLUDE_RFM22B_RCVR */ /** * @} diff --git a/flight/PiOS/Common/pios_sbus.c b/flight/PiOS/Common/pios_sbus.c index 53730b16b..ec8daab62 100644 --- a/flight/PiOS/Common/pios_sbus.c +++ b/flight/PiOS/Common/pios_sbus.c @@ -28,11 +28,11 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include "pios.h" -#include "pios_sbus_priv.h" -#if defined(PIOS_INCLUDE_SBUS) +#ifdef PIOS_INCLUDE_SBUS + +#include "pios_sbus_priv.h" /* Forward Declarations */ static int32_t PIOS_SBus_Get(uint32_t rcvr_id, uint8_t channel); @@ -332,7 +332,7 @@ static void PIOS_SBus_Supervisor(uint32_t sbus_id) } } -#endif /* PIOS_INCLUDE_SBUS */ +#endif /* PIOS_INCLUDE_SBUS */ /** * @} diff --git a/flight/PiOS/Common/pios_sdcard.c b/flight/PiOS/Common/pios_sdcard.c index c404fa718..1ae2ea50e 100644 --- a/flight/PiOS/Common/pios_sdcard.c +++ b/flight/PiOS/Common/pios_sdcard.c @@ -29,10 +29,9 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include "pios.h" -#if defined(PIOS_INCLUDE_SDCARD) +#ifdef PIOS_INCLUDE_SDCARD /* Global Variables */ VOLINFO PIOS_SDCARD_VolInfo; @@ -1000,7 +999,7 @@ int32_t PIOS_SDCARD_FileDelete(char *Filename) return 0; } -#endif +#endif /* PIOS_INCLUDE_SDCARD */ /** * @} diff --git a/flight/PiOS/Common/pios_usb_desc_hid_cdc.c b/flight/PiOS/Common/pios_usb_desc_hid_cdc.c index 747eda3d4..e102aefe3 100644 --- a/flight/PiOS/Common/pios_usb_desc_hid_cdc.c +++ b/flight/PiOS/Common/pios_usb_desc_hid_cdc.c @@ -28,6 +28,10 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "pios.h" + +#ifdef PIOS_INCLUDE_USB + #include "pios_usb_desc_hid_cdc_priv.h" /* exported API */ #include "pios_usb_defs.h" /* struct usb_*, USB_* */ #include "pios_usb_board_data.h" /* PIOS_USB_BOARD_* */ @@ -324,3 +328,5 @@ int32_t PIOS_USB_DESC_HID_CDC_Init(void) return 0; } + +#endif /* PIOS_INCLUDE_USB */ diff --git a/flight/PiOS/Common/pios_usb_desc_hid_only.c b/flight/PiOS/Common/pios_usb_desc_hid_only.c index b15a02b32..0757d0937 100644 --- a/flight/PiOS/Common/pios_usb_desc_hid_only.c +++ b/flight/PiOS/Common/pios_usb_desc_hid_only.c @@ -28,6 +28,10 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "pios.h" + +#ifdef PIOS_INCLUDE_USB + #include "pios_usb_desc_hid_only_priv.h" /* exported API */ #include "pios_usb_defs.h" /* struct usb_*, USB_* */ #include "pios_usb_board_data.h" /* PIOS_USB_BOARD_* */ @@ -163,3 +167,5 @@ int32_t PIOS_USB_DESC_HID_ONLY_Init(void) return 0; } + +#endif /* PIOS_INCLUDE_USB */ diff --git a/flight/PiOS/Common/pios_usb_util.c b/flight/PiOS/Common/pios_usb_util.c index 4bbf98d23..9f7c8c94e 100644 --- a/flight/PiOS/Common/pios_usb_util.c +++ b/flight/PiOS/Common/pios_usb_util.c @@ -28,6 +28,10 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "pios.h" + +#ifdef PIOS_INCLUDE_USB + #include "pios_usb_util.h" uint8_t * PIOS_USB_UTIL_AsciiToUtf8(uint8_t * dst, uint8_t * src, uint16_t srclen) @@ -40,3 +44,5 @@ uint8_t * PIOS_USB_UTIL_AsciiToUtf8(uint8_t * dst, uint8_t * src, uint16_t srcle return dst; } + +#endif /* PIOS_INCLUDE_USB */ diff --git a/flight/PiOS/Common/pios_video.c b/flight/PiOS/Common/pios_video.c index 22e6060ce..5d7452f9d 100644 --- a/flight/PiOS/Common/pios_video.c +++ b/flight/PiOS/Common/pios_video.c @@ -30,7 +30,8 @@ */ #include "pios.h" -#if defined(PIOS_INCLUDE_VIDEO) + +#ifdef PIOS_INCLUDE_VIDEO extern xSemaphoreHandle osdSemaphore; @@ -277,7 +278,4 @@ void PIOS_VIDEO_DMA_Handler(void) } - -#endif - - +#endif /* PIOS_INCLUDE_VIDEO */ diff --git a/flight/PiOS/Common/pios_wavplay.c b/flight/PiOS/Common/pios_wavplay.c index cc0335c07..d2b82d65a 100644 --- a/flight/PiOS/Common/pios_wavplay.c +++ b/flight/PiOS/Common/pios_wavplay.c @@ -30,7 +30,8 @@ */ #include "pios.h" -#if defined(PIOS_INCLUDE_WAVE) + +#ifdef PIOS_INCLUDE_WAVE static const struct pios_dac_cfg * dev_cfg; @@ -606,7 +607,4 @@ void DAC_DMA_Handler(void) } } - -#endif - - +#endif /* PIOS_INCLUDE_WAVE */ diff --git a/flight/PiOS/STM32F10x/Libraries/dosfs/README.txt b/flight/PiOS/STM32F10x/Libraries/dosfs/README.txt deleted file mode 100644 index 0c08b3cde..000000000 --- a/flight/PiOS/STM32F10x/Libraries/dosfs/README.txt +++ /dev/null @@ -1,368 +0,0 @@ -README.TXT (C) Copyright 2006 -DOSFS Level 1 Version 1.02 Lewin A.R.W. Edwards (sysadm@zws.com) -===================================================================== - -Abstract -======== -DOSFS is a FAT-compatible filesystem intended for fairly low-end -embedded applications. It is not the leanest possible implementation -(the leanest FAT implementations operate in << 512 bytes of RAM, with -heavy restrictions). This code strikes a good balance between size -and functionality, with an emphasis on RAM footprint. - -Intended target systems would be in the ballpark of 1K RAM, 4K ROM -or more. - -Features: -* Supports FAT12, FAT16 and FAT32 volumes -* Supports storage devices up to 2048Gbytes in size (LBA32) -* Supports devices with or without MBRs (hard disks vs. floppy disks - or ZIP drives formatted as "big floppies") -* Supports multiple partitions on disks with MBRs -* Supports subdirectories -* Can be operated with a single global 512-byte sector buffer -* Fully reentrant code (assuming the underlying physical device driver - is reentrant and global sector buffers are not used). There are no - global variables in the filesystem -* Does not perform any memory allocation -* Partial support for random-access files - -Applications: -* Firmware upgrades -* Failsafe IPL -* Media playback -* Data logging -* Configuration storage - -There is no technical support for this free product; however, if you -have questions or suggestions, you are encouraged to email Lewin -Edwards at sysadm@zws.com. If you need custom additions to the code, -or if you have other projects for which you need engineering -assistance, please feel free to email or call (646) 549-3715. - -License -======= -The license for DOSFS is very simple but verbose to state. - -1. DOSFS is (C) Copyright 2006 by Lewin A.R.W. Edwards ("Author"). - All rights not explicitly granted herein are reserved. The DOSFS - code is the permanent property of the Author and no transfer of - ownership is implied by this license. - -2. DOSFS is an educational project, provided as-is. No guarantee of - performance or suitability for any application is stated or - implied. You use this product entirely at your own risk. Use of - this product in any manner automatically waives any right to seek - compensation or damages of any sort from the Author. Since the - products you might make are entirely out of the Author's control, - use of this product also constitutes an agreement by you to take - full responsibility for and indemnify the Author against any - action for any loss or damage (including economic loss of any - type, and specifically including patent litigation) that arises - from a product made by you that incorporates any portion of - the DOSFS code. - -3. If you live under the jurisdiction of any legislation that would - prohibit or limit any condition in this license, you cannot be - licensed to use this product. - -4. If you do not fall into the excluded category in point 3, you are - hereby licensed to use the DOSFS code in any application that you - see fit. You are not required to pay any fee or notify the Author - that you are using DOSFS. Any modifications made by you to the - DOSFS code are your property and you may distribute the modified - version in any manner that you wish. You are not required to - disclose sourcecode to such modifications, either to the Author or - to any third party. Any such disclosure made to the Author will - irrevocably become the property of the Author in the absence of a - formal agreement to the contrary, established prior to such - disclosure being made. - -To summarize the intent of the above: DOSFS is free. You can do what -you want with it. Anything that happens as a result is entirely your -responsibility. You can't take ownership of my code and stop me from -doing whatever I want with it. If you do something nifty with DOSFS -and send me the sourcecode, I may include your changes in the next -distribution and it will be released to the world as free software. -If someone sues you because your DOSFS-containing product causes -any sort of legal, financial or other problem, it's your lawsuit, -not mine, and you'll exclude me from the proceedings. - -User-Supplied Functions -======================= -You must provide functions to read sectors into memory and write -them back to the target media. The demo suite includes an emulation -module that reads/writes a disk image file (#define HOSTVER pulls -in hostemu.h which wraps the prototypes for these functions). -There are various tools for UNIX, DOS, Windows et al, to create -images from storage media; my preferred utility is dd. - -The functions you must supply in your embedded app are: - -DFS_ReadSector(unit,buffer,sector,count) -DFS_WriteSector(unit,buffer,sector,count) - -These two functions read and write, respectively, "count" sectors of -size SECTOR_SIZE (512 bytes; see below) from/to physical sector -#"sector" of device "unit", to/from the scratch buffer "buffer". They -should return 0 for success or nonzero for failure. In the current -implementation of DOSFS, count will always be 1. - -The "unit" argument is designed to permit implementation of multiple -storage devices, for example multiple media slots on a single device, -or to differentiate between master and slave devices on an ATAPI bus. - -This code is designed for 512-byte sectors. Although the sector size -is a #define, you should not tinker with it because the vast majority -of FAT filesystems use 512-byte sectors, and the DOSFS code doesn't -support runtime determination of sector size. This will not affect the -vast majority of users. - -Example Code -============ -Refer to the tests in main.c to see how to call DOSFS functions. -(These tests are all commented out). Note that the only two files -you need to add to your project are dosfs.c and dosfs.h. - - -Mounting Volumes -================ ---If the device has a partition table (practically all removable flash - media are formatted this way), call DFS_GetPtnStart to get the - starting sector# of the desired partition. You can optionally also - retrieve the active state, partition type byte and partition size - in this step. The reason this step is broken out separately is so - you can support devices that are formatted like a floppy disk, i.e. - the volume starts directly at physical sector 0 of the media. - ---Call DFS_GetVolInfo to read filesystem info into a VOLINFO structure. - DFS_GetVolInfo needs to know the unit number and partition starting - sector (as returned by DFS_GetPtnStart, or 0 if this is a "floppy- - format" volume without an MBR). - -From this point on, the VOLINFO structure is all you'll need - you can -forget the unit and partition start sector numbers. - -Enumerating Directory Contents -============================== ---Call DFS_Opendir and supply a path, populated VOLINFO and a - DIRINFO structure to receive the results. Note - you must PREPOPULATE - the DIRINFO.scratch field with a pointer to a sector scratch buffer. - This buffer must remain unmolested while you have the directory open - for searching. ---Call DFS_GetNext to receive the DIRENT contents for the next directory - item. This function returns DFS_OK for no error, and DFS_EOF if there - are no more entries in the directory being searched. - Before using the DIRENT, check the first character of the name. If it - is NULL, then this is an unusable entry - call DFS_GetNext again to - keep searching. LFN directory entries are automatically tagged this way - so your application will not be pestered by them. - - Note: A designed side-effect of this code is that when you locate the - file of interest, the DIRINFO.currentcluster, DIRINFO.currentsector - and DIRINFO.currententry-1 fields will identify the directory entry of - interest. - -Reading a File -============== ---Call DFS_OpenFile with mode = DFS_READ and supply a path and the relevant - VOLINFO structure. DFS_OpenFile will populate a FILEINFO that can be used - to refer to the file. ---Optionally call DFS_Seek to set the file pointer. If you attempt to set - the file pointer past the end of file, the file will NOT be extended. Check - the FILEINFO.pointer value after DFS_Seek to verify that the pointer is - where you expect it to be. ---Observe that functionality similar to the "whence" parameter of fseek() can - be obtained by using simple arithmetic on the FILEINFO.pointer and - FILEINFO.filelen members. ---Call DFS_ReadFile with the FILEINFO you obtained from OpenFile, and a - pointer to a buffer plus the desired number of bytes to read, and a - pointer to a sector-sized scratch buffer. The reason a scratch sector is - required is because the underlying sector read function doesn't know - about partial reads. ---Note that a file opened for reading cannot be written. If you need r/w - access, open with mode = DFS_WRITE (see below). - -Writing a file -============== ---Call DFS_OpenFile with mode = DFS_WRITE and supply a path and the relevant - VOLINFO structure. DFS_OpenFile will populate a FILEINFO that can be used to - refer to the file. ---Optionally call DFS_Seek to set the file pointer. Refer to the notes on - this topic in the section on reading files, above. ---Call DFS_WriteFile with the FILEINFO you obtained from OpenFile, and a - pointer to the source buffer, and a pointer to a sector-sized scratch - buffer. ---Note that a file open for writing can also be read. ---Files are created automatically if they do not exist. Subdirectories are - NOT automatically created. ---If you open an existing file for writing, the file pointer will start at - the beginning of the data; if you want to append, seek to the end before - writing new data. ---If you perform random-access writes to a file, the length will NOT change - unless you exceed the file's original length. There is currently no - function to truncate a file at the current pointer position. ---On-disk consistency is guaranteed when DFS_WriteFile exits, unless your - physical layer has a writeback cache in it. - -Deleting a file -=============== ---Call DFS_UnlinkFile ---WARNING: This call will delete a subdirectory (correctly) but will NOT - first recurse the directory to delete the contents - so you will end up - with lost clusters. - -Notes -===== -Some platforms may require explicit pragmas or attributes to the structures -and unions. For example, arm-gcc will require __attribute__ ((__packed__)) -otherwise it will try to be "smart" and place the uint8_t members on 4-byte -boundaries. There is no truly elegant compiler-independent method to get -around this sort of problem. - -The code assumes either a von Neumann architecture, or a compiler that -is smart enough to understand where your pointers are aimed and emit -the right kind of memory read and write instructions. The implications -of this statement depend on your target processor and the compiler you -are using. Be very careful not to straddle bank boundaries on bank- -switched memory systems. - -Physical 32-bit sector numbers are used throughout. Therefore, the -CHS geometry (if any) of the storage media is not known to DOSFS. Your -sector r/w functions may need to query the CHS geometry and perform -mapping. - -File timestamps set by DOSFS are always 1:01:00am on Jan 1, 2006. If -your system has a concept of real time, you can enhance this. - -FILEINFO structures contain a pointer to the corresponding VOLINFO -used to open the file, mainly in order to avoid mixups but also to -obviate the need for an extra parameter to every file read/write. DOSFS -assumes that the VOLINFO won't move around. If you need to move or -destroy VOLINFOs pertaining to open files, you'll have to fix up the -pointer in the FILEINFO structure yourself. - -The subdirectory delimiter is a forward slash ( '/' ) by default. The -reason for this is to avoid the common programming error of forgetting -that backslash is an escape character in C strings; i.e. "\MYDIR\FILE" -is NOT what you want; "\\MYDIR\\FILE" is what you wanted to type. If you -are porting DOS code into an embedded environment, feel free to change -this #define. - -DOSFS does not have a concept of "current directory". A current directory -is owned by a process, and a process is an operating system concept. -DOSFS is a filesystem library, not an operating system. Therefore, any -path you provide to a DOSFS call is assumed to be relative to the root of -the volume. - -There is no call to close a file or directory that is open for reading or -writing. You can simply destroy or reuse the data structures allocated for -that operation; there is no internal state in DOSFS so no cleanup is -necessary. Similarly, there is no call to close a file that is open for -writing. (Observe that dosfs.c has no global variables. All state information -is stored in data structures provided by the caller). - -MAX_PATH is defined as 64. MS-type DOS filesystems support 128 characters -or more in paths. You can increase this define, but it may GREATLY -increase memory requirements. - -VFAT long filenames are not supported. There is a certain amount of -patent controversy about them, but more importantly they don't really -belong in the scope of a "minimalist embedded filesystem". - -Improving Performance -===================== -Read performance is fairly good, but can be improved by implementing read -caching on the FAT (see below) and, depending on your hardware platform, -possibly by implementing multi-sector reads. - -Write performance may benefit ENORMOUSLY from platform-specific -optimization, especially if you are working with a flash media type that -has a large erase block size. While it is not possible to offer detailed -platform-independent advice, my general advice is to implement writeback -caching on the FAT area. One method for doing this would be to have a -cache system that lives in the DFS_ReadSector/WriteSector functions (on -top of the physical sector r/w functions) and is initially switched off. -Once you have called DFS_GetVolInfo, you then extract the VOLINFO.fat1 -and VOLINFO.rootdir parameters and pass them to your caching layer. -Sectors >= fat1 and < rootdir should be cached. The cache strategy is -determined by the physical storage medium underlying the filesystem. - -CACHING HINT: -Observe that there will be numerous read-modify-write operations in the -region from VOLINFO.fat1 through VOLINFO.fat1+VOLINFO.secperfat-1, but -in the region from VOLINFO.fat1+VOLINFO.secperfat through VOLINFO.rootdir -there will ONLY be write operations. - -Platform Compatibility -====================== -DOSFS was derived from code originally written for ARM7TDMI but -designed to be portable. It has been tested on AVR (using avrgcc), -MSP430 (using Rowley's CrossWorks) and PPC603e (using gcc); the host -test suite has also been validated on x86 using gcc under both Cygwin -and 32-bit Fedora Core 4 Linux. - -TODO list -========= -* Add function to create subdirectory -* Make DFS_UnlinkFile recognize non-empty subdirectories -* Support "fast write" files where the FAT is not updated, for - logging applications where latency is important. - -Test cases for V1.02 -==================== -Version 1.02 has NOT been through full regression testing. However the -bugs fixed in this version are important, and people have been asking -about them. - -Test cases for V1.01 -==================== -See below. - -Test cases for V1.00 -==================== -These are the test cases that were used to validate the correct -functionality of the DOSFS suite. Each test was performed on FAT12, -FAT16 and FAT32 volumes. P=Pass, F=Fail. - -Case F12 F16 F32 ---------------------------------------------------------------------- -Get volume information P P P -Open root directory P P P -List contents of root directory (fully populated) P P P -Open subdirectory P P P -List contents of subdirectory (<= 1 cluster) P P P -List contents of large subdirectory (> 1 cluster) P P P -Open 5-level nested subdirectory P P P -Open existing file for reading P P P -Open nonexistent file for reading P P P -Seek past EOF, file open for reading P P P -Seek to cluster boundary P P P -Seek past cluster boundary P P P -Seek backwards to nonzero offset, pointer > cluster size P P P -Block-read entire file >1 cluster in size, odd size P P P -Seek to odd location in file P P P -Perform <1 sector reads from random file locations P P P -Open nonexistent file for writing in root dir P P P -Open nonexistent file for writing in subdir P P P -Repeat prev. 2 tests on volume with 0 free clusters P P P -Seek past EOF, file open for writing P P P -Open existing file for writing in root dir P P P -Write random-length records to file, 20 clusters total P P P -MS-DOS 6.0 SCANDISK cross-check P P P - -Revision History -================ -Jan-06-2005 larwe Initial release (1.0) -Jan-29-2006 larwe Bugfix release (1.01) - - Fixed error in FAT12 FAT read on boundary of sector - - Improved compilability under avrgcc -Sep-16-2006 larwe Bugfix release (1.02) - - DFS_Seek would not correctly rewind to start of file - - DFS_Seek would not correctly seek to a position not on a cluster - boundary - - DFS_OpenFile fencepost error caused memory access at [start of - string-1] with a local variable - - DFS_OpenFile could not open a file in the root directory - - \ No newline at end of file diff --git a/flight/PiOS/STM32F10x/Libraries/dosfs/README_1st.txt b/flight/PiOS/STM32F10x/Libraries/dosfs/README_1st.txt deleted file mode 100644 index a44df8f80..000000000 --- a/flight/PiOS/STM32F10x/Libraries/dosfs/README_1st.txt +++ /dev/null @@ -1,42 +0,0 @@ -DOSFS has been developed by Lewin Edwards, and is provided as freeware. - -See README.txt for details. - -This package has been downloaded from: - http://www.larwe.com/zws/products/dosfs/ - -Version 1.03 from 9/30/06 is used. - - -dfs_sdcard has been added as access layer between DFS functions and PIOS_SDCARD functions - -The original usage examples can be found under unused/main.c - -Addendum: - -TK 2008-12-18: -DFS_Seek was running endless, applied a patch which has been posted at -http://reza.net/wordpress/?p=110 - -TK 2008-12-18: -patched the patch: endcluster wasn't calculated correctly - -TK 2008-12-18: -added 'DFS_CachingEnabledSet(uint8_t enable)' function to enable a simple -caching mechanism. This feature has to be explicitely enabled, as it isn't -reentrant and requires to use the same buffer pointer whenever reading a file! - -TK 2008-18-12 -added missing pendant to DFS_CanonicalToDir; -char *DFS_DirToCanonical(char *dest, char *src) -expects a 13 byte buffer in *dest - -TK 2009-02-12 -added dummy "DFS_Close" function -It has no effect if writing to SD Card, it's only used by the DosFS wrapper -in emulation - -TK 2009-07-04 -fixed bug in DFS_GetNext() in conjunction with the DFS_GetFreeDirEnt() function -New files where not added correctly to subdirectories - diff --git a/flight/PiOS/STM32F10x/Libraries/dosfs/dfs_sdcard.c b/flight/PiOS/STM32F10x/Libraries/dosfs/dfs_sdcard.c deleted file mode 100644 index ff5040c72..000000000 --- a/flight/PiOS/STM32F10x/Libraries/dosfs/dfs_sdcard.c +++ /dev/null @@ -1,143 +0,0 @@ -/** - ****************************************************************************** - * - * @file pios.c - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * Parts by Thorsten Klose (tk@midibox.org) (tk@midibox.org) - * @brief Access layer between DOSFS and PIOS - * @see The GNU Public License (GPL) Version 3 - * - *****************************************************************************/ -/* - * 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 - */ - -/* Include files */ - -#include - -#include "dosfs.h" - - -/* Local variables */ - -/* For caching - this feature has to be explicitly enabled, as it isn't reentrant */ -/* and requires to use the same buffer pointer whenever reading a file. */ -static uint32_t last_sector; -static uint8_t caching_enabled = 0; - -void DFS_CachingEnabledSet(uint8_t enable) -{ - caching_enabled = enable; - last_sector = 0xffffffff; -} - - -/** -* Converts directory name to canonical name -* (missing pendant to DFS_anonicalToDir) -* dest must point to a 13-byte buffer -*/ -char *DFS_DirToCanonical(char *dest, char *src) -{ - uint8_t pos = 0; - - while( pos < 8 && src[pos] != ' ' ) { - *dest++ = src[pos++]; - } - - if( src[8] != ' ' ) { - *dest++ = '.'; - - pos = 8; - while( pos < 11 && src[pos] != ' ' ) { - *dest++ = src[pos++]; - } - } - - /* Terminate string */ - *dest = 0; - - return dest; -} - - - -/** -* Read sector from SD Card -* Returns 0 OK, nonzero for any error -*/ -uint32_t DFS_ReadSector(uint8_t unit, uint8_t *buffer, uint32_t sector, uint32_t count) -{ - /* Only allow access to single unit */ - if(unit != 0) { - return 1; - } - - /* According to README.txt, count is always 1 - check this! */ - if(count != 1) { - return 2; - } - - /* Cache: */ - if(caching_enabled && sector == last_sector) { - /* we assume that sector is already in *buffer */ - /* since the user has to take care that the same buffer is used for file reads, this */ - /* feature has to be explicitly enabled with DFS_CachingEnabledSet(uint8_t enable) */ - return 0; - } - - last_sector = sector; - - /* Forward to PIOS */ - int32_t status; - if((status = PIOS_SDCARD_SectorRead(sector, buffer)) < 0) { - /* Cannot access SD Card */ - return 3; - } - - /* Success */ - return 0; -} - -/** -* Write sector to SD Card -* Returns 0 OK, nonzero for any error -*/ -uint32_t DFS_WriteSector(uint8_t unit, uint8_t *buffer, uint32_t sector, uint32_t count) -{ - /* Only allow access to single unit */ - if(unit != 0) { - return 1; - } - - /* According to README.txt, count is always 1 - check this! */ - if(count != 1) { - return 2; - } - - /* Invalidate cache */ - last_sector = 0xffffffff; - - /* Forward to PIOS */ - int32_t status; - if((status = PIOS_SDCARD_SectorWrite(sector, buffer)) < 0) { - /* Cannot access SD Card */ - return 3; - } - - /* Success */ - return 0; -} diff --git a/flight/PiOS/STM32F10x/Libraries/dosfs/dosfs.c b/flight/PiOS/STM32F10x/Libraries/dosfs/dosfs.c deleted file mode 100644 index 8a75b95d0..000000000 --- a/flight/PiOS/STM32F10x/Libraries/dosfs/dosfs.c +++ /dev/null @@ -1,1336 +0,0 @@ -/* - DOSFS Embedded FAT-Compatible Filesystem - (C) 2005 Lewin A.R.W. Edwards (sysadm@zws.com) - - You are permitted to modify and/or use this code in your own projects without - payment of royalty, regardless of the license(s) you choose for those projects. - - You cannot re-copyright or restrict use of the code as released by Lewin Edwards. -*/ - -//#include "common.h" -#include -#include -//#include "fat.h" - -#define div(a,b) ldiv(a,b) - -#include "dosfs.h" - -/* - Get starting sector# of specified partition on drive #unit - NOTE: This code ASSUMES an MBR on the disk. - scratchsector should point to a SECTOR_SIZE scratch area - Returns 0xffffffff for any error. - If pactive is non-NULL, this function also returns the partition active flag. - If pptype is non-NULL, this function also returns the partition type. - If psize is non-NULL, this function also returns the partition size. -*/ -uint32_t DFS_GetPtnStart(uint8_t unit, uint8_t *scratchsector, uint8_t pnum, uint8_t *pactive, uint8_t *pptype, uint32_t *psize) -{ - uint32_t result=0; - PMBR mbr = (PMBR) scratchsector; - - // DOS ptable supports maximum 4 partitions - if (pnum > 3) - return DFS_ERRMISC; - - // Read MBR from target media - if (DFS_ReadSector(unit,scratchsector,0,1)) { - return DFS_ERRMISC; - } - - // check if jump to boot, VBR - if(mbr->bootcode[0]==0xEB || mbr->bootcode[0]==0xE9){ - // MBR is actually VBR - return 0; - } - - result = (uint32_t) mbr->ptable[pnum].start_0 | - (((uint32_t) mbr->ptable[pnum].start_1) << 8) | - (((uint32_t) mbr->ptable[pnum].start_2) << 16) | - (((uint32_t) mbr->ptable[pnum].start_3) << 24); - - if (pactive) - *pactive = mbr->ptable[pnum].active; - - if (pptype) - *pptype = mbr->ptable[pnum].type; - - if (psize) - *psize = (uint32_t) mbr->ptable[pnum].size_0 | - (((uint32_t) mbr->ptable[pnum].size_1) << 8) | - (((uint32_t) mbr->ptable[pnum].size_2) << 16) | - (((uint32_t) mbr->ptable[pnum].size_3) << 24); - - return result; -} - - -/* - Retrieve volume info from BPB and store it in a VOLINFO structure - You must provide the unit and starting sector of the filesystem, and - a pointer to a sector buffer for scratch - Attempts to read BPB and glean information about the FS from that. - Returns 0 OK, nonzero for any error. -*/ -uint32_t DFS_GetVolInfo(uint8_t unit, uint8_t *scratchsector, uint32_t startsector, PVOLINFO volinfo) -{ - PLBR lbr = (PLBR) scratchsector; - volinfo->unit = unit; - volinfo->startsector = startsector; -#ifdef DEBUG_DOSFS - printf("DFS_GetVolInfo\r\n"); -#endif - - if(DFS_ReadSector(unit,scratchsector,startsector,1)) - return DFS_ERRMISC; - -// tag: OEMID, refer dosfs.h -// strncpy(volinfo->oemid, lbr->oemid, 8); -// volinfo->oemid[8] = 0; - - volinfo->secperclus = lbr->bpb.secperclus; - volinfo->reservedsecs = (uint16_t) lbr->bpb.reserved_l | - (((uint16_t) lbr->bpb.reserved_h) << 8); - - volinfo->numsecs = (uint16_t) lbr->bpb.sectors_s_l | - (((uint16_t) lbr->bpb.sectors_s_h) << 8); - - if (!volinfo->numsecs) - volinfo->numsecs = (uint32_t) lbr->bpb.sectors_l_0 | - (((uint32_t) lbr->bpb.sectors_l_1) << 8) | - (((uint32_t) lbr->bpb.sectors_l_2) << 16) | - (((uint32_t) lbr->bpb.sectors_l_3) << 24); - - // If secperfat is 0, we must be in a FAT32 volume; get secperfat - // from the FAT32 EBPB. The volume label and system ID string are also - // in different locations for FAT12/16 vs FAT32. - volinfo->secperfat = (uint16_t) lbr->bpb.secperfat_l | - (((uint16_t) lbr->bpb.secperfat_h) << 8); - if (!volinfo->secperfat) { - volinfo->secperfat = (uint32_t) lbr->ebpb.ebpb32.fatsize_0 | - (((uint32_t) lbr->ebpb.ebpb32.fatsize_1) << 8) | - (((uint32_t) lbr->ebpb.ebpb32.fatsize_2) << 16) | - (((uint32_t) lbr->ebpb.ebpb32.fatsize_3) << 24); - - memcpy(volinfo->label, lbr->ebpb.ebpb32.label, 11); - volinfo->label[11] = 0; - -// tag: OEMID, refer dosfs.h -// memcpy(volinfo->system, lbr->ebpb.ebpb32.system, 8); -// volinfo->system[8] = 0; - } - else { - memcpy(volinfo->label, lbr->ebpb.ebpb.label, 11); - volinfo->label[11] = 0; - -// tag: OEMID, refer dosfs.h -// memcpy(volinfo->system, lbr->ebpb.ebpb.system, 8); -// volinfo->system[8] = 0; - } - - // note: if rootentries is 0, we must be in a FAT32 volume. - volinfo->rootentries = (uint16_t) lbr->bpb.rootentries_l | - (((uint16_t) lbr->bpb.rootentries_h) << 8); - - // after extracting raw info we perform some useful precalculations - volinfo->fat1 = startsector + volinfo->reservedsecs; - - // The calculation below is designed to round up the root directory size for FAT12/16 - // and to simply ignore the root directory for FAT32, since it's a normal, expandable - // file in that situation. - if (volinfo->rootentries) { - volinfo->rootdir = volinfo->fat1 + (volinfo->secperfat * 2); - volinfo->dataarea = volinfo->rootdir + (((volinfo->rootentries * 32) + (SECTOR_SIZE - 1)) / SECTOR_SIZE); - } - else { - volinfo->dataarea = volinfo->fat1 + (volinfo->secperfat * 2); - volinfo->rootdir = (uint32_t) lbr->ebpb.ebpb32.root_0 | - (((uint32_t) lbr->ebpb.ebpb32.root_1) << 8) | - (((uint32_t) lbr->ebpb.ebpb32.root_2) << 16) | - (((uint32_t) lbr->ebpb.ebpb32.root_3) << 24); - } - - // Calculate number of clusters in data area and infer FAT type from this information. - volinfo->numclusters = (volinfo->numsecs - volinfo->dataarea) / volinfo->secperclus; - if (volinfo->numclusters < 4085) - volinfo->filesystem = FAT12; - else if (volinfo->numclusters < 65525) - volinfo->filesystem = FAT16; - else - volinfo->filesystem = FAT32; - - return DFS_OK; -} - -/* - Fetch FAT entry for specified cluster number - You must provide a scratch buffer for one sector (SECTOR_SIZE) and a populated VOLINFO - Returns a FAT32 BAD_CLUSTER value for any error, otherwise the contents of the desired - FAT entry. - scratchcache should point to a UINT32. This variable caches the physical sector number - last read into the scratch buffer for performance enhancement reasons. -*/ -uint32_t DFS_GetFAT(PVOLINFO volinfo, uint8_t *scratch, uint32_t *scratchcache, uint32_t cluster) -{ - uint32_t offset=0, sector=0, result=0; - -#ifdef DEBUG_DOSFS - printf("DFS_GetFAT\r\n"); -#endif - - if (volinfo->filesystem == FAT12) { - offset = cluster + (cluster / 2); - } - else if (volinfo->filesystem == FAT16) { - offset = cluster * 2; - } - else if (volinfo->filesystem == FAT32) { - offset = cluster * 4; - } - else - return 0x0ffffff7; // FAT32 bad cluster - - // at this point, offset is the BYTE offset of the desired sector from the start - // of the FAT. Calculate the physical sector containing this FAT entry. - sector = ldiv(offset, SECTOR_SIZE).quot + volinfo->fat1; - - // If this is not the same sector we last read, then read it into RAM - if (sector != *scratchcache) { - if(DFS_ReadSector(volinfo->unit, scratch, sector, 1)) { - // avoid anyone assuming that this cache value is still valid, which - // might cause disk corruption - *scratchcache = 0; - return 0x0ffffff7; // FAT32 bad cluster - } - *scratchcache = sector; - } - - // At this point, we "merely" need to extract the relevant entry. - // This is easy for FAT16 and FAT32, but a royal PITA for FAT12 as a single entry - // may span a sector boundary. The normal way around this is always to read two - // FAT sectors, but that luxury is (by design intent) unavailable to DOSFS. - offset = ldiv(offset, SECTOR_SIZE).rem; - - if (volinfo->filesystem == FAT12) { - // Special case for sector boundary - Store last byte of current sector. - // Then read in the next sector and put the first byte of that sector into - // the high byte of result. - if (offset == SECTOR_SIZE - 1) { - result = (uint32_t) scratch[offset]; - sector++; - if(DFS_ReadSector(volinfo->unit, scratch, sector, 1)) { - // avoid anyone assuming that this cache value is still valid, which - // might cause disk corruption - *scratchcache = 0; - return 0x0ffffff7; // FAT32 bad cluster - } - *scratchcache = sector; - // Thanks to Claudio Leonel for pointing out this missing line. - result |= ((uint32_t) scratch[0]) << 8; - } - else { - result = (uint32_t) scratch[offset] | - ((uint32_t) scratch[offset+1]) << 8; - } - if (cluster & 1) - result = result >> 4; - else - result = result & 0xfff; - } - else if (volinfo->filesystem == FAT16) { - result = (uint32_t) scratch[offset] | - ((uint32_t) scratch[offset+1]) << 8; - } - else if (volinfo->filesystem == FAT32) { - result = ((uint32_t) scratch[offset] | - ((uint32_t) scratch[offset+1]) << 8 | - ((uint32_t) scratch[offset+2]) << 16 | - ((uint32_t) scratch[offset+3]) << 24) & 0x0fffffff; - } - else - result = 0x0ffffff7; // FAT32 bad cluster - return result; -} - - -/* - Set FAT entry for specified cluster number - You must provide a scratch buffer for one sector (SECTOR_SIZE) and a populated VOLINFO - Returns DFS_ERRMISC for any error, otherwise DFS_OK - scratchcache should point to a UINT32. This variable caches the physical sector number - last read into the scratch buffer for performance enhancement reasons. - - NOTE: This code is HIGHLY WRITE-INEFFICIENT, particularly for flash media. Considerable - performance gains can be realized by caching the sector. However this is difficult to - achieve on FAT12 without requiring 2 sector buffers of scratch space, and it is a design - requirement of this code to operate on a single 512-byte scratch. - - If you are operating DOSFS over flash, you are strongly advised to implement a writeback - cache in your physical I/O driver. This will speed up your code significantly and will - also conserve power and flash write life. -*/ -uint32_t DFS_SetFAT(PVOLINFO volinfo, uint8_t *scratch, uint32_t *scratchcache, uint32_t cluster, uint32_t new_contents) -{ - uint32_t offset=0, sector=0, result=0; -#ifdef DEBUG_DOSFS - printf("DFS_SetFAT (%lu->%lu)\r\n",cluster,new_contents); -#endif - - if (volinfo->filesystem == FAT12) { - offset = cluster + (cluster / 2); - new_contents &=0xfff; - } - else if (volinfo->filesystem == FAT16) { - offset = cluster * 2; - new_contents &=0xffff; - } - else if (volinfo->filesystem == FAT32) { - offset = cluster * 4; - new_contents &=0x0fffffff; // FAT32 is really "FAT28" - } - else - return DFS_ERRMISC; - - // at this point, offset is the BYTE offset of the desired sector from the start - // of the FAT. Calculate the physical sector containing this FAT entry. - sector = ldiv(offset, SECTOR_SIZE).quot + volinfo->fat1; - - // If this is not the same sector we last read, then read it into RAM - if (sector != *scratchcache) { - if(DFS_ReadSector(volinfo->unit, scratch, sector, 1)) { - // avoid anyone assuming that this cache value is still valid, which - // might cause disk corruption - *scratchcache = 0; - return DFS_ERRMISC; - } - *scratchcache = sector; - } - - // At this point, we "merely" need to extract the relevant entry. - // This is easy for FAT16 and FAT32, but a royal PITA for FAT12 as a single entry - // may span a sector boundary. The normal way around this is always to read two - // FAT sectors, but that luxury is (by design intent) unavailable to DOSFS. - offset = ldiv(offset, SECTOR_SIZE).rem; - - if (volinfo->filesystem == FAT12) { - - // If this is an odd cluster, pre-shift the desired new contents 4 bits to - // make the calculations below simpler - if (cluster & 1) - new_contents = new_contents << 4; - - // Special case for sector boundary - if (offset == SECTOR_SIZE - 1) { - - // Odd cluster: High 12 bits being set - if (cluster & 1) { - scratch[offset] = (scratch[offset] & 0x0f) | (new_contents & 0xf0); - } - // Even cluster: Low 12 bits being set - else { - scratch[offset] = new_contents & 0xff; - } - result = DFS_WriteSector(volinfo->unit, scratch, *scratchcache, 1); - // mirror the FAT into copy 2 - if (DFS_OK == result) - result = DFS_WriteSector(volinfo->unit, scratch, (*scratchcache)+volinfo->secperfat, 1); - - // If we wrote that sector OK, then read in the subsequent sector - // and poke the first byte with the remainder of this FAT entry. - if (DFS_OK == result) { - // *scratchcache++; - ++*scratchcache; // TK: to avoid warning "value computed is not used" - result = DFS_ReadSector(volinfo->unit, scratch, *scratchcache, 1); - if (DFS_OK == result) { - // Odd cluster: High 12 bits being set - if (cluster & 1) { - scratch[0] = new_contents & 0xff00; - } - // Even cluster: Low 12 bits being set - else { - scratch[0] = (scratch[0] & 0xf0) | (new_contents & 0x0f); - } - result = DFS_WriteSector(volinfo->unit, scratch, *scratchcache, 1); - // mirror the FAT into copy 2 - if (DFS_OK == result) - result = DFS_WriteSector(volinfo->unit, scratch, (*scratchcache)+volinfo->secperfat, 1); - } - else { - // avoid anyone assuming that this cache value is still valid, which - // might cause disk corruption - *scratchcache = 0; - } - } - } // if (offset == SECTOR_SIZE - 1) - - // Not a sector boundary. But we still have to worry about if it's an odd - // or even cluster number. - else { - // Odd cluster: High 12 bits being set - if (cluster & 1) { - scratch[offset] = (scratch[offset] & 0x0f) | (new_contents & 0xf0); - scratch[offset+1] = new_contents & 0xff00; - } - // Even cluster: Low 12 bits being set - else { - scratch[offset] = new_contents & 0xff; - scratch[offset+1] = (scratch[offset+1] & 0xf0) | (new_contents & 0x0f); - } - result = DFS_WriteSector(volinfo->unit, scratch, *scratchcache, 1); - // mirror the FAT into copy 2 - if (DFS_OK == result) - result = DFS_WriteSector(volinfo->unit, scratch, (*scratchcache)+volinfo->secperfat, 1); - } - } - else if (volinfo->filesystem == FAT16) { - scratch[offset] = (new_contents & 0xff); - scratch[offset+1] = (new_contents & 0xff00) >> 8; - result = DFS_WriteSector(volinfo->unit, scratch, *scratchcache, 1); - // mirror the FAT into copy 2 - XXX - if (DFS_OK == result) - result = DFS_WriteSector(volinfo->unit, scratch, (*scratchcache)+volinfo->secperfat, 1); - } - else if (volinfo->filesystem == FAT32) { - scratch[offset] = (new_contents & 0xff); - scratch[offset+1] = (new_contents & 0xff00) >> 8; - scratch[offset+2] = (new_contents & 0xff0000) >> 16; - scratch[offset+3] = (scratch[offset+3] & 0xf0) | ((new_contents & 0x0f000000) >> 24); - // Note well from the above: Per Microsoft's guidelines we preserve the upper - // 4 bits of the FAT32 cluster value. It's unclear what these bits will be used - // for; in every example I've encountered they are always zero. - result = DFS_WriteSector(volinfo->unit, scratch, *scratchcache, 1); - // mirror the FAT into copy 2 - if (DFS_OK == result) - result = DFS_WriteSector(volinfo->unit, scratch, (*scratchcache)+volinfo->secperfat, 1); - } - else - result = DFS_ERRMISC; - - return result; -} - -/* - Convert a filename element from canonical (8.3) to directory entry (11) form - src must point to the first non-separator character. - dest must point to a 12-byte buffer. -*/ -uint8_t *DFS_CanonicalToDir(uint8_t *dest, uint8_t *src) -{ - uint8_t *destptr = dest; - - memset(dest, ' ', 11); - dest[11] = 0; - - while (*src && (*src != DIR_SEPARATOR) && (destptr - dest < 11)) { - if (*src >= 'a' && *src <='z') { - *destptr++ = (*src - 'a') + 'A'; - src++; - } - else if (*src == '.') { - src++; - destptr = dest + 8; - } - else { - *destptr++ = *src++; - } - } - - return dest; -} - -/* - Find the first unused FAT entry - You must provide a scratch buffer for one sector (SECTOR_SIZE) and a populated VOLINFO - Returns a FAT32 BAD_CLUSTER value for any error, otherwise the contents of the desired - FAT entry. - Returns FAT32 bad_sector (0x0ffffff7) if there is no free cluster available -*/ -uint32_t DFS_GetFreeFAT(PVOLINFO volinfo, uint8_t *scratch) -{ - uint32_t i, result = 0xffffffff, scratchcache = 0; - - -#ifdef DEBUG_DOSFS - printf("DFS_GetFreeFAT\r\n"); -#endif - - // Search starts at cluster 2, which is the first usable cluster - // NOTE: This search can't terminate at a bad cluster, because there might - // legitimately be bad clusters on the disk. - for (i=2; i < volinfo->numclusters; i++) { - result = DFS_GetFAT(volinfo, scratch, &scratchcache, i); - if (!result) { - return i; - } - } - return 0x0ffffff7; // Can't find a free cluster -} - - -/* - Open a directory for enumeration by DFS_GetNextDirEnt - You must supply a populated VOLINFO (see DFS_GetVolInfo) - ** you must also make sure dirinfo->scratch is valid in the dirinfo you pass it** //reza - The empty string or a string containing only the directory separator are - considered to be the root directory. - Returns 0 OK, nonzero for any error. -*/ -uint32_t DFS_OpenDir(PVOLINFO volinfo, uint8_t *dirname, PDIRINFO dirinfo) -{ - // Default behavior is a regular search for existing entries - dirinfo->flags = 0; -#ifdef DEBUG_DOSFS - printf("DFS_OpenDir\r\n"); -#endif - - if (!strlen((char *) dirname) || (strlen((char *) dirname) == 1 && dirname[0] == DIR_SEPARATOR)) { - if (volinfo->filesystem == FAT32) { - dirinfo->currentcluster = volinfo->rootdir; - dirinfo->currentsector = 0; - dirinfo->currententry = 0; - - // read first sector of directory - return DFS_ReadSector(volinfo->unit, dirinfo->scratch, volinfo->dataarea + ((volinfo->rootdir - 2) * volinfo->secperclus), 1); - } - else { - dirinfo->currentcluster = 0; - dirinfo->currentsector = 0; - dirinfo->currententry = 0; - - // read first sector of directory - return DFS_ReadSector(volinfo->unit, dirinfo->scratch, volinfo->rootdir, 1); - } - } - - // This is not the root directory. We need to find the start of this subdirectory. - // We do this by devious means, using our own companion function DFS_GetNext. - else { - uint8_t tmpfn[12]; - uint8_t *ptr = dirname; - uint32_t result; - DIRENT de; - - if (volinfo->filesystem == FAT32) { - dirinfo->currentcluster = volinfo->rootdir; - dirinfo->currentsector = 0; - dirinfo->currententry = 0; - - // read first sector of directory - if (DFS_ReadSector(volinfo->unit, dirinfo->scratch, volinfo->dataarea + ((volinfo->rootdir - 2) * volinfo->secperclus), 1)) - return DFS_ERRMISC; - } - else { - dirinfo->currentcluster = 0; - dirinfo->currentsector = 0; - dirinfo->currententry = 0; - - // read first sector of directory - if (DFS_ReadSector(volinfo->unit, dirinfo->scratch, volinfo->rootdir, 1)) - return DFS_ERRMISC; - } - - // skip leading path separators - while (*ptr == DIR_SEPARATOR && *ptr) - ptr++; - - // Scan the path from left to right, finding the start cluster of each entry - // Observe that this code is inelegant, but obviates the need for recursion. - while (*ptr) { - DFS_CanonicalToDir(tmpfn, ptr); - - de.name[0] = 0; - - do { - result = DFS_GetNext(volinfo, dirinfo, &de); - } while (!result && memcmp(de.name, tmpfn, 11)); - - if (!memcmp(de.name, tmpfn, 11) && ((de.attr & ATTR_DIRECTORY) == ATTR_DIRECTORY)) { - if (volinfo->filesystem == FAT32) { - dirinfo->currentcluster = (uint32_t) de.startclus_l_l | - ((uint32_t) de.startclus_l_h) << 8 | - ((uint32_t) de.startclus_h_l) << 16 | - ((uint32_t) de.startclus_h_h) << 24; - } - else { - dirinfo->currentcluster = (uint32_t) de.startclus_l_l | - ((uint32_t) de.startclus_l_h) << 8; - } - dirinfo->currentsector = 0; - dirinfo->currententry = 0; - - if (DFS_ReadSector(volinfo->unit, dirinfo->scratch, volinfo->dataarea + ((dirinfo->currentcluster - 2) * volinfo->secperclus), 1)) - return DFS_ERRMISC; - } - else if (!memcmp(de.name, tmpfn, 11) && !(de.attr & ATTR_DIRECTORY)) - return DFS_NOTFOUND; - - // seek to next item in list - while (*ptr != DIR_SEPARATOR && *ptr) - ptr++; - if (*ptr == DIR_SEPARATOR) - ptr++; - } - - if (!dirinfo->currentcluster) - return DFS_NOTFOUND; - } - return DFS_OK; -} - -/* - Get next entry in opened directory structure. Copies fields into the dirent - structure, updates dirinfo. Note that it is the _caller's_ responsibility to - handle the '.' and '..' entries. - A deleted file will be returned as a NULL entry (first char of filename=0) - by this code. Filenames beginning with 0x05 will be translated to 0xE5 - automatically. Long file name entries will be returned as NULL. - returns DFS_EOF if there are no more entries, DFS_OK if this entry is valid, - or DFS_ERRMISC for a media error -*/ -uint32_t DFS_GetNext(PVOLINFO volinfo, PDIRINFO dirinfo, PDIRENT dirent) -{ - uint32_t tempint; // required by DFS_GetFAT - -#ifdef DEBUG_DOSFS - printf("DFS_GetNext\r\n"); -#endif - - // Do we need to read the next sector of the directory? - if (dirinfo->currententry >= SECTOR_SIZE / sizeof(DIRENT)) { - dirinfo->currententry = 0; - dirinfo->currentsector++; - - // Root directory; special case handling - // Note that currentcluster will only ever be zero if both: - // (a) this is the root directory, and - // (b) we are on a FAT12/16 volume, where the root dir can't be expanded - if (dirinfo->currentcluster == 0) { - // Trying to read past end of root directory? - if (dirinfo->currentsector * (SECTOR_SIZE / sizeof(DIRENT)) >= volinfo->rootentries) - return DFS_EOF; - - // Otherwise try to read the next sector - if (DFS_ReadSector(volinfo->unit, dirinfo->scratch, volinfo->rootdir + dirinfo->currentsector, 1)) - return DFS_ERRMISC; - } - - // Normal handling - else { - if (dirinfo->currentsector >= volinfo->secperclus) { - dirinfo->currentsector = 0; - if ((dirinfo->currentcluster >= 0xff7 && volinfo->filesystem == FAT12) || - (dirinfo->currentcluster >= 0xfff7 && volinfo->filesystem == FAT16) || - (dirinfo->currentcluster >= 0x0ffffff7 && volinfo->filesystem == FAT32)) { - - // We are at the end of the directory chain. If this is a normal - // find operation, we should indicate that there is nothing more - // to see. - if (!(dirinfo->flags & DFS_DI_BLANKENT)) - return DFS_EOF; - - // On the other hand, if this is a "find free entry" search, - // we need to tell the caller to allocate a new cluster - else - return DFS_ALLOCNEW; - } - dirinfo->currentcluster = DFS_GetFAT(volinfo, dirinfo->scratch, &tempint, dirinfo->currentcluster); - } - if (DFS_ReadSector(volinfo->unit, dirinfo->scratch, volinfo->dataarea + ((dirinfo->currentcluster - 2) * volinfo->secperclus) + dirinfo->currentsector, 1)) - return DFS_ERRMISC; - } - } - - memcpy(dirent, &(((PDIRENT) dirinfo->scratch)[dirinfo->currententry]), sizeof(DIRENT)); - - if (dirent->name[0] == 0) { // no more files in this directory - // If this is a "find blank" then we can reuse this name. -#if 0 - if (dirinfo->flags & DFS_DI_BLANKENT) - return DFS_OK; -#else - - // TK: DFS_GetFreeDirEnt() expects that currententry has been incremented by 1 - if (dirinfo->flags & DFS_DI_BLANKENT) { - dirinfo->currententry++; - return DFS_OK; - } -#endif - - else - return DFS_EOF; - } - - if (dirent->name[0] == 0xe5) // handle deleted file entries - dirent->name[0] = 0; -#if 1 - // TK: ensure that DFS_GetFreeDirEnt() doesn't return entries with long name - else if( dirinfo->flags & DFS_DI_BLANKENT ) - {} // do nothing.. -#endif - - else if ((dirent->attr & ATTR_LONG_NAME) == ATTR_LONG_NAME) - dirent->name[0] = 0; - else if (dirent->name[0] == 0x05) // handle kanji filenames beginning with 0xE5 - dirent->name[0] = 0xe5; - - dirinfo->currententry++; - - return DFS_OK; -} - -/* - INTERNAL - Find a free directory entry in the directory specified by path - This function MAY cause a disk write if it is necessary to extend the directory - size. - Note - di.scratch must be preinitialized to point to a sector scratch buffer - de is a scratch structure - Returns DFS_ERRMISC if a new entry could not be located or created - de is updated with the same return information you would expect from DFS_GetNext -*/ -uint32_t DFS_GetFreeDirEnt(PVOLINFO volinfo, uint8_t *path, PDIRINFO di, PDIRENT de) -{ - uint32_t tempclus=0,i=0; -#ifdef DEBUG_DOSFS - printf("DFS_GetFreeDirEnt\r\n"); -#endif - - if (DFS_OpenDir(volinfo, path, di)) - return DFS_NOTFOUND; - - // Set "search for empty" flag so DFS_GetNext knows what we're doing - di->flags |= DFS_DI_BLANKENT; - - // We seek through the directory looking for an empty entry - // Note we are reusing tempclus as a temporary result holder. - tempclus = 0; - do { - tempclus = DFS_GetNext(volinfo, di, de); - - // Empty entry found - if (tempclus == DFS_OK && (!de->name[0])) { - return DFS_OK; - } - - // End of root directory reached - else if (tempclus == DFS_EOF) - return DFS_ERRMISC; - - else if (tempclus == DFS_ALLOCNEW) { - tempclus = DFS_GetFreeFAT(volinfo, di->scratch); - if (tempclus == 0x0ffffff7) - return DFS_ERRMISC; - - // write out zeroed sectors to the new cluster - memset(di->scratch, 0, SECTOR_SIZE); - for (i=0;isecperclus;i++) { - if (DFS_WriteSector(volinfo->unit, di->scratch, volinfo->dataarea + ((tempclus - 2) * volinfo->secperclus) + i, 1)) - return DFS_ERRMISC; - } - // Point old end cluster to newly allocated cluster - i = 0; - DFS_SetFAT(volinfo, di->scratch, &i, di->currentcluster, tempclus); - - // Update DIRINFO so caller knows where to place the new file - di->currentcluster = tempclus; - di->currentsector = 0; - di->currententry = 1; // since the code coming after this expects to subtract 1 - - // Mark newly allocated cluster as end of chain - switch(volinfo->filesystem) { - case FAT12: tempclus = 0xff8; break; - case FAT16: tempclus = 0xfff8; break; - case FAT32: tempclus = 0x0ffffff8; break; - default: return DFS_ERRMISC; - } - DFS_SetFAT(volinfo, di->scratch, &i, di->currentcluster, tempclus); - } - } while (!tempclus); - - // We shouldn't get here - return DFS_ERRMISC; -} - -/* - Open a file for reading or writing. You supply populated VOLINFO, a path to the file, - mode (DFS_READ or DFS_WRITE) and an empty fileinfo structure. You also need to - provide a pointer to a sector-sized scratch buffer. - Returns various DFS_* error states. If the result is DFS_OK, fileinfo can be used - to access the file from this point on. -*/ -uint32_t DFS_OpenFile(PVOLINFO volinfo, uint8_t *path, uint8_t mode, uint8_t *scratch, PFILEINFO fileinfo) -{ - uint8_t tmppath[MAX_PATH]; - uint8_t filename[12]; - uint8_t *p; - DIRINFO di; - DIRENT de; - uint32_t temp; -#ifdef DEBUG_DOSFS - printf("DFS_OpenFile\r\n"); -#endif - - // larwe 2006-09-16 +1 zero out file structure - memset(fileinfo, 0, sizeof(FILEINFO)); - - // save access mode - fileinfo->mode = mode; - - // Get a local copy of the path. If it's longer than MAX_PATH, abort. - strncpy((char *) tmppath, (char *) path, MAX_PATH); - tmppath[MAX_PATH - 1] = 0; - if (strcmp((char *) path,(char *) tmppath)) { - return DFS_PATHLEN; - } - - // strip leading path separators - while (tmppath[0] == DIR_SEPARATOR) - strcpy((char *) tmppath, (char *) tmppath + 1); - - // Parse filename off the end of the supplied path - p = tmppath; - while (*(p++)); - - p--; - while (p > tmppath && *p != DIR_SEPARATOR) // larwe 9/16/06 ">=" to ">" bugfix - p--; - if (*p == DIR_SEPARATOR) - p++; - - DFS_CanonicalToDir(filename, p); - - if (p > tmppath) - p--; - if (*p == DIR_SEPARATOR || p == tmppath) // larwe 9/16/06 +"|| p == tmppath" bugfix - *p = 0; - - // At this point, if our path was MYDIR/MYDIR2/FILE.EXT, filename = "FILE EXT" and - // tmppath = "MYDIR/MYDIR2". - di.scratch = scratch; - if (DFS_OpenDir(volinfo, tmppath, &di)) - return DFS_NOTFOUND; - - while (!DFS_GetNext(volinfo, &di, &de)) { - if (!memcmp(de.name, filename, 11)) { - // You can't use this function call to open a directory. - if (de.attr & ATTR_DIRECTORY) - return DFS_NOTFOUND; - - fileinfo->volinfo = volinfo; - fileinfo->pointer = 0; - // The reason we store this extra info about the file is so that we can - // speedily update the file size, modification date, etc. on a file that is - // opened for writing. - if (di.currentcluster == 0) - fileinfo->dirsector = volinfo->rootdir + di.currentsector; - else - fileinfo->dirsector = volinfo->dataarea + ((di.currentcluster - 2) * volinfo->secperclus) + di.currentsector; - fileinfo->diroffset = di.currententry - 1; - if (volinfo->filesystem == FAT32) { - fileinfo->cluster = (uint32_t) de.startclus_l_l | - ((uint32_t) de.startclus_l_h) << 8 | - ((uint32_t) de.startclus_h_l) << 16 | - ((uint32_t) de.startclus_h_h) << 24; - } - else { - fileinfo->cluster = (uint32_t) de.startclus_l_l | - ((uint32_t) de.startclus_l_h) << 8; - } - fileinfo->firstcluster = fileinfo->cluster; - fileinfo->filelen = (uint32_t) de.filesize_0 | - ((uint32_t) de.filesize_1) << 8 | - ((uint32_t) de.filesize_2) << 16 | - ((uint32_t) de.filesize_3) << 24; - - return DFS_OK; - } - } - - // At this point, we KNOW the file does not exist. If the file was opened - // with write access, we can create it. - if (mode & DFS_WRITE) { - uint32_t cluster; - - // Locate or create a directory entry for this file - if (DFS_OK != DFS_GetFreeDirEnt(volinfo, tmppath, &di, &de)) - return DFS_ERRMISC; - - // put sane values in the directory entry - memset(&de, 0, sizeof(de)); - memcpy(de.name, filename, 11); - de.crttime_l = 0x20; // 01:01:00am, Jan 1, 2006. - de.crttime_h = 0x08; - de.crtdate_l = 0x11; - de.crtdate_h = 0x34; - de.lstaccdate_l = 0x11; - de.lstaccdate_h = 0x34; - de.wrttime_l = 0x20; - de.wrttime_h = 0x08; - de.wrtdate_l = 0x11; - de.wrtdate_h = 0x34; - - // allocate a starting cluster for the directory entry - cluster = DFS_GetFreeFAT(volinfo, scratch); - - de.startclus_l_l = cluster & 0xff; - de.startclus_l_h = (cluster & 0xff00) >> 8; - de.startclus_h_l = (cluster & 0xff0000) >> 16; - de.startclus_h_h = (cluster & 0xff000000) >> 24; - - // update FILEINFO for our caller's sake - fileinfo->volinfo = volinfo; - fileinfo->pointer = 0; - // The reason we store this extra info about the file is so that we can - // speedily update the file size, modification date, etc. on a file that is - // opened for writing. - if (di.currentcluster == 0) - fileinfo->dirsector = volinfo->rootdir + di.currentsector; - else - fileinfo->dirsector = volinfo->dataarea + ((di.currentcluster - 2) * volinfo->secperclus) + di.currentsector; - fileinfo->diroffset = di.currententry - 1; - fileinfo->cluster = cluster; - fileinfo->firstcluster = cluster; - fileinfo->filelen = 0; - - // write the directory entry - // note that we no longer have the sector containing the directory entry, - // tragically, so we have to re-read it - if (DFS_ReadSector(volinfo->unit, scratch, fileinfo->dirsector, 1)) - return DFS_ERRMISC; - memcpy(&(((PDIRENT) scratch)[di.currententry-1]), &de, sizeof(DIRENT)); - if (DFS_WriteSector(volinfo->unit, scratch, fileinfo->dirsector, 1)) - return DFS_ERRMISC; - - // Mark newly allocated cluster as end of chain - switch(volinfo->filesystem) { - case FAT12: cluster = 0xff8; break; - case FAT16: cluster = 0xfff8; break; - case FAT32: cluster = 0x0ffffff8; break; - default: return DFS_ERRMISC; - } - temp = 0; - DFS_SetFAT(volinfo, scratch, &temp, fileinfo->cluster, cluster); - - return DFS_OK; - } - - return DFS_NOTFOUND; -} - -/* - Read an open file - You must supply a prepopulated FILEINFO as provided by DFS_OpenFile, and a - pointer to a SECTOR_SIZE scratch buffer. - Note that returning DFS_EOF is not an error condition. This function updates the - successcount field with the number of bytes actually read. -*/ -uint32_t DFS_ReadFile(PFILEINFO fileinfo, uint8_t *scratch, uint8_t *buffer, uint32_t *successcount, uint32_t len) -{ - uint32_t remain=0; - uint32_t result = DFS_OK; - uint32_t sector=0; - uint32_t bytesread=0; -#ifdef DEBUG_DOSFS - printf("DFS_ReadFile\r\n"); -#endif - - // Don't try to read past EOF - if (len > fileinfo->filelen - fileinfo->pointer) - len = fileinfo->filelen - fileinfo->pointer; - - remain = len; - *successcount = 0; - - while (remain && result == DFS_OK) { - // This is a bit complicated. The sector we want to read is addressed at a cluster - // granularity by the fileinfo->cluster member. The file pointer tells us how many - // extra sectors to add to that number. - sector = fileinfo->volinfo->dataarea + - ((fileinfo->cluster - 2) * fileinfo->volinfo->secperclus) + - div(div(fileinfo->pointer,fileinfo->volinfo->secperclus * SECTOR_SIZE).rem, SECTOR_SIZE).quot; - - // Case 1 - File pointer is not on a sector boundary - if (div(fileinfo->pointer, SECTOR_SIZE).rem) { - uint16_t tempreadsize; - - // We always have to go through scratch in this case - result = DFS_ReadSector(fileinfo->volinfo->unit, scratch, sector, 1); - - // This is the number of bytes that we actually care about in the sector - // just read. - tempreadsize = SECTOR_SIZE - (div(fileinfo->pointer, SECTOR_SIZE).rem); - - // Case 1A - We want the entire remainder of the sector. After this - // point, all passes through the read loop will be aligned on a sector - // boundary, which allows us to go through the optimal path 2A below. - if (remain >= tempreadsize) { - memcpy(buffer, scratch + (SECTOR_SIZE - tempreadsize), tempreadsize); - bytesread = tempreadsize; - buffer += tempreadsize; - fileinfo->pointer += tempreadsize; - remain -= tempreadsize; - } - // Case 1B - This read concludes the file read operation - else { - memcpy(buffer, scratch + (SECTOR_SIZE - tempreadsize), remain); - - buffer += remain; - fileinfo->pointer += remain; - bytesread = remain; - remain = 0; - } - } - // Case 2 - File pointer is on sector boundary - else { - // Case 2A - We have at least one more full sector to read and don't have - // to go through the scratch buffer. You could insert optimizations here to - // read multiple sectors at a time, if you were thus inclined (note that - // the maximum multi-read you could perform is a single cluster, so it would - // be advantageous to have code similar to case 1A above that would round the - // pointer to a cluster boundary the first pass through, so all subsequent - // [large] read requests would be able to go a cluster at a time). - if (remain >= SECTOR_SIZE) { - result = DFS_ReadSector(fileinfo->volinfo->unit, buffer, sector, 1); - remain -= SECTOR_SIZE; - buffer += SECTOR_SIZE; - fileinfo->pointer += SECTOR_SIZE; - bytesread = SECTOR_SIZE; - } - // Case 2B - We are only reading a partial sector - else { - result = DFS_ReadSector(fileinfo->volinfo->unit, scratch, sector, 1); - memcpy(buffer, scratch, remain); - buffer += remain; - fileinfo->pointer += remain; - bytesread = remain; - remain = 0; - } - } - - *successcount += bytesread; - - // check to see if we stepped over a cluster boundary - if (div(fileinfo->pointer - bytesread, fileinfo->volinfo->secperclus * SECTOR_SIZE).quot != - div(fileinfo->pointer, fileinfo->volinfo->secperclus * SECTOR_SIZE).quot) { - // An act of minor evil - we use bytesread as a scratch integer, knowing that - // its value is not used after updating *successcount above - bytesread = 0; - if (((fileinfo->volinfo->filesystem == FAT12) && (fileinfo->cluster >= 0xff8)) || - ((fileinfo->volinfo->filesystem == FAT16) && (fileinfo->cluster >= 0xfff8)) || - ((fileinfo->volinfo->filesystem == FAT32) && (fileinfo->cluster >= 0x0ffffff8))) - result = DFS_EOF; - else - fileinfo->cluster = DFS_GetFAT(fileinfo->volinfo, scratch, &bytesread, fileinfo->cluster); - } - } - - return result; -} - -/* - Seek file pointer to a given position - This function does not return status - refer to the fileinfo->pointer value - to see where the pointer wound up. - Requires a SECTOR_SIZE scratch buffer -*/ -void DFS_Seek(PFILEINFO fileinfo, uint32_t offset, uint8_t *scratch) -{ - uint32_t tempint; - uint16_t endcluster=0; //canny/reza 5/7 fixed -#ifdef DEBUG_DOSFS - printf("DFS_Seek\r\n"); -#endif - - // larwe 9/16/06 bugfix split case 0a/0b and changed fallthrough handling - // Case 0a - Return immediately for degenerate case - if (offset == fileinfo->pointer) { - return; - } - - // Case 0b - Don't allow the user to seek past the end of the file - if (offset > fileinfo->filelen) { - offset = fileinfo->filelen; - // NOTE NO RETURN HERE! - } - - // Case 1 - Simple rewind to start - // Note _intentional_ fallthrough from Case 0b above - if (offset == 0) { - fileinfo->cluster = fileinfo->firstcluster; - fileinfo->pointer = 0; - return; // larwe 9/16/06 +1 bugfix - } - // Case 2 - Seeking backwards. Need to reset and seek forwards - else if (offset < fileinfo->pointer) { - fileinfo->cluster = fileinfo->firstcluster; - fileinfo->pointer = 0; - // NOTE NO RETURN HERE! - } - - // Case 3 - Seeking forwards - // Note _intentional_ fallthrough from Case 2 above - // Case 3a - Seek size does not cross cluster boundary - - // very simple case - // larwe 9/16/06 changed .rem to .quot in both div calls, bugfix - if (div(fileinfo->pointer, fileinfo->volinfo->secperclus * SECTOR_SIZE).quot == - div(fileinfo->pointer + offset, fileinfo->volinfo->secperclus * SECTOR_SIZE).quot) { - fileinfo->pointer = offset; - } - // Case 3b - Seeking across cluster boundary(ies) - else { - // round file pointer down to cluster boundary - fileinfo->pointer = div(fileinfo->pointer, fileinfo->volinfo->secperclus * SECTOR_SIZE).quot * - fileinfo->volinfo->secperclus * SECTOR_SIZE; - - // seek by clusters - // larwe 9/30/06 bugfix changed .rem to .quot in both div calls - // canny/reza 5/7 added endcluster related code - // TK 2008-12-18: fixed endcluster calculation - // old: endcluster = div(fileinfo->pointer + offset, fileinfo->volinfo->secperclus * SECTOR_SIZE).quot; - endcluster = div(offset, fileinfo->volinfo->secperclus * SECTOR_SIZE).quot; - while (div(fileinfo->pointer, fileinfo->volinfo->secperclus * SECTOR_SIZE).quot !=endcluster) { - fileinfo->cluster = DFS_GetFAT(fileinfo->volinfo, scratch, &tempint, fileinfo->cluster); - // Abort if there was an error - if (fileinfo->cluster == 0x0ffffff7) { - fileinfo->pointer = 0; - fileinfo->cluster = fileinfo->firstcluster; - return; - } - fileinfo->pointer += SECTOR_SIZE * fileinfo->volinfo->secperclus; - } - - // since we know the cluster is right, we have no more work to do - fileinfo->pointer = offset; - } -} - -/* - Delete a file - scratch must point to a sector-sized buffer -*/ -uint32_t DFS_UnlinkFile(PVOLINFO volinfo, uint8_t *path, uint8_t *scratch) -{ - // PDIRENT de = (PDIRENT) scratch; - FILEINFO fi; - uint32_t cache = 0; - uint32_t tempclus = 0; - -#ifdef DEBUG_DOSFS - printf("DFS_UnlinkFile\r\n"); -#endif - - // DFS_OpenFile gives us all the information we need to delete it - if (DFS_OK != DFS_OpenFile(volinfo, path, DFS_READ, scratch, &fi)) - return DFS_NOTFOUND; - - // First, read the directory sector and delete that entry - if (DFS_ReadSector(volinfo->unit, scratch, fi.dirsector, 1)) - return DFS_ERRMISC; - ((PDIRENT) scratch)[fi.diroffset].name[0] = 0xe5; - if (DFS_WriteSector(volinfo->unit, scratch, fi.dirsector, 1)) - return DFS_ERRMISC; - - // Now follow the cluster chain to free the file space - while (!((volinfo->filesystem == FAT12 && fi.firstcluster >= 0x0ff7) || - (volinfo->filesystem == FAT16 && fi.firstcluster >= 0xfff7) || - (volinfo->filesystem == FAT32 && fi.firstcluster >= 0x0ffffff7))) { - tempclus = fi.firstcluster; - - fi.firstcluster = DFS_GetFAT(volinfo, scratch, &cache, fi.firstcluster); - DFS_SetFAT(volinfo, scratch, &cache, tempclus, 0); - - } - return DFS_OK; -} - - -/* - Write an open file - You must supply a prepopulated FILEINFO as provided by DFS_OpenFile, and a - pointer to a SECTOR_SIZE scratch buffer. - This function updates the successcount field with the number of bytes actually written. -*/ -uint32_t DFS_WriteFile(PFILEINFO fileinfo, uint8_t *scratch, uint8_t *buffer, uint32_t *successcount, uint32_t len) -{ - uint32_t remain=0; - uint32_t result = DFS_OK; - uint32_t sector=0; - uint32_t byteswritten=0; -#ifdef DEBUG_DOSFS - printf("DFS_WriteFile\r\n"); -#endif - - - // Don't allow writes to a file that's open as readonly - if (!(fileinfo->mode & DFS_WRITE)) - return DFS_ERRMISC; - - remain = len; - *successcount = 0; - - while (remain && result == DFS_OK) { - // This is a bit complicated. The sector we want to read is addressed at a cluster - // granularity by the fileinfo->cluster member. The file pointer tells us how many - // extra sectors to add to that number. - sector = fileinfo->volinfo->dataarea + - ((fileinfo->cluster - 2) * fileinfo->volinfo->secperclus) + - div(div(fileinfo->pointer,fileinfo->volinfo->secperclus * SECTOR_SIZE).rem, SECTOR_SIZE).quot; - - // Case 1 - File pointer is not on a sector boundary - if (div(fileinfo->pointer, SECTOR_SIZE).rem) { - uint16_t tempsize; - - // We always have to go through scratch in this case - result = DFS_ReadSector(fileinfo->volinfo->unit, scratch, sector, 1); - - // This is the number of bytes that we don't want to molest in the - // scratch sector just read. - tempsize = div(fileinfo->pointer, SECTOR_SIZE).rem; - - // Case 1A - We are writing the entire remainder of the sector. After - // this point, all passes through the read loop will be aligned on a - // sector boundary, which allows us to go through the optimal path - // 2A below. - if (remain >= SECTOR_SIZE - tempsize) { - memcpy(scratch + tempsize, buffer, SECTOR_SIZE - tempsize); - if (!result) - result = DFS_WriteSector(fileinfo->volinfo->unit, scratch, sector, 1); - - byteswritten = SECTOR_SIZE - tempsize; - buffer += SECTOR_SIZE - tempsize; - fileinfo->pointer += SECTOR_SIZE - tempsize; - if (fileinfo->filelen < fileinfo->pointer) { - fileinfo->filelen = fileinfo->pointer; - } - remain -= SECTOR_SIZE - tempsize; - } - // Case 1B - This concludes the file write operation - else { - memcpy(scratch + tempsize, buffer, remain); - if (!result) - result = DFS_WriteSector(fileinfo->volinfo->unit, scratch, sector, 1); - - buffer += remain; - fileinfo->pointer += remain; - if (fileinfo->filelen < fileinfo->pointer) { - fileinfo->filelen = fileinfo->pointer; - } - byteswritten = remain; - remain = 0; - } - } // case 1 - // Case 2 - File pointer is on sector boundary - else { - // Case 2A - We have at least one more full sector to write and don't have - // to go through the scratch buffer. You could insert optimizations here to - // write multiple sectors at a time, if you were thus inclined. Refer to - // similar notes in DFS_ReadFile. - if (remain >= SECTOR_SIZE) { - result = DFS_WriteSector(fileinfo->volinfo->unit, buffer, sector, 1); - remain -= SECTOR_SIZE; - buffer += SECTOR_SIZE; - fileinfo->pointer += SECTOR_SIZE; - if (fileinfo->filelen < fileinfo->pointer) { - fileinfo->filelen = fileinfo->pointer; - } - byteswritten = SECTOR_SIZE; - } - // Case 2B - We are only writing a partial sector and potentially need to - // go through the scratch buffer. - else { - // If the current file pointer is not yet at or beyond the file - // length, we are writing somewhere in the middle of the file and - // need to load the original sector to do a read-modify-write. - if (fileinfo->pointer < fileinfo->filelen) { - result = DFS_ReadSector(fileinfo->volinfo->unit, scratch, sector, 1); - if (!result) { - memcpy(scratch, buffer, remain); - result = DFS_WriteSector(fileinfo->volinfo->unit, scratch, sector, 1); - } - } - else { - result = DFS_WriteSector(fileinfo->volinfo->unit, buffer, sector, 1); - } - - buffer += remain; - fileinfo->pointer += remain; - if (fileinfo->filelen < fileinfo->pointer) { - fileinfo->filelen = fileinfo->pointer; - } - byteswritten = remain; - remain = 0; - } - } - - *successcount += byteswritten; - - // check to see if we stepped over a cluster boundary - if (div(fileinfo->pointer - byteswritten, fileinfo->volinfo->secperclus * SECTOR_SIZE).quot != - div(fileinfo->pointer, fileinfo->volinfo->secperclus * SECTOR_SIZE).quot) { - uint32_t lastcluster; - - // We've transgressed into another cluster. If we were already at EOF, - // we need to allocate a new cluster. - // An act of minor evil - we use byteswritten as a scratch integer, knowing - // that its value is not used after updating *successcount above - byteswritten = 0; - - lastcluster = fileinfo->cluster; - fileinfo->cluster = DFS_GetFAT(fileinfo->volinfo, scratch, &byteswritten, fileinfo->cluster); - - // Allocate a new cluster? - if (((fileinfo->volinfo->filesystem == FAT12) && (fileinfo->cluster >= 0xff8)) || - ((fileinfo->volinfo->filesystem == FAT16) && (fileinfo->cluster >= 0xfff8)) || - ((fileinfo->volinfo->filesystem == FAT32) && (fileinfo->cluster >= 0x0ffffff8))) { - uint32_t tempclus; - - tempclus = DFS_GetFreeFAT(fileinfo->volinfo, scratch); - byteswritten = 0; // invalidate cache - if (tempclus == 0x0ffffff7) - return DFS_ERRMISC; - - // Link new cluster onto file - DFS_SetFAT(fileinfo->volinfo, scratch, &byteswritten, lastcluster, tempclus); - fileinfo->cluster = tempclus; - - // Mark newly allocated cluster as end of chain - switch(fileinfo->volinfo->filesystem) { - case FAT12: tempclus = 0xff8; break; - case FAT16: tempclus = 0xfff8; break; - case FAT32: tempclus = 0x0ffffff8; break; - default: return DFS_ERRMISC; - } - DFS_SetFAT(fileinfo->volinfo, scratch, &byteswritten, fileinfo->cluster, tempclus); - - result = DFS_OK; - } - // No else clause is required. - } - } - - // Update directory entry - if (DFS_ReadSector(fileinfo->volinfo->unit, scratch, fileinfo->dirsector, 1)) - return DFS_ERRMISC; - ((PDIRENT) scratch)[fileinfo->diroffset].filesize_0 = fileinfo->filelen & 0xff; - ((PDIRENT) scratch)[fileinfo->diroffset].filesize_1 = (fileinfo->filelen & 0xff00) >> 8; - ((PDIRENT) scratch)[fileinfo->diroffset].filesize_2 = (fileinfo->filelen & 0xff0000) >> 16; - ((PDIRENT) scratch)[fileinfo->diroffset].filesize_3 = (fileinfo->filelen & 0xff000000) >> 24; - if (DFS_WriteSector(fileinfo->volinfo->unit, scratch, fileinfo->dirsector, 1)) - return DFS_ERRMISC; - return result; -} - - -/* -// TK: added 2009-02-12 - Close a file - No original function of DosFS driver - It has no effect if writing to SD Card, it's only used by the DosFS wrapper in emulation -*/ -uint32_t DFS_Close(PFILEINFO fileinfo) -{ - return DFS_OK; -} - diff --git a/flight/PiOS/STM32F10x/Libraries/dosfs/dosfs.h b/flight/PiOS/STM32F10x/Libraries/dosfs/dosfs.h deleted file mode 100644 index e255f8ae3..000000000 --- a/flight/PiOS/STM32F10x/Libraries/dosfs/dosfs.h +++ /dev/null @@ -1,405 +0,0 @@ -/* - DOSFS Embedded FAT-Compatible Filesystem - (C) 2005 Lewin A.R.W. Edwards (sysadm@zws.com) -*/ - -#ifndef _DOSFS_H -#define _DOSFS_H - -#include - -//=================================================================== -// User-supplied functions -uint32_t DFS_ReadSector(uint8_t unit, uint8_t *buffer, uint32_t sector, uint32_t count); -uint32_t DFS_WriteSector(uint8_t unit, uint8_t *buffer, uint32_t sector, uint32_t count); - - -//=================================================================== -// Configurable items -#define MAX_PATH 64 // Maximum path length (increasing this will - // GREATLY increase stack requirements!) -#define DIR_SEPARATOR '/' // character separating directory components - -// End of configurable items -//=================================================================== - -//=================================================================== -// 32-bit error codes -#define DFS_OK 0 // no error -#define DFS_EOF 1 // end of file (not an error) -#define DFS_WRITEPROT 2 // volume is write protected -#define DFS_NOTFOUND 3 // path or file not found -#define DFS_PATHLEN 4 // path too long -#define DFS_ALLOCNEW 5 // must allocate new directory cluster -#define DFS_ERRMISC 0xffffffff // generic error - -//=================================================================== -// File access modes -#define DFS_READ 1 // read-only -#define DFS_WRITE 2 // write-only - -//=================================================================== -// Miscellaneous constants -#define SECTOR_SIZE 512 // sector size in bytes - -//=================================================================== -// Internal subformat identifiers -#define FAT12 0 -#define FAT16 1 -#define FAT32 2 - -//=================================================================== -// DOS attribute bits -#define ATTR_READ_ONLY 0x01 -#define ATTR_HIDDEN 0x02 -#define ATTR_SYSTEM 0x04 -#define ATTR_VOLUME_ID 0x08 -#define ATTR_DIRECTORY 0x10 -#define ATTR_ARCHIVE 0x20 -#define ATTR_LONG_NAME (ATTR_READ_ONLY | ATTR_HIDDEN | ATTR_SYSTEM | ATTR_VOLUME_ID) - - -/* - Directory entry structure - note: if name[0] == 0xe5, this is a free dir entry - if name[0] == 0x00, this is a free entry and all subsequent entries are free - if name[0] == 0x05, the first character of the name is 0xe5 [a kanji nicety] - - Date format: bit 0-4 = day of month (1-31) - bit 5-8 = month, 1=Jan..12=Dec - bit 9-15 = count of years since 1980 (0-127) - Time format: bit 0-4 = 2-second count, (0-29) - bit 5-10 = minutes (0-59) - bit 11-15= hours (0-23) -*/ -typedef struct _tagDIRENT { - uint8_t name[11]; // filename - uint8_t attr; // attributes (see ATTR_* constant definitions) - uint8_t reserved; // reserved, must be 0 - uint8_t crttimetenth; // create time, 10ths of a second (0-199 are valid) - uint8_t crttime_l; // creation time low byte - uint8_t crttime_h; // creation time high byte - uint8_t crtdate_l; // creation date low byte - uint8_t crtdate_h; // creation date high byte - uint8_t lstaccdate_l; // last access date low byte - uint8_t lstaccdate_h; // last access date high byte - uint8_t startclus_h_l; // high word of first cluster, low byte (FAT32) - uint8_t startclus_h_h; // high word of first cluster, high byte (FAT32) - uint8_t wrttime_l; // last write time low byte - uint8_t wrttime_h; // last write time high byte - uint8_t wrtdate_l; // last write date low byte - uint8_t wrtdate_h; // last write date high byte - uint8_t startclus_l_l; // low word of first cluster, low byte - uint8_t startclus_l_h; // low word of first cluster, high byte - uint8_t filesize_0; // file size, low byte - uint8_t filesize_1; // - uint8_t filesize_2; // - uint8_t filesize_3; // file size, high byte -} DIRENT, *PDIRENT; - -/* - Partition table entry structure -*/ -typedef struct _tagPTINFO { - uint8_t active; // 0x80 if partition active - uint8_t start_h; // starting head - uint8_t start_cs_l; // starting cylinder and sector (low byte) - uint8_t start_cs_h; // starting cylinder and sector (high byte) - uint8_t type; // type ID byte - uint8_t end_h; // ending head - uint8_t end_cs_l; // ending cylinder and sector (low byte) - uint8_t end_cs_h; // ending cylinder and sector (high byte) - uint8_t start_0; // starting sector# (low byte) - uint8_t start_1; // - uint8_t start_2; // - uint8_t start_3; // starting sector# (high byte) - uint8_t size_0; // size of partition (low byte) - uint8_t size_1; // - uint8_t size_2; // - uint8_t size_3; // size of partition (high byte) -} PTINFO, *PPTINFO; - -/* - Master Boot Record structure -*/ -typedef struct _tagMBR { - uint8_t bootcode[0x1be]; // boot sector - PTINFO ptable[4]; // four partition table structures - uint8_t sig_55; // 0x55 signature byte - uint8_t sig_aa; // 0xaa signature byte -} MBR, *PMBR; - -/* - BIOS Parameter Block structure (FAT12/16) -*/ -typedef struct _tagBPB { - uint8_t bytepersec_l; // bytes per sector low byte (0x00) - uint8_t bytepersec_h; // bytes per sector high byte (0x02) - uint8_t secperclus; // sectors per cluster (1,2,4,8,16,32,64,128 are valid) - uint8_t reserved_l; // reserved sectors low byte - uint8_t reserved_h; // reserved sectors high byte - uint8_t numfats; // number of FAT copies (2) - uint8_t rootentries_l; // number of root dir entries low byte (0x00 normally) - uint8_t rootentries_h; // number of root dir entries high byte (0x02 normally) - uint8_t sectors_s_l; // small num sectors low byte - uint8_t sectors_s_h; // small num sectors high byte - uint8_t mediatype; // media descriptor byte - uint8_t secperfat_l; // sectors per FAT low byte - uint8_t secperfat_h; // sectors per FAT high byte - uint8_t secpertrk_l; // sectors per track low byte - uint8_t secpertrk_h; // sectors per track high byte - uint8_t heads_l; // heads low byte - uint8_t heads_h; // heads high byte - uint8_t hidden_0; // hidden sectors low byte - uint8_t hidden_1; // (note - this is the number of MEDIA sectors before - uint8_t hidden_2; // first sector of VOLUME - we rely on the MBR instead) - uint8_t hidden_3; // hidden sectors high byte - uint8_t sectors_l_0; // large num sectors low byte - uint8_t sectors_l_1; // - uint8_t sectors_l_2; // - uint8_t sectors_l_3; // large num sectors high byte -} BPB, *PBPB; - -/* - Extended BIOS Parameter Block structure (FAT12/16) -*/ -typedef struct _tagEBPB { - uint8_t unit; // int 13h drive# - uint8_t head; // archaic, used by Windows NT-class OSes for flags - uint8_t signature; // 0x28 or 0x29 - uint8_t serial_0; // serial# - uint8_t serial_1; // serial# - uint8_t serial_2; // serial# - uint8_t serial_3; // serial# - uint8_t label[11]; // volume label - uint8_t system[8]; // filesystem ID -} EBPB, *PEBPB; - -/* - Extended BIOS Parameter Block structure (FAT32) -*/ -typedef struct _tagEBPB32 { - uint8_t fatsize_0; // big FAT size in sectors low byte - uint8_t fatsize_1; // - uint8_t fatsize_2; // - uint8_t fatsize_3; // big FAT size in sectors high byte - uint8_t extflags_l; // extended flags low byte - uint8_t extflags_h; // extended flags high byte - uint8_t fsver_l; // filesystem version (0x00) low byte - uint8_t fsver_h; // filesystem version (0x00) high byte - uint8_t root_0; // cluster of root dir, low byte - uint8_t root_1; // - uint8_t root_2; // - uint8_t root_3; // cluster of root dir, high byte - uint8_t fsinfo_l; // sector pointer to FSINFO within reserved area, low byte (2) - uint8_t fsinfo_h; // sector pointer to FSINFO within reserved area, high byte (0) - uint8_t bkboot_l; // sector pointer to backup boot sector within reserved area, low byte (6) - uint8_t bkboot_h; // sector pointer to backup boot sector within reserved area, high byte (0) - uint8_t reserved[12]; // reserved, should be 0 - - uint8_t unit; // int 13h drive# - uint8_t head; // archaic, used by Windows NT-class OSes for flags - uint8_t signature; // 0x28 or 0x29 - uint8_t serial_0; // serial# - uint8_t serial_1; // serial# - uint8_t serial_2; // serial# - uint8_t serial_3; // serial# - uint8_t label[11]; // volume label - uint8_t system[8]; // filesystem ID -} EBPB32, *PEBPB32; - -/* - Logical Boot Record structure (volume boot sector) -*/ -typedef struct _tagLBR { - uint8_t jump[3]; // JMP instruction - uint8_t oemid[8]; // OEM ID, space-padded - BPB bpb; // BIOS Parameter Block - union { - EBPB ebpb; // FAT12/16 Extended BIOS Parameter Block - EBPB32 ebpb32; // FAT32 Extended BIOS Parameter Block - } ebpb; - uint8_t code[420]; // boot sector code - uint8_t sig_55; // 0x55 signature byte - uint8_t sig_aa; // 0xaa signature byte -} LBR, *PLBR; - -/* - Volume information structure (Internal to DOSFS) -*/ -typedef struct _tagVOLINFO { - uint8_t unit; // unit on which this volume resides - uint8_t filesystem; // formatted filesystem - -// These two fields aren't very useful, so support for them has been commented out to -// save memory. (Note that the "system" tag is not actually used by DOS to determine -// filesystem type - that decision is made entirely on the basis of how many clusters -// the drive contains. DOSFS works the same way). -// See tag: OEMID in dosfs.c -// uint8_t oemid[9]; // OEM ID ASCIIZ -// uint8_t system[9]; // system ID ASCIIZ - uint8_t label[12]; // volume label ASCIIZ - uint32_t startsector; // starting sector of filesystem - uint8_t secperclus; // sectors per cluster - uint16_t reservedsecs; // reserved sectors - uint32_t numsecs; // number of sectors in volume - uint32_t secperfat; // sectors per FAT - uint16_t rootentries; // number of root dir entries - - uint32_t numclusters; // number of clusters on drive - - // The fields below are PHYSICAL SECTOR NUMBERS. - uint32_t fat1; // starting sector# of FAT copy 1 - uint32_t rootdir; // starting sector# of root directory (FAT12/FAT16) or cluster (FAT32) - uint32_t dataarea; // starting sector# of data area (cluster #2) -} VOLINFO, *PVOLINFO; - -/* - Flags in DIRINFO.flags -*/ -#define DFS_DI_BLANKENT 0x01 // Searching for blank entry - -/* - Directory search structure (Internal to DOSFS) -*/ -typedef struct _tagDIRINFO { - uint32_t currentcluster; // current cluster in dir - uint8_t currentsector; // current sector in cluster - uint8_t currententry; // current dir entry in sector - uint8_t *scratch; // ptr to user-supplied scratch buffer (one sector) - uint8_t flags; // internal DOSFS flags -} DIRINFO, *PDIRINFO; - -/* - File handle structure (Internal to DOSFS) -*/ -typedef struct _tagFILEINFO { - PVOLINFO volinfo; // VOLINFO used to open this file - uint32_t dirsector; // physical sector containing dir entry of this file - uint8_t diroffset; // # of this entry within the dir sector - uint8_t mode; // mode in which this file was opened - uint32_t firstcluster; // first cluster of file - uint32_t filelen; // byte length of file - - uint32_t cluster; // current cluster - uint32_t pointer; // current (BYTE) pointer -} FILEINFO, *PFILEINFO; - -/* - Get starting sector# of specified partition on drive #unit - NOTE: This code ASSUMES an MBR on the disk. - scratchsector should point to a SECTOR_SIZE scratch area - Returns 0xffffffff for any error. - If pactive is non-NULL, this function also returns the partition active flag. - If pptype is non-NULL, this function also returns the partition type. - If psize is non-NULL, this function also returns the partition size. -*/ -uint32_t DFS_GetPtnStart(uint8_t unit, uint8_t *scratchsector, uint8_t pnum, uint8_t *pactive, uint8_t *pptype, uint32_t *psize); - -/* - Retrieve volume info from BPB and store it in a VOLINFO structure - You must provide the unit and starting sector of the filesystem, and - a pointer to a sector buffer for scratch - Attempts to read BPB and glean information about the FS from that. - Returns 0 OK, nonzero for any error. -*/ -uint32_t DFS_GetVolInfo(uint8_t unit, uint8_t *scratchsector, uint32_t startsector, PVOLINFO volinfo); - -/* - Open a directory for enumeration by DFS_GetNextDirEnt - You must supply a populated VOLINFO (see DFS_GetVolInfo) - The empty string or a string containing only the directory separator are - considered to be the root directory. - Returns 0 OK, nonzero for any error. -*/ -uint32_t DFS_OpenDir(PVOLINFO volinfo, uint8_t *dirname, PDIRINFO dirinfo); - -/* - Get next entry in opened directory structure. Copies fields into the dirent - structure, updates dirinfo. Note that it is the _caller's_ responsibility to - handle the '.' and '..' entries. - A deleted file will be returned as a NULL entry (first char of filename=0) - by this code. Filenames beginning with 0x05 will be translated to 0xE5 - automatically. Long file name entries will be returned as NULL. - returns DFS_EOF if there are no more entries, DFS_OK if this entry is valid, - or DFS_ERRMISC for a media error -*/ -uint32_t DFS_GetNext(PVOLINFO volinfo, PDIRINFO dirinfo, PDIRENT dirent); - -/* - Open a file for reading or writing. You supply populated VOLINFO, a path to the file, - mode (DFS_READ or DFS_WRITE) and an empty fileinfo structure. You also need to - provide a pointer to a sector-sized scratch buffer. - Returns various DFS_* error states. If the result is DFS_OK, fileinfo can be used - to access the file from this point on. -*/ -uint32_t DFS_OpenFile(PVOLINFO volinfo, uint8_t *path, uint8_t mode, uint8_t *scratch, PFILEINFO fileinfo); - -/* - Read an open file - You must supply a prepopulated FILEINFO as provided by DFS_OpenFile, and a - pointer to a SECTOR_SIZE scratch buffer. - Note that returning DFS_EOF is not an error condition. This function updates the - successcount field with the number of bytes actually read. -*/ -uint32_t DFS_ReadFile(PFILEINFO fileinfo, uint8_t *scratch, uint8_t *buffer, uint32_t *successcount, uint32_t len); - -/* - Write an open file - You must supply a prepopulated FILEINFO as provided by DFS_OpenFile, and a - pointer to a SECTOR_SIZE scratch buffer. - This function updates the successcount field with the number of bytes actually written. -*/ -uint32_t DFS_WriteFile(PFILEINFO fileinfo, uint8_t *scratch, uint8_t *buffer, uint32_t *successcount, uint32_t len); - -/* - Seek file pointer to a given position - This function does not return status - refer to the fileinfo->pointer value - to see where the pointer wound up. - Requires a SECTOR_SIZE scratch buffer -*/ -void DFS_Seek(PFILEINFO fileinfo, uint32_t offset, uint8_t *scratch); - -/* - Delete a file - scratch must point to a sector-sized buffer -*/ -uint32_t DFS_UnlinkFile(PVOLINFO volinfo, uint8_t *path, uint8_t *scratch); - -/* - Fetch FAT entry for specified cluster number - You must provide a scratch buffer for one sector (SECTOR_SIZE) and a populated VOLINFO - Returns a FAT32 BAD_CLUSTER value for any error, otherwise the contents of the desired - FAT entry. - scratchcache should point to a UINT32. This variable caches the physical sector number - last read into the scratch buffer for performance enhancement reasons. -*/ -uint32_t DFS_GetFAT(PVOLINFO volinfo, uint8_t *scratch, uint32_t *scratchcache, uint32_t cluster); - -/* -// TK: added 2009-02-12 - Close a file - No original function of DosFS driver - It has no effect if writing to SD Card, it's only used by the DosFS wrapper in emulation -*/ -uint32_t DFS_Close(PFILEINFO fileinfo); - - - -// TK: added 2008-18-12 -// for caching - this feature has to be explicitely enabled, as it isn't reentrant -// and requires to use the same buffer pointer whenever reading a file -void DFS_CachingEnabledSet(uint8_t enable); - -// TK: added 2008-18-12 -// missing pendant to DFS_CanonicalToDir -char *DFS_DirToCanonical(char *dest, char *src); - - -// If we are building a host-emulation version, include host support -#ifdef HOSTVER -#include "hostemu.h" -#endif - - -#endif // _DOSFS_H diff --git a/flight/PiOS/STM32F10x/library.mk b/flight/PiOS/STM32F10x/library.mk index e0af6b637..fc493c84a 100644 --- a/flight/PiOS/STM32F10x/library.mk +++ b/flight/PiOS/STM32F10x/library.mk @@ -2,12 +2,50 @@ # Rules to (help) build the F10x device support. # -# -# Compiler options implied by the F1xx -# -CDEFS += -DARM_MATH_CM3 +# Directory containing this makefile +PIOS_DEVLIB := $(dir $(lastword $(MAKEFILE_LIST))) + +# Linker scripts path (contains board-specific scripts) +LINKER_SCRIPTS_PATH = $(PIOS_DEVLIB) + +# Compiler options implied by the F10x +CDEFS += -DSTM32F10X -DSTM32F10X_$(MODEL) +CDEFS += -DUSE_STDPERIPH_DRIVER +CDEFS += -DARM_MATH_CM3 +ARCHFLAGS += -mcpu=cortex-m3 + +# Board-specific startup files +ASRC += $(PIOS_DEVLIB)startup_stm32f10x_$(MODEL)$(MODEL_SUFFIX).S + +# PIOS device library source and includes +SRC += $(wildcard $(PIOS_DEVLIB)*.c) + +# CMSIS for the F1 +include $(PIOS)/Common/Libraries/CMSIS2/library.mk +CMSIS_DIR = $(PIOS_DEVLIB)Libraries/CMSIS/Core/CM3 +SRC += $(CMSIS_DIR)/core_cm3.c +SRC += $(CMSIS_DIR)/system_stm32f10x.c +EXTRAINCDIRS += $(CMSIS_DIR) + +# ST Peripheral library +PERIPHLIB = $(PIOS_DEVLIB)Libraries/STM32F10x_StdPeriph_Driver +SRC += $(wildcard $(PERIPHLIB)/src/*.c) +EXTRAINCDIRS += $(PERIPHLIB)/inc + +# ST USB Device library +USBDEVLIB = $(PIOS_DEVLIB)Libraries/STM32_USB-FS-Device_Driver +SRC += $(wildcard $(USBDEVLIB)/src/*.c) +EXTRAINCDIRS += $(USBDEVLIB)/inc # -# CMSIS for the F1 +# FreeRTOS # -include $(PIOSCOMMONLIB)/CMSIS2/library.mk +# If the application has included the generic FreeRTOS support, then add in +# the device-specific pieces of the code. +# +ifneq ($(FREERTOS_DIR),) + FREERTOS_PORTDIR := $(PIOS_DEVLIB)Libraries/FreeRTOS/Source + SRC += $(wildcard $(FREERTOS_PORTDIR)/portable/GCC/ARM_CM3/*.c) + SRC += $(wildcard $(FREERTOS_PORTDIR)/portable/MemMang/heap_1.c) + EXTRAINCDIRS += $(FREERTOS_PORTDIR)/portable/GCC/ARM_CM3 +endif diff --git a/flight/PiOS/STM32F10x/link_STM32103CB_AHRS_BL_sections.ld b/flight/PiOS/STM32F10x/link_STM32103CB_AHRS_BL_sections.ld deleted file mode 100644 index d411c3e4f..000000000 --- a/flight/PiOS/STM32F10x/link_STM32103CB_AHRS_BL_sections.ld +++ /dev/null @@ -1,56 +0,0 @@ -_estack = 0x20004FF0; - -/* Section Definitions */ -SECTIONS -{ - .text : - { - PROVIDE (pios_isr_vector_table_base = .); - KEEP(*(.isr_vector .isr_vector.*)) - *(.text .text.* .gnu.linkonce.t.*) - *(.glue_7t) *(.glue_7) - *(.rodata .rodata* .gnu.linkonce.r.*) - } > BL_FLASH - - .ARM.extab : - { - *(.ARM.extab* .gnu.linkonce.armextab.*) - } > BL_FLASH - - .ARM.exidx : - { - *(.ARM.exidx* .gnu.linkonce.armexidx.*) - } > BL_FLASH - - . = ALIGN(4); - _etext = .; - _sidata = .; - - .data : AT (_etext) - { - _sdata = .; - *(.data .data.*) - . = ALIGN(4); - _edata = . ; - } > SRAM - - /* .bss section which is used for uninitialized data */ - .bss (NOLOAD) : - { - _sbss = . ; - *(.bss .bss.*) - *(COMMON) - . = ALIGN(4); - _ebss = . ; - } > SRAM - - . = ALIGN(4); - _end = . ; - - .boardinfo : - { - . = ALIGN(4); - KEEP(*(.boardinfo)) - . = ALIGN(4); - } > BD_INFO -} diff --git a/flight/PiOS/STM32F10x/link_STM32103CB_AHRS_memory.ld b/flight/PiOS/STM32F10x/link_STM32103CB_AHRS_memory.ld deleted file mode 100644 index 9f7bf0f19..000000000 --- a/flight/PiOS/STM32F10x/link_STM32103CB_AHRS_memory.ld +++ /dev/null @@ -1,7 +0,0 @@ -MEMORY -{ - BL_FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 0x02000 - 0x00080 - BD_INFO (r) : ORIGIN = 0x08002000 - 0x80, LENGTH = 0x00080 - FLASH (rx) : ORIGIN = 0x08002000, LENGTH = 0x20000 - 0x02000 - SRAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x05000 -} diff --git a/flight/PiOS/STM32F10x/link_STM32103CB_AHRS_sections.ld b/flight/PiOS/STM32F10x/link_STM32103CB_AHRS_sections.ld deleted file mode 100644 index dd814f561..000000000 --- a/flight/PiOS/STM32F10x/link_STM32103CB_AHRS_sections.ld +++ /dev/null @@ -1,51 +0,0 @@ -PROVIDE(pios_board_info_blob = ORIGIN(BD_INFO)); - -_estack = 0x20004FF0; - -/* Section Definitions */ -SECTIONS -{ - .text : - { - PROVIDE (pios_isr_vector_table_base = .); - KEEP(*(.isr_vector .isr_vector.*)) - *(.text .text.* .gnu.linkonce.t.*) - *(.glue_7t) *(.glue_7) - *(.rodata .rodata* .gnu.linkonce.r.*) - } > FLASH - - .ARM.extab : - { - *(.ARM.extab* .gnu.linkonce.armextab.*) - } > FLASH - - .ARM.exidx : - { - *(.ARM.exidx* .gnu.linkonce.armexidx.*) - } > FLASH - - . = ALIGN(4); - _etext = .; - _sidata = .; - - .data : AT (_etext) - { - _sdata = .; - *(.data .data.*) - . = ALIGN(4); - _edata = . ; - } > SRAM - - /* .bss section which is used for uninitialized data */ - .bss (NOLOAD) : - { - _sbss = . ; - *(.bss .bss.*) - *(COMMON) - . = ALIGN(4); - _ebss = . ; - } > SRAM - - . = ALIGN(4); - _end = . ; -} diff --git a/flight/PiOS/STM32F10x/pios_adc.c b/flight/PiOS/STM32F10x/pios_adc.c index 66eb8f92e..2f5ed4198 100644 --- a/flight/PiOS/STM32F10x/pios_adc.c +++ b/flight/PiOS/STM32F10x/pios_adc.c @@ -28,6 +28,9 @@ */ #include "pios.h" + +#ifdef PIOS_INCLUDE_ADC + #include // Private types @@ -361,6 +364,8 @@ void PIOS_ADC_DMA_Handler(void) } } +#endif /* PIOS_INCLUDE_ADC */ + /** * @} * @} diff --git a/flight/PiOS/STM32F10x/pios_bl_helper.c b/flight/PiOS/STM32F10x/pios_bl_helper.c index 967c3c7e6..f8c8e1db3 100644 --- a/flight/PiOS/STM32F10x/pios_bl_helper.c +++ b/flight/PiOS/STM32F10x/pios_bl_helper.c @@ -28,9 +28,10 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include "pios.h" -#if defined(PIOS_INCLUDE_BL_HELPER) + +#ifdef PIOS_INCLUDE_BL_HELPER + #include #include "stm32f10x_flash.h" @@ -99,4 +100,5 @@ void PIOS_BL_HELPER_CRC_Ini() { RCC_AHBPeriphClockCmd(RCC_AHBPeriph_CRC, ENABLE); } -#endif + +#endif /* PIOS_INCLUDE_BL_HELPER */ diff --git a/flight/PiOS/STM32F10x/pios_debug.c b/flight/PiOS/STM32F10x/pios_debug.c index 18ea0071b..f7c9d6cf3 100644 --- a/flight/PiOS/STM32F10x/pios_debug.c +++ b/flight/PiOS/STM32F10x/pios_debug.c @@ -28,7 +28,6 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include "pios.h" // Global variables @@ -154,9 +153,9 @@ void PIOS_DEBUG_PinValue4BitL(uint8_t value) */ void PIOS_DEBUG_Panic(const char *msg) { -#ifdef PIOS_COM_DEBUG +#ifdef PIOS_INCLUDE_DEBUG_CONSOLE register int *lr asm("lr"); // Link-register holds the PC of the caller - PIOS_COM_SendFormattedStringNonBlocking(PIOS_COM_DEBUG, "\r%s @0x%x\r", msg, lr); + DEBUG_PRINTF(0, "\r%s @0x%x\r", msg, lr); #endif // Stay put diff --git a/flight/PiOS/STM32F10x/pios_delay.c b/flight/PiOS/STM32F10x/pios_delay.c index 7c04e2426..a61ab45f8 100644 --- a/flight/PiOS/STM32F10x/pios_delay.c +++ b/flight/PiOS/STM32F10x/pios_delay.c @@ -30,10 +30,9 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include -#if defined(PIOS_INCLUDE_DELAY) +#ifdef PIOS_INCLUDE_DELAY /* these should be defined by CMSIS, but they aren't */ #define DWT_CTRL (*(volatile uint32_t *)0xe0001000) @@ -167,7 +166,7 @@ uint32_t PIOS_DELAY_DiffuS(uint32_t raw) return diff / us_ticks; } -#endif +#endif /* PIOS_INCLUDE_DELAY */ /** * @} diff --git a/flight/PiOS/STM32F10x/pios_dsm.c b/flight/PiOS/STM32F10x/pios_dsm.c index b35560d5d..b7e3dcbca 100644 --- a/flight/PiOS/STM32F10x/pios_dsm.c +++ b/flight/PiOS/STM32F10x/pios_dsm.c @@ -28,11 +28,12 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include "pios.h" + +#ifdef PIOS_INCLUDE_DSM + #include "pios_dsm_priv.h" -#if defined(PIOS_INCLUDE_DSM) /* Forward Declarations */ static int32_t PIOS_DSM_Get(uint32_t rcvr_id, uint8_t channel); @@ -399,7 +400,7 @@ static void PIOS_DSM_Supervisor(uint32_t dsm_id) } } -#endif /* PIOS_INCLUDE_DSM */ +#endif /* PIOS_INCLUDE_DSM */ /** * @} diff --git a/flight/PiOS/STM32F10x/pios_eeprom.c b/flight/PiOS/STM32F10x/pios_eeprom.c index f604f417b..182e3f4ed 100644 --- a/flight/PiOS/STM32F10x/pios_eeprom.c +++ b/flight/PiOS/STM32F10x/pios_eeprom.c @@ -28,14 +28,13 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include -#include + +#ifdef PIOS_INCLUDE_FLASH_EEPROM + #include #include -#include - static struct pios_eeprom_cfg config; /** @@ -153,3 +152,5 @@ int32_t PIOS_EEPROM_Load(uint8_t *data, uint32_t len) return 0; } + +#endif /* PIOS_INCLUDE_FLASH_EEPROM */ diff --git a/flight/PiOS/STM32F10x/pios_exti.c b/flight/PiOS/STM32F10x/pios_exti.c index 9b8221bbe..9d1980bcc 100644 --- a/flight/PiOS/STM32F10x/pios_exti.c +++ b/flight/PiOS/STM32F10x/pios_exti.c @@ -29,10 +29,9 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include "pios.h" -#if defined(PIOS_INCLUDE_EXTI) +#ifdef PIOS_INCLUDE_EXTI /* Map EXTI line to full config */ #define EXTI_MAX_LINES 16 diff --git a/flight/PiOS/STM32F10x/pios_gpio.c b/flight/PiOS/STM32F10x/pios_gpio.c index 009780306..abedc162d 100644 --- a/flight/PiOS/STM32F10x/pios_gpio.c +++ b/flight/PiOS/STM32F10x/pios_gpio.c @@ -28,10 +28,9 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include "pios.h" -#if defined(PIOS_INCLUDE_GPIO) +#ifdef PIOS_INCLUDE_GPIO /* Private Function Prototypes */ @@ -93,7 +92,7 @@ void PIOS_GPIO_Toggle(uint8_t Pin) GPIO_PORT[Pin]->ODR ^= GPIO_PIN[Pin]; } -#endif +#endif /* PIOS_INCLUDE_GPIO */ /** * @} diff --git a/flight/PiOS/STM32F10x/pios_i2c.c b/flight/PiOS/STM32F10x/pios_i2c.c index 9fb8c529f..f61d00c14 100644 --- a/flight/PiOS/STM32F10x/pios_i2c.c +++ b/flight/PiOS/STM32F10x/pios_i2c.c @@ -28,10 +28,9 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include "pios.h" -#if defined(PIOS_INCLUDE_I2C) +#ifdef PIOS_INCLUDE_I2C #if defined(PIOS_INCLUDE_FREERTOS) #define USE_FREERTOS @@ -1146,7 +1145,7 @@ void PIOS_I2C_ER_IRQ_Handler(uint32_t i2c_id) } } -#endif +#endif /* PIOS_INCLUDE_I2C */ /** * @} diff --git a/flight/PiOS/STM32F10x/pios_iap.c b/flight/PiOS/STM32F10x/pios_iap.c index bb679f067..ae286e231 100644 --- a/flight/PiOS/STM32F10x/pios_iap.c +++ b/flight/PiOS/STM32F10x/pios_iap.c @@ -12,6 +12,8 @@ ****************************************************************************************/ #include +#ifdef PIOS_INCLUDE_IAP + /**************************************************************************************** * Private Definitions/Macros ****************************************************************************************/ @@ -120,3 +122,5 @@ void PIOS_IAP_WriteBootCount (uint16_t boot_count) { BKP_WriteBackupRegister ( IAP_BOOTCOUNT, boot_count ); } + +#endif /* PIOS_INCLUDE_IAP */ diff --git a/flight/PiOS/STM32F10x/pios_irq.c b/flight/PiOS/STM32F10x/pios_irq.c index 46ecf398b..77b3a3b7a 100644 --- a/flight/PiOS/STM32F10x/pios_irq.c +++ b/flight/PiOS/STM32F10x/pios_irq.c @@ -29,10 +29,9 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include "pios.h" -#if defined(PIOS_INCLUDE_IRQ) +#ifdef PIOS_INCLUDE_IRQ /* Private Function Prototypes */ @@ -90,7 +89,7 @@ int32_t PIOS_IRQ_Enable(void) return 0; } -#endif +#endif /* PIOS_INCLUDE_IRQ */ /** * @} diff --git a/flight/PiOS/STM32F10x/pios_led.c b/flight/PiOS/STM32F10x/pios_led.c index 1714a9165..79dad8a8c 100644 --- a/flight/PiOS/STM32F10x/pios_led.c +++ b/flight/PiOS/STM32F10x/pios_led.c @@ -28,10 +28,9 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include "pios.h" -#if defined(PIOS_INCLUDE_LED) +#ifdef PIOS_INCLUDE_LED #include @@ -148,7 +147,7 @@ void PIOS_LED_Toggle(uint32_t led_id) } } -#endif +#endif /* PIOS_INCLUDE_LED */ /** * @} diff --git a/flight/PiOS/STM32F10x/pios_ppm.c b/flight/PiOS/STM32F10x/pios_ppm.c index 64d1196f9..153b331a4 100644 --- a/flight/PiOS/STM32F10x/pios_ppm.c +++ b/flight/PiOS/STM32F10x/pios_ppm.c @@ -28,11 +28,12 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include "pios.h" + +#ifdef PIOS_INCLUDE_PPM + #include "pios_ppm_priv.h" -#if defined(PIOS_INCLUDE_PPM) /* Provide a RCVR driver */ static int32_t PIOS_PPM_Get(uint32_t rcvr_id, uint8_t channel); @@ -349,7 +350,7 @@ static void PIOS_PPM_Supervisor(uint32_t ppm_id) { ppm_dev->Fresh = FALSE; } -#endif +#endif /* PIOS_INCLUDE_PPM */ /** * @} diff --git a/flight/PiOS/STM32F10x/pios_ppm_out.c b/flight/PiOS/STM32F10x/pios_ppm_out.c index 3b6834e4d..6dd8c7915 100644 --- a/flight/PiOS/STM32F10x/pios_ppm_out.c +++ b/flight/PiOS/STM32F10x/pios_ppm_out.c @@ -28,11 +28,11 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include "pios.h" -#include "pios_ppm_out_priv.h" -#if defined(PIOS_INCLUDE_PPM_OUT) +#ifdef PIOS_INCLUDE_PPM_OUT + +#include "pios_ppm_out_priv.h" #define PIOS_PPM_OUT_MAX_DEVS 1 #define PIOS_PPM_OUT_MAX_CHANNELS 8 @@ -228,4 +228,4 @@ static void PIOS_PPM_OUT_tim_edge_cb (uint32_t tim_id, uint32_t context, uint8_t return; } -#endif // PIOS_PPM_OUT +#endif /* PIOS_INCLUDE_PPM_OUT */ diff --git a/flight/PiOS/STM32F10x/pios_pwm.c b/flight/PiOS/STM32F10x/pios_pwm.c index 4e7c98b14..b4996fc4d 100644 --- a/flight/PiOS/STM32F10x/pios_pwm.c +++ b/flight/PiOS/STM32F10x/pios_pwm.c @@ -28,11 +28,12 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include "pios.h" + +#ifdef PIOS_INCLUDE_PWM + #include "pios_pwm_priv.h" -#if defined(PIOS_INCLUDE_PWM) /* Provide a RCVR driver */ static int32_t PIOS_PWM_Get(uint32_t rcvr_id, uint8_t channel); @@ -274,7 +275,7 @@ static void PIOS_PWM_tim_edge_cb (uint32_t tim_id, uint32_t context, uint8_t cha } -#endif +#endif /* PIOS_INCLUDE_PWM */ /** * @} diff --git a/flight/PiOS/STM32F10x/pios_rtc.c b/flight/PiOS/STM32F10x/pios_rtc.c index b80a9e0d1..77f67a2f4 100644 --- a/flight/PiOS/STM32F10x/pios_rtc.c +++ b/flight/PiOS/STM32F10x/pios_rtc.c @@ -28,10 +28,10 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include "pios.h" -#if defined(PIOS_INCLUDE_RTC) +#ifdef PIOS_INCLUDE_RTC + #include #ifndef PIOS_RTC_PRESCALER @@ -121,7 +121,8 @@ void PIOS_RTC_irq_handler (void) RTC_ClearITPendingBit(RTC_IT_SEC); } } -#endif + +#endif /* PIOS_INCLUDE_RTC */ /** * @} diff --git a/flight/PiOS/STM32F10x/pios_servo.c b/flight/PiOS/STM32F10x/pios_servo.c index 46be375c2..5ec4a3550 100644 --- a/flight/PiOS/STM32F10x/pios_servo.c +++ b/flight/PiOS/STM32F10x/pios_servo.c @@ -28,8 +28,10 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include "pios.h" + +#ifdef PIOS_INCLUDE_SERVO + #include "pios_servo_priv.h" #include "pios_tim_priv.h" @@ -145,3 +147,5 @@ void PIOS_Servo_Set(uint8_t servo, uint16_t position) break; } } + +#endif /* PIOS_INCLUDE_SERVO */ diff --git a/flight/PiOS/STM32F10x/pios_spi.c b/flight/PiOS/STM32F10x/pios_spi.c index f8b2f0e63..320f6385d 100644 --- a/flight/PiOS/STM32F10x/pios_spi.c +++ b/flight/PiOS/STM32F10x/pios_spi.c @@ -35,7 +35,7 @@ #include -#if defined(PIOS_INCLUDE_SPI) +#ifdef PIOS_INCLUDE_SPI #include @@ -577,7 +577,7 @@ void PIOS_SPI_IRQ_Handler(uint32_t spi_id) } } -#endif +#endif /* PIOS_INCLUDE_SPI */ /** * @} diff --git a/flight/PiOS/STM32F10x/pios_sys.c b/flight/PiOS/STM32F10x/pios_sys.c index 6b59afbad..5a73d338b 100644 --- a/flight/PiOS/STM32F10x/pios_sys.c +++ b/flight/PiOS/STM32F10x/pios_sys.c @@ -29,10 +29,9 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include "pios.h" -#if defined(PIOS_INCLUDE_SYS) +#ifdef PIOS_INCLUDE_SYS /* Private Function Prototypes */ void NVIC_Configuration(void); @@ -212,7 +211,7 @@ void assert_failed(uint8_t * file, uint32_t line) } #endif -#endif +#endif /* PIOS_INCLUDE_SYS */ /** * @} diff --git a/flight/PiOS/STM32F10x/pios_tim.c b/flight/PiOS/STM32F10x/pios_tim.c index dcdd07670..d160c2c51 100644 --- a/flight/PiOS/STM32F10x/pios_tim.c +++ b/flight/PiOS/STM32F10x/pios_tim.c @@ -1,6 +1,7 @@ #include "pios.h" -#include "pios_tim.h" +#ifdef PIOS_INCLUDE_TIM + #include "pios_tim_priv.h" enum pios_tim_dev_magic { @@ -425,3 +426,4 @@ static void PIOS_TIM_8_CC_irq_handler (void) PIOS_TIM_generic_irq_handler (TIM8); } +#endif /* PIOS_INCLUDE_TIM */ diff --git a/flight/PiOS/STM32F10x/pios_usart.c b/flight/PiOS/STM32F10x/pios_usart.c index 041738f70..3054c09e3 100644 --- a/flight/PiOS/STM32F10x/pios_usart.c +++ b/flight/PiOS/STM32F10x/pios_usart.c @@ -28,10 +28,9 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include "pios.h" -#if defined(PIOS_INCLUDE_USART) +#ifdef PIOS_INCLUDE_USART #include @@ -324,7 +323,7 @@ static void PIOS_USART_generic_irq_handler(uint32_t usart_id) #endif /* PIOS_INCLUDE_FREERTOS */ } -#endif +#endif /* PIOS_INCLUDE_USART */ /** * @} diff --git a/flight/PiOS/STM32F10x/pios_usb.c b/flight/PiOS/STM32F10x/pios_usb.c index bdbc0adc7..6a5d676e5 100644 --- a/flight/PiOS/STM32F10x/pios_usb.c +++ b/flight/PiOS/STM32F10x/pios_usb.c @@ -28,16 +28,17 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include "pios.h" + +#ifdef PIOS_INCLUDE_USB + #include "usb_lib.h" #include "pios_usb_board_data.h" #include "stm32f10x.h" -#include "pios_usb.h" #include "pios_usb_priv.h" -#if defined(PIOS_INCLUDE_USB_HID) +#ifdef PIOS_INCLUDE_USB_HID /* Rx/Tx status */ static bool transfer_possible = false; @@ -66,7 +67,7 @@ static int32_t PIOS_USB_validate(struct pios_usb_dev * usb_dev) return 0; } -#if defined(PIOS_INCLUDE_FREERTOS) +#ifdef PIOS_INCLUDE_FREERTOS static struct pios_usb_dev * PIOS_USB_alloc(void) { struct pios_usb_dev * usb_dev; @@ -156,14 +157,14 @@ int32_t PIOS_USB_ChangeConnectionState(bool Connected) //TODO: Check SetEPRxValid(ENDP1); -#if defined(USB_LED_ON) +#ifdef USB_LED_ON USB_LED_ON; // turn the USB led on #endif } else { // Cable disconnected: disable transfers transfer_possible = false; -#if defined(USB_LED_OFF) +#ifdef USB_LED_OFF USB_LED_OFF; // turn the USB led off #endif } @@ -233,7 +234,9 @@ bool PIOS_USB_CheckAvailable(uint32_t id) return PIOS_USB_CableConnected(id) && transfer_possible; } -#endif +#endif /* PIOS_INCLUDE_USB_HID */ + +#endif /* PIOS_INCLUDE_USB */ /** * @} diff --git a/flight/PiOS/STM32F10x/pios_usb_cdc.c b/flight/PiOS/STM32F10x/pios_usb_cdc.c index abe4b7d3c..0da873966 100644 --- a/flight/PiOS/STM32F10x/pios_usb_cdc.c +++ b/flight/PiOS/STM32F10x/pios_usb_cdc.c @@ -29,12 +29,10 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include "pios.h" -#if defined(PIOS_INCLUDE_USB_CDC) +#ifdef PIOS_INCLUDE_USB_CDC -#include "pios_usb.h" #include "pios_usb_cdc_priv.h" #include "pios_usb_board_data.h" /* PIOS_BOARD_*_DATA_LENGTH */ @@ -417,4 +415,4 @@ static void PIOS_USB_CDC_CTRL_EP_IN_Callback(void) SetEPTxValid(usb_cdc_dev->cfg->data_tx_ep); } -#endif /* PIOS_INCLUDE_USB_CDC */ +#endif /* PIOS_INCLUDE_USB_CDC */ diff --git a/flight/PiOS/STM32F10x/pios_usb_hid.c b/flight/PiOS/STM32F10x/pios_usb_hid.c index 0047c7196..ba49ceb5a 100644 --- a/flight/PiOS/STM32F10x/pios_usb_hid.c +++ b/flight/PiOS/STM32F10x/pios_usb_hid.c @@ -29,12 +29,10 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include "pios.h" -#if defined(PIOS_INCLUDE_USB_HID) +#ifdef PIOS_INCLUDE_USB_HID -#include "pios_usb.h" #include "pios_usb_hid_priv.h" #include "pios_usb_board_data.h" /* PIOS_BOARD_*_DATA_LENGTH */ @@ -81,7 +79,7 @@ static bool PIOS_USB_HID_validate(struct pios_usb_hid_dev * usb_hid_dev) return (usb_hid_dev->magic == PIOS_USB_HID_DEV_MAGIC); } -#if defined(PIOS_INCLUDE_FREERTOS) +#ifdef PIOS_INCLUDE_FREERTOS static struct pios_usb_hid_dev * PIOS_USB_HID_alloc(void) { struct pios_usb_hid_dev * usb_hid_dev; @@ -193,7 +191,7 @@ static void PIOS_USB_HID_SendReport(struct pios_usb_hid_dev * usb_hid_dev) SetEPTxCount(usb_hid_dev->cfg->data_tx_ep, sizeof(usb_hid_dev->tx_packet_buffer)); SetEPTxValid(usb_hid_dev->cfg->data_tx_ep); -#if defined(PIOS_INCLUDE_FREERTOS) +#ifdef PIOS_INCLUDE_FREERTOS if (need_yield) { vPortYieldFromISR(); } @@ -354,7 +352,7 @@ static void PIOS_USB_HID_EP_OUT_Callback(void) SetEPRxStatus(usb_hid_dev->cfg->data_rx_ep, EP_RX_NAK); } -#if defined(PIOS_INCLUDE_FREERTOS) +#ifdef PIOS_INCLUDE_FREERTOS if (need_yield) { vPortYieldFromISR(); } diff --git a/flight/PiOS/STM32F10x/pios_usb_hid_istr.c b/flight/PiOS/STM32F10x/pios_usb_hid_istr.c index 89204d07f..e26dd0b4f 100644 --- a/flight/PiOS/STM32F10x/pios_usb_hid_istr.c +++ b/flight/PiOS/STM32F10x/pios_usb_hid_istr.c @@ -14,8 +14,11 @@ *******************************************************************************/ /* Includes ------------------------------------------------------------------*/ -#include "usb_lib.h" #include "pios.h" + +#ifdef PIOS_INCLUDE_USB + +#include "usb_lib.h" #include "pios_usb_hid_pwr.h" #include "pios_usb_hid_istr.h" #include "pios_usb_hid.h" @@ -330,3 +333,5 @@ u32 STM32_PCD_OTG_ISR_Handler(void) #endif /* STM32F10X_CL */ /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/ + +#endif /* PIOS_INCLUDE_USB */ diff --git a/flight/PiOS/STM32F10x/pios_usb_rctx.c b/flight/PiOS/STM32F10x/pios_usb_rctx.c index 3976eafc3..11e333295 100644 --- a/flight/PiOS/STM32F10x/pios_usb_rctx.c +++ b/flight/PiOS/STM32F10x/pios_usb_rctx.c @@ -28,12 +28,10 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include "pios.h" -#if defined(PIOS_INCLUDE_USB_RCTX) +#ifdef PIOS_INCLUDE_USB_RCTX -#include "pios_usb.h" #include "pios_usb_rctx_priv.h" /* STM32 USB Library Definitions */ @@ -62,7 +60,7 @@ static bool PIOS_USB_RCTX_validate(struct pios_usb_rctx_dev * usb_rctx_dev) return (usb_rctx_dev->magic == PIOS_USB_RCTX_DEV_MAGIC); } -#if defined(PIOS_INCLUDE_FREERTOS) +#ifdef PIOS_INCLUDE_FREERTOS static struct pios_usb_rctx_dev * PIOS_USB_RCTX_alloc(void) { struct pios_usb_rctx_dev * usb_rctx_dev; @@ -126,7 +124,7 @@ out_fail: static void PIOS_USB_RCTX_SendReport(struct pios_usb_rctx_dev * usb_rctx_dev) { -#if defined(PIOS_INCLUDE_FREERTOS) +#ifdef PIOS_INCLUDE_FREERTOS bool need_yield = false; #endif /* PIOS_INCLUDE_FREERTOS */ @@ -139,7 +137,7 @@ static void PIOS_USB_RCTX_SendReport(struct pios_usb_rctx_dev * usb_rctx_dev) SetEPTxCount(usb_rctx_dev->cfg->data_tx_ep, sizeof(usb_rctx_dev->report)); SetEPTxValid(usb_rctx_dev->cfg->data_tx_ep); -#if defined(PIOS_INCLUDE_FREERTOS) +#ifdef PIOS_INCLUDE_FREERTOS if (need_yield) { vPortYieldFromISR(); } @@ -208,4 +206,4 @@ void PIOS_USB_RCTX_Update(uint32_t usbrctx_id, const uint16_t channel[], const i PIOS_USB_RCTX_SendReport(usb_rctx_dev); } -#endif /* PIOS_INCLUDE_USB_RCTX */ +#endif /* PIOS_INCLUDE_USB_RCTX */ diff --git a/flight/PiOS/STM32F10x/pios_usbhook.c b/flight/PiOS/STM32F10x/pios_usbhook.c index a691d8447..0fd6e2e5b 100644 --- a/flight/PiOS/STM32F10x/pios_usbhook.c +++ b/flight/PiOS/STM32F10x/pios_usbhook.c @@ -29,6 +29,9 @@ */ #include "pios.h" + +#ifdef PIOS_INCLUDE_USB + #include "pios_usb.h" /* PIOS_USB_* */ #include "pios_usbhook.h" #include "pios_usb_defs.h" /* struct usb_* */ @@ -549,4 +552,6 @@ static const uint8_t *PIOS_USBHOOK_GetProtocolValue(uint16_t Length) } } +#endif /* PIOS_INCLUDE_USB */ + /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/ diff --git a/flight/PiOS/STM32F10x/pios_wdg.c b/flight/PiOS/STM32F10x/pios_wdg.c index 312807e26..0f3e9d600 100644 --- a/flight/PiOS/STM32F10x/pios_wdg.c +++ b/flight/PiOS/STM32F10x/pios_wdg.c @@ -33,6 +33,9 @@ */ #include "pios.h" + +#ifdef PIOS_INCLUDE_WDG + #include "stm32f10x_iwdg.h" #include "stm32f10x_dbgmcu.h" @@ -173,3 +176,5 @@ void PIOS_WDG_Clear(void) IWDG_ReloadCounter(); #endif } + +#endif /* PIOS_INCLUDE_WDG */ diff --git a/flight/PiOS/STM32F4xx/library.mk b/flight/PiOS/STM32F4xx/library.mk index cbd65e53f..531dbbfb2 100644 --- a/flight/PiOS/STM32F4xx/library.mk +++ b/flight/PiOS/STM32F4xx/library.mk @@ -2,64 +2,48 @@ # Rules to (help) build the F4xx device support. # -# # Directory containing this makefile -# -PIOS_DEVLIB := $(dir $(lastword $(MAKEFILE_LIST))) +PIOS_DEVLIB := $(dir $(lastword $(MAKEFILE_LIST))) -# # Hardcoded linker script names for now -# -LINKER_SCRIPTS_APP = $(PIOS_DEVLIB)/link_STM32F4xx_OP_memory.ld \ - $(PIOS_DEVLIB)/link_STM32F4xx_sections.ld +LINKER_SCRIPTS_APP = $(PIOS_DEVLIB)link_STM32F4xx_OP_memory.ld \ + $(PIOS_DEVLIB)link_STM32F4xx_sections.ld +LINKER_SCRIPTS_BL = $(PIOS_DEVLIB)link_STM32F4xx_BL_memory.ld \ + $(PIOS_DEVLIB)link_STM32F4xx_sections.ld -LINKER_SCRIPTS_BL = $(PIOS_DEVLIB)/link_STM32F4xx_BL_memory.ld \ - $(PIOS_DEVLIB)/link_STM32F4xx_sections.ld - -# # Compiler options implied by the F4xx -# -CDEFS += -DSTM32F4XX -CDEFS += -DHSE_VALUE=$(OSCILLATOR_FREQ) -CDEFS += -DUSE_STDPERIPH_DRIVER -CDEFS += -DARM_MATH_CM4 -D__FPU_PRESENT=1 -ARCHFLAGS += -mcpu=cortex-m4 -march=armv7e-m -mfpu=fpv4-sp-d16 -mfloat-abi=hard +CDEFS += -DSTM32F4XX +CDEFS += -DSYSCLK_FREQ=$(SYSCLK_FREQ) +CDEFS += -DHSE_VALUE=$(OSCILLATOR_FREQ) +CDEFS += -DUSE_STDPERIPH_DRIVER +CDEFS += -DARM_MATH_CM4 -D__FPU_PRESENT=1 +ARCHFLAGS += -mcpu=cortex-m4 -march=armv7e-m -mfpu=fpv4-sp-d16 -mfloat-abi=hard -# # PIOS device library source and includes -# -SRC += $(wildcard $(PIOS_DEVLIB)*.c) -EXTRAINCDIRS += $(PIOS_DEVLIB)/inc +SRC += $(wildcard $(PIOS_DEVLIB)*.c) +EXTRAINCDIRS += $(PIOS_DEVLIB)inc -# # CMSIS for the F4 -# -include $(PIOSCOMMONLIB)/CMSIS2/library.mk -CMSIS2_DEVICEDIR := $(PIOS_DEVLIB)/Libraries/CMSIS2/Device/ST/STM32F4xx -SRC += $(wildcard $(CMSIS2_DEVICEDIR)/Source/$(BOARD_NAME)/*.c) -EXTRAINCDIRS += $(CMSIS2_DEVICEDIR)/Include +include $(PIOSCOMMON)/Libraries/CMSIS2/library.mk +CMSIS2_DEVICEDIR := $(PIOS_DEVLIB)Libraries/CMSIS2/Device/ST/STM32F4xx +SRC += $(wildcard $(CMSIS2_DEVICEDIR)/Source/$(BOARD_NAME)/*.c) +EXTRAINCDIRS += $(CMSIS2_DEVICEDIR)/Include -# # ST Peripheral library -# -PERIPHLIB = $(PIOS_DEVLIB)/Libraries/STM32F4xx_StdPeriph_Driver -SRC += $(wildcard $(PERIPHLIB)/src/*.c) -EXTRAINCDIRS += $(PERIPHLIB)/inc +PERIPHLIB = $(PIOS_DEVLIB)Libraries/STM32F4xx_StdPeriph_Driver +SRC += $(wildcard $(PERIPHLIB)/src/*.c) +EXTRAINCDIRS += $(PERIPHLIB)/inc -# # ST USB OTG library -# -USBOTGLIB = $(PIOS_DEVLIB)/Libraries/STM32_USB_OTG_Driver -USBOTGLIB_SRC = usb_core.c usb_dcd.c usb_dcd_int.c -SRC += $(addprefix $(USBOTGLIB)/src/,$(USBOTGLIB_SRC)) -EXTRAINCDIRS += $(USBOTGLIB)/inc +USBOTGLIB = $(PIOS_DEVLIB)Libraries/STM32_USB_OTG_Driver +USBOTGLIB_SRC = usb_core.c usb_dcd.c usb_dcd_int.c +SRC += $(addprefix $(USBOTGLIB)/src/,$(USBOTGLIB_SRC)) +EXTRAINCDIRS += $(USBOTGLIB)/inc -# # ST USB Device library -# -USBDEVLIB = $(PIOS_DEVLIB)/Libraries/STM32_USB_Device_Library -SRC += $(wildcard $(USBDEVLIB)/Core/src/*.c) -EXTRAINCDIRS += $(USBDEVLIB)/Core/inc +USBDEVLIB = $(PIOS_DEVLIB)Libraries/STM32_USB_Device_Library +SRC += $(wildcard $(USBDEVLIB)/Core/src/*.c) +EXTRAINCDIRS += $(USBDEVLIB)/Core/inc # # FreeRTOS @@ -68,7 +52,8 @@ EXTRAINCDIRS += $(USBDEVLIB)/Core/inc # the device-specific pieces of the code. # ifneq ($(FREERTOS_DIR),) -FREERTOS_PORTDIR := $(PIOS_DEVLIB)/Libraries/FreeRTOS/Source -SRC += $(wildcard $(FREERTOS_PORTDIR)/portable/GCC/ARM_CM4F/*.c) -EXTRAINCDIRS += $(FREERTOS_PORTDIR)/portable/GCC/ARM_CM4F + FREERTOS_PORTDIR := $(PIOS_DEVLIB)Libraries/FreeRTOS/Source + SRC += $(wildcard $(FREERTOS_PORTDIR)/portable/GCC/ARM_CM4F/*.c) + EXTRAINCDIRS += $(FREERTOS_PORTDIR)/portable/GCC/ARM_CM4F + include $(PIOSCOMMON)/Libraries/msheap/library.mk endif diff --git a/flight/PiOS/STM32F4xx/pios_adc.c b/flight/PiOS/STM32F4xx/pios_adc.c index a1320a1be..7131e440a 100644 --- a/flight/PiOS/STM32F4xx/pios_adc.c +++ b/flight/PiOS/STM32F4xx/pios_adc.c @@ -43,9 +43,11 @@ */ #include "pios.h" + +#ifdef PIOS_INCLUDE_ADC + #include -#if defined(PIOS_INCLUDE_ADC) #if !defined(PIOS_ADC_MAX_SAMPLES) #define PIOS_ADC_MAX_SAMPLES 0 diff --git a/flight/PiOS/STM32F4xx/pios_bl_helper.c b/flight/PiOS/STM32F4xx/pios_bl_helper.c index 05de4a305..afa59b3e5 100644 --- a/flight/PiOS/STM32F4xx/pios_bl_helper.c +++ b/flight/PiOS/STM32F4xx/pios_bl_helper.c @@ -28,9 +28,10 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include "pios.h" -#if defined(PIOS_INCLUDE_BL_HELPER) + +#ifdef PIOS_INCLUDE_BL_HELPER + #include #include "stm32f4xx_flash.h" #include @@ -192,4 +193,5 @@ void PIOS_BL_HELPER_FLASH_Read_Description(uint8_t * array, uint8_t size) void PIOS_BL_HELPER_CRC_Ini() { } -#endif + +#endif /* PIOS_INCLUDE_BL_HELPER */ diff --git a/flight/PiOS/STM32F4xx/pios_debug.c b/flight/PiOS/STM32F4xx/pios_debug.c index 339b9d427..51efbc188 100644 --- a/flight/PiOS/STM32F4xx/pios_debug.c +++ b/flight/PiOS/STM32F4xx/pios_debug.c @@ -28,7 +28,6 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include "pios.h" // Global variables @@ -154,9 +153,9 @@ void PIOS_DEBUG_PinValue4BitL(uint8_t value) */ void PIOS_DEBUG_Panic(const char *msg) { -#ifdef PIOS_COM_DEBUG +#ifdef PIOS_INCLUDE_DEBUG_CONSOLE register int *lr asm("lr"); // Link-register holds the PC of the caller - PIOS_COM_SendFormattedStringNonBlocking(PIOS_COM_DEBUG, "\r%s @0x%x\r", msg, lr); + DEBUG_PRINTF(0, "\r%s @0x%x\r", msg, lr); #endif // Stay put diff --git a/flight/PiOS/STM32F4xx/pios_delay.c b/flight/PiOS/STM32F4xx/pios_delay.c index 947998c3f..5faeef2c7 100644 --- a/flight/PiOS/STM32F4xx/pios_delay.c +++ b/flight/PiOS/STM32F4xx/pios_delay.c @@ -30,10 +30,9 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include -#if defined(PIOS_INCLUDE_DELAY) +#ifdef PIOS_INCLUDE_DELAY /* these should be defined by CMSIS, but they aren't */ #define DWT_CTRL (*(volatile uint32_t *)0xe0001000) @@ -167,7 +166,7 @@ uint32_t PIOS_DELAY_DiffuS(uint32_t raw) return diff / us_ticks; } -#endif +#endif /* PIOS_INCLUDE_DELAY */ /** * @} diff --git a/flight/PiOS/STM32F4xx/pios_dsm.c b/flight/PiOS/STM32F4xx/pios_dsm.c index 7c5348560..4bcc0187f 100644 --- a/flight/PiOS/STM32F4xx/pios_dsm.c +++ b/flight/PiOS/STM32F4xx/pios_dsm.c @@ -28,13 +28,13 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include "pios.h" + +#ifdef PIOS_INCLUDE_DSM + #include "pios_dsm_priv.h" -#if defined(PIOS_INCLUDE_DSM) - -#if !defined(PIOS_INCLUDE_RTC) +#ifndef PIOS_INCLUDE_RTC #error PIOS_INCLUDE_RTC must be used to use DSM #endif @@ -401,7 +401,7 @@ static void PIOS_DSM_Supervisor(uint32_t dsm_id) } } -#endif /* PIOS_INCLUDE_DSM */ +#endif /* PIOS_INCLUDE_DSM */ /** * @} diff --git a/flight/PiOS/STM32F4xx/pios_exti.c b/flight/PiOS/STM32F4xx/pios_exti.c index 45efb2ae5..3dc1e1158 100644 --- a/flight/PiOS/STM32F4xx/pios_exti.c +++ b/flight/PiOS/STM32F4xx/pios_exti.c @@ -29,10 +29,9 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include "pios.h" -#if defined(PIOS_INCLUDE_EXTI) +#ifdef PIOS_INCLUDE_EXTI /* Map EXTI line to full config */ #define EXTI_MAX_LINES 16 diff --git a/flight/PiOS/STM32F4xx/pios_flash_internal.c b/flight/PiOS/STM32F4xx/pios_flash_internal.c index 534b911fd..fceae8038 100644 --- a/flight/PiOS/STM32F4xx/pios_flash_internal.c +++ b/flight/PiOS/STM32F4xx/pios_flash_internal.c @@ -26,7 +26,7 @@ #include "pios.h" -#if defined(PIOS_INCLUDE_FLASH_INTERNAL) +#ifdef PIOS_INCLUDE_FLASH_INTERNAL #include "stm32f4xx_flash.h" #include "pios_flash_internal_priv.h" @@ -334,4 +334,4 @@ const struct pios_flash_driver pios_internal_flash_driver = { .read_data = PIOS_Flash_Internal_ReadData, }; -#endif /* defined(PIOS_INCLUDE_FLASH_INTERNAL) */ +#endif /* PIOS_INCLUDE_FLASH_INTERNAL */ diff --git a/flight/PiOS/STM32F4xx/pios_gpio.c b/flight/PiOS/STM32F4xx/pios_gpio.c index 88f342a74..18c083d9b 100644 --- a/flight/PiOS/STM32F4xx/pios_gpio.c +++ b/flight/PiOS/STM32F4xx/pios_gpio.c @@ -28,10 +28,9 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include "pios.h" -#if defined(PIOS_INCLUDE_GPIO) +#ifdef PIOS_INCLUDE_GPIO /* Private Function Prototypes */ @@ -92,7 +91,7 @@ void PIOS_GPIO_Toggle(uint8_t Pin) GPIO_ToggleBits(GPIO_PORT[Pin], GPIO_PIN[Pin]); } -#endif +#endif /* PIOS_INCLUDE_GPIO */ /** * @} diff --git a/flight/PiOS/STM32F4xx/pios_i2c.c b/flight/PiOS/STM32F4xx/pios_i2c.c index bb2a1bfc1..9ceb72337 100644 --- a/flight/PiOS/STM32F4xx/pios_i2c.c +++ b/flight/PiOS/STM32F4xx/pios_i2c.c @@ -33,12 +33,11 @@ * be merged. */ -/* Project Includes */ #include "pios.h" -#if defined(PIOS_INCLUDE_I2C) +#ifdef PIOS_INCLUDE_I2C -#if defined(PIOS_INCLUDE_FREERTOS) +#ifdef PIOS_INCLUDE_FREERTOS #define USE_FREERTOS #endif @@ -1232,7 +1231,7 @@ void PIOS_I2C_ER_IRQ_Handler(uint32_t i2c_id) } } -#endif +#endif /* PIOS_INCLUDE_I2C */ /** * @} diff --git a/flight/PiOS/STM32F4xx/pios_iap.c b/flight/PiOS/STM32F4xx/pios_iap.c index ca4ef89ba..e08ccd09a 100644 --- a/flight/PiOS/STM32F4xx/pios_iap.c +++ b/flight/PiOS/STM32F4xx/pios_iap.c @@ -33,6 +33,8 @@ ****************************************************************************************/ #include +#ifdef PIOS_INCLUDE_IAP + /**************************************************************************************** * Private Definitions/Macros ****************************************************************************************/ @@ -140,3 +142,5 @@ void PIOS_IAP_WriteBootCount (uint16_t boot_count) { RTC_WriteBackupRegister ( IAP_BOOTCOUNT, boot_count ); } + +#endif /* PIOS_INCLUDE_IAP */ diff --git a/flight/PiOS/STM32F4xx/pios_irq.c b/flight/PiOS/STM32F4xx/pios_irq.c index b556931bc..d14120829 100644 --- a/flight/PiOS/STM32F4xx/pios_irq.c +++ b/flight/PiOS/STM32F4xx/pios_irq.c @@ -32,10 +32,9 @@ * @todo This should be shared with the F1xx code. */ -/* Project Includes */ #include "pios.h" -#if defined(PIOS_INCLUDE_IRQ) +#ifdef PIOS_INCLUDE_IRQ /* Private Function Prototypes */ @@ -93,7 +92,7 @@ int32_t PIOS_IRQ_Enable(void) return 0; } -#endif +#endif /* PIOS_INCLUDE_IRQ */ /** * @} diff --git a/flight/PiOS/STM32F4xx/pios_led.c b/flight/PiOS/STM32F4xx/pios_led.c index 1f7fd6365..7ff5dec42 100644 --- a/flight/PiOS/STM32F4xx/pios_led.c +++ b/flight/PiOS/STM32F4xx/pios_led.c @@ -28,10 +28,9 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include "pios.h" -#if defined(PIOS_INCLUDE_LED) +#ifdef PIOS_INCLUDE_LED #include @@ -166,7 +165,7 @@ void PIOS_LED_Toggle(uint32_t led_id) } } -#endif +#endif /* PIOS_INCLUDE_LED */ /** * @} diff --git a/flight/PiOS/STM32F4xx/pios_overo.c b/flight/PiOS/STM32F4xx/pios_overo.c index c535d413e..2de75591a 100644 --- a/flight/PiOS/STM32F4xx/pios_overo.c +++ b/flight/PiOS/STM32F4xx/pios_overo.c @@ -31,6 +31,8 @@ #include +#ifdef PIOS_INCLUDE_OVERO + /** * Configures the SPI device to use a double buffered DMA for transferring * data. At the end of each transfer (NSS goes high) it makes sure to reset @@ -38,7 +40,7 @@ * buffer */ -#if defined(PIOS_INCLUDE_SPI) +#ifdef PIOS_INCLUDE_SPI #include @@ -368,7 +370,9 @@ static void PIOS_OVERO_RxStart(uint32_t overo_id, uint16_t rx_bytes_avail) {}; #endif /* PIOS_INCLUDE_FREERTOS */ -#endif +#endif /* PIOS_INCLUDE_SPI */ + +#endif /* PIOS_INCLUDE_OVERO */ /** * @} diff --git a/flight/PiOS/STM32F4xx/pios_ppm.c b/flight/PiOS/STM32F4xx/pios_ppm.c index e17b342b7..3040287da 100644 --- a/flight/PiOS/STM32F4xx/pios_ppm.c +++ b/flight/PiOS/STM32F4xx/pios_ppm.c @@ -28,11 +28,11 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include "pios.h" -#include "pios_ppm_priv.h" -#if defined(PIOS_INCLUDE_PPM) +#ifdef PIOS_INCLUDE_PPM + +#include "pios_ppm_priv.h" /* Provide a RCVR driver */ static int32_t PIOS_PPM_Get(uint32_t rcvr_id, uint8_t channel); @@ -349,7 +349,7 @@ static void PIOS_PPM_Supervisor(uint32_t ppm_id) { ppm_dev->Fresh = false; } -#endif +#endif /* PIOS_INCLUDE_PPM */ /** * @} diff --git a/flight/PiOS/STM32F4xx/pios_pwm.c b/flight/PiOS/STM32F4xx/pios_pwm.c index 5bbec32aa..4f7f6c942 100644 --- a/flight/PiOS/STM32F4xx/pios_pwm.c +++ b/flight/PiOS/STM32F4xx/pios_pwm.c @@ -28,11 +28,11 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include "pios.h" -#include "pios_pwm_priv.h" -#if defined(PIOS_INCLUDE_PWM) +#ifdef PIOS_INCLUDE_PWM + +#include "pios_pwm_priv.h" /* Provide a RCVR driver */ static int32_t PIOS_PWM_Get(uint32_t rcvr_id, uint8_t channel); @@ -274,7 +274,7 @@ static void PIOS_PWM_tim_edge_cb (uint32_t tim_id, uint32_t context, uint8_t cha } -#endif +#endif /* PIOS_INCLUDE_PWM */ /** * @} diff --git a/flight/PiOS/STM32F4xx/pios_rtc.c b/flight/PiOS/STM32F4xx/pios_rtc.c index cc2de2ce2..e5b2e64ab 100644 --- a/flight/PiOS/STM32F4xx/pios_rtc.c +++ b/flight/PiOS/STM32F4xx/pios_rtc.c @@ -28,10 +28,10 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include "pios.h" -#if defined(PIOS_INCLUDE_RTC) +#ifdef PIOS_INCLUDE_RTC + #include #ifndef PIOS_RTC_PRESCALER @@ -130,7 +130,8 @@ void PIOS_RTC_irq_handler (void) if (EXTI_GetITStatus(EXTI_Line22) != RESET) EXTI_ClearITPendingBit(EXTI_Line22); } -#endif + +#endif /* PIOS_INCLUDE_RTC */ /** * @} diff --git a/flight/PiOS/STM32F4xx/pios_servo.c b/flight/PiOS/STM32F4xx/pios_servo.c index 05188d563..5c5d6ef52 100644 --- a/flight/PiOS/STM32F4xx/pios_servo.c +++ b/flight/PiOS/STM32F4xx/pios_servo.c @@ -28,8 +28,10 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include "pios.h" + +#ifdef PIOS_INCLUDE_SERVO + #include "pios_servo_priv.h" #include "pios_tim_priv.h" @@ -153,3 +155,5 @@ void PIOS_Servo_Set(uint8_t servo, uint16_t position) break; } } + +#endif /* PIOS_INCLUDE_SERVO */ diff --git a/flight/PiOS/STM32F4xx/pios_spi.c b/flight/PiOS/STM32F4xx/pios_spi.c index 87a8e0e9e..2bd07284a 100644 --- a/flight/PiOS/STM32F4xx/pios_spi.c +++ b/flight/PiOS/STM32F4xx/pios_spi.c @@ -38,7 +38,7 @@ */ #include -#if defined(PIOS_INCLUDE_SPI) +#ifdef PIOS_INCLUDE_SPI #include @@ -659,7 +659,7 @@ void PIOS_SPI_IRQ_Handler(uint32_t spi_id) } } -#endif +#endif /* PIOS_INCLUDE_SPI */ /** * @} diff --git a/flight/PiOS/STM32F4xx/pios_sys.c b/flight/PiOS/STM32F4xx/pios_sys.c index 1bb0a090b..a25e01182 100644 --- a/flight/PiOS/STM32F4xx/pios_sys.c +++ b/flight/PiOS/STM32F4xx/pios_sys.c @@ -29,10 +29,9 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include "pios.h" -#if defined(PIOS_INCLUDE_SYS) +#ifdef PIOS_INCLUDE_SYS /* Private Function Prototypes */ void NVIC_Configuration(void); @@ -320,7 +319,7 @@ void assert_failed(uint8_t * file, uint32_t line) } #endif -#endif +#endif /* PIOS_INCLUDE_SYS */ /** * @} diff --git a/flight/PiOS/STM32F4xx/pios_tim.c b/flight/PiOS/STM32F4xx/pios_tim.c index 129e88a86..4f3828d68 100644 --- a/flight/PiOS/STM32F4xx/pios_tim.c +++ b/flight/PiOS/STM32F4xx/pios_tim.c @@ -31,7 +31,8 @@ #include "pios.h" -#include "pios_tim.h" +#ifdef PIOS_INCLUDE_TIM + #include "pios_tim_priv.h" enum pios_tim_dev_magic { @@ -465,6 +466,8 @@ static void PIOS_TIM8_TRG_COM_TIM14_IRQHandler (void) } } +#endif /* PIOS_INCLUDE_TIM */ + /** * @} * @} diff --git a/flight/PiOS/STM32F4xx/pios_usart.c b/flight/PiOS/STM32F4xx/pios_usart.c index 2fe780e48..8080cbb69 100644 --- a/flight/PiOS/STM32F4xx/pios_usart.c +++ b/flight/PiOS/STM32F4xx/pios_usart.c @@ -32,10 +32,9 @@ * @todo This is virtually identical to the F1xx driver and should be merged. */ -/* Project Includes */ #include "pios.h" -#if defined(PIOS_INCLUDE_USART) +#ifdef PIOS_INCLUDE_USART #include @@ -350,7 +349,7 @@ static void PIOS_USART_generic_irq_handler(uint32_t usart_id) #endif /* PIOS_INCLUDE_FREERTOS */ } -#endif +#endif /* PIOS_INCLUDE_USART */ /** * @} diff --git a/flight/PiOS/STM32F4xx/pios_usb.c b/flight/PiOS/STM32F4xx/pios_usb.c index ae74d0e89..50ae0837f 100644 --- a/flight/PiOS/STM32F4xx/pios_usb.c +++ b/flight/PiOS/STM32F4xx/pios_usb.c @@ -28,14 +28,14 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include "pios.h" + +#ifdef PIOS_INCLUDE_USB + #include "usb_core.h" #include "pios_usb_board_data.h" -#include "pios_usb.h" #include "pios_usb_priv.h" -#if defined(PIOS_INCLUDE_USB) /* Rx/Tx status */ static uint8_t transfer_possible = 0; @@ -261,7 +261,7 @@ void USB_OTG_BSP_TimerIRQ (void) } -#endif /* PIOS_INCLUDE_USB */ +#endif /* PIOS_INCLUDE_USB */ /** * @} diff --git a/flight/PiOS/STM32F4xx/pios_usb_cdc.c b/flight/PiOS/STM32F4xx/pios_usb_cdc.c index c26997ccd..30151330e 100644 --- a/flight/PiOS/STM32F4xx/pios_usb_cdc.c +++ b/flight/PiOS/STM32F4xx/pios_usb_cdc.c @@ -29,12 +29,10 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include "pios.h" -#if defined(PIOS_INCLUDE_USB_CDC) +#ifdef PIOS_INCLUDE_USB_CDC -#include "pios_usb.h" #include "pios_usb_cdc_priv.h" #include "pios_usb_board_data.h" /* PIOS_BOARD_*_DATA_LENGTH */ @@ -398,4 +396,4 @@ static void PIOS_USB_CDC_CTRL_EP_IN_Callback(void) SetEPTxValid(usb_cdc_dev->cfg->data_tx_ep); } -#endif /* PIOS_INCLUDE_USB_CDC */ +#endif /* PIOS_INCLUDE_USB_CDC */ diff --git a/flight/PiOS/STM32F4xx/pios_usb_hid.c b/flight/PiOS/STM32F4xx/pios_usb_hid.c index 4fa50960c..88f45978b 100644 --- a/flight/PiOS/STM32F4xx/pios_usb_hid.c +++ b/flight/PiOS/STM32F4xx/pios_usb_hid.c @@ -29,12 +29,10 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include "pios.h" -#if defined(PIOS_INCLUDE_USB_HID) +#ifdef PIOS_INCLUDE_USB_HID -#include "pios_usb.h" #include "pios_usb_hid_priv.h" #include "pios_usb_board_data.h" /* PIOS_BOARD_*_DATA_LENGTH */ #include "pios_usbhook.h" /* PIOS_USBHOOK_* */ @@ -525,4 +523,4 @@ static bool PIOS_USB_HID_EP_OUT_Callback(uint32_t usb_hid_id, uint8_t epnum, uin return rc; } -#endif /* PIOS_INCLUDE_USB_HID */ +#endif /* PIOS_INCLUDE_USB_HID */ diff --git a/flight/PiOS/STM32F4xx/pios_usbhook.c b/flight/PiOS/STM32F4xx/pios_usbhook.c index 08653a74a..fa7b8284b 100644 --- a/flight/PiOS/STM32F4xx/pios_usbhook.c +++ b/flight/PiOS/STM32F4xx/pios_usbhook.c @@ -29,6 +29,9 @@ */ #include "pios.h" + +#ifdef PIOS_INCLUDE_USB + #include "pios_usb.h" /* PIOS_USB_* */ #include "pios_usbhook.h" #include "pios_usb_defs.h" /* struct usb_* */ @@ -470,3 +473,4 @@ static USBD_Class_cb_TypeDef class_callbacks = { #endif /* USB_SUPPORT_USER_STRING_DESC */ }; +#endif /* PIOS_INCLUDE_USB */ diff --git a/flight/PiOS/STM32F4xx/pios_wdg.c b/flight/PiOS/STM32F4xx/pios_wdg.c index 2c718ecfd..f1a5e5d10 100644 --- a/flight/PiOS/STM32F4xx/pios_wdg.c +++ b/flight/PiOS/STM32F4xx/pios_wdg.c @@ -37,6 +37,9 @@ */ #include "pios.h" + +#ifdef PIOS_INCLUDE_WDG + #include "stm32f4xx_iwdg.h" #include "stm32f4xx_dbgmcu.h" #include "stm32f4xx_rtc.h" @@ -177,3 +180,5 @@ void PIOS_WDG_Clear(void) IWDG_ReloadCounter(); #endif } + +#endif /* PIOS_INCLUDE_WDG */ diff --git a/flight/PiOS/inc/pios_adxl345.h b/flight/PiOS/inc/pios_adxl345.h index 4701aaf55..10022569f 100644 --- a/flight/PiOS/inc/pios_adxl345.h +++ b/flight/PiOS/inc/pios_adxl345.h @@ -75,7 +75,7 @@ uint8_t PIOS_ADXL345_Read(struct pios_adxl345_data * data); int32_t PIOS_ADXL345_FifoElements(); int32_t PIOS_ADXL345_Test(); -#endif +#endif /* PIOS_ADXL345_H */ /** * @} diff --git a/flight/PiOS/inc/pios_bl_helper.h b/flight/PiOS/inc/pios_bl_helper.h index e2e9e694e..620c6c7d9 100644 --- a/flight/PiOS/inc/pios_bl_helper.h +++ b/flight/PiOS/inc/pios_bl_helper.h @@ -28,19 +28,14 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef PIOS_BL_HELPER_H_ -#define PIOS_BL_HELPER_H_ +#ifndef PIOS_BL_HELPER_H +#define PIOS_BL_HELPER_H extern uint8_t *PIOS_BL_HELPER_FLASH_If_Read(uint32_t SectorAddress); - extern uint8_t PIOS_BL_HELPER_FLASH_Ini(); - extern uint32_t PIOS_BL_HELPER_CRC_Memory_Calc(); - extern void PIOS_BL_HELPER_FLASH_Read_Description(uint8_t * array, uint8_t size); - extern uint8_t PIOS_BL_HELPER_FLASH_Start(); - extern void PIOS_BL_HELPER_CRC_Ini(); -#endif /* PIOS_BL_HELPER_H_ */ +#endif /* PIOS_BL_HELPER_H */ diff --git a/flight/PiOS/inc/pios_bma180.h b/flight/PiOS/inc/pios_bma180.h index 51e65a6ec..84c310dd8 100644 --- a/flight/PiOS/inc/pios_bma180.h +++ b/flight/PiOS/inc/pios_bma180.h @@ -29,11 +29,11 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "fifo_buffer.h" - #ifndef PIOS_BMA180_H #define PIOS_BMA180_H +#include "fifo_buffer.h" + #include /* BMA180 Addresses */ diff --git a/flight/PiOS/inc/pios_crc.h b/flight/PiOS/inc/pios_crc.h index 612c89e49..7e35dee02 100644 --- a/flight/PiOS/inc/pios_crc.h +++ b/flight/PiOS/inc/pios_crc.h @@ -27,6 +27,9 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifndef PIOS_CRC_H +#define PIOS_CRC_H + uint8_t PIOS_CRC_updateByte(uint8_t crc, const uint8_t data); uint8_t PIOS_CRC_updateCRC(uint8_t crc, const uint8_t* data, int32_t length); @@ -35,3 +38,5 @@ uint16_t PIOS_CRC16_updateCRC(uint16_t crc, const uint8_t* data, int32_t length) uint32_t PIOS_CRC32_updateByte(uint32_t crc, const uint8_t data); uint32_t PIOS_CRC32_updateCRC(uint32_t crc, const uint8_t* data, int32_t length); + +#endif /* PIOS_CRC_H */ diff --git a/flight/PiOS/inc/pios_debug.h b/flight/PiOS/inc/pios_debug.h index aa3eb3332..4bc1e0802 100644 --- a/flight/PiOS/inc/pios_debug.h +++ b/flight/PiOS/inc/pios_debug.h @@ -31,15 +31,29 @@ #ifndef PIOS_DEBUG_H #define PIOS_DEBUG_H +#ifdef PIOS_INCLUDE_DEBUG_CONSOLE +#ifndef DEBUG_LEVEL +#define DEBUG_LEVEL 0 +#endif +#define DEBUG_PRINTF(level, ...) \ + { \ + if ((level <= DEBUG_LEVEL) && (PIOS_COM_DEBUG > 0)) { \ + PIOS_COM_SendFormattedStringNonBlocking(PIOS_COM_DEBUG, __VA_ARGS__); \ + } \ + } +#else +#define DEBUG_PRINTF(level, ...) +#endif /* PIOS_INCLUDE_DEBUG_CONSOLE */ + extern const char *PIOS_DEBUG_AssertMsg; #ifdef USE_SIM_POSIX void PIOS_DEBUG_Init(void); #else #include - void PIOS_DEBUG_Init(const struct pios_tim_channel * channels, uint8_t num_channels); #endif + void PIOS_DEBUG_PinHigh(uint8_t pin); void PIOS_DEBUG_PinLow(uint8_t pin); void PIOS_DEBUG_PinValue8Bit(uint8_t value); diff --git a/flight/PiOS/inc/pios_etasv3.h b/flight/PiOS/inc/pios_etasv3.h index afa038d3d..fab354e5a 100644 --- a/flight/PiOS/inc/pios_etasv3.h +++ b/flight/PiOS/inc/pios_etasv3.h @@ -28,7 +28,11 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifndef PIOS_ETASV3_H +#define PIOS_ETASV3_H + #define ETASV3_I2C_ADDR 0x75 - int16_t PIOS_ETASV3_ReadAirspeed (void); + +#endif /* PIOS_ETASV3_H */ diff --git a/flight/PiOS/inc/pios_flash.h b/flight/PiOS/inc/pios_flash.h index 8ae69ab3f..a9de63593 100644 --- a/flight/PiOS/inc/pios_flash.h +++ b/flight/PiOS/inc/pios_flash.h @@ -24,8 +24,8 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef PIOS_FLASH_H_ -#define PIOS_FLASH_H_ +#ifndef PIOS_FLASH_H +#define PIOS_FLASH_H #include @@ -44,4 +44,4 @@ struct pios_flash_driver { int32_t (*read_data)(uintptr_t flash_id, uint32_t addr, uint8_t * data, uint16_t len); }; -#endif /* PIOS_FLASH_H_ */ +#endif /* PIOS_FLASH_H */ diff --git a/flight/PiOS/inc/pios_flash_internal_priv.h b/flight/PiOS/inc/pios_flash_internal_priv.h index 4c690fefb..15be5df5f 100644 --- a/flight/PiOS/inc/pios_flash_internal_priv.h +++ b/flight/PiOS/inc/pios_flash_internal_priv.h @@ -24,8 +24,8 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef PIOS_FLASH_INTERNAL_H_ -#define PIOS_FLASH_INTERNAL_H_ +#ifndef PIOS_FLASH_INTERNAL_H +#define PIOS_FLASH_INTERNAL_H #include "pios_flash.h" /* API definition for flash drivers */ @@ -37,4 +37,4 @@ struct pios_flash_internal_cfg { extern int32_t PIOS_Flash_Internal_Init(uintptr_t * flash_id, const struct pios_flash_internal_cfg * cfg); -#endif /* PIOS_FLASH_INTERNAL_H_ */ +#endif /* PIOS_FLASH_INTERNAL_H */ diff --git a/flight/PiOS/inc/pios_flash_jedec_priv.h b/flight/PiOS/inc/pios_flash_jedec_priv.h index 8b772c0b9..b1d4f369f 100644 --- a/flight/PiOS/inc/pios_flash_jedec_priv.h +++ b/flight/PiOS/inc/pios_flash_jedec_priv.h @@ -28,8 +28,8 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef PIOS_FLASH_JEDEC_H_ -#define PIOS_FLASH_JEDEC_H_ +#ifndef PIOS_FLASH_JEDEC_H +#define PIOS_FLASH_JEDEC_H #include "pios_flash.h" /* API definition for flash drivers */ @@ -49,4 +49,4 @@ struct pios_flash_jedec_cfg { int32_t PIOS_Flash_Jedec_Init(uintptr_t * flash_id, uint32_t spi_id, uint32_t slave_num, const struct pios_flash_jedec_cfg * cfg); -#endif /* PIOS_FLASH_JEDEC_H_ */ +#endif /* PIOS_FLASH_JEDEC_H */ diff --git a/flight/PiOS/inc/pios_flashfs.h b/flight/PiOS/inc/pios_flashfs.h index b59cac48f..073cf9490 100644 --- a/flight/PiOS/inc/pios_flashfs.h +++ b/flight/PiOS/inc/pios_flashfs.h @@ -24,8 +24,8 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef PIOS_FLASHFS_H_ -#define PIOS_FLASHFS_H_ +#ifndef PIOS_FLASHFS_H +#define PIOS_FLASHFS_H #include @@ -34,4 +34,4 @@ int32_t PIOS_FLASHFS_ObjSave(uint32_t fs_id, uint32_t obj_id, uint16_t obj_inst_ int32_t PIOS_FLASHFS_ObjLoad(uint32_t fs_id, uint32_t obj_id, uint16_t obj_inst_id, uint8_t * obj_data, uint16_t obj_size); int32_t PIOS_FLASHFS_ObjDelete(uint32_t fs_id, uint32_t obj_id, uint16_t obj_inst_id); -#endif /* PIOS_FLASHFS_H_ */ +#endif /* PIOS_FLASHFS_H */ diff --git a/flight/PiOS/inc/pios_flashfs_logfs_priv.h b/flight/PiOS/inc/pios_flashfs_logfs_priv.h index d948f4f76..88ce65109 100644 --- a/flight/PiOS/inc/pios_flashfs_logfs_priv.h +++ b/flight/PiOS/inc/pios_flashfs_logfs_priv.h @@ -24,8 +24,8 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef PIOS_FLASHFS_LOGFS_PRIV_H_ -#define PIOS_FLASHFS_LOGFS_PRIV_H_ +#ifndef PIOS_FLASHFS_LOGFS_PRIV_H +#define PIOS_FLASHFS_LOGFS_PRIV_H #include #include "pios_flash.h" /* struct pios_flash_driver */ @@ -43,4 +43,4 @@ struct flashfs_logfs_cfg { int32_t PIOS_FLASHFS_Logfs_Init(uintptr_t * fs_id, const struct flashfs_logfs_cfg * cfg, const struct pios_flash_driver * driver, uintptr_t flash_id); -#endif /* PIOS_FLASHFS_LOGFS_PRIV_H_ */ +#endif /* PIOS_FLASHFS_LOGFS_PRIV_H */ diff --git a/flight/PiOS/inc/pios_hmc5883.h b/flight/PiOS/inc/pios_hmc5883.h index daa9437b8..921b99d07 100644 --- a/flight/PiOS/inc/pios_hmc5883.h +++ b/flight/PiOS/inc/pios_hmc5883.h @@ -31,8 +31,6 @@ #ifndef PIOS_HMC5883_H #define PIOS_HMC5883_H -#include - /* HMC5883 Addresses */ #define PIOS_HMC5883_I2C_ADDR 0x1E #define PIOS_HMC5883_I2C_READ_ADDR 0x3D @@ -110,6 +108,7 @@ extern int32_t PIOS_HMC5883_ReadMag(int16_t out[3]); extern uint8_t PIOS_HMC5883_ReadID(uint8_t out[4]); extern int32_t PIOS_HMC5883_Test(void); extern bool PIOS_HMC5883_IRQHandler(); + #endif /* PIOS_HMC5883_H */ /** diff --git a/flight/PiOS/inc/pios_iap.h b/flight/PiOS/inc/pios_iap.h index d9b41170b..5ea916970 100644 --- a/flight/PiOS/inc/pios_iap.h +++ b/flight/PiOS/inc/pios_iap.h @@ -6,8 +6,8 @@ * Author: joe */ -#ifndef PIOS_IAP_H_ -#define PIOS_IAP_H_ +#ifndef PIOS_IAP_H +#define PIOS_IAP_H /**************************************************************************************** @@ -42,4 +42,4 @@ void PIOS_IAP_WriteBootCount(uint16_t); * Public Data ****************************************************************************************/ -#endif /* PIOS_IAP_H_ */ +#endif /* PIOS_IAP_H */ diff --git a/flight/PiOS/inc/pios_initcall.h b/flight/PiOS/inc/pios_initcall.h index 1f1dea393..410c3c72a 100644 --- a/flight/PiOS/inc/pios_initcall.h +++ b/flight/PiOS/inc/pios_initcall.h @@ -98,6 +98,7 @@ extern void StartModules(); (fn->fn_tinit)(); } #endif /* USE_SIM_POSIX */ + #endif /* PIOS_INITCALL_H */ /** diff --git a/flight/PiOS/inc/pios_l3gd20.h b/flight/PiOS/inc/pios_l3gd20.h index 241f983c6..794c5c2f2 100644 --- a/flight/PiOS/inc/pios_l3gd20.h +++ b/flight/PiOS/inc/pios_l3gd20.h @@ -32,8 +32,6 @@ #ifndef PIOS_L3GD20_H #define PIOS_L3GD20_H -#include "pios.h" - /* L3GD20 Addresses */ #define PIOS_L3GD20_WHOAMI 0x0F #define PIOS_L3GD20_CTRL_REG1 0X20 diff --git a/flight/PiOS/inc/pios_mpu6000.h b/flight/PiOS/inc/pios_mpu6000.h index 1be368575..80b924331 100644 --- a/flight/PiOS/inc/pios_mpu6000.h +++ b/flight/PiOS/inc/pios_mpu6000.h @@ -32,8 +32,6 @@ #ifndef PIOS_MPU6000_H #define PIOS_MPU6000_H -#include "pios.h" - /* MPU6000 Addresses */ #define PIOS_MPU6000_SMPLRT_DIV_REG 0X19 #define PIOS_MPU6000_DLPF_CFG_REG 0X1A diff --git a/flight/PiOS/inc/pios_mpxv.h b/flight/PiOS/inc/pios_mpxv.h index 824f0aa7b..4e7dffaba 100644 --- a/flight/PiOS/inc/pios_mpxv.h +++ b/flight/PiOS/inc/pios_mpxv.h @@ -28,8 +28,8 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef PIOS_MPXV_H__ -#define PIOS_MPXV_H__ +#ifndef PIOS_MPXV_H +#define PIOS_MPXV_H typedef enum{ PIOS_MPXV_UNKNOWN,PIOS_MPXV_5004,PIOS_MPXV_7002 } PIOS_MPXV_sensortype; typedef struct{ @@ -63,4 +63,4 @@ uint16_t PIOS_MPXV_Measure(PIOS_MPXV_descriptor *desc); uint16_t PIOS_MPXV_Calibrate(PIOS_MPXV_descriptor *desc, uint16_t measurement); float PIOS_MPXV_CalcAirspeed (PIOS_MPXV_descriptor *desc,uint16_t measurement); -#endif // PIOS_MPXV_H__ +#endif /* PIOS_MPXV_H */ diff --git a/flight/PiOS/inc/pios_ms5611.h b/flight/PiOS/inc/pios_ms5611.h index 7068988c4..ac0a79305 100644 --- a/flight/PiOS/inc/pios_ms5611.h +++ b/flight/PiOS/inc/pios_ms5611.h @@ -31,18 +31,16 @@ #ifndef PIOS_MS5611_H #define PIOS_MS5611_H -#include - /* BMP085 Addresses */ #define MS5611_I2C_ADDR 0x77 #define MS5611_RESET 0x1E -#define MS5611_CALIB_ADDR 0xA2 /* First sample is factory stuff */ -#define MS5611_CALIB_LEN 16 -#define MS5611_ADC_READ 0x00 -#define MS5611_PRES_ADDR 0x40 -#define MS5611_TEMP_ADDR 0x50 -#define MS5611_ADC_MSB 0xF6 -#define MS5611_P0 101.3250f +#define MS5611_CALIB_ADDR 0xA2 /* First sample is factory stuff */ +#define MS5611_CALIB_LEN 16 +#define MS5611_ADC_READ 0x00 +#define MS5611_PRES_ADDR 0x40 +#define MS5611_TEMP_ADDR 0x50 +#define MS5611_ADC_MSB 0xF6 +#define MS5611_P0 101.3250f /* Local Types */ typedef struct { diff --git a/flight/PiOS/inc/pios_opahrs.h b/flight/PiOS/inc/pios_opahrs.h deleted file mode 100644 index 3b995ba7a..000000000 --- a/flight/PiOS/inc/pios_opahrs.h +++ /dev/null @@ -1,77 +0,0 @@ -/** - ****************************************************************************** - * @addtogroup PIOS PIOS Core hardware abstraction layer - * @{ - * @addtogroup PIOS_OPAHRS OPAHRS Functions - * @{ - * - * @file pios_opahrs.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief OpenPilot AHRS functions header. - * @see The GNU Public License (GPL) Version 3 - * - *****************************************************************************/ -/* - * 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 - */ - -#ifndef PIOS_OPAHRS_H -#define PIOS_OPAHRS_H - -#include "pios_opahrs_proto.h" /* opahrs message structs */ - -enum opahrs_result { - OPAHRS_RESULT_OK = 0, - OPAHRS_RESULT_TIMEOUT, - OPAHRS_RESULT_FAILED, -}; - -extern void PIOS_OPAHRS_Attach(uint32_t spi_id); -extern void PIOS_OPAHRS_ForceSlaveSelected(bool selected); - -/* - * Protocol V0 messages used to talk to bootloaders - */ - -extern enum opahrs_result PIOS_OPAHRS_bl_GetVersions(struct opahrs_msg_v0 *rsp); -extern enum opahrs_result PIOS_OPAHRS_bl_GetSerial(struct opahrs_msg_v0 *rsp); -extern enum opahrs_result PIOS_OPAHRS_bl_FwupStart(struct opahrs_msg_v0 *rsp); -extern enum opahrs_result PIOS_OPAHRS_bl_FwupStatus(struct opahrs_msg_v0 *rsp); -extern enum opahrs_result PIOS_OPAHRS_bl_FwupData(struct opahrs_msg_v0 *req, struct opahrs_msg_v0 *rsp); -extern enum opahrs_result PIOS_OPAHRS_bl_FwupVerify(struct opahrs_msg_v0 *rsp); -extern enum opahrs_result PIOS_OPAHRS_bl_resync(void); -extern enum opahrs_result PIOS_OPAHRS_bl_GetMemMap(struct opahrs_msg_v0 *rsp); -extern enum opahrs_result PIOS_OPAHRS_bl_reset(uint32_t delay); -extern enum opahrs_result PIOS_OPAHRS_bl_boot(uint32_t delay); -extern enum opahrs_result PIOS_OPAHRS_bl_FwDlData(struct opahrs_msg_v0 *req, struct opahrs_msg_v0 *rsp); -/* - * Protocol V1 messages used by application - */ -extern enum opahrs_result PIOS_OPAHRS_Sync(struct opahrs_msg_v1 *rsp); -extern enum opahrs_result PIOS_OPAHRS_GetSerial(struct opahrs_msg_v1 *rsp); -extern enum opahrs_result PIOS_OPAHRS_SetGetUpdate(struct opahrs_msg_v1 *rsp, struct opahrs_msg_v1 *req); -extern enum opahrs_result PIOS_OPAHRS_GetAttitudeRaw(struct opahrs_msg_v1 *rsp); -extern enum opahrs_result PIOS_OPAHRS_SetAlgorithm(struct opahrs_msg_v1 *req); -extern enum opahrs_result PIOS_OPAHRS_SetMagNorth(struct opahrs_msg_v1 *req); -extern enum opahrs_result PIOS_OPAHRS_SetGetCalibration(struct opahrs_msg_v1 *req, struct opahrs_msg_v1 *rsp); -extern enum opahrs_result PIOS_OPAHRS_SetGetInitialized(struct opahrs_msg_v1 *req, struct opahrs_msg_v1 *rsp); -extern enum opahrs_result PIOS_OPAHRS_resync(void); - -#endif /* PIOS_OPAHRS_H */ - -/** - * @} - * @} - */ diff --git a/flight/PiOS/inc/pios_opahrs_proto.h b/flight/PiOS/inc/pios_opahrs_proto.h deleted file mode 100644 index 554ed00e5..000000000 --- a/flight/PiOS/inc/pios_opahrs_proto.h +++ /dev/null @@ -1,406 +0,0 @@ -/** - * @addtogroup PIOS PIOS Core hardware abstraction layer - * @{ - * @addtogroup PIOS_OPAHRS OPAHRS Functions - * @{ - * - * @file pios_opahrs_proto.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief PPM Input functions - * @see The GNU Public License (GPL) Version 3 - * - */ - -#ifndef PIOS_OPAHRS_PROTO_H -#define PIOS_OPAHRS_PROTO_H - -#include - -enum opahrs_msg_type { - OPAHRS_MSG_TYPE_LINK = 0x00, - - OPAHRS_MSG_TYPE_USER_V0, - OPAHRS_MSG_TYPE_USER_V1, -}; - -enum opahrs_msg_link_state { - OPAHRS_MSG_LINK_STATE_INACTIVE, - OPAHRS_MSG_LINK_STATE_BUSY, - OPAHRS_MSG_LINK_STATE_READY, -}; - -#define OPAHRS_MSG_MAGIC_HEAD 0x53524841 /* ASCII "AHRS" */ -struct opahrs_msg_link_head { - uint32_t magic; /* Set to OPAHRS_MSG_MAGIC_HEAD */ - enum opahrs_msg_type type; -} __attribute__ ((__packed__)); - -#define OPAHRS_MSG_MAGIC_TAIL 0xFEFE -struct opahrs_msg_link_tail { - uint16_t magic; - uint8_t crc8; -} __attribute__ ((__packed__)); - -enum opahrs_msg_link_tag { - OPAHRS_MSG_LINK_TAG_NOP, -}; - -#define SPI_MSG_LINK_ERROR_BADCRC 0x00000001 -struct opahrs_msg_link { - enum opahrs_msg_link_state state; - uint16_t errors; - - enum opahrs_msg_link_tag t; - union { - } v; -} __attribute__ ((__packed__)); - -/******** - * SPI protocol v0 definitions - * - * This protocol version is NOT to be changed after release since it is the - * protocol used for upgrading the firmware of AHRS boards that are already - * in end user hands. - * - ********/ - -struct opahrs_msg_v0_req_nop { -} __attribute__ ((__packed__)); - -struct opahrs_msg_v0_req_versions { -} __attribute__ ((__packed__)); - -struct opahrs_msg_v0_req_reset { - uint32_t reset_delay_in_ms; -} __attribute__ ((__packed__)); - -struct opahrs_msg_v0_req_boot { - uint32_t boot_delay_in_ms; -} __attribute__ ((__packed__)); - -struct opahrs_msg_v0_req_serial { -} __attribute__ ((__packed__)); - -struct opahrs_msg_v0_req_fwup_start { -} __attribute__ ((__packed__)); - -struct opahrs_msg_v0_req_fwup_status { -} __attribute__ ((__packed__)); - -struct opahrs_msg_v0_req_fwup_data { - uint32_t adress; - uint32_t data[14]; - uint8_t size; -} __attribute__ ((__packed__)); - -struct opahrs_msg_v0_req_fwdn_data { - uint32_t adress; -} __attribute__ ((__packed__)); - -struct opahrs_msg_v0_req_mem_map { -} __attribute__ ((__packed__)); - -struct opahrs_msg_v0_req_fwup_verify { -} __attribute__ ((__packed__)); - -union opahrs_msg_v0_req { - struct opahrs_msg_v0_req_nop nop; - struct opahrs_msg_v0_req_versions versions; - struct opahrs_msg_v0_req_reset reset; - struct opahrs_msg_v0_req_boot boot; - struct opahrs_msg_v0_req_serial serial; - struct opahrs_msg_v0_req_fwup_status status_req; - struct opahrs_msg_v0_req_fwdn_data fwdn_data; - struct opahrs_msg_v0_req_mem_map mem_map; - struct opahrs_msg_v0_req_fwup_start fwup_start; - struct opahrs_msg_v0_req_fwup_data fwup_data; - struct opahrs_msg_v0_req_fwup_verify fwup_verify; -} __attribute__ ((__packed__)); - -struct opahrs_msg_v0_rsp_fwdn_data { - uint8_t data[4]; -} __attribute__ ((__packed__)); - -struct opahrs_msg_v0_rsp_versions { - uint16_t hw_version; - uint16_t bl_version; - uint32_t fw_crc; -} __attribute__ ((__packed__)); - -struct opahrs_msg_v0_rsp_serial { - uint8_t serial_bcd[24]; -} __attribute__ ((__packed__)); - -enum bootloader_status { idle, started, start_failed, write_error, outside_dev_capabilities, jump_failed }; -struct opahrs_msg_v0_rsp_fwup_status { - enum bootloader_status status; -} __attribute__ ((__packed__)); - -enum hw_density { high_density, medium_density }; -struct opahrs_msg_v0_rsp_mem_map { - uint32_t start_of_user_code; - uint32_t size_of_code_memory; - uint8_t size_of_description; - uint8_t rw_flags; - enum hw_density density; -} __attribute__ ((__packed__)); - -union opahrs_msg_v0_rsp { - struct opahrs_msg_v0_rsp_versions versions; - struct opahrs_msg_v0_rsp_serial serial; - struct opahrs_msg_v0_rsp_fwup_status fwup_status; - struct opahrs_msg_v0_rsp_mem_map mem_map; - struct opahrs_msg_v0_rsp_fwdn_data fw_dn; -} __attribute__ ((__packed__)); - -enum opahrs_msg_v0_tag { - OPAHRS_MSG_V0_REQ_NOP = 0x00, - OPAHRS_MSG_V0_REQ_VERSIONS, - OPAHRS_MSG_V0_REQ_RESET, - OPAHRS_MSG_V0_REQ_BOOT, - OPAHRS_MSG_V0_REQ_SERIAL, - OPAHRS_MSG_V0_REQ_FWDN_DATA, - OPAHRS_MSG_V0_REQ_MEM_MAP, - - OPAHRS_MSG_V0_REQ_FWUP_START, - OPAHRS_MSG_V0_REQ_FWUP_DATA, - OPAHRS_MSG_V0_REQ_FWUP_VERIFY, - OPAHRS_MSG_V0_REQ_FWUP_STATUS, - - OPAHRS_MSG_V0_RSP_VERSIONS, - OPAHRS_MSG_V0_RSP_SERIAL, - OPAHRS_MSG_V0_RSP_FWUP_STATUS, - OPAHRS_MSG_V0_RSP_FWDN_DATA, - OPAHRS_MSG_V0_RSP_MEM_MAP, -}; - -struct opahrs_msg_v0_payload { - enum opahrs_msg_v0_tag t; - union { - union opahrs_msg_v0_req req; - union opahrs_msg_v0_rsp rsp; - } v; -} __attribute__ ((__packed__)); - -struct opahrs_msg_v0 { - struct opahrs_msg_link_head head; - union { - struct opahrs_msg_link link; - struct opahrs_msg_v0_payload user; - } payload; - struct opahrs_msg_link_tail tail; -} __attribute__ ((__packed__)); - -/******** - * SPI protocol v1 definitions - ********/ - -struct opahrs_msg_v1_req_nop { -} __attribute__ ((__packed__)); - -struct opahrs_msg_v1_req_versions { -} __attribute__ ((__packed__)); - -struct opahrs_msg_v1_req_reset { - uint32_t reset_delay_in_ms; -} __attribute__ ((__packed__)); - -struct opahrs_msg_v1_req_serial { -} __attribute__ ((__packed__)); - -enum initialized_mode { AHRS_UNINITIALIZED, AHRS_INITIALIZED, AHRS_INIT_QUERY }; - -struct opahrs_msg_v1_req_initialized { - enum initialized_mode initialized; -} __attribute__ ((__packed__)); - -struct opahrs_msg_v1_req_north { - float Be[3]; -} __attribute__ ((__packed__)); - -enum algorithms { SIMPLE_Algo, INSGPS_Algo }; - -struct opahrs_msg_v1_req_algorithm { - enum algorithms algorithm; -} __attribute__ ((__packed__)); - -struct opahrs_msg_v1_req_update { - struct { - uint8_t updated; - float NED[3]; - float groundspeed; - float heading; - float quality; - } gps; - struct { - uint8_t updated; - float altitude; - } barometer; -} __attribute__ ((__packed__)); - -struct opahrs_msg_v1_req_attituderaw { -} __attribute__ ((__packed__)); - -enum measure_mode { AHRS_SET, AHRS_MEASURE, AHRS_ECHO }; - -struct opahrs_msg_v1_req_calibration { - enum measure_mode measure_var; - float accel_bias[3]; - float accel_scale[3]; - float accel_var[3]; - float gyro_bias[3]; - float gyro_scale[3]; - float gyro_var[3]; - float mag_bias[3]; - float mag_scale[3]; - float mag_var[3]; -} __attribute__ ((__packed__)); - -union opahrs_msg_v1_req { - struct opahrs_msg_v1_req_nop nop; - struct opahrs_msg_v1_req_versions versions; - struct opahrs_msg_v1_req_reset reset; - struct opahrs_msg_v1_req_initialized initialized; - struct opahrs_msg_v1_req_serial serial; - struct opahrs_msg_v1_req_update update; - struct opahrs_msg_v1_req_algorithm algorithm; - struct opahrs_msg_v1_req_north north; - struct opahrs_msg_v1_req_attituderaw attituderaw; - struct opahrs_msg_v1_req_calibration calibration; -} __attribute__ ((__packed__)); - -struct opahrs_msg_v1_rsp_versions { - uint8_t hw_version; - uint16_t bl_version; - uint32_t fw_crc; -} __attribute__ ((__packed__)); - -struct opahrs_msg_v1_rsp_serial { - uint8_t serial_bcd[25]; -} __attribute__ ((__packed__)); - -struct opahrs_msg_v1_rsp_initialized { - enum initialized_mode initialized; -} __attribute__ ((__packed__)); - -struct opahrs_msg_v1_rsp_north { -} __attribute__ ((__packed__)); - -struct opahrs_msg_v1_rsp_algorithm { -} __attribute__ ((__packed__)); - -struct opahrs_msg_v1_rsp_attituderaw { - struct { - int16_t x; - int16_t y; - int16_t z; - } mags; - struct { - uint16_t x; - uint16_t y; - uint16_t z; - uint16_t xy_temp; - uint16_t z_temp; - } gyros; - struct { - float x; - float y; - float z; - } gyros_filtered; - struct { - uint16_t x; - uint16_t y; - uint16_t z; - } accels; - struct { - float x; - float y; - float z; - } accels_filtered; -} __attribute__ ((__packed__)); - -struct opahrs_msg_v1_rsp_update { - struct { - float q1; - float q2; - float q3; - float q4; - } quaternion; - int32_t NED[3]; - int32_t Vel[3]; - uint8_t load; - uint8_t idle_time; - uint8_t run_time; - uint8_t dropped_updates; -} __attribute__ ((__packed__)); - -struct opahrs_msg_v1_rsp_calibration { - float accel_var[3]; - float gyro_var[3]; - float mag_var[3]; -} __attribute__ ((__packed__)); - -union opahrs_msg_v1_rsp { - struct opahrs_msg_v1_rsp_versions versions; - struct opahrs_msg_v1_rsp_serial serial; - struct opahrs_msg_v1_rsp_initialized initialized; - struct opahrs_msg_v1_rsp_north north; - struct opahrs_msg_v1_rsp_algorithm algorithm; - struct opahrs_msg_v1_rsp_attituderaw attituderaw; - struct opahrs_msg_v1_rsp_update update; - struct opahrs_msg_v1_rsp_calibration calibration; -} __attribute__ ((__packed__)); - -enum opahrs_msg_v1_tag { - OPAHRS_MSG_V1_REQ_NOP = 0x02000000, - OPAHRS_MSG_V1_REQ_VERSIONS, - OPAHRS_MSG_V1_REQ_RESET, - OPAHRS_MSG_V1_REQ_SERIAL, - OPAHRS_MSG_V1_REQ_INITIALIZED, - OPAHRS_MSG_V1_REQ_NORTH, - OPAHRS_MSG_V1_REQ_ALGORITHM, - OPAHRS_MSG_V1_REQ_UPDATE, - OPAHRS_MSG_V1_REQ_ATTITUDERAW, - OPAHRS_MSG_V1_REQ_CALIBRATION, - - OPAHRS_MSG_V1_RSP_VERSIONS, - OPAHRS_MSG_V1_RSP_SERIAL, - OPAHRS_MSG_V1_RSP_INITIALIZED, - OPAHRS_MSG_V1_RSP_NORTH, - OPAHRS_MSG_V1_RSP_ALGORITHM, - OPAHRS_MSG_V1_RSP_UPDATE, - OPAHRS_MSG_V1_RSP_ATTITUDERAW, - OPAHRS_MSG_V1_RSP_CALIBRATION, -}; - -struct opahrs_msg_v1_payload { - enum opahrs_msg_v1_tag t; - union { - union opahrs_msg_v1_req req; - union opahrs_msg_v1_rsp rsp; - } v; -} __attribute__ ((__packed__)); - -struct opahrs_msg_v1 { - struct opahrs_msg_link_head head; - union { - struct opahrs_msg_link link; - struct opahrs_msg_v1_payload user; - } payload; - struct opahrs_msg_link_tail tail; -} __attribute__ ((__packed__)); - -/* Helper functions for setting up messages */ -extern void opahrs_msg_v0_init_rx(struct opahrs_msg_v0 *msg); -extern void opahrs_msg_v0_init_user_tx(struct opahrs_msg_v0 *msg, enum opahrs_msg_v0_tag tag); -extern void opahrs_msg_v0_init_link_tx(struct opahrs_msg_v0 *msg, enum opahrs_msg_link_tag tag); -extern void opahrs_msg_v1_init_rx(struct opahrs_msg_v1 *msg); -extern void opahrs_msg_v1_init_user_tx(struct opahrs_msg_v1 *msg, enum opahrs_msg_v1_tag tag); -extern void opahrs_msg_v1_init_link_tx(struct opahrs_msg_v1 *msg, enum opahrs_msg_link_tag tag); - -#endif /* PIOS_OPAHRS_PROTO_H */ - -/** - * @} - * @} - */ diff --git a/flight/PiOS/inc/pios_posix.h b/flight/PiOS/inc/pios_posix.h index 2b411d270..7b6fe7fb1 100644 --- a/flight/PiOS/inc/pios_posix.h +++ b/flight/PiOS/inc/pios_posix.h @@ -40,5 +40,4 @@ typedef enum {FALSE = 0, TRUE = !FALSE} bool; //#define PIOS_SERVO_NUM_OUTPUTS 8 //#define PIOS_SERVO_NUM_TIMERS PIOS_SERVO_NUM_OUTPUTS -#endif - +#endif /* PIOS_POSIX_H */ diff --git a/flight/PiOS/inc/pios_sdcard.h b/flight/PiOS/inc/pios_sdcard.h index 8cbe3fd9f..df55d83f8 100644 --- a/flight/PiOS/inc/pios_sdcard.h +++ b/flight/PiOS/inc/pios_sdcard.h @@ -31,8 +31,6 @@ #ifndef PIOS_SDCARD_H #define PIOS_SDCARD_H -#if defined(PIOS_INCLUDE_SDCARD) - /* Public Functions */ typedef struct { uint8_t CSDStruct; /* CSD structure */ @@ -113,6 +111,4 @@ extern int32_t PIOS_SDCARD_ReadLine(PFILEINFO fileinfo, uint8_t * buffer, uint32 extern int32_t PIOS_SDCARD_FileCopy(char *Source, char *Destination); extern int32_t PIOS_SDCARD_FileDelete(char *Filename); -#endif - #endif /* PIOS_SDCARD_H */ diff --git a/flight/PiOS/inc/pios_spi_priv.h b/flight/PiOS/inc/pios_spi_priv.h index fd8a6a4e5..f89f52495 100644 --- a/flight/PiOS/inc/pios_spi_priv.h +++ b/flight/PiOS/inc/pios_spi_priv.h @@ -60,6 +60,7 @@ struct pios_spi_dev { }; extern int32_t PIOS_SPI_Init(uint32_t * spi_id, const struct pios_spi_cfg * cfg); + #endif /* PIOS_SPI_PRIV_H */ /** diff --git a/flight/PiOS/inc/pios_struct_helper.h b/flight/PiOS/inc/pios_struct_helper.h index 6196d9b26..f061a6e01 100644 --- a/flight/PiOS/inc/pios_struct_helper.h +++ b/flight/PiOS/inc/pios_struct_helper.h @@ -7,6 +7,12 @@ * @member: the name of the member within the struct. * */ + +#ifndef PIOS_STRUCT_HELPER_H +#define PIOS_STRUCT_HELPER_H + #define container_of(ptr, type, member) ({ \ const typeof( ((type *)0)->member ) *__mptr = (ptr); \ (type *)( (char *)__mptr - offsetof(type,member) );}) + +#endif /* PIOS_STRUCT_HELPER_H */ diff --git a/flight/PiOS/inc/pios_usart.h b/flight/PiOS/inc/pios_usart.h index d7bebc18e..dd98a660f 100644 --- a/flight/PiOS/inc/pios_usart.h +++ b/flight/PiOS/inc/pios_usart.h @@ -31,8 +31,6 @@ #ifndef PIOS_USART_H #define PIOS_USART_H -#include - /* Global Types */ /* Public Functions */ diff --git a/flight/PiOS/inc/pios_usb_desc_hid_cdc_priv.h b/flight/PiOS/inc/pios_usb_desc_hid_cdc_priv.h index 2ae94c74e..8a56d6b19 100644 --- a/flight/PiOS/inc/pios_usb_desc_hid_cdc_priv.h +++ b/flight/PiOS/inc/pios_usb_desc_hid_cdc_priv.h @@ -34,7 +34,7 @@ extern int32_t PIOS_USB_DESC_HID_CDC_Init(void); -#endif /* PIOS_USB_DESC_HID_CDC_PRIV_H */ +#endif /* PIOS_USB_DESC_HID_CDC_PRIV_H */ /** * @} diff --git a/flight/PiOS/inc/pios_usb_desc_hid_only_priv.h b/flight/PiOS/inc/pios_usb_desc_hid_only_priv.h index 321d15efa..9e7d12401 100644 --- a/flight/PiOS/inc/pios_usb_desc_hid_only_priv.h +++ b/flight/PiOS/inc/pios_usb_desc_hid_only_priv.h @@ -34,7 +34,7 @@ extern int32_t PIOS_USB_DESC_HID_ONLY_Init(void); -#endif /* PIOS_USB_DESC_HID_ONLY_PRIV_H */ +#endif /* PIOS_USB_DESC_HID_ONLY_PRIV_H */ /** * @} diff --git a/flight/PiOS/inc/pios_usb_priv.h b/flight/PiOS/inc/pios_usb_priv.h index 6f7edf652..76b430a99 100644 --- a/flight/PiOS/inc/pios_usb_priv.h +++ b/flight/PiOS/inc/pios_usb_priv.h @@ -47,4 +47,3 @@ extern int32_t PIOS_USB_Init(uint32_t * usb_id, const struct pios_usb_cfg * cfg) * @} * @} */ - diff --git a/flight/PiOS/inc/pios_usb_rctx.h b/flight/PiOS/inc/pios_usb_rctx.h index ea07a6d7f..a97581c1a 100644 --- a/flight/PiOS/inc/pios_usb_rctx.h +++ b/flight/PiOS/inc/pios_usb_rctx.h @@ -1,3 +1,8 @@ +#ifndef PIOS_USB_RCTX_H +#define PIOS_USB_RCTX_H + extern uint32_t pios_usb_rctx_id; extern void PIOS_USB_RCTX_Update(uint32_t usbrctx_id, const uint16_t channel[], const int16_t channel_min[], const int16_t channel_max[], uint8_t num_channels); + +#endif /* PIOS_USB_RCTX_H */ diff --git a/flight/PiOS/inc/pios_video.h b/flight/PiOS/inc/pios_video.h index 029a19fbf..4be4a2f7d 100644 --- a/flight/PiOS/inc/pios_video.h +++ b/flight/PiOS/inc/pios_video.h @@ -32,11 +32,6 @@ #ifndef PIOS_VIDEO_H #define PIOS_VIDEO_H -#include - -// ***************************************************************************** -#if defined(PIOS_INCLUDE_VIDEO) - #include #include @@ -107,5 +102,4 @@ extern bool PIOS_Vsync_ISR(); // Macro to swap buffers given a temporary pointer. #define SWAP_BUFFS(tmp, a, b) { tmp = a; a = b; b = tmp; } -#endif #endif /* PIOS_VIDEO_H */ diff --git a/flight/PiOS/inc/pios_wavplay.h b/flight/PiOS/inc/pios_wavplay.h index e2ac9c0ae..8d55ec5c4 100644 --- a/flight/PiOS/inc/pios_wavplay.h +++ b/flight/PiOS/inc/pios_wavplay.h @@ -32,12 +32,8 @@ #ifndef PIOS_WAVPLAY_H #define PIOS_WAVPLAY_H -#include - -// ***************************************************************************** -#if defined(PIOS_INCLUDE_WAVE) - #include + #define BUFFERSIZE 512 //Defines the buffer size to hold data from the SD card. struct pios_dac_cfg { @@ -53,5 +49,4 @@ struct pios_dac_cfg { extern void PIOS_WavPlay_Init(const struct pios_dac_cfg * cfg); extern uint8_t WavePlayer_Start(void); -#endif -#endif /* PIOS_VIDEO_H */ +#endif /* PIOS_WAVPLAY_H */ diff --git a/flight/PiOS/inc/pios_wdg.h b/flight/PiOS/inc/pios_wdg.h index 9c51a2ec2..b8fa1bae5 100644 --- a/flight/PiOS/inc/pios_wdg.h +++ b/flight/PiOS/inc/pios_wdg.h @@ -28,8 +28,8 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef PIOS_WDG -#define PIOS_WDG +#ifndef PIOS_WDG_H +#define PIOS_WDG_H uint16_t PIOS_WDG_Init(); bool PIOS_WDG_RegisterFlag(uint16_t flag_requested); @@ -38,4 +38,4 @@ uint16_t PIOS_WDG_GetBootupFlags(); uint16_t PIOS_WDG_GetActiveFlags(); void PIOS_WDG_Clear(void); -#endif +#endif /* PIOS_WDG_H */ diff --git a/flight/PiOS/pios.h b/flight/PiOS/pios.h index 924f7d16b..96ca8304b 100644 --- a/flight/PiOS/pios.h +++ b/flight/PiOS/pios.h @@ -1,13 +1,10 @@ /** ****************************************************************************** - * * @file pios.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010-2013 * @author PhoenixPilot, http://github.com/PhoenixPilot, Copyright (C) 2012 - * @brief Main PiOS header. - * - Central header for the project. + * @brief Main PiOS header. * @see The GNU Public License (GPL) Version 3 - * *****************************************************************************/ /* * This program is free software; you can redistribute it and/or modify @@ -25,151 +22,268 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +/* + * To add new PIOS options, drivers or functions please insert their + * includes below into a corresponding group. If new driver has optional + * features, add them as comments before including the driver header. + * Finally update all pios_config.h files for every board in the same order + * as in this file. Include new definition and all options, but comment + * out unused ones. + */ #ifndef PIOS_H #define PIOS_H + +/* Used in pios_*.* files macro */ +#define NELEMENTS(x) (sizeof(x) / sizeof((x)[0])) + #ifdef USE_SIM_POSIX +/* SimPosix version of this file. This will probably be removed later */ #include #else -/* PIOS Feature Selection */ -#include "pios_config.h" -#if defined(PIOS_INCLUDE_FREERTOS) -/* FreeRTOS Includes */ -#include "FreeRTOS.h" -#include "task.h" -#include "queue.h" -#include "semphr.h" -#endif - -/* C Lib Includes */ +/* C Lib includes */ #include #include #include #include #include -#include "pios_config.h" -/* STM32 Std Perf Lib */ -#if defined(STM32F4XX) -# include -# include -#elif defined(STM32F2XX) -#include -#include +/* STM32 Std Peripherals Lib */ +#ifdef STM32F4XX +#include +#include #else #include #endif -#if defined(PIOS_INCLUDE_SDCARD) -/* Dosfs Includes */ -#include +/* PIOS board specific feature selection */ +#include "pios_config.h" -/* Mass Storage Device Includes */ -//#include +/* PIOS board specific device configuration */ +#include "pios_board.h" + +/* PIOS debug interface */ +/* #define PIOS_INCLUDE_DEBUG_CONSOLE */ +/* #define DEBUG_LEVEL 0 */ +#include + +/* PIOS common functions */ +#include + +/* PIOS FreeRTOS support */ +#ifdef PIOS_INCLUDE_FREERTOS +#include "FreeRTOS.h" +#include "task.h" +#include "queue.h" +#include "semphr.h" #endif -/* Generic initcall infrastructure */ -#if defined(PIOS_INCLUDE_INITCALL) +/* PIOS bootloader helper */ +#ifdef PIOS_INCLUDE_BL_HELPER +/* #define PIOS_INCLUDE_BL_HELPER_WRITE_SUPPORT */ +#include +#endif + +/* PIOS system functions */ +#ifdef PIOS_INCLUDE_DELAY +#include +#endif + +#ifdef PIOS_INCLUDE_INITCALL #include "pios_initcall.h" #endif -/* PIOS Board Specific Device Configuration */ -#include "pios_board.h" - -/* PIOS Hardware Includes (STM32F10x) */ +#ifdef PIOS_INCLUDE_SYS #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#endif -/* PIOS Hardware Includes (Common) */ -#include -#include -#if defined(PIOS_INCLUDE_MPXV) -#include +/* PIOS hardware peripherals */ +#ifdef PIOS_INCLUDE_IRQ +#include #endif -#if defined(PIOS_INCLUDE_ETASV3) -#include + +#ifdef PIOS_INCLUDE_RTC +#include #endif -#if defined(PIOS_INCLUDE_BMP085) -#include + +#ifdef PIOS_INCLUDE_TIM +#include #endif -#if defined(PIOS_INCLUDE_HCSR04) -#include + +#ifdef PIOS_INCLUDE_USART +#include #endif -#if defined(PIOS_INCLUDE_HMC5843) -#include + +#ifdef PIOS_INCLUDE_ADC +#include #endif -#if defined(PIOS_INCLUDE_HMC5883) -#include + +#ifdef PIOS_INCLUDE_I2C +#include #endif -#if defined(PIOS_INCLUDE_I2C_ESC) -#include + +#ifdef PIOS_INCLUDE_SPI +#include #endif -#if defined(PIOS_INCLUDE_IMU3000) -#include + +#ifdef PIOS_INCLUDE_GPIO +#include #endif -#if defined(PIOS_INCLUDE_MPU6050) -#include + +#ifdef PIOS_INCLUDE_EXTI +#include #endif -#if defined(PIOS_INCLUDE_MPU6000) -#include + +#ifdef PIOS_INCLUDE_WDG +#include #endif -#if defined(PIOS_INCLUDE_L3GD20) -#include + +/* PIOS USB functions */ +#ifdef PIOS_INCLUDE_USB +/* #define PIOS_INCLUDE_USB_HID */ +/* #define PIOS_INCLUDE_USB_CDC */ +/* #define PIOS_INCLUDE_USB_RCTX */ +#include +#ifdef PIOS_INCLUDE_USB_HID +#include #endif -#if defined(PIOS_INCLUDE_MS5611) -#include +#ifdef PIOS_INCLUDE_USB_RCTX +#include #endif -#if defined(PIOS_INCLUDE_IAP) -#include #endif -#if defined(PIOS_INCLUDE_ADXL345) + +/* PIOS sensor interfaces */ +#ifdef PIOS_INCLUDE_ADXL345 +/* ADXL345 3-Axis Accelerometer */ #include #endif -#if defined(PIOS_INCLUDE_BMA180) + +#ifdef PIOS_INCLUDE_BMA180 +/* BMA180 3-Axis Accelerometer */ #include #endif -#if defined(PIOS_INCLUDE_VIDEO) -#include -#endif -#if defined(PIOS_INCLUDE_WAVE) -#include + +#ifdef PIOS_INCLUDE_L3GD20 +/* L3GD20 3-Axis Gyro */ +#include #endif -#if defined(PIOS_INCLUDE_FLASH) +#ifdef PIOS_INCLUDE_MPU6000 +/* MPU6000 3-Axis Gyro/Accelerometer */ +/* #define PIOS_MPU6000_ACCEL */ +#include +#endif + +#ifdef PIOS_INCLUDE_HMC5843 +/* HMC5843 3-Axis Digital Compass */ +#include +#endif + +#ifdef PIOS_INCLUDE_HMC5883 +/* HMC5883 3-Axis Digital Compass */ +/* #define PIOS_HMC5883_HAS_GPIOS */ +#include +#endif + +#ifdef PIOS_INCLUDE_BMP085 +/* BMP085 Barometric Pressure Sensor */ +#include +#endif + +#ifdef PIOS_INCLUDE_MS5611 +/* MS5611 Barometric Pressure Sensor */ +#include +#endif + +#ifdef PIOS_INCLUDE_MPXV +/* MPXV5004, MPXV7002 based Airspeed Sensor */ +#include +#endif + +#ifdef PIOS_INCLUDE_ETASV3 +/* Eagle Tree Systems Airspeed MicroSensor V3 */ +#include +#endif + +#ifdef PIOS_INCLUDE_HCSR04 +/* HC-SR04 Ultrasonic Sensor */ +#include +#endif + +/* PIOS receiver drivers */ +#ifdef PIOS_INCLUDE_PWM +#include +#endif + +#ifdef PIOS_INCLUDE_PPM +#include +#endif + +#ifdef PIOS_INCLUDE_PPM_FLEXI +/* PPM on CC flexi port */ +#endif + +#ifdef PIOS_INCLUDE_DSM +#include +#endif + +#ifdef PIOS_INCLUDE_SBUS +#include +#endif + +#ifdef PIOS_INCLUDE_GCSRCVR +/* only priv header */ +#endif + +/* PIOS abstract receiver interface */ +#ifdef PIOS_INCLUDE_RCVR +#include +#endif + +/* PIOS common peripherals */ +#ifdef PIOS_INCLUDE_LED +#include +#endif + +#ifdef PIOS_INCLUDE_IAP +#include +#endif + +#ifdef PIOS_INCLUDE_SERVO +#include +#endif + +#ifdef PIOS_INCLUDE_I2C_ESC +#include +#endif + +#ifdef PIOS_INCLUDE_OVERO +/* #define PIOS_OVERO_SPI */ +#include +#endif + +#ifdef PIOS_INCLUDE_SDCARD +/* #define LOG_FILENAME "startup.log" */ +#include +#include +#endif + +#ifdef PIOS_INCLUDE_FLASH +/* #define PIOS_INCLUDE_FLASH_SECTOR_SETTINGS */ +/* #define FLASH_FREERTOS */ #include #include #endif -#if defined(PIOS_INCLUDE_BL_HELPER) -#include +#ifdef PIOS_INCLUDE_FLASH_EEPROM +#include #endif -#if defined(PIOS_INCLUDE_USB) -#include -#endif - -#if defined(PIOS_INCLUDE_RFM22B) +/* PIOS radio modules */ +#ifdef PIOS_INCLUDE_RFM22B +/* #define PIOS_INCLUDE_PPM_OUT */ +/* #define PIOS_RFM22B_DEBUG_ON_TELEM */ #include #ifdef PIOS_INCLUDE_RFM22B_COM #include @@ -177,10 +291,42 @@ #ifdef PIOS_INCLUDE_RFM22B_RCVR #include #endif +#endif /* PIOS_INCLUDE_RFM22B */ + +/* PIOS misc peripherals */ +#ifdef PIOS_INCLUDE_VIDEO +#include #endif -#include +#ifdef PIOS_INCLUDE_WAVE +#include +#endif -#define NELEMENTS(x) (sizeof(x) / sizeof(*(x))) -#endif /* USE_SIMPOSIX */ +#ifdef PIOS_INCLUDE_UDP +#include +#endif + +/* PIOS abstract comms interface with options */ +#ifdef PIOS_INCLUDE_COM +/* #define PIOS_INCLUDE_COM_MSG */ +/* #define PIOS_INCLUDE_TELEMETRY_RF */ +/* #define PIOS_INCLUDE_COM_TELEM */ +/* #define PIOS_INCLUDE_COM_FLEXI */ +/* #define PIOS_INCLUDE_COM_AUX */ +/* #define PIOS_TELEM_PRIORITY_QUEUE */ +/* #define PIOS_INCLUDE_GPS */ +/* #define PIOS_GPS_MINIMAL */ +/* #define PIOS_INCLUDE_GPS_NMEA_PARSER */ +/* #define PIOS_INCLUDE_GPS_UBX_PARSER */ +/* #define PIOS_GPS_SETS_HOMELOCATION */ +#include +#endif + +/* Stabilization options */ +/* #define PIOS_QUATERNION_STABILIZATION */ + +/* Performance counters */ +/* #define IDLE_COUNTS_PER_SEC_AT_NO_LOAD 995998 */ + +#endif /* USE_SIM_POSIX */ #endif /* PIOS_H */ diff --git a/flight/PiOS/pios_sim_posix.h b/flight/PiOS/pios_sim_posix.h index b51837f3e..12fd81725 100644 --- a/flight/PiOS/pios_sim_posix.h +++ b/flight/PiOS/pios_sim_posix.h @@ -75,6 +75,4 @@ #include #endif -#define NELEMENTS(x) (sizeof(x) / sizeof(*(x))) - #endif /* PIOS_POSIX_H */ diff --git a/flight/PiOS/posix/Libraries/FreeRTOS/library.mk b/flight/PiOS/posix/Libraries/FreeRTOS/library.mk index ae65aff82..c6267255f 100644 --- a/flight/PiOS/posix/Libraries/FreeRTOS/library.mk +++ b/flight/PiOS/posix/Libraries/FreeRTOS/library.mk @@ -5,7 +5,6 @@ # has been defined and add in the target-specific pieces separately. # -FREERTOS_DIR := $(dir $(lastword $(MAKEFILE_LIST)))/Source -SRC += $(wildcard $(FREERTOS_DIR)/*.c) -EXTRAINCDIRS += $(FREERTOS_DIR)/include - +FREERTOS_DIR := $(dir $(lastword $(MAKEFILE_LIST)))/Source +SRC += $(wildcard $(FREERTOS_DIR)/*.c) +EXTRAINCDIRS += $(FREERTOS_DIR)/include diff --git a/flight/Project/OpenOCD/foss-jtag.revb.ahrs.cfg b/flight/Project/OpenOCD/foss-jtag.revb.ahrs.cfg deleted file mode 100644 index a2214c6f4..000000000 --- a/flight/Project/OpenOCD/foss-jtag.revb.ahrs.cfg +++ /dev/null @@ -1,15 +0,0 @@ -# -# Floss JTAG OpenPilot -# - -interface ft2232 -ft2232_vid_pid 0x0403 0x6010 -#ft2232_device_desc "Dual RS232-HS" -#ft2232_bus_addr "002:088" -#ft2232_serial "1234567890" -ft2232_layout "usbjtag" -ft2232_latency 2 - -gdb_port 3334 -tcl_port 6666 -telnet_port 4444 diff --git a/flight/README.txt b/flight/README.txt index 7a8b04e9d..f5df8bc54 100644 --- a/flight/README.txt +++ b/flight/README.txt @@ -1,3 +1 @@ -Check the wiki - - +Check the wiki: http://wiki.openpilot.org/display/Doc/OpenPilot+Developer+Manual diff --git a/flight/targets/BootloaderUpdater/Makefile b/flight/targets/BootloaderUpdater/Makefile new file mode 100644 index 000000000..27f10363e --- /dev/null +++ b/flight/targets/BootloaderUpdater/Makefile @@ -0,0 +1,67 @@ +# +# Copyright (c) 2009-2013, The OpenPilot Team, http://www.openpilot.org +# +# 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 +# + +ifndef OPENPILOT_IS_COOL + $(error Top level Makefile must be used to build this target) +endif + +include $(ROOT_DIR)/make/boards/$(BOARD_NAME)/board-info.mk +include $(ROOT_DIR)/make/firmware-defs.mk + +# ARM DSP library +override USE_DSP_LIB := NO + +# Paths +TOPDIR = . +OPSYSTEM = $(TOPDIR) +OPSYSTEMINC = $(OPSYSTEM)/inc +PIOSINC = $(PIOS)/inc +PIOSCOMMON = $(PIOS)/Common +PIOSBOARDS = $(PIOS)/Boards +FLIGHTLIBINC = $(FLIGHTLIB)/inc + +# List C source files here (C dependencies are automatically generated). +# 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 + + # 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 + $(error Unsupported MCU for BootloaderUpdater: $(MCU)) +endif + +# List any extra directories to look for include files here. +# Each directory must be seperated by a space. +EXTRAINCDIRS += $(PIOS) +EXTRAINCDIRS += $(PIOSINC) +EXTRAINCDIRS += $(FLIGHTLIBINC) +EXTRAINCDIRS += $(PIOSCOMMON) +EXTRAINCDIRS += $(PIOSBOARDS) +EXTRAINCDIRS += $(HWDEFSINC) +EXTRAINCDIRS += $(OPSYSTEMINC) + +# Link: create ELF output file from object files. +EXTRAOBJ := $(BUILD_DIR)/bl_$(BOARD_NAME)/bl_$(BOARD_NAME).bin.o + +include $(ROOT_DIR)/make/common-defs.mk diff --git a/flight/targets/Bootloaders/BootloaderUpdater/inc/pios_config.h b/flight/targets/BootloaderUpdater/inc/pios_config.h similarity index 94% rename from flight/targets/Bootloaders/BootloaderUpdater/inc/pios_config.h rename to flight/targets/BootloaderUpdater/inc/pios_config.h index f31de6673..b9a0ebb3b 100644 --- a/flight/targets/Bootloaders/BootloaderUpdater/inc/pios_config.h +++ b/flight/targets/BootloaderUpdater/inc/pios_config.h @@ -27,19 +27,19 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - #ifndef PIOS_CONFIG_H #define PIOS_CONFIG_H -#define PIOS_INCLUDE_BL_HELPER + +/* Enable/Disable PiOS modules */ #define PIOS_INCLUDE_DELAY -#define PIOS_INCLUDE_LED #define PIOS_INCLUDE_SYS -#define PIOS_INCLUDE_GPIO -#define PIOS_NO_GPS -//#define DEBUG_SSP #define PIOS_INCLUDE_IRQ +#define PIOS_INCLUDE_GPIO +#define PIOS_INCLUDE_LED +#define PIOS_INCLUDE_BL_HELPER #endif /* PIOS_CONFIG_H */ + /** * @} * @} diff --git a/flight/targets/Bootloaders/BootloaderUpdater/main.c b/flight/targets/BootloaderUpdater/main.c similarity index 100% rename from flight/targets/Bootloaders/BootloaderUpdater/main.c rename to flight/targets/BootloaderUpdater/main.c diff --git a/flight/targets/Bootloaders/BootloaderUpdater/pios_board.c b/flight/targets/BootloaderUpdater/pios_board.c similarity index 100% rename from flight/targets/Bootloaders/BootloaderUpdater/pios_board.c rename to flight/targets/BootloaderUpdater/pios_board.c diff --git a/flight/targets/Bootloaders/BootloaderUpdater/Makefile b/flight/targets/Bootloaders/BootloaderUpdater/Makefile deleted file mode 100644 index 0ddea753b..000000000 --- a/flight/targets/Bootloaders/BootloaderUpdater/Makefile +++ /dev/null @@ -1,442 +0,0 @@ - ##### - # Project: OpenPilot - # - # - # Makefile for OpenPilot project build PiOS and the AP. - # - # The OpenPilot Team, http://www.openpilot.org, Copyright (C) 2009. - # - # - # 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 - -# Set developer code and compile options -# Set to YES to compile for debugging -DEBUG ?= NO - -# Set to YES to use the Servo output pins for debugging via scope or logic analyser -ENABLE_DEBUG_PINS ?= NO - -# Set to Yes to enable the AUX UART which is mapped on the S1 (Tx) and S2 (Rx) servo outputs -ENABLE_AUX_UART ?= NO - -# Set to YES when using Code Sourcery toolchain -CODE_SOURCERY ?= NO - -# Toolchain prefix (i.e arm-elf- -> arm-elf-gcc.exe) -TCHAIN_PREFIX ?= arm-none-eabi- - -# Remove command is different for Code Sourcery on Windows -ifeq ($(CODE_SOURCERY), YES) -REMOVE_CMD = cs-rm -else -REMOVE_CMD = rm -endif - -FLASH_TOOL = OPENOCD - -# Paths -OPSYSTEM = . -OPSYSTEMINC = $(OPSYSTEM)/inc -PIOSINC = $(PIOS)/inc -PIOSSTM32F10X = $(PIOS)/STM32F10x -PIOSCOMMON = $(PIOS)/Common -PIOSBOARDS = $(PIOS)/Boards -PIOSCOMMONLIB = $(PIOSCOMMON)/Libraries -APPLIBDIR = $(PIOSSTM32F10X)/Libraries -STMLIBDIR = $(APPLIBDIR) -STMSPDDIR = $(STMLIBDIR)/STM32F10x_StdPeriph_Driver -STMUSBDIR = $(STMLIBDIR)/STM32_USB-FS-Device_Driver -STMSPDSRCDIR = $(STMSPDDIR)/src -STMSPDINCDIR = $(STMSPDDIR)/inc -STMUSBSRCDIR = $(STMUSBDIR)/src -STMUSBINCDIR = $(STMUSBDIR)/inc -CMSISDIR = $(STMLIBDIR)/CMSIS/Core/CM3 -DOSFSDIR = $(APPLIBDIR)/dosfs -MSDDIR = $(APPLIBDIR)/msd -RTOSDIR = $(APPLIBDIR)/FreeRTOS -RTOSSRCDIR = $(RTOSDIR)/Source -RTOSINCDIR = $(RTOSSRCDIR)/include - -# List C source files here. (C dependencies are automatically generated.) -# use file-extension c for "c-only"-files - -## CORE: -SRC += $(OPSYSTEM)/main.c -SRC += $(OPSYSTEM)/pios_board.c - - -## PIOS Hardware (STM32F10x) -include $(PIOS)/STM32F10x/library.mk -SRC += $(PIOSSTM32F10X)/pios_sys.c -SRC += $(PIOSSTM32F10X)/pios_led.c -SRC += $(PIOSSTM32F10X)/pios_delay.c -SRC += $(PIOSSTM32F10X)/pios_irq.c -SRC += $(PIOSSTM32F10X)/pios_gpio.c - -## CMSIS for STM32 -SRC += $(CMSISDIR)/core_cm3.c -SRC += $(CMSISDIR)/system_stm32f10x.c - -## Used parts of the STM-Library -SRC += $(STMSPDSRCDIR)/stm32f10x_flash.c -SRC += $(STMSPDSRCDIR)/stm32f10x_gpio.c -SRC += $(STMSPDSRCDIR)/stm32f10x_rcc.c -SRC += $(STMSPDSRCDIR)/stm32f10x_rtc.c -SRC += $(STMSPDSRCDIR)/stm32f10x_tim.c -SRC += $(STMSPDSRCDIR)/misc.c - -# List C source files here which must be compiled in ARM-Mode (no -mthumb). -# use file-extension c for "c-only"-files -## just for testing, timer.c could be compiled in thumb-mode too -SRCARM = - -# List C++ source files here. -# use file-extension .cpp for C++-files (not .C) -CPPSRC = - -# List C++ source files here which must be compiled in ARM-Mode. -# use file-extension .cpp for C++-files (not .C) -#CPPSRCARM = $(TARGET).cpp -CPPSRCARM = - -# List Assembler source files here. -# Make them always end in a capital .S. Files ending in a lowercase .s -# will not be considered source files but generated files (assembler -# output from the compiler), and will be deleted upon "make clean"! -# Even though the DOS/Win* filesystem matches both .s and .S the same, -# it will preserve the spelling of the filenames, and gcc itself does -# care about how the name is spelled on its command-line. -ASRC = $(PIOSSTM32F10X)/startup_stm32f10x_$(MODEL)$(MODEL_SUFFIX).S - -# List Assembler source files here which must be assembled in ARM-Mode.. -ASRCARM = - -# List any extra directories to look for include files here. -# Each directory must be seperated by a space. -EXTRAINCDIRS += $(OPSYSTEM) -EXTRAINCDIRS += $(OPSYSTEMINC) -EXTRAINCDIRS += $(OPUAVTALK) -EXTRAINCDIRS += $(OPUAVTALKINC) -EXTRAINCDIRS += $(OPUAVOBJ) -EXTRAINCDIRS += $(OPUAVOBJINC) -EXTRAINCDIRS += $(PIOS) -EXTRAINCDIRS += $(PIOSINC) -EXTRAINCDIRS += $(FLIGHTLIBINC) -EXTRAINCDIRS += $(PIOSSTM32F10X) -EXTRAINCDIRS += $(PIOSCOMMON) -EXTRAINCDIRS += $(PIOSBOARDS) -EXTRAINCDIRS += $(STMSPDINCDIR) -EXTRAINCDIRS += $(STMUSBINCDIR) -EXTRAINCDIRS += $(CMSISDIR) -EXTRAINCDIRS += $(DOSFSDIR) -EXTRAINCDIRS += $(MSDDIR) -EXTRAINCDIRS += $(RTOSINCDIR) -EXTRAINCDIRS += $(APPLIBDIR) -EXTRAINCDIRS += $(RTOSSRCDIR)/portable/GCC/ARM_CM3 -EXTRAINCDIRS += $(HWDEFSINC) - - - -# List any extra directories to look for library files here. -# Also add directories where the linker should search for -# includes from linker-script to the list -# Each directory must be seperated by a space. -#EXTRA_LIBDIRS += - -# Extra Libraries -# Each library-name must be seperated by a space. -# i.e. to link with libxyz.a, libabc.a and libefsl.a: -# EXTRA_LIBS = xyz abc efsl -# for newlib-lpc (file: libnewlibc-lpc.a): -# EXTRA_LIBS = newlib-lpc -#EXTRA_LIBS += - -# Path to Linker-Scripts -LINKERSCRIPTPATH = $(PIOSSTM32F10X) - -# Optimization level, can be [0, 1, 2, 3, s]. -# 0 = turn off optimization. s = optimize for size. -# (Note: 3 is not always the best optimization level. See avr-libc FAQ.) - -ifeq ($(DEBUG),YES) -OPT = 0 -else -OPT = s -endif - -# Output format. (can be ihex or binary or both) -# binary to create a load-image in raw-binary format i.e. for SAM-BA, -# ihex to create a load-image in Intel hex format -#LOADFORMAT = ihex -#LOADFORMAT = binary -LOADFORMAT = both - -# Debugging format. -DEBUGF = dwarf-2 - -# Place project-specific -D (define) and/or -# -U options for C here. -CDEFS += -DSTM32F10X_$(MODEL) -CDEFS += -DUSE_STDPERIPH_DRIVER -CDEFS += -DUSE_$(BOARD) -ifeq ($(ENABLE_DEBUG_PINS), YES) -CDEFS += -DPIOS_ENABLE_DEBUG_PINS -endif -ifeq ($(ENABLE_AUX_UART), YES) -CDEFS += -DPIOS_ENABLE_AUX_UART -endif - -# Place project-specific -D and/or -U options for -# Assembler with preprocessor here. -#ADEFS = -DUSE_IRQ_ASM_WRAPPER -ADEFS = -D__ASSEMBLY__ - -# Compiler flag to set the C Standard level. -# c89 - "ANSI" C -# gnu89 - c89 plus GCC extensions -# c99 - ISO C99 standard (not yet fully implemented) -# gnu99 - c99 plus GCC extensions -CSTANDARD = -std=gnu99 - -#----- - -# Compiler flags. - -# -g*: generate debugging information -# -O*: optimization level -# -f...: tuning, see GCC manual and avr-libc documentation -# -Wall...: warning level -# -Wa,...: tell GCC to pass this to the assembler. -# -adhlns...: create assembler listing -# -# Flags for C and C++ (arm-elf-gcc/arm-elf-g++) - -ifeq ($(DEBUG),YES) -CFLAGS = -DDEBUG -endif - -CFLAGS += -g$(DEBUGF) -CFLAGS += -O$(OPT) -ifeq ($(DEBUG),NO) -CFLAGS += -ffunction-sections -endif - -CFLAGS += -mcpu=$(MCU) -mthumb -CFLAGS += $(CDEFS) -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 -CFLAGS += -Wa,-adhlns=$(addprefix $(OUTDIR)/, $(notdir $(addsuffix .lst, $(basename $<)))) -# Compiler flags to generate dependency files: -CFLAGS += -MD -MP -MF $(OUTDIR)/dep/$(@F).d - -# flags only for C -#CONLYFLAGS += -Wnested-externs -CONLYFLAGS += $(CSTANDARD) - -# Assembler flags. -# -Wa,...: tell GCC to pass this to the assembler. -# -ahlns: create listing -ASFLAGS = -mcpu=$(MCU) -mthumb -I. -x assembler-with-cpp -ASFLAGS += $(ADEFS) -ASFLAGS += -Wa,-adhlns=$(addprefix $(OUTDIR)/, $(notdir $(addsuffix .lst, $(basename $<)))) -ASFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) - -MATH_LIB = -lm - -# Linker flags. -# -Wl,...: tell GCC to pass this to linker. -# -Map: create map file -# --cref: add cross reference to map file -LDFLAGS = -nostartfiles -Wl,-Map=$(OUTDIR)/$(TARGET).map,--cref,--gc-sections -ifeq ($(DEBUG),NO) -LDFLAGS += -Wl,-static -endif -LDFLAGS += $(patsubst %,-L%,$(EXTRA_LIBDIRS)) -LDFLAGS += -lc -LDFLAGS += $(patsubst %,-l%,$(EXTRA_LIBS)) -LDFLAGS += $(MATH_LIB) -LDFLAGS += -lc -lgcc - -# Set linker-script name depending on selected submodel name -LDFLAGS += -T$(LINKERSCRIPTPATH)/link_$(BOARD)_memory.ld -LDFLAGS += -T$(LINKERSCRIPTPATH)/link_$(BOARD)_sections.ld - -OOCD_LOADFILE+=$(OUTDIR)/$(TARGET).bin -# Program -OOCD_CL+=-c "flash write_image erase $(OOCD_LOADFILE) $(START_OF_FW_CODE) bin" -# Verify -OOCD_CL+=-c "verify_image $(OOCD_LOADFILE) $(START_OF_FW_CODE) bin" -# reset target -OOCD_CL+=-c "reset run" -# terminate OOCD after programming -OOCD_CL+=-c shutdown -# --------------------------------------------------------------------------- - - -# Define programs and commands. -REMOVE = $(REMOVE_CMD) -f -###SHELL = sh -###COPY = cp - -# List of all source files. -ALLSRC = $(ASRCARM) $(ASRC) $(SRCARM) $(SRC) $(CPPSRCARM) $(CPPSRC) -# List of all source files without directory and file-extension. -ALLSRCBASE = $(notdir $(basename $(ALLSRC))) - -# Define all object files. -ALLOBJ = $(addprefix $(OUTDIR)/, $(addsuffix .o, $(ALLSRCBASE))) - -# Define all listing files (used for make clean). -LSTFILES = $(addprefix $(OUTDIR)/, $(addsuffix .lst, $(ALLSRCBASE))) -# Define all depedency-files (used for make clean). -DEPFILES = $(addprefix $(OUTDIR)/dep/, $(addsuffix .o.d, $(ALLSRCBASE))) - - -# Default target. -all: build - -ifeq ($(LOADFORMAT),ihex) -build: elf hex sym -else -ifeq ($(LOADFORMAT),binary) -build: elf bin sym -else -ifeq ($(LOADFORMAT),both) -build: elf hex bin sym -else -$(error "$(MSG_FORMATERROR) $(FORMAT)") -endif -endif -endif - -# Program the device. -ifeq ($(FLASH_TOOL),OPENOCD) -# Program the device with Dominic Rath's OPENOCD in "batch-mode", needs cfg and "reset-script". -program: $(OUTDIR)/$(TARGET).bin - @echo ${quote}Programming with OPENOCD${quote} - $(OOCD_EXE) $(OOCD_CL) -endif - -# Link: create ELF output file from object files. -BLOBJ := $(TOP)/build/bl_$(BOARD_NAME)/bl_$(BOARD_NAME).bin.o -$(eval $(call LINK_TEMPLATE, $(OUTDIR)/$(TARGET).elf, $(ALLOBJ) $(BLOBJ))) - -# Assemble: create object files from assembler source files. -$(foreach src, $(ASRC), $(eval $(call ASSEMBLE_TEMPLATE, $(src)))) - -# Assemble: create object files from assembler source files. ARM-only -$(foreach src, $(ASRCARM), $(eval $(call ASSEMBLE_ARM_TEMPLATE, $(src)))) - -# Compile: create object files from C source files. -$(foreach src, $(SRC), $(eval $(call COMPILE_C_TEMPLATE, $(src)))) - -# Compile: create object files from C source files. ARM-only -$(foreach src, $(SRCARM), $(eval $(call COMPILE_C_ARM_TEMPLATE, $(src)))) - -# Compile: create object files from C++ source files. -$(foreach src, $(CPPSRC), $(eval $(call COMPILE_CPP_TEMPLATE, $(src)))) - -# Compile: create object files from C++ source files. ARM-only -$(foreach src, $(CPPSRCARM), $(eval $(call COMPILE_CPP_ARM_TEMPLATE, $(src)))) - -# Compile: create assembler files from C source files. ARM/Thumb -$(eval $(call PARTIAL_COMPILE_TEMPLATE, SRC)) - -# Compile: create assembler files from C source files. ARM only -$(eval $(call PARTIAL_COMPILE_ARM_TEMPLATE, SRCARM)) - -$(OUTDIR)/$(TARGET).bin.o: $(OUTDIR)/$(TARGET).bin - -$(eval $(call OPFW_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(BOARD_TYPE),$(BOARD_REVISION))) - -.PHONY: elf lss sym hex bin bino opfw -elf: $(OUTDIR)/$(TARGET).elf -lss: $(OUTDIR)/$(TARGET).lss -sym: $(OUTDIR)/$(TARGET).sym -hex: $(OUTDIR)/$(TARGET).hex -bin: $(OUTDIR)/$(TARGET).bin -bino: $(OUTDIR)/$(TARGET).bin.o -opfw: $(OUTDIR)/$(TARGET).opfw - -# Display sizes of sections. -$(eval $(call SIZE_TEMPLATE, $(OUTDIR)/$(TARGET).elf)) -.PHONY: size -size: $(OUTDIR)/$(TARGET).elf_size - -# Generate Doxygen documents -docs: - doxygen $(DOXYGENDIR)/doxygen.cfg - -# Install: install binary file with prefix/suffix into install directory -install: $(OUTDIR)/$(TARGET).opfw -ifneq ($(INSTALL_DIR),) - @echo $(MSG_INSTALLING) $(call toprel, $<) - $(V1) mkdir -p $(INSTALL_DIR) - $(V1) $(INSTALL) $< $(INSTALL_DIR)/$(INSTALL_PFX)$(TARGET)$(INSTALL_SFX).opfw -else - $(error INSTALL_DIR must be specified for $@) -endif - -# Target: clean project. -clean: begin clean_list finished end - -clean_list : - @echo $(MSG_CLEANING) - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).map - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).elf - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).hex - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).bin - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).sym - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).lss - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).bin.o - $(V1) $(REMOVE) $(ALLOBJ) - $(V1) $(REMOVE) $(LSTFILES) - $(V1) $(REMOVE) $(DEPFILES) - $(V1) $(REMOVE) $(SRC:.c=.s) - $(V1) $(REMOVE) $(SRCARM:.c=.s) - $(V1) $(REMOVE) $(CPPSRC:.cpp=.s) - $(V1) $(REMOVE) $(CPPSRCARM:.cpp=.s) - -# Create output files directory -# all known MS Windows OS define the ComSpec environment variable -ifdef ComSpec -$(shell md $(subst /,\\,$(OUTDIR)) 2>NUL) -else -$(shell mkdir -p $(OUTDIR) 2>/dev/null) -endif - -# Include the dependency files. -ifdef ComSpec --include $(shell md $(subst /,\\,$(OUTDIR))\dep 2>NUL) $(wildcard $(OUTDIR)/dep/*) -else --include $(shell mkdir -p $(OUTDIR) 2>/dev/null) $(shell mkdir $(OUTDIR)/dep 2>/dev/null) $(wildcard $(OUTDIR)/dep/*) -endif - -# Listing of phony targets. -.PHONY : all build clean clean_list program install diff --git a/flight/targets/Bootloaders/CopterControl/Makefile b/flight/targets/Bootloaders/CopterControl/Makefile index 92f400fc5..bdfea5986 100644 --- a/flight/targets/Bootloaders/CopterControl/Makefile +++ b/flight/targets/Bootloaders/CopterControl/Makefile @@ -1,468 +1,29 @@ - ##### - # Project: OpenPilot - # - # - # Makefile for OpenPilot project build PiOS and the AP. - # - # The OpenPilot Team, http://www.openpilot.org, Copyright (C) 2009. - # - # - # 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 - -# Set developer code and compile options -# Set to YES to compile for debugging -DEBUG ?= NO - -# Set to YES to use the Servo output pins for debugging via scope or logic analyser -ENABLE_DEBUG_PINS ?= NO - -# Set to Yes to enable the AUX UART which is mapped on the S1 (Tx) and S2 (Rx) servo outputs -ENABLE_AUX_UART ?= NO - -# Set to YES when using Code Sourcery toolchain -CODE_SOURCERY ?= NO - -# Remove command is different for Code Sourcery on Windows -ifeq ($(CODE_SOURCERY), YES) -REMOVE_CMD = cs-rm -else -REMOVE_CMD = rm -endif - -FLASH_TOOL = OPENOCD - -# Paths -OPSYSTEM = . -OPSYSTEMINC = $(OPSYSTEM)/inc -FLIGHTLIBINC = $(FLIGHTLIB)/inc -PIOSINC = $(PIOS)/inc -PIOSSTM32F10X = $(PIOS)/STM32F10x -PIOSCOMMON = $(PIOS)/Common -PIOSBOARDS = $(PIOS)/Boards -PIOSCOMMONLIB = $(PIOSCOMMON)/Libraries -APPLIBDIR = $(PIOSSTM32F10X)/Libraries -STMLIBDIR = $(APPLIBDIR) -STMSPDDIR = $(STMLIBDIR)/STM32F10x_StdPeriph_Driver -STMUSBDIR = $(STMLIBDIR)/STM32_USB-FS-Device_Driver -STMSPDSRCDIR = $(STMSPDDIR)/src -STMSPDINCDIR = $(STMSPDDIR)/inc -STMUSBSRCDIR = $(STMUSBDIR)/src -STMUSBINCDIR = $(STMUSBDIR)/inc -CMSISDIR = $(STMLIBDIR)/CMSIS/Core/CM3 -DOSFSDIR = $(APPLIBDIR)/dosfs -MSDDIR = $(APPLIBDIR)/msd -RTOSDIR = $(APPLIBDIR)/FreeRTOS -RTOSSRCDIR = $(RTOSDIR)/Source -RTOSINCDIR = $(RTOSSRCDIR)/include - -# List C source files here. (C dependencies are automatically generated.) -# use file-extension c for "c-only"-files - -## COPTERCONTROL_BL CORE: -SRC += $(OPSYSTEM)/main.c -SRC += $(OPSYSTEM)/pios_board.c -SRC += $(OPSYSTEM)/op_dfu.c - -## PIOS Hardware (STM32F10x) -include $(PIOS)/STM32F10x/library.mk -SRC += $(PIOSSTM32F10X)/pios_sys.c -SRC += $(PIOSSTM32F10X)/pios_led.c -SRC += $(PIOSSTM32F10X)/pios_delay.c -SRC += $(PIOSSTM32F10X)/pios_usart.c -SRC += $(PIOSSTM32F10X)/pios_irq.c -SRC += $(PIOSSTM32F10X)/pios_debug.c -SRC += $(PIOSSTM32F10X)/pios_gpio.c -SRC += $(PIOSSTM32F10X)/pios_iap.c -SRC += $(PIOSSTM32F10X)/pios_bl_helper.c - -# PIOS USB related files (seperated to make code maintenance more easy) -SRC += $(PIOSSTM32F10X)/pios_usb.c -SRC += $(PIOSSTM32F10X)/pios_usbhook.c -SRC += $(PIOSSTM32F10X)/pios_usb_hid.c -SRC += $(PIOSSTM32F10X)/pios_usb_hid_istr.c -SRC += $(PIOSSTM32F10X)/pios_usb_hid_pwr.c -SRC += $(OPSYSTEM)/pios_usb_board_data.c -SRC += $(PIOSCOMMON)/pios_usb_desc_hid_only.c -SRC += $(PIOSCOMMON)/pios_usb_util.c - -## PIOS Hardware (Common) -SRC += $(PIOSCOMMON)/pios_board_info.c -SRC += $(PIOSCOMMON)/pios_com_msg.c -SRC += $(PIOSCOMMON)/printf-stdarg.c - -## Libraries for flight calculations -SRC += $(FLIGHTLIB)/fifo_buffer.c - -## CMSIS for STM32 -SRC += $(CMSISDIR)/core_cm3.c -SRC += $(CMSISDIR)/system_stm32f10x.c - -## Used parts of the STM-Library -SRC += $(STMSPDSRCDIR)/stm32f10x_bkp.c -SRC += $(STMSPDSRCDIR)/stm32f10x_crc.c -SRC += $(STMSPDSRCDIR)/stm32f10x_dma.c -SRC += $(STMSPDSRCDIR)/stm32f10x_exti.c -SRC += $(STMSPDSRCDIR)/stm32f10x_flash.c -SRC += $(STMSPDSRCDIR)/stm32f10x_gpio.c -SRC += $(STMSPDSRCDIR)/stm32f10x_pwr.c -SRC += $(STMSPDSRCDIR)/stm32f10x_rcc.c -SRC += $(STMSPDSRCDIR)/stm32f10x_rtc.c -SRC += $(STMSPDSRCDIR)/stm32f10x_spi.c -SRC += $(STMSPDSRCDIR)/stm32f10x_usart.c -SRC += $(STMSPDSRCDIR)/stm32f10x_dbgmcu.c -SRC += $(STMSPDSRCDIR)/misc.c - -## STM32 USB Library -SRC += $(STMUSBSRCDIR)/usb_core.c -SRC += $(STMUSBSRCDIR)/usb_init.c -SRC += $(STMUSBSRCDIR)/usb_int.c -SRC += $(STMUSBSRCDIR)/usb_mem.c -SRC += $(STMUSBSRCDIR)/usb_regs.c -SRC += $(STMUSBSRCDIR)/usb_sil.c - -# List C source files here which must be compiled in ARM-Mode (no -mthumb). -# use file-extension c for "c-only"-files -## just for testing, timer.c could be compiled in thumb-mode too -SRCARM = - -# List C++ source files here. -# use file-extension .cpp for C++-files (not .C) -CPPSRC = - -# List C++ source files here which must be compiled in ARM-Mode. -# use file-extension .cpp for C++-files (not .C) -#CPPSRCARM = $(TARGET).cpp -CPPSRCARM = - -# List Assembler source files here. -# Make them always end in a capital .S. Files ending in a lowercase .s -# will not be considered source files but generated files (assembler -# output from the compiler), and will be deleted upon "make clean"! -# Even though the DOS/Win* filesystem matches both .s and .S the same, -# it will preserve the spelling of the filenames, and gcc itself does -# care about how the name is spelled on its command-line. -ASRC = $(PIOSSTM32F10X)/startup_stm32f10x_$(MODEL)$(MODEL_SUFFIX).S - -# List Assembler source files here which must be assembled in ARM-Mode.. -ASRCARM = - -# List any extra directories to look for include files here. -# Each directory must be seperated by a space. -EXTRAINCDIRS += $(OPSYSTEM) -EXTRAINCDIRS += $(OPSYSTEMINC) -EXTRAINCDIRS += $(OPUAVTALK) -EXTRAINCDIRS += $(OPUAVTALKINC) -EXTRAINCDIRS += $(OPUAVOBJ) -EXTRAINCDIRS += $(OPUAVOBJINC) -EXTRAINCDIRS += $(PIOS) -EXTRAINCDIRS += $(PIOSINC) -EXTRAINCDIRS += $(FLIGHTLIBINC) -EXTRAINCDIRS += $(PIOSSTM32F10X) -EXTRAINCDIRS += $(PIOSCOMMON) -EXTRAINCDIRS += $(PIOSBOARDS) -EXTRAINCDIRS += $(STMSPDINCDIR) -EXTRAINCDIRS += $(STMUSBINCDIR) -EXTRAINCDIRS += $(CMSISDIR) -EXTRAINCDIRS += $(DOSFSDIR) -EXTRAINCDIRS += $(MSDDIR) -EXTRAINCDIRS += $(RTOSINCDIR) -EXTRAINCDIRS += $(APPLIBDIR) -EXTRAINCDIRS += $(RTOSSRCDIR)/portable/GCC/ARM_CM3 -EXTRAINCDIRS += $(HWDEFSINC) - -# List any extra directories to look for library files here. -# Also add directories where the linker should search for -# includes from linker-script to the list -# Each directory must be seperated by a space. -#EXTRA_LIBDIRS += - -# Extra Libraries -# Each library-name must be seperated by a space. -# i.e. to link with libxyz.a, libabc.a and libefsl.a: -# EXTRA_LIBS = xyz abc efsl -# for newlib-lpc (file: libnewlibc-lpc.a): -# EXTRA_LIBS = newlib-lpc -#EXTRA_LIBS += - -# Path to Linker-Scripts -LINKERSCRIPTPATH = $(PIOSSTM32F10X) - -# Optimization level, can be [0, 1, 2, 3, s]. -# 0 = turn off optimization. s = optimize for size. -# (Note: 3 is not always the best optimization level. See avr-libc FAQ.) - -ifeq ($(DEBUG),YES) -OPT = 0 -else -OPT = s -endif - -# Output format. (can be ihex or binary or both) -# binary to create a load-image in raw-binary format i.e. for SAM-BA, -# ihex to create a load-image in Intel hex format -#LOADFORMAT = ihex -#LOADFORMAT = binary -LOADFORMAT = both - -# Debugging format. -DEBUGF = dwarf-2 - -# Place project-specific -D (define) and/or -# -U options for C here. -CDEFS += -DSTM32F10X_$(MODEL) -CDEFS += -DUSE_STDPERIPH_DRIVER -CDEFS += -DUSE_$(BOARD) -ifeq ($(ENABLE_DEBUG_PINS), YES) -CDEFS += -DPIOS_ENABLE_DEBUG_PINS -endif -ifeq ($(ENABLE_AUX_UART), YES) -CDEFS += -DPIOS_ENABLE_AUX_UART -endif - -# 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) - -# Place project-specific -D and/or -U options for -# Assembler with preprocessor here. -#ADEFS = -DUSE_IRQ_ASM_WRAPPER -ADEFS = -D__ASSEMBLY__ - -# Compiler flag to set the C Standard level. -# c89 - "ANSI" C -# gnu89 - c89 plus GCC extensions -# c99 - ISO C99 standard (not yet fully implemented) -# gnu99 - c99 plus GCC extensions -CSTANDARD = -std=gnu99 - -#----- - -# Compiler flags. - -# -g*: generate debugging information -# -O*: optimization level -# -f...: tuning, see GCC manual and avr-libc documentation -# -Wall...: warning level -# -Wa,...: tell GCC to pass this to the assembler. -# -adhlns...: create assembler listing # -# Flags for C and C++ (arm-elf-gcc/arm-elf-g++) +# Copyright (c) 2009-2013, The OpenPilot Team, http://www.openpilot.org +# +# 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 +# -ifeq ($(DEBUG),YES) -CFLAGS += -DDEBUG +ifndef OPENPILOT_IS_COOL + $(error Top level Makefile must be used to build this target) endif -CFLAGS += -g$(DEBUGF) -CFLAGS += -O$(OPT) -ifeq ($(DEBUG),NO) -CFLAGS += -ffunction-sections -endif +include $(ROOT_DIR)/make/boards/$(BOARD_NAME)/board-info.mk +include $(ROOT_DIR)/make/firmware-defs.mk +include $(ROOT_DIR)/make/boot-defs.mk +include $(ROOT_DIR)/make/common-defs.mk -CFLAGS += -mcpu=$(MCU) -CFLAGS += $(CDEFS) -CFLAGS += $(BLONLY_CDEFS) -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 -CFLAGS += -Wa,-adhlns=$(addprefix $(OUTDIR)/, $(notdir $(addsuffix .lst, $(basename $<)))) -# Compiler flags to generate dependency files: -CFLAGS += -MD -MP -MF $(OUTDIR)/dep/$(@F).d - -# flags only for C -#CONLYFLAGS += -Wnested-externs -CONLYFLAGS += $(CSTANDARD) - -# Assembler flags. -# -Wa,...: tell GCC to pass this to the assembler. -# -ahlns: create listing -ASFLAGS = -mcpu=$(MCU) -I. -x assembler-with-cpp -ASFLAGS += $(ADEFS) -ASFLAGS += -Wa,-adhlns=$(addprefix $(OUTDIR)/, $(notdir $(addsuffix .lst, $(basename $<)))) -ASFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) - -MATH_LIB = -lm - -# Linker flags. -# -Wl,...: tell GCC to pass this to linker. -# -Map: create map file -# --cref: add cross reference to map file -LDFLAGS = -nostartfiles -Wl,-Map=$(OUTDIR)/$(TARGET).map,--cref,--gc-sections -ifeq ($(DEBUG),NO) -LDFLAGS += -Wl,-static -endif -LDFLAGS += $(patsubst %,-L%,$(EXTRA_LIBDIRS)) -LDFLAGS += -lc -LDFLAGS += $(patsubst %,-l%,$(EXTRA_LIBS)) -LDFLAGS += $(MATH_LIB) -LDFLAGS += -lc -lgcc - -# Set linker-script name depending on selected submodel name -LDFLAGS += -T$(LINKERSCRIPTPATH)/link_$(BOARD)_memory.ld -LDFLAGS += -T$(LINKERSCRIPTPATH)/link_$(BOARD)_BL_sections.ld - -# Define programs and commands. -REMOVE = $(REMOVE_CMD) -f - -# List of all source files. -ALLSRC = $(ASRCARM) $(ASRC) $(SRCARM) $(SRC) $(CPPSRCARM) $(CPPSRC) -# List of all source files without directory and file-extension. -ALLSRCBASE = $(notdir $(basename $(ALLSRC))) - -# Define all object files. -ALLOBJ = $(addprefix $(OUTDIR)/, $(addsuffix .o, $(ALLSRCBASE))) - -# Define all listing files (used for make clean). -LSTFILES = $(addprefix $(OUTDIR)/, $(addsuffix .lst, $(ALLSRCBASE))) -# Define all depedency-files (used for make clean). -DEPFILES = $(addprefix $(OUTDIR)/dep/, $(addsuffix .o.d, $(ALLSRCBASE))) - -# Default target. -all: build - -ifeq ($(LOADFORMAT),ihex) -build: elf hex sym -else -ifeq ($(LOADFORMAT),binary) -build: elf bin sym -else -ifeq ($(LOADFORMAT),both) -build: elf hex bin sym -else -$(error "$(MSG_FORMATERROR) $(FORMAT)") -endif -endif -endif - -${OUTDIR}/InitMods.c: Makefile - @echo $(MSG_MODINIT) $(call toprel, $@) - @echo ${quote}// Autogenerated file${quote} > ${OUTDIR}/InitMods.c - @echo ${quote}${foreach MOD, ${MODNAMES}, extern unsigned int ${MOD}Initialize(void);}${quote} >> ${OUTDIR}/InitMods.c - @echo ${quote}void InitModules() {${quote} >> ${OUTDIR}/InitMods.c - @echo ${quote}${foreach MOD, ${MODNAMES}, ${MOD}Initialize();}${quote} >> ${OUTDIR}/InitMods.c - @echo ${quote}}${quote} >> ${OUTDIR}/InitMods.c - -# Link: create ELF output file from object files. -$(eval $(call LINK_TEMPLATE, $(OUTDIR)/$(TARGET).elf, $(ALLOBJ))) - -# Assemble: create object files from assembler source files. -$(foreach src, $(ASRC), $(eval $(call ASSEMBLE_TEMPLATE, $(src)))) - -# Assemble: create object files from assembler source files. ARM-only -$(foreach src, $(ASRCARM), $(eval $(call ASSEMBLE_ARM_TEMPLATE, $(src)))) - -# Compile: create object files from C source files. -$(foreach src, $(SRC), $(eval $(call COMPILE_C_TEMPLATE, $(src)))) - -# Compile: create object files from C source files. ARM-only -$(foreach src, $(SRCARM), $(eval $(call COMPILE_C_ARM_TEMPLATE, $(src)))) - -# Compile: create object files from C++ source files. -$(foreach src, $(CPPSRC), $(eval $(call COMPILE_CPP_TEMPLATE, $(src)))) - -# Compile: create object files from C++ source files. ARM-only -$(foreach src, $(CPPSRCARM), $(eval $(call COMPILE_CPP_ARM_TEMPLATE, $(src)))) - -# Compile: create assembler files from C source files. ARM/Thumb -$(eval $(call PARTIAL_COMPILE_TEMPLATE, SRC)) - -# Compile: create assembler files from C source files. ARM only -$(eval $(call PARTIAL_COMPILE_ARM_TEMPLATE, SRCARM)) - -$(OUTDIR)/$(TARGET).bin.o: $(OUTDIR)/$(TARGET).bin - -# Add jtag targets (program and wipe) -$(eval $(call JTAG_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(BL_BANK_BASE),$(BL_BANK_SIZE),$(OPENOCD_JTAG_CONFIG),$(OPENOCD_CONFIG))) - -.PHONY: elf lss sym hex bin bino -elf: $(OUTDIR)/$(TARGET).elf -lss: $(OUTDIR)/$(TARGET).lss -sym: $(OUTDIR)/$(TARGET).sym -hex: $(OUTDIR)/$(TARGET).hex -bin: $(OUTDIR)/$(TARGET).bin -bino: $(OUTDIR)/$(TARGET).bin.o - -# Display sizes of sections. -$(eval $(call SIZE_TEMPLATE, $(OUTDIR)/$(TARGET).elf)) - -# Generate Doxygen documents -docs: - doxygen $(DOXYGENDIR)/doxygen.cfg - -# Install: install binary file with prefix/suffix into install directory -install: $(OUTDIR)/$(TARGET).bin -ifneq ($(INSTALL_DIR),) - @echo $(MSG_INSTALLING) $(call toprel, $<) - $(V1) mkdir -p $(INSTALL_DIR) - $(V1) $(INSTALL) $< $(INSTALL_DIR)/$(INSTALL_PFX)$(TARGET)$(INSTALL_SFX).bin -else - $(error INSTALL_DIR must be specified for $@) -endif - -# Target: clean project. -clean: clean_list - -clean_list : - @echo $(MSG_CLEANING) - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).map - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).elf - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).hex - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).bin - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).sym - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).lss - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).bin.o - $(V1) $(REMOVE) $(ALLOBJ) - $(V1) $(REMOVE) $(LSTFILES) - $(V1) $(REMOVE) $(DEPFILES) - $(V1) $(REMOVE) $(SRC:.c=.s) - $(V1) $(REMOVE) $(SRCARM:.c=.s) - $(V1) $(REMOVE) $(CPPSRC:.cpp=.s) - $(V1) $(REMOVE) $(CPPSRCARM:.cpp=.s) - - -# Create output files directory -# all known MS Windows OS define the ComSpec environment variable -ifdef ComSpec -$(shell md $(subst /,\\,$(OUTDIR)) 2>NUL) -else -$(shell mkdir -p $(OUTDIR) 2>/dev/null) -endif - -# Include the dependency files. -ifdef ComSpec --include $(shell md $(subst /,\\,$(OUTDIR))\dep 2>NUL) $(wildcard $(OUTDIR)/dep/*) -else --include $(shell mkdir -p $(OUTDIR) 2>/dev/null) $(shell mkdir $(OUTDIR)/dep 2>/dev/null) $(wildcard $(OUTDIR)/dep/*) -endif - -# Listing of phony targets. -.PHONY : all build clean clean_list install +$(info Making bootloader for CopterControl, board revision $(BOARD_REVISION)) +$(info Use BOARD_REVISION=1 for CC, BOARD_REVISION=2 for CC3D (default)) diff --git a/flight/targets/Bootloaders/CopterControl/inc/pios_config.h b/flight/targets/Bootloaders/CopterControl/inc/pios_config.h index 3eb2c281a..6661f0b18 100644 --- a/flight/targets/Bootloaders/CopterControl/inc/pios_config.h +++ b/flight/targets/Bootloaders/CopterControl/inc/pios_config.h @@ -30,21 +30,23 @@ #ifndef PIOS_CONFIG_H #define PIOS_CONFIG_H -#define PIOS_INCLUDE_BL_HELPER -#define PIOS_INCLUDE_BL_HELPER_WRITE_SUPPORT -/* Enable/Disable PiOS Modules */ + +/* Enable/Disable PiOS modules */ #define PIOS_INCLUDE_DELAY -#define PIOS_INCLUDE_IRQ -#define PIOS_INCLUDE_LED #define PIOS_INCLUDE_SYS +#define PIOS_INCLUDE_IRQ +#define PIOS_INCLUDE_GPIO #define PIOS_INCLUDE_USB #define PIOS_INCLUDE_USB_HID -#define PIOS_INCLUDE_COM_MSG -#define PIOS_INCLUDE_GPIO +#define PIOS_INCLUDE_LED #define PIOS_INCLUDE_IAP -#define PIOS_NO_GPS +#define PIOS_INCLUDE_COM +#define PIOS_INCLUDE_COM_MSG +#define PIOS_INCLUDE_BL_HELPER +#define PIOS_INCLUDE_BL_HELPER_WRITE_SUPPORT #endif /* PIOS_CONFIG_H */ + /** * @} * @} diff --git a/flight/targets/Bootloaders/OSD/Makefile b/flight/targets/Bootloaders/OSD/Makefile index 2eec92430..ed5d04928 100644 --- a/flight/targets/Bootloaders/OSD/Makefile +++ b/flight/targets/Bootloaders/OSD/Makefile @@ -1,374 +1,26 @@ - ##### - # Project: OpenPilot INS_BOOTLOADER - # - # - # Makefile for OpenPilot INS project - # - # The OpenPilot Team, http://www.openpilot.org, Copyright (C) 2009. - # - # - # 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 - -# Set developer code and compile options -# Set to YES for debugging -DEBUG ?= NO - -# Set to YES when using Code Sourcery toolchain -CODE_SOURCERY ?= NO - -ifeq ($(CODE_SOURCERY), YES) -REMOVE_CMD = cs-rm -else -REMOVE_CMD = rm -endif - -# Paths -OSD_BL = $(WHEREAMI) -OSD_BLINC = $(OSD_BL)/inc -PIOSINC = $(PIOS)/inc -FLIGHTLIBINC = $(FLIGHTLIB)/inc -PIOSSTM32F4XX = $(PIOS)/STM32F4xx -PIOSCOMMON = $(PIOS)/Common -PIOSBOARDS = $(PIOS)/Boards -PIOSCOMMONLIB = $(PIOSCOMMON)/Libraries -APPLIBDIR = $(PIOSSTM32F4XX)/Libraries -STMLIBDIR = $(APPLIBDIR) -STMSPDDIR = $(STMLIBDIR)/STM32F4xx_StdPeriph_Driver -STMSPDSRCDIR = $(STMSPDDIR)/src -STMSPDINCDIR = $(STMSPDDIR)/inc - -# List C source files here. (C dependencies are automatically generated.) -# use file-extension c for "c-only"-files - -## BOOTLOADER: -SRC += main.c -SRC += pios_board.c -SRC += pios_usb_board_data.c -SRC += op_dfu.c - -## PIOS Hardware (STM32F4xx) -include $(PIOS)/STM32F4xx/library.mk - -# PIOS Hardware (Common) -SRC += $(PIOSCOMMON)/pios_board_info.c -SRC += $(PIOSCOMMON)/pios_com_msg.c -SRC += $(PIOSCOMMON)/printf-stdarg.c -SRC += $(PIOSCOMMON)/pios_usb_desc_hid_only.c -SRC += $(PIOSCOMMON)/pios_usb_util.c - -# List C source files here which must be compiled in ARM-Mode (no -mthumb). -# use file-extension c for "c-only"-files -## just for testing, timer.c could be compiled in thumb-mode too -SRCARM = - -# List C++ source files here. -# use file-extension .cpp for C++-files (not .C) -CPPSRC = - -# List C++ source files here which must be compiled in ARM-Mode. -# use file-extension .cpp for C++-files (not .C) -#CPPSRCARM = $(TARGET).cpp -CPPSRCARM = - -# List any extra directories to look for include files here. -# Each directory must be seperated by a space. -EXTRAINCDIRS += $(PIOS) -EXTRAINCDIRS += $(PIOSINC) -EXTRAINCDIRS += $(FLIGHTLIBINC) -EXTRAINCDIRS += $(PIOSSTM34FXX) -EXTRAINCDIRS += $(PIOSCOMMON) -EXTRAINCDIRS += $(PIOSBOARDS) -EXTRAINCDIRS += $(STMSPDINCDIR) -EXTRAINCDIRS += $(CMSISDIR) -EXTRAINCDIRS += $(OSD_BLINC) -EXTRAINCDIRS += $(HWDEFSINC) - -# List any extra directories to look for library files here. -# Also add directories where the linker should search for -# includes from linker-script to the list -# Each directory must be seperated by a space. -#EXTRA_LIBDIRS += - -# Extra Libraries -# Each library-name must be seperated by a space. -# i.e. to link with libxyz.a, libabc.a and libefsl.a: -# EXTRA_LIBS = xyz abc efsl -# for newlib-lpc (file: libnewlibc-lpc.a): -# EXTRA_LIBS = newlib-lpc -#EXTRA_LIBS += - -# Path to Linker-Scripts -LINKERSCRIPTPATH = $(PIOSSTM32FXX) - -# Optimization level, can be [0, 1, 2, 3, s]. -# 0 = turn off optimization. s = optimize for size. -# (Note: 3 is not always the best optimization level. See avr-libc FAQ.) - -ifeq ($(DEBUG),YES) -OPT = 0 -else -OPT = s -endif - -# Output format. (can be ihex or binary or both) -# binary to create a load-image in raw-binary format i.e. for SAM-BA, -# ihex to create a load-image in Intel hex format -#LOADFORMAT = ihex -#LOADFORMAT = binary -LOADFORMAT = both - -# Debugging format. -DEBUGF = dwarf-2 - -# Place project-specific -D (define) and/or -# -U options for C here. -CDEFS += -DSTM32F4XX -CDEFS += -DSYSCLK_FREQ=$(SYSCLK_FREQ) -CDEFS += -DHSE_VALUE=$(OSCILLATOR_FREQ) -CDEFS += -DUSE_STDPERIPH_DRIVER -CDEFS += -DUSE_$(BOARD) - -# 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) - -# Place project-specific -D and/or -U options for -# Assembler with preprocessor here. -#ADEFS = -DUSE_IRQ_ASM_WRAPPER -ADEFS = -D__ASSEMBLY__ - -# Compiler flag to set the C Standard level. -# c89 - "ANSI" C -# gnu89 - c89 plus GCC extensions -# c99 - ISO C99 standard (not yet fully implemented) -# gnu99 - c99 plus GCC extensions -CSTANDARD = -std=gnu99 - -#----- - -# Compiler flags. - -# -g*: generate debugging information -# -O*: optimization level -# -f...: tuning, see GCC manual and avr-libc documentation -# -Wall...: warning level -# -Wa,...: tell GCC to pass this to the assembler. -# -adhlns...: create assembler listing # -# Flags for C and C++ (arm-elf-gcc/arm-elf-g++) +# Copyright (c) 2009-2013, The OpenPilot Team, http://www.openpilot.org +# +# 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 +# -ifeq ($(DEBUG),YES) -CFLAGS = +ifndef OPENPILOT_IS_COOL + $(error Top level Makefile must be used to build this target) endif -# This is not the best place for these. Really should abstract out -# to the board file or something -CFLAGS += -DSTM32F4XX -CFLAGS += -DMEM_SIZE=1024000000 - -CFLAGS += -g$(DEBUGF) -CFLAGS += -O$(OPT) -ifeq ($(DEBUG),NO) -CFLAGS += -fdata-sections -ffunction-sections -endif -CFLAGS += -mcpu=$(MCU) -CFLAGS += $(CDEFS) -CFLAGS += $(BLONLY_CDEFS) -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 -CFLAGS += -Wa,-adhlns=$(addprefix $(OUTDIR)/, $(notdir $(addsuffix .lst, $(basename $<)))) -# Compiler flags to generate dependency files: -CFLAGS += -MD -MP -MF $(OUTDIR)/dep/$(@F).d - -# flags only for C -#CONLYFLAGS += -Wnested-externs -CONLYFLAGS += $(CSTANDARD) - -# Assembler flags. -# -Wa,...: tell GCC to pass this to the assembler. -# -ahlns: create listing -ASFLAGS = -mcpu=$(MCU) -I. -x assembler-with-cpp -ASFLAGS += $(ADEFS) -ASFLAGS += -Wa,-adhlns=$(addprefix $(OUTDIR)/, $(notdir $(addsuffix .lst, $(basename $<)))) -ASFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) - -MATH_LIB = -lm - -# Linker flags. -# -Wl,...: tell GCC to pass this to linker. -# -Map: create map file -# --cref: add cross reference to map file -LDFLAGS = -nostartfiles -Wl,-Map=$(OUTDIR)/$(TARGET).map,--cref,--gc-sections -ifeq ($(DEBUG),NO) -LDFLAGS += -Wl,-static -endif -LDFLAGS += $(patsubst %,-L%,$(EXTRA_LIBDIRS)) -LDFLAGS += -lc -LDFLAGS += $(patsubst %,-l%,$(EXTRA_LIBS)) -LDFLAGS += $(MATH_LIB) -LDFLAGS += -lc -lgcc - -#Linker scripts -LDFLAGS += $(addprefix -T,$(LINKER_SCRIPTS_BL)) - -# Define programs and commands. -REMOVE = $(REMOVE_CMD) -f - -# List of all source files. -ALLSRC = $(ASRCARM) $(ASRC) $(SRCARM) $(SRC) $(CPPSRCARM) $(CPPSRC) -# List of all source files without directory and file-extension. -ALLSRCBASE = $(notdir $(basename $(ALLSRC))) - -# Define all object files. -ALLOBJ = $(addprefix $(OUTDIR)/, $(addsuffix .o, $(ALLSRCBASE))) - -# Define all listing files (used for make clean). -LSTFILES = $(addprefix $(OUTDIR)/, $(addsuffix .lst, $(ALLSRCBASE))) -# Define all depedency-files (used for make clean). -DEPFILES = $(addprefix $(OUTDIR)/dep/, $(addsuffix .o.d, $(ALLSRCBASE))) - -# Default target. -all: build - -ifeq ($(LOADFORMAT),ihex) -build: elf hex sym -else -ifeq ($(LOADFORMAT),binary) -build: elf bin sym -else -ifeq ($(LOADFORMAT),both) -build: elf hex bin sym -else -$(error "$(MSG_FORMATERROR) $(FORMAT)") -endif -endif -endif - -# Link: create ELF output file from object files. -$(eval $(call LINK_TEMPLATE, $(OUTDIR)/$(TARGET).elf, $(ALLOBJ))) - -# Assemble: create object files from assembler source files. -$(foreach src, $(ASRC), $(eval $(call ASSEMBLE_TEMPLATE, $(src)))) - -# Assemble: create object files from assembler source files. ARM-only -$(foreach src, $(ASRCARM), $(eval $(call ASSEMBLE_ARM_TEMPLATE, $(src)))) - -# Compile: create object files from C source files. -$(foreach src, $(SRC), $(eval $(call COMPILE_C_TEMPLATE, $(src)))) - -# Compile: create object files from C source files. ARM-only -$(foreach src, $(SRCARM), $(eval $(call COMPILE_C_ARM_TEMPLATE, $(src)))) - -# Compile: create object files from C++ source files. -$(foreach src, $(CPPSRC), $(eval $(call COMPILE_CPP_TEMPLATE, $(src)))) - -# Compile: create object files from C++ source files. ARM-only -$(foreach src, $(CPPSRCARM), $(eval $(call COMPILE_CPP_ARM_TEMPLATE, $(src)))) - -# Compile: create assembler files from C source files. ARM/Thumb -$(eval $(call PARTIAL_COMPILE_TEMPLATE, SRC)) - -# Compile: create assembler files from C source files. ARM only -$(eval $(call PARTIAL_COMPILE_ARM_TEMPLATE, SRCARM)) - -$(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,$(BL_BANK_BASE),$(BL_BANK_SIZE),$(OPENOCD_JTAG_CONFIG),$(OPENOCD_CONFIG))) - -.PHONY: elf lss sym hex bin bino -elf: $(OUTDIR)/$(TARGET).elf -lss: $(OUTDIR)/$(TARGET).lss -sym: $(OUTDIR)/$(TARGET).sym -hex: $(OUTDIR)/$(TARGET).hex -bin: $(OUTDIR)/$(TARGET).bin -bino: $(OUTDIR)/$(TARGET).bin.o - -# Display sizes of sections. -$(eval $(call SIZE_TEMPLATE, $(OUTDIR)/$(TARGET).elf)) - -# Generate Doxygen documents -docs: - doxygen $(DOXYGENDIR)/doxygen.cfg - -# Install: install binary file with prefix/suffix into install directory -install: $(OUTDIR)/$(TARGET).bin -ifneq ($(INSTALL_DIR),) - @echo $(MSG_INSTALLING) $(call toprel, $<) - $(V1) mkdir -p $(INSTALL_DIR) - $(V1) $(INSTALL) $< $(INSTALL_DIR)/$(INSTALL_PFX)$(TARGET)$(INSTALL_SFX).bin -else - $(error INSTALL_DIR must be specified for $@) -endif - -# Target: clean project. -clean: clean_list - -clean_list : - @echo $(MSG_CLEANING) - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).map - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).elf - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).hex - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).bin - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).sym - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).lss - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).bin.o - $(V1) $(REMOVE) $(ALLOBJ) - $(V1) $(REMOVE) $(LSTFILES) - $(V1) $(REMOVE) $(DEPFILES) - $(V1) $(REMOVE) $(SRC:.c=.s) - $(V1) $(REMOVE) $(SRCARM:.c=.s) - $(V1) $(REMOVE) $(CPPSRC:.cpp=.s) - $(V1) $(REMOVE) $(CPPSRCARM:.cpp=.s) - - -# Create output files directory -# all known MS Windows OS define the ComSpec environment variable -ifdef ComSpec -$(shell md $(subst /,\\,$(OUTDIR)) 2>NUL) -else -$(shell mkdir -p $(OUTDIR) 2>/dev/null) -endif - -# Include the dependency files. -ifdef ComSpec --include $(shell md $(subst /,\\,$(OUTDIR))\dep 2>NUL) $(wildcard $(OUTDIR)/dep/*) -else --include $(shell mkdir -p $(OUTDIR) 2>/dev/null) $(shell mkdir $(OUTDIR)/dep 2>/dev/null) $(wildcard $(OUTDIR)/dep/*) -endif - -# Listing of phony targets. -.PHONY : all build clean clean_list install +include $(ROOT_DIR)/make/boards/$(BOARD_NAME)/board-info.mk +include $(ROOT_DIR)/make/firmware-defs.mk +include $(ROOT_DIR)/make/boot-defs.mk +include $(ROOT_DIR)/make/common-defs.mk diff --git a/flight/targets/Bootloaders/OSD/inc/pios_config.h b/flight/targets/Bootloaders/OSD/inc/pios_config.h index dc71a1556..1d121c321 100644 --- a/flight/targets/Bootloaders/OSD/inc/pios_config.h +++ b/flight/targets/Bootloaders/OSD/inc/pios_config.h @@ -27,15 +27,15 @@ #ifndef PIOS_CONFIG_H #define PIOS_CONFIG_H -/* Enable/Disable PiOS Modules */ +/* Enable/Disable PiOS modules */ #define PIOS_INCLUDE_DELAY -#define PIOS_INCLUDE_IRQ -#define PIOS_INCLUDE_LED -#define PIOS_INCLUDE_SPI #define PIOS_INCLUDE_SYS -#define PIOS_INCLUDE_IAP +#define PIOS_INCLUDE_IRQ #define PIOS_INCLUDE_USB #define PIOS_INCLUDE_USB_HID +#define PIOS_INCLUDE_LED +#define PIOS_INCLUDE_IAP +#define PIOS_INCLUDE_COM #define PIOS_INCLUDE_COM_MSG #define PIOS_INCLUDE_BL_HELPER #define PIOS_INCLUDE_BL_HELPER_WRITE_SUPPORT diff --git a/flight/targets/Bootloaders/PipXtreme/Makefile b/flight/targets/Bootloaders/PipXtreme/Makefile index 818e0df1e..e6a37c2e4 100644 --- a/flight/targets/Bootloaders/PipXtreme/Makefile +++ b/flight/targets/Bootloaders/PipXtreme/Makefile @@ -1,470 +1,29 @@ - ##### - # Project: OpenPilot - # - # - # Makefile for OpenPilot project build PiOS and the AP. - # - # The OpenPilot Team, http://www.openpilot.org, Copyright (C) 2009. - # - # - # 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 - ##### +# +# Copyright (c) 2009-2013, The OpenPilot Team, http://www.openpilot.org +# +# 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 - -# Set developer code and compile options -# Set to YES to compile for debugging -DEBUG ?= NO - -# Set to YES to use the Servo output pins for debugging via scope or logic analyser -ENABLE_DEBUG_PINS ?= NO - -# Set to Yes to enable the AUX UART which is mapped on the S1 (Tx) and S2 (Rx) servo outputs -ENABLE_AUX_UART ?= NO - -# Set to YES when using Code Sourcery toolchain -CODE_SOURCERY ?= NO - -# Remove command is different for Code Sourcery on Windows -ifeq ($(CODE_SOURCERY), YES) -REMOVE_CMD = cs-rm -else -REMOVE_CMD = rm +ifndef OPENPILOT_IS_COOL + $(error Top level Makefile must be used to build this target) endif -FLASH_TOOL = OPENOCD +include $(ROOT_DIR)/make/boards/$(BOARD_NAME)/board-info.mk +include $(ROOT_DIR)/make/firmware-defs.mk +include $(ROOT_DIR)/make/boot-defs.mk +include $(ROOT_DIR)/make/common-defs.mk -# Paths -OPSYSTEM = . -OPSYSTEMINC = $(OPSYSTEM)/inc -FLIGHTLIBINC = $(FLIGHTLIB)/inc -PIOSINC = $(PIOS)/inc -PIOSSTM32F10X = $(PIOS)/STM32F10x -PIOSCOMMON = $(PIOS)/Common -PIOSBOARDS = $(PIOS)/Boards -PIOSCOMMONLIB = $(PIOSCOMMON)/Libraries -APPLIBDIR = $(PIOSSTM32F10X)/Libraries -STMLIBDIR = $(APPLIBDIR) -STMSPDDIR = $(STMLIBDIR)/STM32F10x_StdPeriph_Driver -STMUSBDIR = $(STMLIBDIR)/STM32_USB-FS-Device_Driver -STMSPDSRCDIR = $(STMSPDDIR)/src -STMSPDINCDIR = $(STMSPDDIR)/inc -STMUSBSRCDIR = $(STMUSBDIR)/src -STMUSBINCDIR = $(STMUSBDIR)/inc -CMSISDIR = $(STMLIBDIR)/CMSIS/Core/CM3 -DOSFSDIR = $(APPLIBDIR)/dosfs -MSDDIR = $(APPLIBDIR)/msd -RTOSDIR = $(APPLIBDIR)/FreeRTOS -RTOSSRCDIR = $(RTOSDIR)/Source -RTOSINCDIR = $(RTOSSRCDIR)/include - -# List C source files here. (C dependencies are automatically generated.) -# use file-extension c for "c-only"-files - -## OPENPILOT_BL CORE: -SRC += $(OPSYSTEM)/main.c -SRC += $(OPSYSTEM)/pios_board.c -SRC += $(OPSYSTEM)/op_dfu.c - -## PIOS Hardware (STM32F10x) -include $(PIOS)/STM32F10x/library.mk -SRC += $(PIOSSTM32F10X)/pios_sys.c -SRC += $(PIOSSTM32F10X)/pios_led.c -SRC += $(PIOSSTM32F10X)/pios_delay.c -SRC += $(PIOSSTM32F10X)/pios_usart.c -SRC += $(PIOSSTM32F10X)/pios_irq.c -SRC += $(PIOSSTM32F10X)/pios_debug.c -SRC += $(PIOSSTM32F10X)/pios_gpio.c -SRC += $(PIOSSTM32F10X)/pios_iap.c -SRC += $(PIOSSTM32F10X)/pios_bl_helper.c - -# PIOS USB related files (seperated to make code maintenance more easy) -SRC += $(PIOSSTM32F10X)/pios_usb.c -SRC += $(PIOSSTM32F10X)/pios_usbhook.c -SRC += $(PIOSSTM32F10X)/pios_usb_hid.c -SRC += $(PIOSSTM32F10X)/pios_usb_hid_istr.c -SRC += $(PIOSSTM32F10X)/pios_usb_hid_pwr.c -SRC += $(OPSYSTEM)/pios_usb_board_data.c -SRC += $(PIOSCOMMON)/pios_usb_desc_hid_only.c -SRC += $(PIOSCOMMON)/pios_usb_util.c - -## PIOS Hardware (Common) -SRC += $(PIOSCOMMON)/pios_board_info.c -SRC += $(PIOSCOMMON)/pios_com_msg.c -SRC += $(PIOSCOMMON)/printf-stdarg.c - -## Libraries for flight calculations -SRC += $(FLIGHTLIB)/fifo_buffer.c - -## CMSIS for STM32 -SRC += $(CMSISDIR)/core_cm3.c -SRC += $(CMSISDIR)/system_stm32f10x.c - -## Used parts of the STM-Library -SRC += $(STMSPDSRCDIR)/stm32f10x_bkp.c -SRC += $(STMSPDSRCDIR)/stm32f10x_crc.c -SRC += $(STMSPDSRCDIR)/stm32f10x_dma.c -SRC += $(STMSPDSRCDIR)/stm32f10x_exti.c -SRC += $(STMSPDSRCDIR)/stm32f10x_flash.c -SRC += $(STMSPDSRCDIR)/stm32f10x_gpio.c -SRC += $(STMSPDSRCDIR)/stm32f10x_pwr.c -SRC += $(STMSPDSRCDIR)/stm32f10x_rcc.c -SRC += $(STMSPDSRCDIR)/stm32f10x_rtc.c -SRC += $(STMSPDSRCDIR)/stm32f10x_spi.c -SRC += $(STMSPDSRCDIR)/stm32f10x_usart.c -SRC += $(STMSPDSRCDIR)/stm32f10x_dbgmcu.c -SRC += $(STMSPDSRCDIR)/misc.c - -## STM32 USB Library -SRC += $(STMUSBSRCDIR)/usb_core.c -SRC += $(STMUSBSRCDIR)/usb_init.c -SRC += $(STMUSBSRCDIR)/usb_int.c -SRC += $(STMUSBSRCDIR)/usb_mem.c -SRC += $(STMUSBSRCDIR)/usb_regs.c -SRC += $(STMUSBSRCDIR)/usb_sil.c - -# List C source files here which must be compiled in ARM-Mode (no -mthumb). -# use file-extension c for "c-only"-files -## just for testing, timer.c could be compiled in thumb-mode too -SRCARM = - -# List C++ source files here. -# use file-extension .cpp for C++-files (not .C) -CPPSRC = - -# List C++ source files here which must be compiled in ARM-Mode. -# use file-extension .cpp for C++-files (not .C) -#CPPSRCARM = $(TARGET).cpp -CPPSRCARM = - -# List Assembler source files here. -# Make them always end in a capital .S. Files ending in a lowercase .s -# will not be considered source files but generated files (assembler -# output from the compiler), and will be deleted upon "make clean"! -# Even though the DOS/Win* filesystem matches both .s and .S the same, -# it will preserve the spelling of the filenames, and gcc itself does -# care about how the name is spelled on its command-line. -ASRC = $(PIOSSTM32F10X)/startup_stm32f10x_$(MODEL)$(MODEL_SUFFIX).S - -# List Assembler source files here which must be assembled in ARM-Mode.. -ASRCARM = - -# List any extra directories to look for include files here. -# Each directory must be seperated by a space. -EXTRAINCDIRS += $(OPSYSTEM) -EXTRAINCDIRS += $(OPSYSTEMINC) -EXTRAINCDIRS += $(OPUAVTALK) -EXTRAINCDIRS += $(OPUAVTALKINC) -EXTRAINCDIRS += $(OPUAVOBJ) -EXTRAINCDIRS += $(OPUAVOBJINC) -EXTRAINCDIRS += $(PIOS) -EXTRAINCDIRS += $(PIOSINC) -EXTRAINCDIRS += $(FLIGHTLIBINC) -EXTRAINCDIRS += $(PIOSSTM32F10X) -EXTRAINCDIRS += $(PIOSCOMMON) -EXTRAINCDIRS += $(PIOSBOARDS) -EXTRAINCDIRS += $(STMSPDINCDIR) -EXTRAINCDIRS += $(STMUSBINCDIR) -EXTRAINCDIRS += $(CMSISDIR) -EXTRAINCDIRS += $(DOSFSDIR) -EXTRAINCDIRS += $(MSDDIR) -EXTRAINCDIRS += $(RTOSINCDIR) -EXTRAINCDIRS += $(APPLIBDIR) -EXTRAINCDIRS += $(RTOSSRCDIR)/portable/GCC/ARM_CM3 -EXTRAINCDIRS += $(HWDEFSINC) - -# List any extra directories to look for library files here. -# Also add directories where the linker should search for -# includes from linker-script to the list -# Each directory must be seperated by a space. -#EXTRA_LIBDIRS += - -# Extra Libraries -# Each library-name must be seperated by a space. -# i.e. to link with libxyz.a, libabc.a and libefsl.a: -# EXTRA_LIBS = xyz abc efsl -# for newlib-lpc (file: libnewlibc-lpc.a): -# EXTRA_LIBS = newlib-lpc -#EXTRA_LIBS += - -# Path to Linker-Scripts -LINKERSCRIPTPATH = $(PIOSSTM32F10X) - -# Optimization level, can be [0, 1, 2, 3, s]. -# 0 = turn off optimization. s = optimize for size. -# (Note: 3 is not always the best optimization level. See avr-libc FAQ.) - -ifeq ($(DEBUG),YES) -OPT = 0 -else -OPT = s -endif - -# Output format. (can be ihex or binary or both) -# binary to create a load-image in raw-binary format i.e. for SAM-BA, -# ihex to create a load-image in Intel hex format -#LOADFORMAT = ihex -#LOADFORMAT = binary -LOADFORMAT = both - -# Debugging format. -DEBUGF = dwarf-2 - -# Place project-specific -D (define) and/or -# -U options for C here. -CDEFS += -DSTM32F10X_$(MODEL) -CDEFS += -DUSE_STDPERIPH_DRIVER -CDEFS += -DUSE_$(BOARD) -ifeq ($(ENABLE_DEBUG_PINS), YES) -CDEFS += -DPIOS_ENABLE_DEBUG_PINS -endif -ifeq ($(ENABLE_AUX_UART), YES) -CDEFS += -DPIOS_ENABLE_AUX_UART -endif - -# 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) BLONLY_CDEFS += -DEE_BANK_BASE=$(EE_BANK_BASE) BLONLY_CDEFS += -DEE_BANK_SIZE=$(EE_BANK_SIZE) - -# Place project-specific -D and/or -U options for -# Assembler with preprocessor here. -#ADEFS = -DUSE_IRQ_ASM_WRAPPER -ADEFS = -D__ASSEMBLY__ - -# Compiler flag to set the C Standard level. -# c89 - "ANSI" C -# gnu89 - c89 plus GCC extensions -# c99 - ISO C99 standard (not yet fully implemented) -# gnu99 - c99 plus GCC extensions -CSTANDARD = -std=gnu99 - -#----- - -# Compiler flags. - -# -g*: generate debugging information -# -O*: optimization level -# -f...: tuning, see GCC manual and avr-libc documentation -# -Wall...: warning level -# -Wa,...: tell GCC to pass this to the assembler. -# -adhlns...: create assembler listing -# -# Flags for C and C++ (arm-elf-gcc/arm-elf-g++) - -ifeq ($(DEBUG),YES) -CFLAGS += -DDEBUG -endif - -CFLAGS += -g$(DEBUGF) -CFLAGS += -O$(OPT) -ifeq ($(DEBUG),NO) -CFLAGS += -ffunction-sections -endif - -CFLAGS += -mcpu=$(MCU) -CFLAGS += $(CDEFS) -CFLAGS += $(BLONLY_CDEFS) -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 -CFLAGS += -Wa,-adhlns=$(addprefix $(OUTDIR)/, $(notdir $(addsuffix .lst, $(basename $<)))) -# Compiler flags to generate dependency files: -CFLAGS += -MD -MP -MF $(OUTDIR)/dep/$(@F).d - -# flags only for C -#CONLYFLAGS += -Wnested-externs -CONLYFLAGS += $(CSTANDARD) - -# Assembler flags. -# -Wa,...: tell GCC to pass this to the assembler. -# -ahlns: create listing -ASFLAGS = -mcpu=$(MCU) -I. -x assembler-with-cpp -ASFLAGS += $(ADEFS) -ASFLAGS += -Wa,-adhlns=$(addprefix $(OUTDIR)/, $(notdir $(addsuffix .lst, $(basename $<)))) -ASFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) - -MATH_LIB = -lm - -# Linker flags. -# -Wl,...: tell GCC to pass this to linker. -# -Map: create map file -# --cref: add cross reference to map file -LDFLAGS = -nostartfiles -Wl,-Map=$(OUTDIR)/$(TARGET).map,--cref,--gc-sections -ifeq ($(DEBUG),NO) -LDFLAGS += -Wl,-static -endif -LDFLAGS += $(patsubst %,-L%,$(EXTRA_LIBDIRS)) -LDFLAGS += -lc -LDFLAGS += $(patsubst %,-l%,$(EXTRA_LIBS)) -LDFLAGS += $(MATH_LIB) -LDFLAGS += -lc -lgcc - -# Set linker-script name depending on selected submodel name -LDFLAGS += -T$(LINKERSCRIPTPATH)/link_$(BOARD)_memory.ld -LDFLAGS += -T$(LINKERSCRIPTPATH)/link_$(BOARD)_BL_sections.ld - -# Define programs and commands. -REMOVE = $(REMOVE_CMD) -f - -# List of all source files. -ALLSRC = $(ASRCARM) $(ASRC) $(SRCARM) $(SRC) $(CPPSRCARM) $(CPPSRC) -# List of all source files without directory and file-extension. -ALLSRCBASE = $(notdir $(basename $(ALLSRC))) - -# Define all object files. -ALLOBJ = $(addprefix $(OUTDIR)/, $(addsuffix .o, $(ALLSRCBASE))) - -# Define all listing files (used for make clean). -LSTFILES = $(addprefix $(OUTDIR)/, $(addsuffix .lst, $(ALLSRCBASE))) -# Define all depedency-files (used for make clean). -DEPFILES = $(addprefix $(OUTDIR)/dep/, $(addsuffix .o.d, $(ALLSRCBASE))) - -# Default target. -all: build - -ifeq ($(LOADFORMAT),ihex) -build: elf hex sym -else -ifeq ($(LOADFORMAT),binary) -build: elf bin sym -else -ifeq ($(LOADFORMAT),both) -build: elf hex bin sym -else -$(error "$(MSG_FORMATERROR) $(FORMAT)") -endif -endif -endif - -${OUTDIR}/InitMods.c: Makefile - @echo $(MSG_MODINIT) $(call toprel, $@) - @echo ${quote}// Autogenerated file${quote} > ${OUTDIR}/InitMods.c - @echo ${quote}${foreach MOD, ${MODNAMES}, extern unsigned int ${MOD}Initialize(void);}${quote} >> ${OUTDIR}/InitMods.c - @echo ${quote}void InitModules() {${quote} >> ${OUTDIR}/InitMods.c - @echo ${quote}${foreach MOD, ${MODNAMES}, ${MOD}Initialize();}${quote} >> ${OUTDIR}/InitMods.c - @echo ${quote}}${quote} >> ${OUTDIR}/InitMods.c - -# Link: create ELF output file from object files. -$(eval $(call LINK_TEMPLATE, $(OUTDIR)/$(TARGET).elf, $(ALLOBJ))) - -# Assemble: create object files from assembler source files. -$(foreach src, $(ASRC), $(eval $(call ASSEMBLE_TEMPLATE, $(src)))) - -# Assemble: create object files from assembler source files. ARM-only -$(foreach src, $(ASRCARM), $(eval $(call ASSEMBLE_ARM_TEMPLATE, $(src)))) - -# Compile: create object files from C source files. -$(foreach src, $(SRC), $(eval $(call COMPILE_C_TEMPLATE, $(src)))) - -# Compile: create object files from C source files. ARM-only -$(foreach src, $(SRCARM), $(eval $(call COMPILE_C_ARM_TEMPLATE, $(src)))) - -# Compile: create object files from C++ source files. -$(foreach src, $(CPPSRC), $(eval $(call COMPILE_CPP_TEMPLATE, $(src)))) - -# Compile: create object files from C++ source files. ARM-only -$(foreach src, $(CPPSRCARM), $(eval $(call COMPILE_CPP_ARM_TEMPLATE, $(src)))) - -# Compile: create assembler files from C source files. ARM/Thumb -$(eval $(call PARTIAL_COMPILE_TEMPLATE, SRC)) - -# Compile: create assembler files from C source files. ARM only -$(eval $(call PARTIAL_COMPILE_ARM_TEMPLATE, SRCARM)) - -$(OUTDIR)/$(TARGET).bin.o: $(OUTDIR)/$(TARGET).bin - -# Add jtag targets (program and wipe) -$(eval $(call JTAG_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(BL_BANK_BASE),$(BL_BANK_SIZE),$(OPENOCD_JTAG_CONFIG),$(OPENOCD_CONFIG))) - -.PHONY: elf lss sym hex bin bino -elf: $(OUTDIR)/$(TARGET).elf -lss: $(OUTDIR)/$(TARGET).lss -sym: $(OUTDIR)/$(TARGET).sym -hex: $(OUTDIR)/$(TARGET).hex -bin: $(OUTDIR)/$(TARGET).bin -bino: $(OUTDIR)/$(TARGET).bin.o - -# Display sizes of sections. -$(eval $(call SIZE_TEMPLATE, $(OUTDIR)/$(TARGET).elf)) - -# Generate Doxygen documents -docs: - doxygen $(DOXYGENDIR)/doxygen.cfg - -# Install: install binary file with prefix/suffix into install directory -install: $(OUTDIR)/$(TARGET).bin -ifneq ($(INSTALL_DIR),) - @echo $(MSG_INSTALLING) $(call toprel, $<) - $(V1) mkdir -p $(INSTALL_DIR) - $(V1) $(INSTALL) $< $(INSTALL_DIR)/$(INSTALL_PFX)$(TARGET)$(INSTALL_SFX).bin -else - $(error INSTALL_DIR must be specified for $@) -endif - -# Target: clean project. -clean: clean_list - -clean_list : - @echo $(MSG_CLEANING) - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).map - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).elf - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).hex - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).bin - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).sym - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).lss - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).bin.o - $(V1) $(REMOVE) $(ALLOBJ) - $(V1) $(REMOVE) $(LSTFILES) - $(V1) $(REMOVE) $(DEPFILES) - $(V1) $(REMOVE) $(SRC:.c=.s) - $(V1) $(REMOVE) $(SRCARM:.c=.s) - $(V1) $(REMOVE) $(CPPSRC:.cpp=.s) - $(V1) $(REMOVE) $(CPPSRCARM:.cpp=.s) - - -# Create output files directory -# all known MS Windows OS define the ComSpec environment variable -ifdef ComSpec -$(shell md $(subst /,\\,$(OUTDIR)) 2>NUL) -else -$(shell mkdir -p $(OUTDIR) 2>/dev/null) -endif - -# Include the dependency files. -ifdef ComSpec --include $(shell md $(subst /,\\,$(OUTDIR))\dep 2>NUL) $(wildcard $(OUTDIR)/dep/*) -else --include $(shell mkdir -p $(OUTDIR) 2>/dev/null) $(shell mkdir $(OUTDIR)/dep 2>/dev/null) $(wildcard $(OUTDIR)/dep/*) -endif - -# Listing of phony targets. -.PHONY : all build clean clean_list install diff --git a/flight/targets/Bootloaders/PipXtreme/inc/pios_config.h b/flight/targets/Bootloaders/PipXtreme/inc/pios_config.h index 1b1b9c2bc..f378c66b7 100644 --- a/flight/targets/Bootloaders/PipXtreme/inc/pios_config.h +++ b/flight/targets/Bootloaders/PipXtreme/inc/pios_config.h @@ -29,24 +29,23 @@ #ifndef PIOS_CONFIG_H #define PIOS_CONFIG_H -#define PIOS_INCLUDE_BL_HELPER -#define PIOS_INCLUDE_BL_HELPER_WRITE_SUPPORT -/* Enable/Disable PiOS Modules */ + +/* Enable/Disable PiOS modules */ #define PIOS_INCLUDE_DELAY -#define PIOS_INCLUDE_IRQ -#define PIOS_INCLUDE_LED #define PIOS_INCLUDE_SYS +#define PIOS_INCLUDE_IRQ +#define PIOS_INCLUDE_GPIO #define PIOS_INCLUDE_USB #define PIOS_INCLUDE_USB_HID -#define PIOS_INCLUDE_COM_MSG -#define PIOS_INCLUDE_GPIO +#define PIOS_INCLUDE_LED #define PIOS_INCLUDE_IAP - -/* Defaults for Logging */ -#define LOG_FILENAME "PIOS.LOG" -#define STARTUP_LOG_ENABLED 1 +#define PIOS_INCLUDE_COM +#define PIOS_INCLUDE_COM_MSG +#define PIOS_INCLUDE_BL_HELPER +#define PIOS_INCLUDE_BL_HELPER_WRITE_SUPPORT #endif /* PIOS_CONFIG_H */ + /** * @} * @} diff --git a/flight/targets/Bootloaders/RevoMini/Makefile b/flight/targets/Bootloaders/RevoMini/Makefile index 24c1f308e..ed5d04928 100644 --- a/flight/targets/Bootloaders/RevoMini/Makefile +++ b/flight/targets/Bootloaders/RevoMini/Makefile @@ -1,374 +1,26 @@ - ##### - # Project: OpenPilot INS_BOOTLOADER - # - # - # Makefile for OpenPilot INS project - # - # The OpenPilot Team, http://www.openpilot.org, Copyright (C) 2009. - # - # - # 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 - -# Set developer code and compile options -# Set to YES for debugging -DEBUG ?= NO - -# Set to YES when using Code Sourcery toolchain -CODE_SOURCERY ?= NO - -ifeq ($(CODE_SOURCERY), YES) -REMOVE_CMD = cs-rm -else -REMOVE_CMD = rm -endif - -# Paths -REVO_BL = $(WHEREAMI) -REVO_BLINC = $(REVO_BL)/inc -PIOSINC = $(PIOS)/inc -FLIGHTLIBINC = $(FLIGHTLIB)/inc -PIOSSTM32F4XX = $(PIOS)/STM32F4xx -PIOSCOMMON = $(PIOS)/Common -PIOSBOARDS = $(PIOS)/Boards -PIOSCOMMONLIB = $(PIOSCOMMON)/Libraries -APPLIBDIR = $(PIOSSTM32F4XX)/Libraries -STMLIBDIR = $(APPLIBDIR) -STMSPDDIR = $(STMLIBDIR)/STM32F4xx_StdPeriph_Driver -STMSPDSRCDIR = $(STMSPDDIR)/src -STMSPDINCDIR = $(STMSPDDIR)/inc - -# List C source files here. (C dependencies are automatically generated.) -# use file-extension c for "c-only"-files - -## BOOTLOADER: -SRC += main.c -SRC += pios_board.c -SRC += pios_usb_board_data.c -SRC += op_dfu.c - -## PIOS Hardware (STM32F4xx) -include $(PIOS)/STM32F4xx/library.mk - -# PIOS Hardware (Common) -SRC += $(PIOSCOMMON)/pios_board_info.c -SRC += $(PIOSCOMMON)/pios_com_msg.c -SRC += $(PIOSCOMMON)/printf-stdarg.c -SRC += $(PIOSCOMMON)/pios_usb_desc_hid_only.c -SRC += $(PIOSCOMMON)/pios_usb_util.c - -# List C source files here which must be compiled in ARM-Mode (no -mthumb). -# use file-extension c for "c-only"-files -## just for testing, timer.c could be compiled in thumb-mode too -SRCARM = - -# List C++ source files here. -# use file-extension .cpp for C++-files (not .C) -CPPSRC = - -# List C++ source files here which must be compiled in ARM-Mode. -# use file-extension .cpp for C++-files (not .C) -#CPPSRCARM = $(TARGET).cpp -CPPSRCARM = - -# List any extra directories to look for include files here. -# Each directory must be seperated by a space. -EXTRAINCDIRS += $(PIOS) -EXTRAINCDIRS += $(PIOSINC) -EXTRAINCDIRS += $(FLIGHTLIBINC) -EXTRAINCDIRS += $(PIOSSTM34FXX) -EXTRAINCDIRS += $(PIOSCOMMON) -EXTRAINCDIRS += $(PIOSBOARDS) -EXTRAINCDIRS += $(STMSPDINCDIR) -EXTRAINCDIRS += $(CMSISDIR) -EXTRAINCDIRS += $(REVO_BLINC) -EXTRAINCDIRS += $(HWDEFSINC) - -# List any extra directories to look for library files here. -# Also add directories where the linker should search for -# includes from linker-script to the list -# Each directory must be seperated by a space. -#EXTRA_LIBDIRS += - -# Extra Libraries -# Each library-name must be seperated by a space. -# i.e. to link with libxyz.a, libabc.a and libefsl.a: -# EXTRA_LIBS = xyz abc efsl -# for newlib-lpc (file: libnewlibc-lpc.a): -# EXTRA_LIBS = newlib-lpc -#EXTRA_LIBS += - -# Path to Linker-Scripts -LINKERSCRIPTPATH = $(PIOSSTM32FXX) - -# Optimization level, can be [0, 1, 2, 3, s]. -# 0 = turn off optimization. s = optimize for size. -# (Note: 3 is not always the best optimization level. See avr-libc FAQ.) - -ifeq ($(DEBUG),YES) -OPT = 0 -else -OPT = s -endif - -# Output format. (can be ihex or binary or both) -# binary to create a load-image in raw-binary format i.e. for SAM-BA, -# ihex to create a load-image in Intel hex format -#LOADFORMAT = ihex -#LOADFORMAT = binary -LOADFORMAT = both - -# Debugging format. -DEBUGF = dwarf-2 - -# Place project-specific -D (define) and/or -# -U options for C here. -CDEFS += -DSTM32F4XX -CDEFS += -DSYSCLK_FREQ=$(SYSCLK_FREQ) -CDEFS += -DHSE_VALUE=$(OSCILLATOR_FREQ) -CDEFS += -DUSE_STDPERIPH_DRIVER -CDEFS += -DUSE_$(BOARD) - -# 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) - -# Place project-specific -D and/or -U options for -# Assembler with preprocessor here. -#ADEFS = -DUSE_IRQ_ASM_WRAPPER -ADEFS = -D__ASSEMBLY__ - -# Compiler flag to set the C Standard level. -# c89 - "ANSI" C -# gnu89 - c89 plus GCC extensions -# c99 - ISO C99 standard (not yet fully implemented) -# gnu99 - c99 plus GCC extensions -CSTANDARD = -std=gnu99 - -#----- - -# Compiler flags. - -# -g*: generate debugging information -# -O*: optimization level -# -f...: tuning, see GCC manual and avr-libc documentation -# -Wall...: warning level -# -Wa,...: tell GCC to pass this to the assembler. -# -adhlns...: create assembler listing # -# Flags for C and C++ (arm-elf-gcc/arm-elf-g++) +# Copyright (c) 2009-2013, The OpenPilot Team, http://www.openpilot.org +# +# 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 +# -ifeq ($(DEBUG),YES) -CFLAGS = +ifndef OPENPILOT_IS_COOL + $(error Top level Makefile must be used to build this target) endif -# This is not the best place for these. Really should abstract out -# to the board file or something -CFLAGS += -DSTM32F4XX -CFLAGS += -DMEM_SIZE=1024000000 - -CFLAGS += -g$(DEBUGF) -CFLAGS += -O$(OPT) -ifeq ($(DEBUG),NO) -CFLAGS += -fdata-sections -ffunction-sections -endif -CFLAGS += -mcpu=$(MCU) -CFLAGS += $(CDEFS) -CFLAGS += $(BLONLY_CDEFS) -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 -CFLAGS += -Wa,-adhlns=$(addprefix $(OUTDIR)/, $(notdir $(addsuffix .lst, $(basename $<)))) -# Compiler flags to generate dependency files: -CFLAGS += -MD -MP -MF $(OUTDIR)/dep/$(@F).d - -# flags only for C -#CONLYFLAGS += -Wnested-externs -CONLYFLAGS += $(CSTANDARD) - -# Assembler flags. -# -Wa,...: tell GCC to pass this to the assembler. -# -ahlns: create listing -ASFLAGS = -mcpu=$(MCU) -I. -x assembler-with-cpp -ASFLAGS += $(ADEFS) -ASFLAGS += -Wa,-adhlns=$(addprefix $(OUTDIR)/, $(notdir $(addsuffix .lst, $(basename $<)))) -ASFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) - -MATH_LIB = -lm - -# Linker flags. -# -Wl,...: tell GCC to pass this to linker. -# -Map: create map file -# --cref: add cross reference to map file -LDFLAGS = -nostartfiles -Wl,-Map=$(OUTDIR)/$(TARGET).map,--cref,--gc-sections -ifeq ($(DEBUG),NO) -LDFLAGS += -Wl,-static -endif -LDFLAGS += $(patsubst %,-L%,$(EXTRA_LIBDIRS)) -LDFLAGS += -lc -LDFLAGS += $(patsubst %,-l%,$(EXTRA_LIBS)) -LDFLAGS += $(MATH_LIB) -LDFLAGS += -lc -lgcc - -#Linker scripts -LDFLAGS += $(addprefix -T,$(LINKER_SCRIPTS_BL)) - -# Define programs and commands. -REMOVE = $(REMOVE_CMD) -f - -# List of all source files. -ALLSRC = $(ASRCARM) $(ASRC) $(SRCARM) $(SRC) $(CPPSRCARM) $(CPPSRC) -# List of all source files without directory and file-extension. -ALLSRCBASE = $(notdir $(basename $(ALLSRC))) - -# Define all object files. -ALLOBJ = $(addprefix $(OUTDIR)/, $(addsuffix .o, $(ALLSRCBASE))) - -# Define all listing files (used for make clean). -LSTFILES = $(addprefix $(OUTDIR)/, $(addsuffix .lst, $(ALLSRCBASE))) -# Define all depedency-files (used for make clean). -DEPFILES = $(addprefix $(OUTDIR)/dep/, $(addsuffix .o.d, $(ALLSRCBASE))) - -# Default target. -all: build - -ifeq ($(LOADFORMAT),ihex) -build: elf hex sym -else -ifeq ($(LOADFORMAT),binary) -build: elf bin sym -else -ifeq ($(LOADFORMAT),both) -build: elf hex bin sym -else -$(error "$(MSG_FORMATERROR) $(FORMAT)") -endif -endif -endif - -# Link: create ELF output file from object files. -$(eval $(call LINK_TEMPLATE, $(OUTDIR)/$(TARGET).elf, $(ALLOBJ))) - -# Assemble: create object files from assembler source files. -$(foreach src, $(ASRC), $(eval $(call ASSEMBLE_TEMPLATE, $(src)))) - -# Assemble: create object files from assembler source files. ARM-only -$(foreach src, $(ASRCARM), $(eval $(call ASSEMBLE_ARM_TEMPLATE, $(src)))) - -# Compile: create object files from C source files. -$(foreach src, $(SRC), $(eval $(call COMPILE_C_TEMPLATE, $(src)))) - -# Compile: create object files from C source files. ARM-only -$(foreach src, $(SRCARM), $(eval $(call COMPILE_C_ARM_TEMPLATE, $(src)))) - -# Compile: create object files from C++ source files. -$(foreach src, $(CPPSRC), $(eval $(call COMPILE_CPP_TEMPLATE, $(src)))) - -# Compile: create object files from C++ source files. ARM-only -$(foreach src, $(CPPSRCARM), $(eval $(call COMPILE_CPP_ARM_TEMPLATE, $(src)))) - -# Compile: create assembler files from C source files. ARM/Thumb -$(eval $(call PARTIAL_COMPILE_TEMPLATE, SRC)) - -# Compile: create assembler files from C source files. ARM only -$(eval $(call PARTIAL_COMPILE_ARM_TEMPLATE, SRCARM)) - -$(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,$(BL_BANK_BASE),$(BL_BANK_SIZE),$(OPENOCD_JTAG_CONFIG),$(OPENOCD_CONFIG))) - -.PHONY: elf lss sym hex bin bino -elf: $(OUTDIR)/$(TARGET).elf -lss: $(OUTDIR)/$(TARGET).lss -sym: $(OUTDIR)/$(TARGET).sym -hex: $(OUTDIR)/$(TARGET).hex -bin: $(OUTDIR)/$(TARGET).bin -bino: $(OUTDIR)/$(TARGET).bin.o - -# Display sizes of sections. -$(eval $(call SIZE_TEMPLATE, $(OUTDIR)/$(TARGET).elf)) - -# Generate Doxygen documents -docs: - doxygen $(DOXYGENDIR)/doxygen.cfg - -# Install: install binary file with prefix/suffix into install directory -install: $(OUTDIR)/$(TARGET).bin -ifneq ($(INSTALL_DIR),) - @echo $(MSG_INSTALLING) $(call toprel, $<) - $(V1) mkdir -p $(INSTALL_DIR) - $(V1) $(INSTALL) $< $(INSTALL_DIR)/$(INSTALL_PFX)$(TARGET)$(INSTALL_SFX).bin -else - $(error INSTALL_DIR must be specified for $@) -endif - -# Target: clean project. -clean: clean_list - -clean_list : - @echo $(MSG_CLEANING) - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).map - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).elf - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).hex - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).bin - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).sym - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).lss - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).bin.o - $(V1) $(REMOVE) $(ALLOBJ) - $(V1) $(REMOVE) $(LSTFILES) - $(V1) $(REMOVE) $(DEPFILES) - $(V1) $(REMOVE) $(SRC:.c=.s) - $(V1) $(REMOVE) $(SRCARM:.c=.s) - $(V1) $(REMOVE) $(CPPSRC:.cpp=.s) - $(V1) $(REMOVE) $(CPPSRCARM:.cpp=.s) - - -# Create output files directory -# all known MS Windows OS define the ComSpec environment variable -ifdef ComSpec -$(shell md $(subst /,\\,$(OUTDIR)) 2>NUL) -else -$(shell mkdir -p $(OUTDIR) 2>/dev/null) -endif - -# Include the dependency files. -ifdef ComSpec --include $(shell md $(subst /,\\,$(OUTDIR))\dep 2>NUL) $(wildcard $(OUTDIR)/dep/*) -else --include $(shell mkdir -p $(OUTDIR) 2>/dev/null) $(shell mkdir $(OUTDIR)/dep 2>/dev/null) $(wildcard $(OUTDIR)/dep/*) -endif - -# Listing of phony targets. -.PHONY : all build clean clean_list install +include $(ROOT_DIR)/make/boards/$(BOARD_NAME)/board-info.mk +include $(ROOT_DIR)/make/firmware-defs.mk +include $(ROOT_DIR)/make/boot-defs.mk +include $(ROOT_DIR)/make/common-defs.mk diff --git a/flight/targets/Bootloaders/RevoMini/inc/pios_config.h b/flight/targets/Bootloaders/RevoMini/inc/pios_config.h index cfe34aaad..91c131ed3 100644 --- a/flight/targets/Bootloaders/RevoMini/inc/pios_config.h +++ b/flight/targets/Bootloaders/RevoMini/inc/pios_config.h @@ -27,15 +27,15 @@ #ifndef PIOS_CONFIG_H #define PIOS_CONFIG_H -/* Enable/Disable PiOS Modules */ + #define PIOS_INCLUDE_DELAY -#define PIOS_INCLUDE_IRQ -#define PIOS_INCLUDE_LED -#define PIOS_INCLUDE_SPI #define PIOS_INCLUDE_SYS -#define PIOS_INCLUDE_IAP +#define PIOS_INCLUDE_IRQ #define PIOS_INCLUDE_USB #define PIOS_INCLUDE_USB_HID +#define PIOS_INCLUDE_LED +#define PIOS_INCLUDE_IAP +#define PIOS_INCLUDE_COM #define PIOS_INCLUDE_COM_MSG #define PIOS_INCLUDE_BL_HELPER #define PIOS_INCLUDE_BL_HELPER_WRITE_SUPPORT diff --git a/flight/targets/Bootloaders/Revolution/Makefile b/flight/targets/Bootloaders/Revolution/Makefile index 24c1f308e..ed5d04928 100644 --- a/flight/targets/Bootloaders/Revolution/Makefile +++ b/flight/targets/Bootloaders/Revolution/Makefile @@ -1,374 +1,26 @@ - ##### - # Project: OpenPilot INS_BOOTLOADER - # - # - # Makefile for OpenPilot INS project - # - # The OpenPilot Team, http://www.openpilot.org, Copyright (C) 2009. - # - # - # 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 - -# Set developer code and compile options -# Set to YES for debugging -DEBUG ?= NO - -# Set to YES when using Code Sourcery toolchain -CODE_SOURCERY ?= NO - -ifeq ($(CODE_SOURCERY), YES) -REMOVE_CMD = cs-rm -else -REMOVE_CMD = rm -endif - -# Paths -REVO_BL = $(WHEREAMI) -REVO_BLINC = $(REVO_BL)/inc -PIOSINC = $(PIOS)/inc -FLIGHTLIBINC = $(FLIGHTLIB)/inc -PIOSSTM32F4XX = $(PIOS)/STM32F4xx -PIOSCOMMON = $(PIOS)/Common -PIOSBOARDS = $(PIOS)/Boards -PIOSCOMMONLIB = $(PIOSCOMMON)/Libraries -APPLIBDIR = $(PIOSSTM32F4XX)/Libraries -STMLIBDIR = $(APPLIBDIR) -STMSPDDIR = $(STMLIBDIR)/STM32F4xx_StdPeriph_Driver -STMSPDSRCDIR = $(STMSPDDIR)/src -STMSPDINCDIR = $(STMSPDDIR)/inc - -# List C source files here. (C dependencies are automatically generated.) -# use file-extension c for "c-only"-files - -## BOOTLOADER: -SRC += main.c -SRC += pios_board.c -SRC += pios_usb_board_data.c -SRC += op_dfu.c - -## PIOS Hardware (STM32F4xx) -include $(PIOS)/STM32F4xx/library.mk - -# PIOS Hardware (Common) -SRC += $(PIOSCOMMON)/pios_board_info.c -SRC += $(PIOSCOMMON)/pios_com_msg.c -SRC += $(PIOSCOMMON)/printf-stdarg.c -SRC += $(PIOSCOMMON)/pios_usb_desc_hid_only.c -SRC += $(PIOSCOMMON)/pios_usb_util.c - -# List C source files here which must be compiled in ARM-Mode (no -mthumb). -# use file-extension c for "c-only"-files -## just for testing, timer.c could be compiled in thumb-mode too -SRCARM = - -# List C++ source files here. -# use file-extension .cpp for C++-files (not .C) -CPPSRC = - -# List C++ source files here which must be compiled in ARM-Mode. -# use file-extension .cpp for C++-files (not .C) -#CPPSRCARM = $(TARGET).cpp -CPPSRCARM = - -# List any extra directories to look for include files here. -# Each directory must be seperated by a space. -EXTRAINCDIRS += $(PIOS) -EXTRAINCDIRS += $(PIOSINC) -EXTRAINCDIRS += $(FLIGHTLIBINC) -EXTRAINCDIRS += $(PIOSSTM34FXX) -EXTRAINCDIRS += $(PIOSCOMMON) -EXTRAINCDIRS += $(PIOSBOARDS) -EXTRAINCDIRS += $(STMSPDINCDIR) -EXTRAINCDIRS += $(CMSISDIR) -EXTRAINCDIRS += $(REVO_BLINC) -EXTRAINCDIRS += $(HWDEFSINC) - -# List any extra directories to look for library files here. -# Also add directories where the linker should search for -# includes from linker-script to the list -# Each directory must be seperated by a space. -#EXTRA_LIBDIRS += - -# Extra Libraries -# Each library-name must be seperated by a space. -# i.e. to link with libxyz.a, libabc.a and libefsl.a: -# EXTRA_LIBS = xyz abc efsl -# for newlib-lpc (file: libnewlibc-lpc.a): -# EXTRA_LIBS = newlib-lpc -#EXTRA_LIBS += - -# Path to Linker-Scripts -LINKERSCRIPTPATH = $(PIOSSTM32FXX) - -# Optimization level, can be [0, 1, 2, 3, s]. -# 0 = turn off optimization. s = optimize for size. -# (Note: 3 is not always the best optimization level. See avr-libc FAQ.) - -ifeq ($(DEBUG),YES) -OPT = 0 -else -OPT = s -endif - -# Output format. (can be ihex or binary or both) -# binary to create a load-image in raw-binary format i.e. for SAM-BA, -# ihex to create a load-image in Intel hex format -#LOADFORMAT = ihex -#LOADFORMAT = binary -LOADFORMAT = both - -# Debugging format. -DEBUGF = dwarf-2 - -# Place project-specific -D (define) and/or -# -U options for C here. -CDEFS += -DSTM32F4XX -CDEFS += -DSYSCLK_FREQ=$(SYSCLK_FREQ) -CDEFS += -DHSE_VALUE=$(OSCILLATOR_FREQ) -CDEFS += -DUSE_STDPERIPH_DRIVER -CDEFS += -DUSE_$(BOARD) - -# 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) - -# Place project-specific -D and/or -U options for -# Assembler with preprocessor here. -#ADEFS = -DUSE_IRQ_ASM_WRAPPER -ADEFS = -D__ASSEMBLY__ - -# Compiler flag to set the C Standard level. -# c89 - "ANSI" C -# gnu89 - c89 plus GCC extensions -# c99 - ISO C99 standard (not yet fully implemented) -# gnu99 - c99 plus GCC extensions -CSTANDARD = -std=gnu99 - -#----- - -# Compiler flags. - -# -g*: generate debugging information -# -O*: optimization level -# -f...: tuning, see GCC manual and avr-libc documentation -# -Wall...: warning level -# -Wa,...: tell GCC to pass this to the assembler. -# -adhlns...: create assembler listing # -# Flags for C and C++ (arm-elf-gcc/arm-elf-g++) +# Copyright (c) 2009-2013, The OpenPilot Team, http://www.openpilot.org +# +# 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 +# -ifeq ($(DEBUG),YES) -CFLAGS = +ifndef OPENPILOT_IS_COOL + $(error Top level Makefile must be used to build this target) endif -# This is not the best place for these. Really should abstract out -# to the board file or something -CFLAGS += -DSTM32F4XX -CFLAGS += -DMEM_SIZE=1024000000 - -CFLAGS += -g$(DEBUGF) -CFLAGS += -O$(OPT) -ifeq ($(DEBUG),NO) -CFLAGS += -fdata-sections -ffunction-sections -endif -CFLAGS += -mcpu=$(MCU) -CFLAGS += $(CDEFS) -CFLAGS += $(BLONLY_CDEFS) -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 -CFLAGS += -Wa,-adhlns=$(addprefix $(OUTDIR)/, $(notdir $(addsuffix .lst, $(basename $<)))) -# Compiler flags to generate dependency files: -CFLAGS += -MD -MP -MF $(OUTDIR)/dep/$(@F).d - -# flags only for C -#CONLYFLAGS += -Wnested-externs -CONLYFLAGS += $(CSTANDARD) - -# Assembler flags. -# -Wa,...: tell GCC to pass this to the assembler. -# -ahlns: create listing -ASFLAGS = -mcpu=$(MCU) -I. -x assembler-with-cpp -ASFLAGS += $(ADEFS) -ASFLAGS += -Wa,-adhlns=$(addprefix $(OUTDIR)/, $(notdir $(addsuffix .lst, $(basename $<)))) -ASFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) - -MATH_LIB = -lm - -# Linker flags. -# -Wl,...: tell GCC to pass this to linker. -# -Map: create map file -# --cref: add cross reference to map file -LDFLAGS = -nostartfiles -Wl,-Map=$(OUTDIR)/$(TARGET).map,--cref,--gc-sections -ifeq ($(DEBUG),NO) -LDFLAGS += -Wl,-static -endif -LDFLAGS += $(patsubst %,-L%,$(EXTRA_LIBDIRS)) -LDFLAGS += -lc -LDFLAGS += $(patsubst %,-l%,$(EXTRA_LIBS)) -LDFLAGS += $(MATH_LIB) -LDFLAGS += -lc -lgcc - -#Linker scripts -LDFLAGS += $(addprefix -T,$(LINKER_SCRIPTS_BL)) - -# Define programs and commands. -REMOVE = $(REMOVE_CMD) -f - -# List of all source files. -ALLSRC = $(ASRCARM) $(ASRC) $(SRCARM) $(SRC) $(CPPSRCARM) $(CPPSRC) -# List of all source files without directory and file-extension. -ALLSRCBASE = $(notdir $(basename $(ALLSRC))) - -# Define all object files. -ALLOBJ = $(addprefix $(OUTDIR)/, $(addsuffix .o, $(ALLSRCBASE))) - -# Define all listing files (used for make clean). -LSTFILES = $(addprefix $(OUTDIR)/, $(addsuffix .lst, $(ALLSRCBASE))) -# Define all depedency-files (used for make clean). -DEPFILES = $(addprefix $(OUTDIR)/dep/, $(addsuffix .o.d, $(ALLSRCBASE))) - -# Default target. -all: build - -ifeq ($(LOADFORMAT),ihex) -build: elf hex sym -else -ifeq ($(LOADFORMAT),binary) -build: elf bin sym -else -ifeq ($(LOADFORMAT),both) -build: elf hex bin sym -else -$(error "$(MSG_FORMATERROR) $(FORMAT)") -endif -endif -endif - -# Link: create ELF output file from object files. -$(eval $(call LINK_TEMPLATE, $(OUTDIR)/$(TARGET).elf, $(ALLOBJ))) - -# Assemble: create object files from assembler source files. -$(foreach src, $(ASRC), $(eval $(call ASSEMBLE_TEMPLATE, $(src)))) - -# Assemble: create object files from assembler source files. ARM-only -$(foreach src, $(ASRCARM), $(eval $(call ASSEMBLE_ARM_TEMPLATE, $(src)))) - -# Compile: create object files from C source files. -$(foreach src, $(SRC), $(eval $(call COMPILE_C_TEMPLATE, $(src)))) - -# Compile: create object files from C source files. ARM-only -$(foreach src, $(SRCARM), $(eval $(call COMPILE_C_ARM_TEMPLATE, $(src)))) - -# Compile: create object files from C++ source files. -$(foreach src, $(CPPSRC), $(eval $(call COMPILE_CPP_TEMPLATE, $(src)))) - -# Compile: create object files from C++ source files. ARM-only -$(foreach src, $(CPPSRCARM), $(eval $(call COMPILE_CPP_ARM_TEMPLATE, $(src)))) - -# Compile: create assembler files from C source files. ARM/Thumb -$(eval $(call PARTIAL_COMPILE_TEMPLATE, SRC)) - -# Compile: create assembler files from C source files. ARM only -$(eval $(call PARTIAL_COMPILE_ARM_TEMPLATE, SRCARM)) - -$(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,$(BL_BANK_BASE),$(BL_BANK_SIZE),$(OPENOCD_JTAG_CONFIG),$(OPENOCD_CONFIG))) - -.PHONY: elf lss sym hex bin bino -elf: $(OUTDIR)/$(TARGET).elf -lss: $(OUTDIR)/$(TARGET).lss -sym: $(OUTDIR)/$(TARGET).sym -hex: $(OUTDIR)/$(TARGET).hex -bin: $(OUTDIR)/$(TARGET).bin -bino: $(OUTDIR)/$(TARGET).bin.o - -# Display sizes of sections. -$(eval $(call SIZE_TEMPLATE, $(OUTDIR)/$(TARGET).elf)) - -# Generate Doxygen documents -docs: - doxygen $(DOXYGENDIR)/doxygen.cfg - -# Install: install binary file with prefix/suffix into install directory -install: $(OUTDIR)/$(TARGET).bin -ifneq ($(INSTALL_DIR),) - @echo $(MSG_INSTALLING) $(call toprel, $<) - $(V1) mkdir -p $(INSTALL_DIR) - $(V1) $(INSTALL) $< $(INSTALL_DIR)/$(INSTALL_PFX)$(TARGET)$(INSTALL_SFX).bin -else - $(error INSTALL_DIR must be specified for $@) -endif - -# Target: clean project. -clean: clean_list - -clean_list : - @echo $(MSG_CLEANING) - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).map - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).elf - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).hex - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).bin - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).sym - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).lss - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).bin.o - $(V1) $(REMOVE) $(ALLOBJ) - $(V1) $(REMOVE) $(LSTFILES) - $(V1) $(REMOVE) $(DEPFILES) - $(V1) $(REMOVE) $(SRC:.c=.s) - $(V1) $(REMOVE) $(SRCARM:.c=.s) - $(V1) $(REMOVE) $(CPPSRC:.cpp=.s) - $(V1) $(REMOVE) $(CPPSRCARM:.cpp=.s) - - -# Create output files directory -# all known MS Windows OS define the ComSpec environment variable -ifdef ComSpec -$(shell md $(subst /,\\,$(OUTDIR)) 2>NUL) -else -$(shell mkdir -p $(OUTDIR) 2>/dev/null) -endif - -# Include the dependency files. -ifdef ComSpec --include $(shell md $(subst /,\\,$(OUTDIR))\dep 2>NUL) $(wildcard $(OUTDIR)/dep/*) -else --include $(shell mkdir -p $(OUTDIR) 2>/dev/null) $(shell mkdir $(OUTDIR)/dep 2>/dev/null) $(wildcard $(OUTDIR)/dep/*) -endif - -# Listing of phony targets. -.PHONY : all build clean clean_list install +include $(ROOT_DIR)/make/boards/$(BOARD_NAME)/board-info.mk +include $(ROOT_DIR)/make/firmware-defs.mk +include $(ROOT_DIR)/make/boot-defs.mk +include $(ROOT_DIR)/make/common-defs.mk diff --git a/flight/targets/Bootloaders/Revolution/inc/pios_config.h b/flight/targets/Bootloaders/Revolution/inc/pios_config.h index dc71a1556..1d121c321 100644 --- a/flight/targets/Bootloaders/Revolution/inc/pios_config.h +++ b/flight/targets/Bootloaders/Revolution/inc/pios_config.h @@ -27,15 +27,15 @@ #ifndef PIOS_CONFIG_H #define PIOS_CONFIG_H -/* Enable/Disable PiOS Modules */ +/* Enable/Disable PiOS modules */ #define PIOS_INCLUDE_DELAY -#define PIOS_INCLUDE_IRQ -#define PIOS_INCLUDE_LED -#define PIOS_INCLUDE_SPI #define PIOS_INCLUDE_SYS -#define PIOS_INCLUDE_IAP +#define PIOS_INCLUDE_IRQ #define PIOS_INCLUDE_USB #define PIOS_INCLUDE_USB_HID +#define PIOS_INCLUDE_LED +#define PIOS_INCLUDE_IAP +#define PIOS_INCLUDE_COM #define PIOS_INCLUDE_COM_MSG #define PIOS_INCLUDE_BL_HELPER #define PIOS_INCLUDE_BL_HELPER_WRITE_SUPPORT diff --git a/flight/targets/CopterControl/Makefile b/flight/targets/CopterControl/Makefile index e2a603587..1db667a81 100644 --- a/flight/targets/CopterControl/Makefile +++ b/flight/targets/CopterControl/Makefile @@ -1,13 +1,6 @@ -############################################################################### -# @file Makefile -# @author The OpenPilot Team, http://www.openpilot.org, Copyright (C) 2009. -# @author PhoenixPilot, http://github.com/PhoenixPilot, Copyright (C) 2012 -# @addtogroup -# @{ -# @addtogroup -# @{ -# @brief Makefile to build firmware for the CopterControl board. -############################################################################### +# +# Copyright (c) 2009-2013, The OpenPilot Team, http://www.openpilot.org +# Copyright (c) 2012, PhoenixPilot, http://github.com/PhoenixPilot # # 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 @@ -24,699 +17,102 @@ # 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 +ifndef OPENPILOT_IS_COOL + $(error Top level Makefile must be used to build this target) +endif -# Set developer code and compile options -# Set to YES to compile for debugging -DEBUG ?= NO +include $(ROOT_DIR)/make/boards/$(BOARD_NAME)/board-info.mk +include $(ROOT_DIR)/make/firmware-defs.mk -# Include objects that are just nice information to show -STACK_DIAGNOSTICS ?= NO -MIXERSTATUS_DIAGNOSTICS ?= NO -RATEDESIRED_DIAGNOSTICS ?= NO -I2C_WDG_STATS_DIAGNOSTICS ?= NO -DIAG_TASKS ?= NO +# ARM DSP library +USE_DSP_LIB ?= NO -#Or just turn on all the above diagnostics. WARNING: This consumes massive amounts of memory. -ALL_DIGNOSTICS ?=NO - -# Set to YES to build a FW version that will erase all flash memory +# Set to YES to build a FW version that will erase data flash memory ERASE_FLASH ?= NO -# Set to YES to use the Servo output pins for debugging via scope or logic analyser -ENABLE_DEBUG_PINS ?= NO - -# Set to Yes to enable the AUX UART which is mapped on the S1 (Tx) and S2 (Rx) servo outputs -ENABLE_AUX_UART ?= NO - -# Set to YES when using Code Sourcery toolchain -CODE_SOURCERY ?= NO - -# Remove command is different for Code Sourcery on Windows -ifeq ($(CODE_SOURCERY), YES) -REMOVE_CMD = cs-rm -else -REMOVE_CMD = rm -endif - -FLASH_TOOL = OPENOCD - -# Optional module and driver defaults -USE_CAMERASTAB ?= YES -USE_COMUSBBRIDGE ?= YES -USE_GPS ?= YES -USE_TXPID ?= YES -USE_I2C ?= NO -USE_ALTITUDE ?= NO -USE_AUTOTUNE ?= YES -TEST_FAULTS ?= NO - -# Camera gimbal options -USE_INPUT_LPF ?= YES -USE_GIMBAL_LPF ?= YES -USE_GIMBAL_FF ?= YES - -# List of optional modules to include -OPTMODULES = -ifeq ($(USE_CAMERASTAB), YES) -OPTMODULES += CameraStab -endif -ifeq ($(USE_COMUSBBRIDGE), YES) -OPTMODULES += ComUsbBridge -endif -ifeq ($(USE_GPS), YES) -OPTMODULES += GPS -endif -ifeq ($(USE_TXPID), YES) -OPTMODULES += TxPID -endif -ifeq ($(USE_ALTITUDE), YES) -ifeq ($(USE_I2C), YES) -OPTMODULES += Altitude -else -$(error "Altitude module (USE_ALTITUDE=YES) requires i2c (USE_I2C=YES)") -endif -endif -ifeq ($(TEST_FAULTS), YES) -OPTMODULES += Fault -endif -ifeq ($(USE_AUTOTUNE), YES) -OPTMODULES += Autotune -endif # List of mandatory modules to include -MODULES = Attitude Stabilization Actuator ManualControl FirmwareIAP -# Telemetry must be last to grab the optional modules (why?) +MODULES += Attitude +MODULES += Stabilization +MODULES += Actuator +MODULES += ManualControl +MODULES += FirmwareIAP MODULES += Telemetry -# Enable ARM DSP library -USE_DSP_LIB = NO +# List of optional modules to include +OPTMODULES += CameraStab +OPTMODULES += ComUsbBridge +OPTMODULES += GPS +OPTMODULES += TxPID +#OPTMODULES += Altitude +#OPTMODULES += Fault -# Paths -OPSYSTEM = ./System -OPSYSTEMINC = $(OPSYSTEM)/inc -OPUAVTALKINC = $(OPUAVTALK)/inc -OPUAVOBJINC = $(OPUAVOBJ)/inc -OPTESTS = ./Tests -FLIGHTLIBINC = $(FLIGHTLIB)/inc -MATHLIB = $(FLIGHTLIB)/math -MATHLIBINC = $(FLIGHTLIB)/math -PIOSINC = $(PIOS)/inc -PIOSSTM32F10X = $(PIOS)/STM32F10x -PIOSCOMMON = $(PIOS)/Common -PIOSBOARDS = $(PIOS)/Boards -PIOSCOMMONLIB = $(PIOSCOMMON)/Libraries -APPLIBDIR = $(PIOSSTM32F10X)/Libraries -STMLIBDIR = $(APPLIBDIR) -STMSPDDIR = $(STMLIBDIR)/STM32F10x_StdPeriph_Driver -STMUSBDIR = $(STMLIBDIR)/STM32_USB-FS-Device_Driver -STMSPDSRCDIR = $(STMSPDDIR)/src -STMSPDINCDIR = $(STMSPDDIR)/inc -STMUSBSRCDIR = $(STMUSBDIR)/src -STMUSBINCDIR = $(STMUSBDIR)/inc -CMSISDIR = $(STMLIBDIR)/CMSIS/Core/CM3 -DOSFSDIR = $(APPLIBDIR)/dosfs -MSDDIR = $(APPLIBDIR)/msd -RTOSDIR = $(PIOSCOMMON)/Libraries/FreeRTOS -RTOSSRCDIR = $(RTOSDIR)/Source -RTOSINCDIR = $(RTOSSRCDIR)/include -RTOSPORTDIR = $(APPLIBDIR)/FreeRTOS/Source -DOXYGENDIR = ../Doc/Doxygen -PYMITE = $(FLIGHTLIB)/PyMite -PYMITELIB = $(PYMITE)/lib -PYMITEPLAT = $(PYMITE)/platform/openpilot -PYMITETOOLS = $(PYMITE)/tools -PYMITEVM = $(PYMITE)/vm -PYMITEINC = $(PYMITEVM) -PYMITEINC += $(PYMITEPLAT) -PYMITEINC += $(OUTDIR) -FLIGHTPLANLIB = $(OPMODULEDIR)/FlightPlan/lib -FLIGHTPLANS = $(OPMODULEDIR)/FlightPlan/flightplans +# Include all camera options +CDEFS += -DUSE_INPUT_LPF -DUSE_GIMBAL_LPF -DUSE_GIMBAL_FF -# List C source files here. (C dependencies are automatically generated.) -# use file-extension c for "c-only"-files - -ifndef TESTAPP -## MODULES -SRC += ${foreach MOD, ${OPTMODULES}, ${wildcard ${OPMODULEDIR}/${MOD}/*.c}} -SRC += ${foreach MOD, ${MODULES}, ${wildcard ${OPMODULEDIR}/${MOD}/*.c}} -## OPENPILOT CORE: -SRC += ${OPMODULEDIR}/System/systemmod.c -SRC += $(OPSYSTEM)/coptercontrol.c -SRC += $(OPSYSTEM)/pios_board.c -SRC += $(OPSYSTEM)/alarms.c -SRC += $(OPUAVTALK)/uavtalk.c -SRC += $(OPUAVOBJ)/uavobjectmanager.c -SRC += $(OPUAVOBJ)/eventdispatcher.c -else -## TESTCODE -SRC += $(OPTESTS)/test_common.c -SRC += $(OPTESTS)/$(TESTAPP).c -endif - - - -## UAVOBJECTS -ifndef TESTAPP -SRC += $(OPUAVSYNTHDIR)/accessorydesired.c -SRC += $(OPUAVSYNTHDIR)/objectpersistence.c -SRC += $(OPUAVSYNTHDIR)/gcstelemetrystats.c -SRC += $(OPUAVSYNTHDIR)/flighttelemetrystats.c -SRC += $(OPUAVSYNTHDIR)/faultsettings.c -SRC += $(OPUAVSYNTHDIR)/flightstatus.c -SRC += $(OPUAVSYNTHDIR)/systemstats.c -SRC += $(OPUAVSYNTHDIR)/systemalarms.c -SRC += $(OPUAVSYNTHDIR)/systemsettings.c -SRC += $(OPUAVSYNTHDIR)/stabilizationdesired.c -SRC += $(OPUAVSYNTHDIR)/stabilizationsettings.c -SRC += $(OPUAVSYNTHDIR)/actuatorcommand.c -SRC += $(OPUAVSYNTHDIR)/actuatordesired.c -SRC += $(OPUAVSYNTHDIR)/actuatorsettings.c -SRC += $(OPUAVSYNTHDIR)/accels.c -SRC += $(OPUAVSYNTHDIR)/gyros.c -SRC += $(OPUAVSYNTHDIR)/attitudeactual.c -SRC += $(OPUAVSYNTHDIR)/manualcontrolcommand.c -SRC += $(OPUAVSYNTHDIR)/i2cstats.c -SRC += $(OPUAVSYNTHDIR)/watchdogstatus.c -SRC += $(OPUAVSYNTHDIR)/manualcontrolsettings.c -SRC += $(OPUAVSYNTHDIR)/mixersettings.c -SRC += $(OPUAVSYNTHDIR)/firmwareiapobj.c -SRC += $(OPUAVSYNTHDIR)/attitudesettings.c -SRC += $(OPUAVSYNTHDIR)/camerastabsettings.c -SRC += $(OPUAVSYNTHDIR)/cameradesired.c -SRC += $(OPUAVSYNTHDIR)/gpsposition.c -SRC += $(OPUAVSYNTHDIR)/gpsvelocity.c -SRC += $(OPUAVSYNTHDIR)/hwsettings.c -SRC += $(OPUAVSYNTHDIR)/gcsreceiver.c -SRC += $(OPUAVSYNTHDIR)/receiveractivity.c -SRC += $(OPUAVSYNTHDIR)/relaytuningsettings.c -SRC += $(OPUAVSYNTHDIR)/relaytuning.c -SRC += $(OPUAVSYNTHDIR)/taskinfo.c -SRC += $(OPUAVSYNTHDIR)/mixerstatus.c -SRC += $(OPUAVSYNTHDIR)/ratedesired.c -SRC += $(OPUAVSYNTHDIR)/baroaltitude.c -SRC += $(OPUAVSYNTHDIR)/txpidsettings.c -SRC += $(OPUAVSYNTHDIR)/airspeedactual.c -SRC += $(OPUAVSYNTHDIR)/mpu6000settings.c - -endif - -## PIOS Hardware (STM32F10x) -include $(PIOS)/STM32F10x/library.mk -SRC += $(PIOSSTM32F10X)/pios_sys.c -SRC += $(PIOSSTM32F10X)/pios_led.c -SRC += $(PIOSSTM32F10X)/pios_delay.c -SRC += $(PIOSSTM32F10X)/pios_usart.c -SRC += $(PIOSSTM32F10X)/pios_irq.c -SRC += $(PIOSSTM32F10X)/pios_adc.c -SRC += $(PIOSSTM32F10X)/pios_servo.c -SRC += $(PIOSSTM32F10X)/pios_i2c.c -SRC += $(PIOSSTM32F10X)/pios_spi.c -SRC += $(PIOSSTM32F10X)/pios_ppm.c -SRC += $(PIOSSTM32F10X)/pios_pwm.c -SRC += $(PIOSSTM32F10X)/pios_dsm.c -SRC += $(PIOSSTM32F10X)/pios_debug.c -SRC += $(PIOSSTM32F10X)/pios_gpio.c -SRC += $(PIOSSTM32F10X)/pios_exti.c -SRC += $(PIOSSTM32F10X)/pios_rtc.c -SRC += $(PIOSSTM32F10X)/pios_wdg.c -SRC += $(PIOSSTM32F10X)/pios_iap.c -SRC += $(PIOSSTM32F10X)/pios_tim.c -SRC += $(PIOSSTM32F10X)/pios_bl_helper.c - -# PIOS USB related files (separated to make code maintenance more easy) -SRC += $(PIOSSTM32F10X)/pios_usb.c -SRC += $(PIOSSTM32F10X)/pios_usbhook.c -SRC += $(PIOSSTM32F10X)/pios_usb_hid.c -SRC += $(PIOSSTM32F10X)/pios_usb_rctx.c -SRC += $(PIOSSTM32F10X)/pios_usb_cdc.c -SRC += $(PIOSSTM32F10X)/pios_usb_hid_istr.c -SRC += $(PIOSSTM32F10X)/pios_usb_hid_pwr.c -SRC += $(OPSYSTEM)/pios_usb_board_data.c -SRC += $(PIOSCOMMON)/pios_usb_desc_hid_cdc.c -SRC += $(PIOSCOMMON)/pios_usb_desc_hid_only.c -SRC += $(PIOSCOMMON)/pios_usb_util.c - -## PIOS Hardware (Common) -SRC += $(PIOSCOMMON)/pios_crc.c -SRC += $(PIOSCOMMON)/pios_flashfs_logfs.c -SRC += $(PIOSCOMMON)/pios_flash_jedec.c -SRC += $(PIOSCOMMON)/pios_adxl345.c -SRC += $(PIOSCOMMON)/pios_mpu6000.c -SRC += $(PIOSCOMMON)/pios_com.c -SRC += $(PIOSCOMMON)/pios_sbus.c -#SRC += $(PIOSCOMMON)/pios_i2c_esc.c -#SRC += $(PIOSCOMMON)/pios_bmp085.c -SRC += $(PIOSCOMMON)/pios_rcvr.c -SRC += $(PIOSCOMMON)/pios_gcsrcvr.c -SRC += $(PIOSCOMMON)/printf-stdarg.c -## Libraries for flight calculations -SRC += $(FLIGHTLIB)/fifo_buffer.c -SRC += $(FLIGHTLIB)/CoordinateConversions.c -SRC += $(FLIGHTLIB)/taskmonitor.c -SRC += $(FLIGHTLIB)/sanitycheck.c -SRC += $(MATHLIB)/sin_lookup.c -SRC += $(MATHLIB)/pid.c - -## CMSIS for STM32 -SRC += $(CMSISDIR)/core_cm3.c -SRC += $(CMSISDIR)/system_stm32f10x.c - -## Used parts of the STM-Library -SRC += $(STMSPDSRCDIR)/stm32f10x_adc.c -SRC += $(STMSPDSRCDIR)/stm32f10x_bkp.c -SRC += $(STMSPDSRCDIR)/stm32f10x_crc.c -SRC += $(STMSPDSRCDIR)/stm32f10x_dac.c -SRC += $(STMSPDSRCDIR)/stm32f10x_dma.c -SRC += $(STMSPDSRCDIR)/stm32f10x_exti.c -SRC += $(STMSPDSRCDIR)/stm32f10x_flash.c -SRC += $(STMSPDSRCDIR)/stm32f10x_gpio.c -SRC += $(STMSPDSRCDIR)/stm32f10x_i2c.c -SRC += $(STMSPDSRCDIR)/stm32f10x_pwr.c -SRC += $(STMSPDSRCDIR)/stm32f10x_rcc.c -SRC += $(STMSPDSRCDIR)/stm32f10x_rtc.c -SRC += $(STMSPDSRCDIR)/stm32f10x_spi.c -SRC += $(STMSPDSRCDIR)/stm32f10x_tim.c -SRC += $(STMSPDSRCDIR)/stm32f10x_usart.c -SRC += $(STMSPDSRCDIR)/stm32f10x_iwdg.c -SRC += $(STMSPDSRCDIR)/stm32f10x_dbgmcu.c -SRC += $(STMSPDSRCDIR)/misc.c - -## STM32 USB Library -SRC += $(STMUSBSRCDIR)/usb_core.c -SRC += $(STMUSBSRCDIR)/usb_init.c -SRC += $(STMUSBSRCDIR)/usb_int.c -SRC += $(STMUSBSRCDIR)/usb_mem.c -SRC += $(STMUSBSRCDIR)/usb_regs.c -SRC += $(STMUSBSRCDIR)/usb_sil.c - -## RTOS -SRC += $(RTOSSRCDIR)/list.c -SRC += $(RTOSSRCDIR)/queue.c -SRC += $(RTOSSRCDIR)/tasks.c - -## RTOS Portable -SRC += $(RTOSPORTDIR)/portable/GCC/ARM_CM3/port.c -SRC += $(RTOSPORTDIR)/portable/MemMang/heap_1.c - -## Dosfs file system -#SRC += $(DOSFSDIR)/dosfs.c -#SRC += $(DOSFSDIR)/dfs_sdcard.c - -## PyMite files -#SRC += $(wildcard ${PYMITEVM}/*.c) -#SRC += $(wildcard ${PYMITEPLAT}/*.c) -#SRC += $(OUTDIR)/pmlib_img.c -#SRC += $(OUTDIR)/pmlib_nat.c -#SRC += $(OUTDIR)/pmlibusr_img.c -#SRC += $(OUTDIR)/pmlibusr_nat.c - -## Mass Storage Device -#SRC += $(MSDDIR)/msd.c -#SRC += $(MSDDIR)/msd_bot.c -#SRC += $(MSDDIR)/msd_desc.c -#SRC += $(MSDDIR)/msd_memory.c -#SRC += $(MSDDIR)/msd_scsi.c -#SRC += $(MSDDIR)/msd_scsi_data.c - -# List C source files here which must be compiled in ARM-Mode (no -mthumb). -# use file-extension c for "c-only"-files -## just for testing, timer.c could be compiled in thumb-mode too -SRCARM = - -# List C++ source files here. -# use file-extension .cpp for C++-files (not .C) -CPPSRC = - -# List C++ source files here which must be compiled in ARM-Mode. -# use file-extension .cpp for C++-files (not .C) -#CPPSRCARM = $(TARGET).cpp -CPPSRCARM = - -# List Assembler source files here. -# Make them always end in a capital .S. Files ending in a lowercase .s -# will not be considered source files but generated files (assembler -# output from the compiler), and will be deleted upon "make clean"! -# Even though the DOS/Win* filesystem matches both .s and .S the same, -# it will preserve the spelling of the filenames, and gcc itself does -# care about how the name is spelled on its command-line. -ASRC = $(PIOSSTM32F10X)/startup_stm32f10x_$(MODEL)$(MODEL_SUFFIX).S - -# List Assembler source files here which must be assembled in ARM-Mode.. -ASRCARM = - -# List any extra directories to look for include files here. -# Each directory must be seperated by a space. -EXTRAINCDIRS += $(OPSYSTEM) -EXTRAINCDIRS += $(OPSYSTEMINC) -EXTRAINCDIRS += $(OPUAVTALK) -EXTRAINCDIRS += $(OPUAVTALKINC) -EXTRAINCDIRS += $(OPUAVOBJ) -EXTRAINCDIRS += $(OPUAVOBJINC) -EXTRAINCDIRS += $(OPUAVSYNTHDIR) -EXTRAINCDIRS += $(PIOS) -EXTRAINCDIRS += $(PIOSINC) -EXTRAINCDIRS += $(FLIGHTLIBINC) -EXTRAINCDIRS += $(MATHLIBINC) -EXTRAINCDIRS += $(PIOSSTM32F10X) -EXTRAINCDIRS += $(PIOSCOMMON) -EXTRAINCDIRS += $(PIOSBOARDS) -EXTRAINCDIRS += $(STMSPDINCDIR) -EXTRAINCDIRS += $(STMUSBINCDIR) -EXTRAINCDIRS += $(CMSISDIR) -EXTRAINCDIRS += $(DOSFSDIR) -EXTRAINCDIRS += $(MSDDIR) -EXTRAINCDIRS += $(RTOSINCDIR) -EXTRAINCDIRS += $(APPLIBDIR) -EXTRAINCDIRS += $(RTOSPORTDIR)/portable/GCC/ARM_CM3 -EXTRAINCDIRS += $(AHRSBOOTLOADERINC) -EXTRAINCDIRS += $(PYMITEINC) -EXTRAINCDIRS += $(HWDEFSINC) - -EXTRAINCDIRS += ${foreach MOD, ${OPTMODULES} ${MODULES}, ${OPMODULEDIR}/${MOD}/inc} ${OPMODULEDIR}/System/inc - - -# List any extra directories to look for library files here. -# Also add directories where the linker should search for -# includes from linker-script to the list -# Each directory must be seperated by a space. -#EXTRA_LIBDIRS += - -# Extra Libraries -# Each library-name must be seperated by a space. -# i.e. to link with libxyz.a, libabc.a and libefsl.a: -# EXTRA_LIBS = xyz abc efsl -# for newlib-lpc (file: libnewlibc-lpc.a): -# EXTRA_LIBS = newlib-lpc -#EXTRA_LIBS += - -# Path to Linker-Scripts -LINKERSCRIPTPATH = $(PIOSSTM32F10X) - -# Optimization level, can be [0, 1, 2, 3, s]. -# 0 = turn off optimization. s = optimize for size. -# (Note: 3 is not always the best optimization level. See avr-libc FAQ.) - -ifeq ($(DEBUG),YES) -OPT = 1 -else -OPT = s -endif - -# Output format. (can be ihex or binary or both) -# binary to create a load-image in raw-binary format i.e. for SAM-BA, -# ihex to create a load-image in Intel hex format -#LOADFORMAT = ihex -#LOADFORMAT = binary -LOADFORMAT = both - -# Debugging format. -DEBUGF = dwarf-2 - -# Place project-specific -D (define) and/or -# -U options for C here. -CDEFS += -DSTM32F10X_$(MODEL) -CDEFS += -DUSE_STDPERIPH_DRIVER -CDEFS += -DUSE_$(BOARD) -ifeq ($(ENABLE_DEBUG_PINS), YES) -CDEFS += -DPIOS_ENABLE_DEBUG_PINS -endif -ifeq ($(ENABLE_DEBUG_CONSOLE), YES) -CDEFS += -DPIOS_INCLUDE_DEBUG_CONSOLE -endif +# Erase flash firmware should be buildable from command line ifeq ($(ERASE_FLASH), YES) -CDEFS += -DERASE_FLASH + CDEFS += -DERASE_FLASH endif -ifneq ($(USE_GPS), NO) -CDEFS += -DUSE_GPS -endif +# List C source files here (C dependencies are automatically generated). +# Use file-extension c for "c-only"-files +ifndef TESTAPP + ## Application Core + SRC += ${OPMODULEDIR}/System/systemmod.c + SRC += $(OPSYSTEM)/coptercontrol.c + SRC += $(OPSYSTEM)/pios_board.c + SRC += $(OPSYSTEM)/pios_usb_board_data.c + SRC += $(OPSYSTEM)/alarms.c + SRC += $(OPUAVTALK)/uavtalk.c + SRC += $(OPUAVOBJ)/uavobjectmanager.c + SRC += $(OPUAVOBJ)/eventdispatcher.c -ifeq ($(USE_I2C), YES) -CDEFS += -DUSE_I2C -endif - -ifeq ($(USE_INPUT_LPF), YES) -CDEFS += -DUSE_INPUT_LPF -endif - -ifeq ($(USE_GIMBAL_LPF), YES) -CDEFS += -DUSE_GIMBAL_LPF -endif - -ifeq ($(USE_GIMBAL_FF), YES) -CDEFS += -DUSE_GIMBAL_FF -endif - -# Declare all non-optional modules as built-in to force inclusion -CDEFS += ${foreach MOD, ${MODULES}, -DMODULE_$(MOD)_BUILTIN } - -# Place project-specific -D and/or -U options for -# Assembler with preprocessor here. -#ADEFS = -DUSE_IRQ_ASM_WRAPPER -ADEFS = -D__ASSEMBLY__ - -# Compiler flag to set the C Standard level. -# c89 - "ANSI" C -# gnu89 - c89 plus GCC extensions -# c99 - ISO C99 standard (not yet fully implemented) -# gnu99 - c99 plus GCC extensions -CSTANDARD = -std=gnu99 - -#----- - -# Compiler flags. - -# -g*: generate debugging information -# -O*: optimization level -# -f...: tuning, see GCC manual and avr-libc documentation -# -Wall...: warning level -# -Wa,...: tell GCC to pass this to the assembler. -# -adhlns...: create assembler listing -# -# Flags for C and C++ (arm-elf-gcc/arm-elf-g++) - -ifeq ($(DEBUG),YES) -CFLAGS += -DDEBUG -endif - -#The following Makefile command, ifneq (, $(filter) $(A), $(B) $(C)) is equivalent -# to the pseudocode `if(A== B || A==C)` -ifneq (,$(filter YES,$(STACK_DIAGNOSTICS) $(ALL_DIGNOSTICS))) -CFLAGS += -DSTACK_DIAGNOSTICS -endif - -ifneq (,$(filter YES,$(MIXERSTATUS_DIAGNOSTICS) $(ALL_DIGNOSTICS))) -CFLAGS += -DMIXERSTATUS_DIAGNOSTICS -endif - -ifneq (,$(filter YES,$(RATEDESIRED_DIAGNOSTICS) $(ALL_DIGNOSTICS))) -CFLAGS += -DRATEDESIRED_DIAGNOSTICS -endif - -ifneq (,$(filter YES,$(I2C_WDG_STATS_DIAGNOSTICS) $(ALL_DIGNOSTICS))) -CFLAGS += -DI2C_WDG_STATS_DIAGNOSTICS -endif - -ifneq (,$(filter YES,$(DIAG_TASKS) $(ALL_DIGNOSTICS))) -CFLAGS += -DDIAG_TASKS -endif - -CFLAGS += -g$(DEBUGF) -CFLAGS += -O$(OPT) -CFLAGS += -mcpu=$(MCU) -CFLAGS += $(CDEFS) -CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) -I. - -#CFLAGS += -fno-cprop-registers -fno-defer-pop -fno-guess-branch-probability -fno-section-anchors -#CFLAGS += -fno-if-conversion -fno-if-conversion2 -fno-ipa-pure-const -fno-ipa-reference -fno-merge-constants -#CFLAGS += -fno-split-wide-types -fno-tree-ccp -fno-tree-ch -fno-tree-copy-prop -fno-tree-copyrename -#CFLAGS += -fno-tree-dce -fno-tree-dominator-opts -fno-tree-dse -fno-tree-fre -fno-tree-sink -fno-tree-sra -#CFLAGS += -fno-tree-ter -#CFLAGS += -g$(DEBUGF) -DDEBUG - -CFLAGS += -mapcs-frame -CFLAGS += -fomit-frame-pointer -ifeq ($(CODE_SOURCERY), YES) -CFLAGS += -fpromote-loop-indices -endif - -CFLAGS += -Wall -CFLAGS += -Werror -CFLAGS += -ffunction-sections -fdata-sections -CFLAGS += -Wa,-adhlns=$(addprefix $(OUTDIR)/, $(notdir $(addsuffix .lst, $(basename $<)))) -# Compiler flags to generate dependency files: -CFLAGS += -MD -MP -MF $(OUTDIR)/dep/$(@F).d - -# flags only for C -#CONLYFLAGS += -Wnested-externs -CONLYFLAGS += $(CSTANDARD) - -# Assembler flags. -# -Wa,...: tell GCC to pass this to the assembler. -# -ahlns: create listing -ASFLAGS = -mcpu=$(MCU) -I. -x assembler-with-cpp -ASFLAGS += $(ADEFS) -ASFLAGS += -Wa,-adhlns=$(addprefix $(OUTDIR)/, $(notdir $(addsuffix .lst, $(basename $<)))) -ASFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) - -MATH_LIB = -lm - -# Linker flags. -# -Wl,...: tell GCC to pass this to linker. -# -Map: create map file -# --cref: add cross reference to map file -LDFLAGS = -nostartfiles -Wl,-Map=$(OUTDIR)/$(TARGET).map,--cref,--gc-sections -LDFLAGS += $(patsubst %,-L%,$(EXTRA_LIBDIRS)) -LDFLAGS += -lc -LDFLAGS += $(patsubst %,-l%,$(EXTRA_LIBS)) -LDFLAGS += $(MATH_LIB) -LDFLAGS += -lc -lgcc - -# Set linker-script name depending on selected submodel name -LDFLAGS += -T$(LINKERSCRIPTPATH)/link_$(BOARD)_memory.ld -LDFLAGS += -T$(LINKERSCRIPTPATH)/link_$(BOARD)_sections.ld - -# Define programs and commands. -REMOVE = $(REMOVE_CMD) -f -PYTHON = python - -# List of all source files. -ALLSRC = $(ASRCARM) $(ASRC) $(SRCARM) $(SRC) $(CPPSRCARM) $(CPPSRC) -# List of all source files without directory and file-extension. -ALLSRCBASE = $(notdir $(basename $(ALLSRC))) - -# Define all object files. -ALLOBJ = $(addprefix $(OUTDIR)/, $(addsuffix .o, $(ALLSRCBASE))) - -# Define all listing files (used for make clean). -LSTFILES = $(addprefix $(OUTDIR)/, $(addsuffix .lst, $(ALLSRCBASE))) -# Define all depedency-files (used for make clean). -DEPFILES = $(addprefix $(OUTDIR)/dep/, $(addsuffix .o.d, $(ALLSRCBASE))) - -# Default target. -all: build - -ifeq ($(LOADFORMAT),ihex) -build: elf hex lss sym + ## UAVObjects + SRC += $(OPUAVSYNTHDIR)/accessorydesired.c + SRC += $(OPUAVSYNTHDIR)/objectpersistence.c + SRC += $(OPUAVSYNTHDIR)/gcstelemetrystats.c + SRC += $(OPUAVSYNTHDIR)/flighttelemetrystats.c + SRC += $(OPUAVSYNTHDIR)/faultsettings.c + SRC += $(OPUAVSYNTHDIR)/flightstatus.c + SRC += $(OPUAVSYNTHDIR)/systemstats.c + SRC += $(OPUAVSYNTHDIR)/systemalarms.c + SRC += $(OPUAVSYNTHDIR)/systemsettings.c + SRC += $(OPUAVSYNTHDIR)/stabilizationdesired.c + SRC += $(OPUAVSYNTHDIR)/stabilizationsettings.c + SRC += $(OPUAVSYNTHDIR)/actuatorcommand.c + SRC += $(OPUAVSYNTHDIR)/actuatordesired.c + SRC += $(OPUAVSYNTHDIR)/actuatorsettings.c + SRC += $(OPUAVSYNTHDIR)/accels.c + SRC += $(OPUAVSYNTHDIR)/gyros.c + SRC += $(OPUAVSYNTHDIR)/attitudeactual.c + SRC += $(OPUAVSYNTHDIR)/manualcontrolcommand.c + SRC += $(OPUAVSYNTHDIR)/i2cstats.c + SRC += $(OPUAVSYNTHDIR)/watchdogstatus.c + SRC += $(OPUAVSYNTHDIR)/manualcontrolsettings.c + SRC += $(OPUAVSYNTHDIR)/mixersettings.c + SRC += $(OPUAVSYNTHDIR)/firmwareiapobj.c + SRC += $(OPUAVSYNTHDIR)/attitudesettings.c + SRC += $(OPUAVSYNTHDIR)/camerastabsettings.c + SRC += $(OPUAVSYNTHDIR)/cameradesired.c + SRC += $(OPUAVSYNTHDIR)/gpsposition.c + SRC += $(OPUAVSYNTHDIR)/gpsvelocity.c + SRC += $(OPUAVSYNTHDIR)/hwsettings.c + SRC += $(OPUAVSYNTHDIR)/gcsreceiver.c + SRC += $(OPUAVSYNTHDIR)/receiveractivity.c + SRC += $(OPUAVSYNTHDIR)/relaytuningsettings.c + SRC += $(OPUAVSYNTHDIR)/relaytuning.c + SRC += $(OPUAVSYNTHDIR)/taskinfo.c + SRC += $(OPUAVSYNTHDIR)/mixerstatus.c + SRC += $(OPUAVSYNTHDIR)/ratedesired.c + SRC += $(OPUAVSYNTHDIR)/baroaltitude.c + SRC += $(OPUAVSYNTHDIR)/txpidsettings.c + SRC += $(OPUAVSYNTHDIR)/airspeedactual.c + SRC += $(OPUAVSYNTHDIR)/mpu6000settings.c else -ifeq ($(LOADFORMAT),binary) -build: elf bin lss sym -else -ifeq ($(LOADFORMAT),both) -build: elf hex bin lss sym -else -$(error "$(MSG_FORMATERROR) $(FORMAT)") -endif -endif + ## Test Code + SRC += $(OPTESTS)/test_common.c + SRC += $(OPTESTS)/$(TESTAPP).c endif -# Generate code for PyMite -#$(OUTDIR)/pmlib_img.c $(OUTDIR)/pmlib_nat.c $(OUTDIR)/pmlibusr_img.c $(OUTDIR)/pmlibusr_nat.c $(OUTDIR)/pmfeatures.h: $(wildcard $(PYMITELIB)/*.py) $(wildcard $(PYMITEPLAT)/*.py) $(wildcard $(FLIGHTPLANLIB)/*.py) $(wildcard $(FLIGHTPLANS)/*.py) -# @echo $(MSG_PYMITEINIT) $(call toprel, $@) -# @$(PYTHON) $(PYMITETOOLS)/pmImgCreator.py -f $(PYMITEPLAT)/pmfeatures.py -c -s --memspace=flash -o $(OUTDIR)/pmlib_img.c --native-file=$(OUTDIR)/pmlib_nat.c $(PYMITELIB)/list.py $(PYMITELIB)/dict.py $(PYMITELIB)/__bi.py $(PYMITELIB)/sys.py $(PYMITELIB)/string.py $(wildcard $(FLIGHTPLANLIB)/*.py) -# @$(PYTHON) $(PYMITETOOLS)/pmGenPmFeatures.py $(PYMITEPLAT)/pmfeatures.py > $(OUTDIR)/pmfeatures.h -# @$(PYTHON) $(PYMITETOOLS)/pmImgCreator.py -f $(PYMITEPLAT)/pmfeatures.py -c -u -o $(OUTDIR)/pmlibusr_img.c --native-file=$(OUTDIR)/pmlibusr_nat.c $(FLIGHTPLANS)/test.py - -# Link: create ELF output file from object files. -$(eval $(call LINK_TEMPLATE, $(OUTDIR)/$(TARGET).elf, $(ALLOBJ), $(ALLLIB))) - -# Assemble: create object files from assembler source files. -$(foreach src, $(ASRC), $(eval $(call ASSEMBLE_TEMPLATE, $(src)))) - -# Assemble: create object files from assembler source files. ARM-only -$(foreach src, $(ASRCARM), $(eval $(call ASSEMBLE_ARM_TEMPLATE, $(src)))) - -# Compile: create object files from C source files. -$(foreach src, $(SRC), $(eval $(call COMPILE_C_TEMPLATE, $(src)))) - -# Compile: create object files from C source files. ARM-only -$(foreach src, $(SRCARM), $(eval $(call COMPILE_C_ARM_TEMPLATE, $(src)))) - -# Compile: create object files from C++ source files. -$(foreach src, $(CPPSRC), $(eval $(call COMPILE_CPP_TEMPLATE, $(src)))) - -# Compile: create object files from C++ source files. ARM-only -$(foreach src, $(CPPSRCARM), $(eval $(call COMPILE_CPP_ARM_TEMPLATE, $(src)))) - -# Compile: create assembler files from C source files. ARM/Thumb -$(eval $(call PARTIAL_COMPILE_TEMPLATE, SRC)) - -# Compile: create assembler files from C source files. ARM only -$(eval $(call PARTIAL_COMPILE_ARM_TEMPLATE, SRCARM)) - -$(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),$(OPENOCD_JTAG_CONFIG),$(OPENOCD_CONFIG))) - -.PHONY: elf lss sym hex bin bino opfw -elf: $(OUTDIR)/$(TARGET).elf -lss: $(OUTDIR)/$(TARGET).lss -sym: $(OUTDIR)/$(TARGET).sym -hex: $(OUTDIR)/$(TARGET).hex -bin: $(OUTDIR)/$(TARGET).bin -bino: $(OUTDIR)/$(TARGET).bin.o -opfw: $(OUTDIR)/$(TARGET).opfw - -# Display sizes of sections. -$(eval $(call SIZE_TEMPLATE, $(OUTDIR)/$(TARGET).elf)) - -# Generate Doxygen documents -docs: - doxygen $(DOXYGENDIR)/doxygen.cfg - -# Install: install binary file with prefix/suffix into install directory -install: $(OUTDIR)/$(TARGET).opfw -ifneq ($(INSTALL_DIR),) - @echo $(MSG_INSTALLING) $(call toprel, $<) - $(V1) mkdir -p $(INSTALL_DIR) - $(V1) $(INSTALL) $< $(INSTALL_DIR)/$(INSTALL_PFX)$(TARGET)$(INSTALL_SFX).opfw -else - $(error INSTALL_DIR must be specified for $@) -endif - -# Target: clean project. -clean: clean_list - -clean_list : - @echo $(MSG_CLEANING) - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).map - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).elf - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).hex - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).bin - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).sym - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).lss - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).bin.o - $(V1) $(REMOVE) $(wildcard $(OUTDIR)/*.c) - $(V1) $(REMOVE) $(wildcard $(OUTDIR)/*.h) - $(V1) $(REMOVE) $(ALLOBJ) - $(V1) $(REMOVE) $(LSTFILES) - $(V1) $(REMOVE) $(DEPFILES) - $(V1) $(REMOVE) $(SRC:.c=.s) - $(V1) $(REMOVE) $(SRCARM:.c=.s) - $(V1) $(REMOVE) $(CPPSRC:.cpp=.s) - $(V1) $(REMOVE) $(CPPSRCARM:.cpp=.s) - - -# Create output files directory -# all known MS Windows OS define the ComSpec environment variable -ifdef ComSpec -$(shell md $(subst /,\\,$(OUTDIR)) 2>NUL) -else -$(shell mkdir -p $(OUTDIR) 2>/dev/null) -endif - -# Include the dependency files. -ifdef ComSpec --include $(shell md $(subst /,\\,$(OUTDIR))\dep 2>NUL) $(wildcard $(OUTDIR)/dep/*) -else --include $(shell mkdir -p $(OUTDIR) 2>/dev/null) $(shell mkdir $(OUTDIR)/dep 2>/dev/null) $(wildcard $(OUTDIR)/dep/*) -endif - -# Listing of phony targets. -.PHONY : all build clean clean_list install +include $(ROOT_DIR)/make/apps-defs.mk +include $(ROOT_DIR)/make/common-defs.mk diff --git a/flight/targets/CopterControl/System/inc/FreeRTOSConfig.h b/flight/targets/CopterControl/System/inc/FreeRTOSConfig.h index 996726133..01e4f5b1b 100644 --- a/flight/targets/CopterControl/System/inc/FreeRTOSConfig.h +++ b/flight/targets/CopterControl/System/inc/FreeRTOSConfig.h @@ -76,7 +76,7 @@ NVIC value of 255. */ #endif /* Enable run time stats collection */ -#if defined(DIAG_TASKS) +#ifdef DIAG_TASKS #define configCHECK_FOR_STACK_OVERFLOW 2 #define configGENERATE_RUN_TIME_STATS 1 diff --git a/flight/targets/CopterControl/System/inc/op_config.h b/flight/targets/CopterControl/System/inc/op_config.h deleted file mode 100644 index 97910f392..000000000 --- a/flight/targets/CopterControl/System/inc/op_config.h +++ /dev/null @@ -1,39 +0,0 @@ -/** - ****************************************************************************** - * @addtogroup OpenPilotSystem OpenPilot System - * @{ - * @addtogroup OpenPilotCore OpenPilot Core - * @{ - * - * @file op_config.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief OpenPilot configuration header. - * Compile time config for OpenPilot Application - * @see The GNU Public License (GPL) Version 3 - * - *****************************************************************************/ -/* - * 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 - */ - - -#ifndef OP_CONFIG_H -#define OP_CONFIG_H - -#endif /* OP_CONFIG_H */ -/** - * @} - * @} - */ diff --git a/flight/targets/CopterControl/System/inc/openpilot.h b/flight/targets/CopterControl/System/inc/openpilot.h index 59ae76fd4..7f1ac3758 100644 --- a/flight/targets/CopterControl/System/inc/openpilot.h +++ b/flight/targets/CopterControl/System/inc/openpilot.h @@ -35,7 +35,6 @@ #include /* OpenPilot Libraries */ -#include "op_config.h" #include "utlist.h" #include "uavobjectmanager.h" #include "eventdispatcher.h" diff --git a/flight/targets/CopterControl/System/inc/pios_config.h b/flight/targets/CopterControl/System/inc/pios_config.h index 09423ea45..149f8490b 100644 --- a/flight/targets/CopterControl/System/inc/pios_config.h +++ b/flight/targets/CopterControl/System/inc/pios_config.h @@ -1,117 +1,170 @@ -/** - ****************************************************************************** - * @addtogroup OpenPilotSystem OpenPilot System - * @{ - * @addtogroup OpenPilotCore OpenPilot Core - * @{ - * - * @file pios_config.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief PiOS configuration header. - * Central compile time config for the project. - * In particular, pios_config.h is where you define which PiOS libraries - * and features are included in the firmware. - * @see The GNU Public License (GPL) Version 3 - * - *****************************************************************************/ -/* - * 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 - */ - -#ifndef PIOS_CONFIG_H -#define PIOS_CONFIG_H - -/* Enable/Disable PiOS Modules */ -#define PIOS_INCLUDE_ADC -#define PIOS_INCLUDE_DELAY -//#if defined(USE_I2C) -//#define PIOS_INCLUDE_I2C -//#define PIOS_INCLUDE_I2C_ESC -//#endif -#define PIOS_INCLUDE_IRQ -#define PIOS_INCLUDE_LED -#define PIOS_INCLUDE_IAP -#define PIOS_INCLUDE_TIM - -#define PIOS_INCLUDE_RCVR - -/* Supported receiver interfaces */ -#define PIOS_INCLUDE_DSM -#define PIOS_INCLUDE_SBUS -#define PIOS_INCLUDE_PPM -#define PIOS_INCLUDE_PPM_FLEXI -#define PIOS_INCLUDE_PWM -#define PIOS_INCLUDE_GCSRCVR - -/* Supported USART-based PIOS modules */ -#define PIOS_INCLUDE_TELEMETRY_RF -#define PIOS_INCLUDE_GPS -#define PIOS_GPS_MINIMAL -#define PIOS_INCLUDE_GPS_NMEA_PARSER /* Include the NMEA protocol parser */ -#define PIOS_INCLUDE_GPS_UBX_PARSER /* Include the UBX protocol parser */ -#define PIOS_INCLUDE_SERVO -#define PIOS_INCLUDE_SPI -#define PIOS_INCLUDE_SYS -#define PIOS_INCLUDE_USART -#define PIOS_INCLUDE_USB -#define PIOS_INCLUDE_USB_HID -#define PIOS_INCLUDE_USB_RCTX -#define PIOS_INCLUDE_USB_CDC -#define PIOS_INCLUDE_COM -#define PIOS_INCLUDE_SETTINGS -#define PIOS_INCLUDE_FREERTOS -#define PIOS_INCLUDE_GPIO -#define PIOS_INCLUDE_EXTI -#define PIOS_INCLUDE_RTC -#define PIOS_INCLUDE_WDG -#define PIOS_INCLUDE_BL_HELPER - -#define PIOS_INCLUDE_ADXL345 -#define PIOS_INCLUDE_FLASH -#define PIOS_INCLUDE_MPU6000 -#define PIOS_MPU6000_ACCEL - -/* A really shitty setting saving implementation */ -#define PIOS_INCLUDE_FLASH_SECTOR_SETTINGS - -/* Alarm Thresholds */ -#define HEAP_LIMIT_WARNING 220 -#define HEAP_LIMIT_CRITICAL 40 -#define IRQSTACK_LIMIT_WARNING 100 -#define IRQSTACK_LIMIT_CRITICAL 60 -#define CPULOAD_LIMIT_WARNING 85 -#define CPULOAD_LIMIT_CRITICAL 95 - -/* Task stack sizes */ -#define PIOS_ACTUATOR_STACK_SIZE 1020 -#define PIOS_MANUAL_STACK_SIZE 800 -#define PIOS_SYSTEM_STACK_SIZE 660 -#define PIOS_STABILIZATION_STACK_SIZE 524 -#define PIOS_TELEM_STACK_SIZE 500 -#define PIOS_EVENTDISPATCHER_STACK_SIZE 130 -#define IDLE_COUNTS_PER_SEC_AT_NO_LOAD 1995998 -//#define PIOS_QUATERNION_STABILIZATION - -// This can't be too high to stop eventdispatcher thread overflowing -#define PIOS_EVENTDISAPTCHER_QUEUE 10 - -/* PIOS Initcall infrastructure */ -#define PIOS_INCLUDE_INITCALL - -#endif /* PIOS_CONFIG_H */ -/** - * @} - * @} - */ +/** + ****************************************************************************** + * @addtogroup OpenPilotSystem OpenPilot System + * @{ + * @addtogroup OpenPilotCore OpenPilot Core + * @{ + * @file pios_config.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010-2013. + * @brief PiOS configuration header, the compile time config file for the PIOS. + * Defines which PiOS libraries and features are included in the firmware. + * @see The GNU Public License (GPL) Version 3 + *****************************************************************************/ +/* + * 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 + */ + +#ifndef PIOS_CONFIG_H +#define PIOS_CONFIG_H + +/* + * Below is a complete list of PIOS configurable options. + * Please do not remove or rearrange them. Only comment out + * unused options in the list. See main pios.h header for more + * details. + */ + +/* #define PIOS_INCLUDE_DEBUG_CONSOLE */ +/* #define DEBUG_LEVEL 0 */ + +/* PIOS FreeRTOS support */ +#define PIOS_INCLUDE_FREERTOS + +/* PIOS bootloader helper */ +#define PIOS_INCLUDE_BL_HELPER +/* #define PIOS_INCLUDE_BL_HELPER_WRITE_SUPPORT */ + +/* PIOS system functions */ +#define PIOS_INCLUDE_DELAY +#define PIOS_INCLUDE_INITCALL +#define PIOS_INCLUDE_SYS + +/* PIOS hardware peripherals */ +#define PIOS_INCLUDE_IRQ +#define PIOS_INCLUDE_RTC +#define PIOS_INCLUDE_TIM +#define PIOS_INCLUDE_USART +#define PIOS_INCLUDE_ADC +/* #define PIOS_INCLUDE_I2C */ +#define PIOS_INCLUDE_SPI +#define PIOS_INCLUDE_GPIO +#define PIOS_INCLUDE_EXTI +#define PIOS_INCLUDE_WDG + +/* PIOS USB functions */ +#define PIOS_INCLUDE_USB +#define PIOS_INCLUDE_USB_HID +#define PIOS_INCLUDE_USB_CDC +#define PIOS_INCLUDE_USB_RCTX + +/* PIOS sensor interfaces */ +#define PIOS_INCLUDE_ADXL345 +/* #define PIOS_INCLUDE_BMA180 */ +/* #define PIOS_INCLUDE_L3GD20 */ +#define PIOS_INCLUDE_MPU6000 +#define PIOS_MPU6000_ACCEL +/* #define PIOS_INCLUDE_HMC5843 */ +/* #define PIOS_INCLUDE_HMC5883 */ +/* #define PIOS_HMC5883_HAS_GPIOS */ +/* #define PIOS_INCLUDE_BMP085 */ +/* #define PIOS_INCLUDE_MS5611 */ +/* #define PIOS_INCLUDE_MPXV */ +/* #define PIOS_INCLUDE_ETASV3 */ +/* #define PIOS_INCLUDE_HCSR04 */ + +/* PIOS receiver drivers */ +#define PIOS_INCLUDE_PWM +#define PIOS_INCLUDE_PPM +#define PIOS_INCLUDE_PPM_FLEXI +#define PIOS_INCLUDE_DSM +#define PIOS_INCLUDE_SBUS +#define PIOS_INCLUDE_GCSRCVR + +/* PIOS abstract receiver interface */ +#define PIOS_INCLUDE_RCVR + +/* PIOS common peripherals */ +#define PIOS_INCLUDE_LED +#define PIOS_INCLUDE_IAP +#define PIOS_INCLUDE_SERVO +/* #define PIOS_INCLUDE_I2C_ESC */ +/* #define PIOS_INCLUDE_OVERO */ +/* #define PIOS_OVERO_SPI */ +/* #define PIOS_INCLUDE_SDCARD */ +/* #define LOG_FILENAME "startup.log" */ +#define PIOS_INCLUDE_FLASH +#define PIOS_INCLUDE_FLASH_SECTOR_SETTINGS +/* #define FLASH_FREERTOS */ +/* #define PIOS_INCLUDE_FLASH_EEPROM */ + +/* PIOS radio modules */ +/* #define PIOS_INCLUDE_RFM22B */ +/* #define PIOS_INCLUDE_RFM22B_COM */ +/* #define PIOS_INCLUDE_RFM22B_RCVR */ +/* #define PIOS_INCLUDE_PPM_OUT */ +/* #define PIOS_RFM22B_DEBUG_ON_TELEM */ + +/* PIOS misc peripherals */ +/* #define PIOS_INCLUDE_VIDEO */ +/* #define PIOS_INCLUDE_WAVE */ +/* #define PIOS_INCLUDE_UDP */ + +/* PIOS abstract comms interface with options */ +#define PIOS_INCLUDE_COM +/* #define PIOS_INCLUDE_COM_MSG */ +#define PIOS_INCLUDE_TELEMETRY_RF +/* #define PIOS_INCLUDE_COM_TELEM */ +/* #define PIOS_INCLUDE_COM_FLEXI */ +/* #define PIOS_INCLUDE_COM_AUX */ +/* #define PIOS_TELEM_PRIORITY_QUEUE */ +#define PIOS_INCLUDE_GPS +#define PIOS_GPS_MINIMAL +#define PIOS_INCLUDE_GPS_NMEA_PARSER +#define PIOS_INCLUDE_GPS_UBX_PARSER +/* #define PIOS_GPS_SETS_HOMELOCATION */ + +/* Stabilization options */ +/* #define PIOS_QUATERNION_STABILIZATION */ + +/* Performance counters */ +#define IDLE_COUNTS_PER_SEC_AT_NO_LOAD 1995998 + +/* Alarm Thresholds */ +#define HEAP_LIMIT_WARNING 220 +#define HEAP_LIMIT_CRITICAL 40 +#define IRQSTACK_LIMIT_WARNING 100 +#define IRQSTACK_LIMIT_CRITICAL 60 +#define CPULOAD_LIMIT_WARNING 85 +#define CPULOAD_LIMIT_CRITICAL 95 + +/* Task stack sizes */ +#define PIOS_ACTUATOR_STACK_SIZE 1020 +#define PIOS_MANUAL_STACK_SIZE 800 +#define PIOS_SYSTEM_STACK_SIZE 660 +#define PIOS_STABILIZATION_STACK_SIZE 524 +#define PIOS_TELEM_STACK_SIZE 500 +#define PIOS_EVENTDISPATCHER_STACK_SIZE 130 + +/* This can't be too high to stop eventdispatcher thread overflowing */ +#define PIOS_EVENTDISAPTCHER_QUEUE 10 + +/* Revolution series */ +/* #define REVOLUTION */ + +#endif /* PIOS_CONFIG_H */ +/** + * @} + * @} + */ diff --git a/flight/targets/EntireFlash/Makefile b/flight/targets/EntireFlash/Makefile index 24d86a92d..6b2910f94 100644 --- a/flight/targets/EntireFlash/Makefile +++ b/flight/targets/EntireFlash/Makefile @@ -1,8 +1,5 @@ -##### -# Makefile for Entire Flash (EF) images -# -# The OpenPilot Team, http://www.openpilot.org, Copyright (C) 2012. # +# Copyright (c) 2009-2013, The OpenPilot Team, http://www.openpilot.org # # 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 @@ -17,33 +14,43 @@ # 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 +ifndef OPENPILOT_IS_COOL + $(error Top level Makefile must be used to build this target) +endif + +include $(ROOT_DIR)/make/boards/$(BOARD_NAME)/board-info.mk + +# Paths +TOPDIR = . +ENTIRE_FLASH = $(PYTHON) "$(TOPDIR)/entire-flash.py" + +ifeq ($(V), 1) + EF_VERBOSE := --verbose +else + EF_VERBOSE := +endif .PHONY: bin bin: $(OUTDIR)/$(TARGET).bin -FW_PRE_PAD = $(shell echo $$[$(FW_BANK_BASE)-$(BL_BANK_BASE)-$(BL_BANK_SIZE)]) -$(OUTDIR)/$(TARGET).fw_pre.pad: - $(V0) @echo $(MSG_PADDING) $@ - $(V1) dd status=noxfer if=/dev/zero count=$(FW_PRE_PAD) bs=1 2>/dev/null | tr '\000' '\377' > $@ - -FW_POST_PAD = $(shell echo $$[$(FW_BANK_SIZE)-$(FW_DESC_SIZE)-$$(stat -c%s $(FW_BIN))]) -$(OUTDIR)/$(TARGET).fw_post.pad: - $(V0) @echo $(MSG_PADDING) $@ - $(V1) dd status=noxfer if=/dev/zero count=$(FW_POST_PAD) bs=1 2>/dev/null | tr '\000' '\377' > $@ - - -BL_BIN = $(TOP)/build/bl_$(BOARD_NAME)/bl_$(BOARD_NAME).bin -FW_BIN = $(TOP)/build/fw_$(BOARD_NAME)/fw_$(BOARD_NAME).bin +BL_BIN = $(BUILD_DIR)/bl_$(BOARD_NAME)/bl_$(BOARD_NAME).bin +FW_BIN = $(BUILD_DIR)/fw_$(BOARD_NAME)/fw_$(BOARD_NAME).bin FWINFO_BIN = $(FW_BIN).firmwareinfo.bin -$(OUTDIR)/$(TARGET).bin: $(BL_BIN) $(FW_BIN) $(OUTDIR)/$(TARGET).fw_pre.pad $(OUTDIR)/$(TARGET).fw_post.pad - $(V0) @echo $(MSG_FLASH_IMG) $@ - $(V1) cat $(BL_BIN) $(OUTDIR)/$(TARGET).fw_pre.pad $(FW_BIN) $(OUTDIR)/$(TARGET).fw_post.pad $(FWINFO_BIN) > $@ + +$(OUTDIR)/$(TARGET).bin: $(BL_BIN) $(FW_BIN) + $(V0) @$(ECHO) $(MSG_FLASH_IMG) $@ + $(V1) $(ENTIRE_FLASH) $(EF_VERBOSE) \ + --bl-bank-base=$(BL_BANK_BASE) \ + --bl-bank-size=$(BL_BANK_SIZE) \ + --fw-bank-base=$(FW_BANK_BASE) \ + --fw-bank-size=$(FW_BANK_SIZE) \ + --fw-desc-size=$(FW_DESC_SIZE) \ + --bl-bin-path="$(BL_BIN)" \ + --fw-bin-path="$(FW_BIN)" \ + --fwinfo-bin-path="$(FWINFO_BIN)" \ + --outfile="$@" .PHONY: dfu dfu: $(OUTDIR)/$(TARGET).bin @@ -52,4 +59,3 @@ dfu: $(OUTDIR)/$(TARGET).bin sudo $(DFU_CMD) -l && \ sudo $(DFU_CMD) -d 0483:df11 -c 1 -i 0 -a 0 -D $< -s $(BL_BANK_BASE) ; \ ) - diff --git a/flight/targets/EntireFlash/entire-flash.py b/flight/targets/EntireFlash/entire-flash.py new file mode 100644 index 000000000..0863451d1 --- /dev/null +++ b/flight/targets/EntireFlash/entire-flash.py @@ -0,0 +1,121 @@ +#!/usr/bin/env python +# +# Helper function to generate an entire flash image. +# +# (c) 2013, The OpenPilot Team, http://www.openpilot.org +# See also: The GNU Public License (GPL) Version 3 +# + +import optparse +import sys + +def append(verbose, text, data): + """Appends data to global image, updates global offset, prints details if verbose is set""" + global image, offset + if verbose: + print text, "0x%08x" % len(data), "@ 0x%08x" % offset, "%8d bytes" % len(data) + image += data + offset += len(data) + +def create_entire_flash(args): + """Generates entire flash image, prints image info and writes image to a file""" + global image, offset + + assert args.bl_bank_base is not None + assert args.bl_bank_size is not None + assert args.fw_bank_base is not None + assert args.fw_bank_size is not None + assert args.fw_desc_size is not None + assert args.bl_bin_path is not None + assert args.fw_bin_path is not None + assert args.fwinfo_bin_path is not None + + image = "" + offset = 0 + pad = chr(0xff) + + try: + bl_bin_file = open(args.bl_bin_path, "rb") + bl_bin = bl_bin_file.read() + bl_bin_file.close() + + fw_bin_file = open(args.fw_bin_path, "rb") + fw_bin = fw_bin_file.read() + fw_bin_file.close() + + fwinfo_bin_file = open(args.fwinfo_bin_path, "rb") + fwinfo_bin = fwinfo_bin_file.read() + fwinfo_bin_file.close() + + pre_pad_size = args.fw_bank_base - args.bl_bank_base - args.bl_bank_size + post_pad_size = args.fw_bank_size - args.fw_desc_size - len(fw_bin) + + append(args.verbose, "Bootloader image: ", bl_bin) + append(args.verbose, "Padding: ", pad * pre_pad_size) + append(args.verbose, "Firmware image: ", fw_bin) + append(args.verbose, "Padding: ", pad * post_pad_size) + append(args.verbose, "Firmware info blob: ", fwinfo_bin) + + if args.verbose: + print "Entire flash image size:", offset, "bytes" + + if args.outfile: + of = open(args.outfile, "wb") + of.write(image) + of.close() + + except: + import traceback + traceback.print_exc() + return -2 + + return 0 + +def main(): + """Entire image data will be written to OUTFILE (if given) as concatenation of: + - bootloader + padding + firmware + padding + firmware info + """ + + # Parse command line. + class RawDescriptionHelpFormatter(optparse.IndentedHelpFormatter): + """optparse formatter function to pretty print raw epilog""" + def format_epilog(self, epilog): + if epilog: + return "\n" + epilog + "\n" + else: + return "" + + parser = optparse.OptionParser( + formatter=RawDescriptionHelpFormatter(), + description = "Helper function to generate an entire flash image.", + epilog = main.__doc__); + + parser.add_option('--bl-bank-base', type='long', action='store', + help='start of bootloader flash'); + parser.add_option('--bl-bank-size', type='long', action='store', + help='should include BD_INFO region'); + parser.add_option('--fw-bank-base', type='long', action='store', + help='start of firmware flash'); + parser.add_option('--fw-bank-size', type='long', action='store', + help='should include FW_DESC_SIZE'); + parser.add_option('--fw-desc-size', type='long', action='store', + help='firmware description area size'); + parser.add_option('--bl-bin-path', action='store', + help='path to bootloader image'); + parser.add_option('--fw-bin-path', action='store', + help='path to firmware image'); + parser.add_option('--fwinfo-bin-path', action='store', + help='path to firmware info blob'); + parser.add_option('--outfile', action='store', + help='name of entire flash output file'); + parser.add_option('--verbose', action='store_true', + help='print addresses and sizes'); + (args, positional_args) = parser.parse_args() + + if (len(positional_args) != 0) or (len(sys.argv) == 1): + parser.error("incorrect number of arguments, try --help for help") + + return create_entire_flash(args) + +if __name__ == "__main__": + sys.exit(main()) diff --git a/flight/targets/OSD/Makefile b/flight/targets/OSD/Makefile index fd3d4f189..9ff2df65d 100644 --- a/flight/targets/OSD/Makefile +++ b/flight/targets/OSD/Makefile @@ -1,531 +1,104 @@ - ##### - # Project: OpenPilot OSD - # - # - # Makefile for OpenPilot OSD project - # - # The OpenPilot Team, http://www.openpilot.org, Copyright (C) 2009. - # - # - # 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 - ##### +# +# Copyright (c) 2009-2013, The OpenPilot Team, http://www.openpilot.org +# +# 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 - -# Set developer code and compile options -# Set to YES for debugging -DEBUG ?= NO - -# Set to YES when using Code Sourcery toolchain -CODE_SOURCERY ?= NO - -ifeq ($(CODE_SOURCERY), YES) -REMOVE_CMD = cs-rm -else -REMOVE_CMD = rm +ifndef OPENPILOT_IS_COOL + $(error Top level Makefile must be used to build this target) endif -FLASH_TOOL = OPENOCD +include $(ROOT_DIR)/make/boards/$(BOARD_NAME)/board-info.mk +include $(ROOT_DIR)/make/firmware-defs.mk -# Optional module and driver defaults -USE_CAMERASTAB ?= NO -USE_COMUSBBRIDGE ?= NO -USE_GPS ?= NO -USE_TXPID ?= NO -USE_I2C ?= NO -USE_ALTITUDE ?= NO -TEST_FAULTS ?= NO -USE_MAGBARO ?= NO - -# List of optional modules to include -OPTMODULES = -ifeq ($(USE_CAMERASTAB), YES) -OPTMODULES += CameraStab -endif -ifeq ($(USE_COMUSBBRIDGE), YES) -OPTMODULES += ComUsbBridge -endif -ifeq ($(USE_GPS), YES) -OPTMODULES += GPS -endif -ifeq ($(USE_TXPID), YES) -OPTMODULES += TxPID -endif -ifeq ($(USE_ALTITUDE), YES) -ifeq ($(USE_I2C), YES) -OPTMODULES += Altitude -else -$(error "Altitude module (USE_ALTITUDE=YES) requires i2c (USE_I2C=YES)") -endif -endif -ifeq ($(TEST_FAULTS), YES) -OPTMODULES += Fault -endif -ifeq ($(USE_MAGBARO), YES) -ifeq ($(USE_I2C), YES) -OPTMODULES += Extensions/MagBaro -else -$(error "MagBaro module (USE_MAGBARO=YES) requires i2c (USE_I2C=YES)") -endif -endif +# ARM DSP library +override USE_DSP_LIB := NO # List of mandatory modules to include -MODULES = Osd/osdgen -MODULES += GPS +MODULES += Osd/osdgen MODULES += Osd/osdinput MODULES += Osd/WavPlayer +MODULES += GPS MODULES += Extensions/MagBaro -MODULES += Telemetry MODULES += FirmwareIAP +MODULES += Telemetry -# Paths -OPSYSTEM = ./System -OPSYSTEMINC = $(OPSYSTEM)/inc -OPUAVTALKINC = $(OPUAVTALK)/inc -PIOSINC = $(PIOS)/inc -FLIGHTLIBINC = $(FLIGHTLIB)/inc -PIOSSTM32F4XX = $(PIOS)/STM32F4xx -PIOSCOMMON = $(PIOS)/Common -PIOSBOARDS = $(PIOS)/Boards -PIOSCOMMONLIB = $(PIOSCOMMON)/Libraries -PIOS_DEVLIB = $(PIOS)/STM32F4xx -APPLIBDIR = $(PIOSSTM32F4XX)/Libraries -STMLIBDIR = $(APPLIBDIR) -STMSPDDIR = $(STMLIBDIR)/STM32F4xx_StdPeriph_Driver -STMUSBDIR = $(STMLIBDIR)/STM32_USB-FS-Device_Driver -STMSPDSRCDIR = $(STMSPDDIR)/src -STMSPDINCDIR = $(STMSPDDIR)/inc -CMSISDIR = $(STMLIBDIR)/CMSIS/Core/CM3 -RTOSDIR = $(PIOSCOMMONLIB)/FreeRTOS -RTOSSRCDIR = $(RTOSDIR)/Source -RTOSINCDIR = $(RTOSSRCDIR)/include -OPUAVOBJINC = $(OPUAVOBJ)/inc - -# List C source files here. (C dependencies are automatically generated.) -# use file-extension c for "c-only"-files - -## MODULES -SRC += ${foreach MOD, ${OPTMODULES}, ${wildcard ${OPMODULEDIR}/${MOD}/*.c}} -SRC += ${foreach MOD, ${MODULES}, ${wildcard ${OPMODULEDIR}/${MOD}/*.c}} -## OPENPILOT CORE: -SRC += ${OPMODULEDIR}/System/systemmod.c -SRC += $(OPSYSTEM)/osd.c -SRC += $(OPSYSTEM)/pios_board.c -SRC += $(OPSYSTEM)/pios_usb_board_data.c -SRC += $(OPSYSTEM)/fonts.c -SRC += $(OPSYSTEM)/font_outlined8x14.c -SRC += $(OPSYSTEM)/font_outlined8x8.c -SRC += $(OPSYSTEM)/alarms.c -SRC += $(OPUAVTALK)/uavtalk.c -SRC += $(OPUAVOBJ)/uavobjectmanager.c -SRC += $(OPUAVOBJ)/eventdispatcher.c - -#ifeq ($(DEBUG),YES) -SRC += $(OPSYSTEM)/dcc_stdio.c -SRC += $(OPSYSTEM)/cm3_fault_handlers.c -#endif - -SRC += $(FLIGHTLIB)/fifo_buffer.c -SRC += $(FLIGHTLIB)/taskmonitor.c -SRC += $(FLIGHTLIB)/CoordinateConversions.c -SRC += $(FLIGHTLIB)/WorldMagModel.c - -## UAVOBJECTS -#SRC += $(OPUAVSYNTHDIR)/accessorydesired.c -SRC += $(OPUAVSYNTHDIR)/objectpersistence.c -SRC += $(OPUAVSYNTHDIR)/gcstelemetrystats.c -SRC += $(OPUAVSYNTHDIR)/flighttelemetrystats.c -SRC += $(OPUAVSYNTHDIR)/flightstatus.c -SRC += $(OPUAVSYNTHDIR)/systemstats.c -SRC += $(OPUAVSYNTHDIR)/systemalarms.c -SRC += $(OPUAVSYNTHDIR)/systemsettings.c -#SRC += $(OPUAVSYNTHDIR)/stabilizationdesired.c -#SRC += $(OPUAVSYNTHDIR)/stabilizationsettings.c -#SRC += $(OPUAVSYNTHDIR)/actuatorcommand.c -#SRC += $(OPUAVSYNTHDIR)/actuatordesired.c -#SRC += $(OPUAVSYNTHDIR)/actuatorsettings.c -#SRC += $(OPUAVSYNTHDIR)/attituderaw.c -SRC += $(OPUAVSYNTHDIR)/attitudeactual.c -#SRC += $(OPUAVSYNTHDIR)/manualcontrolcommand.c -SRC += $(OPUAVSYNTHDIR)/i2cstats.c -SRC += $(OPUAVSYNTHDIR)/watchdogstatus.c -#SRC += $(OPUAVSYNTHDIR)/telemetrysettings.c -#SRC += $(OPUAVSYNTHDIR)/manualcontrolsettings.c -#SRC += $(OPUAVSYNTHDIR)/mixersettings.c -SRC += $(OPUAVSYNTHDIR)/firmwareiapobj.c -#SRC += $(OPUAVSYNTHDIR)/attitudesettings.c -#SRC += $(OPUAVSYNTHDIR)/camerastabsettings.c -#SRC += $(OPUAVSYNTHDIR)/cameradesired.c -SRC += $(OPUAVSYNTHDIR)/hwsettings.c -#SRC += $(OPUAVSYNTHDIR)/gcsreceiver.c -#SRC += $(OPUAVSYNTHDIR)/receiveractivity.c -SRC += $(OPUAVSYNTHDIR)/taskinfo.c -SRC += $(OPUAVSYNTHDIR)/mixerstatus.c -#SRC += $(OPUAVSYNTHDIR)/ratedesired.c -SRC += $(OPUAVSYNTHDIR)/homelocation.c -SRC += $(OPUAVSYNTHDIR)/gpsposition.c -SRC += $(OPUAVSYNTHDIR)/gpssatellites.c -SRC += $(OPUAVSYNTHDIR)/gpsvelocity.c -SRC += $(OPUAVSYNTHDIR)/gpstime.c -SRC += $(OPUAVSYNTHDIR)/osdsettings.c -SRC += $(OPUAVSYNTHDIR)/baroaltitude.c -SRC += $(OPUAVSYNTHDIR)/magnetometer.c - -## PIOS Hardware (Common) -SRC += $(PIOSCOMMON)/pios_com.c -SRC += $(PIOSCOMMON)/pios_bmp085.c -SRC += $(PIOSCOMMON)/pios_hmc5883.c -#SRC += $(PIOSCOMMON)/printf-stdarg.c -SRC += $(PIOSCOMMON)/printf2.c -SRC += $(PIOSCOMMON)/pios_crc.c -SRC += $(PIOSCOMMON)/pios_video.c -SRC += $(PIOSCOMMON)/pios_wavplay.c -SRC += $(PIOSCOMMON)/pios_usb_desc_hid_cdc.c -SRC += $(PIOSCOMMON)/pios_usb_desc_hid_only.c -SRC += $(PIOSCOMMON)/pios_usb_util.c -SRC += $(PIOSCOMMON)/pios_sdcard.c - -# optional component libraries -include $(PIOSCOMMONLIB)/FreeRTOS/library.mk -include $(PIOSCOMMONLIB)/dosfs/library.mk -include $(PIOSCOMMONLIB)/msheap/library.mk - -## PIOS Hardware (STM32F4xx) -include $(PIOS)/STM32F4xx/library.mk - - -# List C source files here which must be compiled in ARM-Mode (no -mthumb). -# use file-extension c for "c-only"-files -## just for testing, timer.c could be compiled in thumb-mode too -SRCARM = - -# List C++ source files here. -# use file-extension .cpp for C++-files (not .C) -CPPSRC = - -# List C++ source files here which must be compiled in ARM-Mode. -# use file-extension .cpp for C++-files (not .C) -#CPPSRCARM = $(TARGET).cpp -CPPSRCARM = - -# List Assembler source files here. -# Make them always end in a capital .S. Files ending in a lowercase .s -# will not be considered source files but generated files (assembler -# output from the compiler), and will be deleted upon "make clean"! -# Even though the DOS/Win* filesystem matches both .s and .S the same, -# it will preserve the spelling of the filenames, and gcc itself does -# care about how the name is spelled on its command-line. -#ASRC = $(PIOSSTM32F4XX)/startup_stm32f10x_$(MODEL)$(MODEL_SUFFIX).S - -# List Assembler source files here which must be assembled in ARM-Mode.. -ASRCARM = - -# List any extra directories to look for include files here. -# Each directory must be seperated by a space. -EXTRAINCDIRS += $(OPSYSTEM) -EXTRAINCDIRS += $(OPSYSTEMINC) -EXTRAINCDIRS += $(OPUAVTALK) -EXTRAINCDIRS += $(OPUAVTALKINC) -EXTRAINCDIRS += $(OPUAVOBJ) -EXTRAINCDIRS += $(OPUAVOBJINC) -EXTRAINCDIRS += $(OPUAVSYNTHDIR) -EXTRAINCDIRS += $(PIOS) -EXTRAINCDIRS += $(PIOSINC) -EXTRAINCDIRS += $(FLIGHTLIBINC) -EXTRAINCDIRS += $(PIOSSTM32F4XX) -EXTRAINCDIRS += $(PIOSCOMMON) -EXTRAINCDIRS += $(PIOSBOARDS) -EXTRAINCDIRS += $(STMSPDINCDIR) -EXTRAINCDIRS += $(CMSISDIR) -EXTRAINCDIRS += $(RTOSINCDIR) -EXTRAINCDIRS += $(APPLIBDIR) -EXTRAINCDIRS += $(RTOSSRCDIR)/portable/GCC/ARM_CM3 -EXTRAINCDIRS += $(OPUAVSYNTHDIR) -EXTRAINCDIRS += $(HWDEFSINC) - -EXTRAINCDIRS += ${foreach MOD, ${OPTMODULES} ${MODULES}, ${OPMODULEDIR}/${MOD}/inc} ${OPMODULEDIR}/System/inc - -# List any extra directories to look for library files here. -# Also add directories where the linker should search for -# includes from linker-script to the list -# Each directory must be seperated by a space. -#EXTRA_LIBDIRS += - -# Extra Libraries -# Each library-name must be seperated by a space. -# i.e. to link with libxyz.a, libabc.a and libefsl.a: -# EXTRA_LIBS = xyz abc efsl -# for newlib-lpc (file: libnewlibc-lpc.a): -# EXTRA_LIBS = newlib-lpc -#EXTRA_LIBS += - -# Path to Linker-Scripts -LINKERSCRIPTPATH = $(PIOSSTM32F4XX) - - -# Optimization level, can be [0, 1, 2, 3, s]. -# 0 = turn off optimization. s = optimize for size. -# (Note: 3 is not always the best optimization level. See avr-libc FAQ.) - -ifeq ($(DEBUG),YES) -CFLAGS += -O0 -CFLAGS += -DGENERAL_COV -CFLAGS += -finstrument-functions -ffixed-r10 -else -CFLAGS += -Os -endif - - - -# common architecture-specific flags from the device-specific library makefile -CFLAGS += $(ARCHFLAGS) - - -CFLAGS += -DDIAGNOSTICS -CFLAGS += -DDIAG_TASKS - -# This is not the best place for these. Really should abstract out -# to the board file or something -CFLAGS += -DSTM32F4XX -CFLAGS += -DMEM_SIZE=1024000000 - - -# Output format. (can be ihex or binary or both) -# binary to create a load-image in raw-binary format i.e. for SAM-BA, -# ihex to create a load-image in Intel hex format -#LOADFORMAT = ihex -#LOADFORMAT = binary -LOADFORMAT = both - -# Debugging format. -DEBUGF = dwarf-2 - -# Place project-specific -D (define) and/or -# -U options for C here. -CDEFS += -DHSE_VALUE=$(OSCILLATOR_FREQ) -CDEFS += -DSYSCLK_FREQ=$(SYSCLK_FREQ) -CDEFS += -DUSE_STDPERIPH_DRIVER -CDEFS += -DUSE_$(BOARD) - -# Declare all non-optional modules as built-in to force inclusion -CDEFS += $(foreach MOD, $(notdir $(MODULES)), -DMODULE_$(MOD)_BUILTIN) - -# Place project-specific -D and/or -U options for -# Assembler with preprocessor here. -#ADEFS = -DUSE_IRQ_ASM_WRAPPER -ADEFS = -D__ASSEMBLY__ - -# Compiler flag to set the C Standard level. -# c89 - "ANSI" C -# gnu89 - c89 plus GCC extensions -# c99 - ISO C99 standard (not yet fully implemented) -# gnu99 - c99 plus GCC extensions -CSTANDARD = -std=gnu99 - -#----- - -# Compiler flags. - -# -g*: generate debugging information -# -O*: optimization level -# -f...: tuning, see GCC manual and avr-libc documentation -# -Wall...: warning level -# -Wa,...: tell GCC to pass this to the assembler. -# -adhlns...: create assembler listing -# -# Flags for C and C++ (arm-elf-gcc/arm-elf-g++) - -CFLAGS += -g$(DEBUGF) +OPTMODULES = +# Misc options CFLAGS += -ffast-math -CFLAGS += -mcpu=$(MCU) -CFLAGS += $(CDEFS) -CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) -I. +# List C source files here (C dependencies are automatically generated). +# Use file-extension c for "c-only"-files +ifndef TESTAPP + ## Application Core + SRC += ${OPMODULEDIR}/System/systemmod.c + SRC += $(OPSYSTEM)/osd.c + SRC += $(OPSYSTEM)/pios_board.c + SRC += $(OPSYSTEM)/pios_usb_board_data.c + SRC += $(OPSYSTEM)/alarms.c + SRC += $(OPUAVTALK)/uavtalk.c + SRC += $(OPUAVOBJ)/uavobjectmanager.c + SRC += $(OPUAVOBJ)/eventdispatcher.c -CFLAGS += -mapcs-frame -CFLAGS += -fomit-frame-pointer -ifeq ($(CODE_SOURCERY), YES) -CFLAGS += -fpromote-loop-indices -endif + ## OSD fonts + SRC += $(OPSYSTEM)/fonts.c + SRC += $(OPSYSTEM)/font_outlined8x14.c + SRC += $(OPSYSTEM)/font_outlined8x8.c -CFLAGS += -Wall -#CFLAGS += -Werror -CFLAGS += -Wa,-adhlns=$(addprefix $(OUTDIR)/, $(notdir $(addsuffix .lst, $(basename $<)))) -# Compiler flags to generate dependency files: -CFLAGS += -MD -MP -MF $(OUTDIR)/dep/$(@F).d + #ifeq ($(DEBUG), YES) + SRC += $(OPSYSTEM)/dcc_stdio.c + SRC += $(OPSYSTEM)/cm3_fault_handlers.c + #endif -# flags only for C -#CONLYFLAGS += -Wnested-externs -CONLYFLAGS += $(CSTANDARD) + ## Misc library functions + SRC += $(FLIGHTLIB)/printf2.c + SRC += $(FLIGHTLIB)/WorldMagModel.c -# Assembler flags. -# -Wa,...: tell GCC to pass this to the assembler. -# -ahlns: create listing -ASFLAGS = $(ARCHFLAGS) -mthumb -I. -x assembler-with-cpp -ASFLAGS += $(ADEFS) -ASFLAGS += -Wa,-adhlns=$(addprefix $(OUTDIR)/, $(notdir $(addsuffix .lst, $(basename $<)))) -ASFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) - -MATH_LIB = -lm - -# Linker flags. -# -Wl,...: tell GCC to pass this to linker. -# -Map: create map file -# --cref: add cross reference to map file -LDFLAGS = -nostartfiles -Wl,-Map=$(OUTDIR)/$(TARGET).map,--cref,--gc-sections -LDFLAGS += $(patsubst %,-L%,$(EXTRA_LIBDIRS)) -LDFLAGS += -lc -LDFLAGS += $(patsubst %,-l%,$(EXTRA_LIBS)) -LDFLAGS += $(MATH_LIB) -LDFLAGS += -lc -lgcc - -#Linker scripts -LDFLAGS += $(addprefix -T,$(LINKER_SCRIPTS_APP)) - - -# Define programs and commands. -REMOVE = $(REMOVE_CMD) -f - -# List of all source files. -ALLSRC = $(ASRCARM) $(ASRC) $(SRCARM) $(SRC) $(CPPSRCARM) $(CPPSRC) -# List of all source files without directory and file-extension. -ALLSRCBASE = $(notdir $(basename $(ALLSRC))) - -# Define all object files. -ALLOBJ = $(addprefix $(OUTDIR)/, $(addsuffix .o, $(ALLSRCBASE))) - -# Define all listing files (used for make clean). -LSTFILES = $(addprefix $(OUTDIR)/, $(addsuffix .lst, $(ALLSRCBASE))) -# Define all depedency-files (used for make clean). -DEPFILES = $(addprefix $(OUTDIR)/dep/, $(addsuffix .o.d, $(ALLSRCBASE))) - -# Default target. -all: gccversion build - -ifeq ($(LOADFORMAT),ihex) -build: elf hex lss sym + ## UAVObjects + SRC += $(OPUAVSYNTHDIR)/objectpersistence.c + SRC += $(OPUAVSYNTHDIR)/gcstelemetrystats.c + SRC += $(OPUAVSYNTHDIR)/flighttelemetrystats.c + SRC += $(OPUAVSYNTHDIR)/flightstatus.c + SRC += $(OPUAVSYNTHDIR)/systemstats.c + SRC += $(OPUAVSYNTHDIR)/systemalarms.c + SRC += $(OPUAVSYNTHDIR)/systemsettings.c + SRC += $(OPUAVSYNTHDIR)/attitudeactual.c + SRC += $(OPUAVSYNTHDIR)/i2cstats.c + SRC += $(OPUAVSYNTHDIR)/watchdogstatus.c + SRC += $(OPUAVSYNTHDIR)/firmwareiapobj.c + SRC += $(OPUAVSYNTHDIR)/hwsettings.c + SRC += $(OPUAVSYNTHDIR)/taskinfo.c + SRC += $(OPUAVSYNTHDIR)/mixerstatus.c + SRC += $(OPUAVSYNTHDIR)/homelocation.c + SRC += $(OPUAVSYNTHDIR)/gpsposition.c + SRC += $(OPUAVSYNTHDIR)/gpssatellites.c + SRC += $(OPUAVSYNTHDIR)/gpsvelocity.c + SRC += $(OPUAVSYNTHDIR)/gpstime.c + SRC += $(OPUAVSYNTHDIR)/osdsettings.c + SRC += $(OPUAVSYNTHDIR)/baroaltitude.c + SRC += $(OPUAVSYNTHDIR)/magnetometer.c else -ifeq ($(LOADFORMAT),binary) -build: elf bin lss sym -else -ifeq ($(LOADFORMAT),both) -build: elf hex bin lss sym -else -$(error "$(MSG_FORMATERROR) $(FORMAT)") -endif -endif + ## Test Code + SRC += $(OPTESTS)/test_common.c + SRC += $(OPTESTS)/$(TESTAPP).c endif -# Link: create ELF output file from object files. -$(eval $(call LINK_TEMPLATE, $(OUTDIR)/$(TARGET).elf, $(ALLOBJ), $(ALLLIB))) + +# Optional component libraries +include $(PIOS)/Common/Libraries/dosfs/library.mk -# Assemble: create object files from assembler source files. -$(foreach src, $(ASRC), $(eval $(call ASSEMBLE_TEMPLATE, $(src)))) - -# Assemble: create object files from assembler source files. ARM-only -$(foreach src, $(ASRCARM), $(eval $(call ASSEMBLE_ARM_TEMPLATE, $(src)))) - -# Compile: create object files from C source files. -$(foreach src, $(SRC), $(eval $(call COMPILE_C_TEMPLATE, $(src)))) - -# Compile: create object files from C source files. ARM-only -$(foreach src, $(SRCARM), $(eval $(call COMPILE_C_ARM_TEMPLATE, $(src)))) - -# Compile: create object files from C++ source files. -$(foreach src, $(CPPSRC), $(eval $(call COMPILE_CPP_TEMPLATE, $(src)))) - -# Compile: create object files from C++ source files. ARM-only -$(foreach src, $(CPPSRCARM), $(eval $(call COMPILE_CPP_ARM_TEMPLATE, $(src)))) - -# Compile: create assembler files from C source files. ARM/Thumb -$(eval $(call PARTIAL_COMPILE_TEMPLATE, SRC)) - -# Compile: create assembler files from C source files. ARM only -$(eval $(call PARTIAL_COMPILE_ARM_TEMPLATE, SRCARM)) - -$(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),$(OPENOCD_JTAG_CONFIG),$(OPENOCD_CONFIG))) - -.PHONY: elf lss sym hex bin bino opfw -elf: $(OUTDIR)/$(TARGET).elf -lss: $(OUTDIR)/$(TARGET).lss -sym: $(OUTDIR)/$(TARGET).sym -hex: $(OUTDIR)/$(TARGET).hex -bin: $(OUTDIR)/$(TARGET).bin -bino: $(OUTDIR)/$(TARGET).bin.o -opfw: $(OUTDIR)/$(TARGET).opfw - -# Display sizes of sections. -$(eval $(call SIZE_TEMPLATE, $(OUTDIR)/$(TARGET).elf)) - -# Generate Doxygen documents -docs: - doxygen $(DOXYGENDIR)/doxygen.cfg - -# Install: install binary file with prefix/suffix into install directory -install: $(OUTDIR)/$(TARGET).opfw -ifneq ($(INSTALL_DIR),) - @echo $(MSG_INSTALLING) $(call toprel, $<) - $(V1) mkdir -p $(INSTALL_DIR) - $(V1) $(INSTALL) $< $(INSTALL_DIR)/$(INSTALL_PFX)$(TARGET)$(INSTALL_SFX).opfw -else - $(error INSTALL_DIR must be specified for $@) -endif - -# Target: clean project. -clean: clean_list - -clean_list : - @echo $(MSG_CLEANING) - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).map - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).elf - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).hex - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).bin - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).sym - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).lss - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).bin.o - $(V1) $(REMOVE) $(ALLOBJ) - $(V1) $(REMOVE) $(LSTFILES) - $(V1) $(REMOVE) $(DEPFILES) - $(V1) $(REMOVE) $(SRC:.c=.s) - $(V1) $(REMOVE) $(SRCARM:.c=.s) - $(V1) $(REMOVE) $(CPPSRC:.cpp=.s) - $(V1) $(REMOVE) $(CPPSRCARM:.cpp=.s) - -# Create output files directory -# all known MS Windows OS define the ComSpec environment variable -ifdef ComSpec -$(shell md $(subst /,\\,$(OUTDIR)) 2>NUL) -else -$(shell mkdir -p $(OUTDIR) 2>/dev/null) -endif - -# Include the dependency files. -ifdef ComSpec --include $(shell md $(subst /,\\,$(OUTDIR))\dep 2>NUL) $(wildcard $(OUTDIR)/dep/*) -else --include $(shell mkdir -p $(OUTDIR) 2>/dev/null) $(shell mkdir $(OUTDIR)/dep 2>/dev/null) $(wildcard $(OUTDIR)/dep/*) -endif - -# Listing of phony targets. -.PHONY : all build clean clean_list install \ No newline at end of file +include $(ROOT_DIR)/make/apps-defs.mk +include $(ROOT_DIR)/make/common-defs.mk diff --git a/flight/targets/OSD/System/font_outlined8x14.h b/flight/targets/OSD/System/inc/font_outlined8x14.h similarity index 100% rename from flight/targets/OSD/System/font_outlined8x14.h rename to flight/targets/OSD/System/inc/font_outlined8x14.h diff --git a/flight/targets/OSD/System/font_outlined8x8.h b/flight/targets/OSD/System/inc/font_outlined8x8.h similarity index 100% rename from flight/targets/OSD/System/font_outlined8x8.h rename to flight/targets/OSD/System/inc/font_outlined8x8.h diff --git a/flight/targets/OSD/System/fonts.h b/flight/targets/OSD/System/inc/fonts.h similarity index 100% rename from flight/targets/OSD/System/fonts.h rename to flight/targets/OSD/System/inc/fonts.h diff --git a/flight/targets/OSD/System/inc/op_config.h b/flight/targets/OSD/System/inc/op_config.h deleted file mode 100644 index 97910f392..000000000 --- a/flight/targets/OSD/System/inc/op_config.h +++ /dev/null @@ -1,39 +0,0 @@ -/** - ****************************************************************************** - * @addtogroup OpenPilotSystem OpenPilot System - * @{ - * @addtogroup OpenPilotCore OpenPilot Core - * @{ - * - * @file op_config.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief OpenPilot configuration header. - * Compile time config for OpenPilot Application - * @see The GNU Public License (GPL) Version 3 - * - *****************************************************************************/ -/* - * 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 - */ - - -#ifndef OP_CONFIG_H -#define OP_CONFIG_H - -#endif /* OP_CONFIG_H */ -/** - * @} - * @} - */ diff --git a/flight/targets/OSD/System/inc/openpilot.h b/flight/targets/OSD/System/inc/openpilot.h index 59ae76fd4..7f1ac3758 100644 --- a/flight/targets/OSD/System/inc/openpilot.h +++ b/flight/targets/OSD/System/inc/openpilot.h @@ -35,7 +35,6 @@ #include /* OpenPilot Libraries */ -#include "op_config.h" #include "utlist.h" #include "uavobjectmanager.h" #include "eventdispatcher.h" diff --git a/flight/targets/OSD/System/inc/pios_config.h b/flight/targets/OSD/System/inc/pios_config.h index 332c9a79b..92fc3ee9b 100644 --- a/flight/targets/OSD/System/inc/pios_config.h +++ b/flight/targets/OSD/System/inc/pios_config.h @@ -1,12 +1,14 @@ /** ****************************************************************************** - * + * @addtogroup OpenPilotSystem OpenPilot System + * @{ + * @addtogroup OpenPilotCore OpenPilot Core + * @{ * @file pios_config.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief PiOS configuration header. - * - Central compile time config for the project. + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010-2013. + * @brief PiOS configuration header, the compile time config file for the PIOS. + * Defines which PiOS libraries and features are included in the firmware. * @see The GNU Public License (GPL) Version 3 - * *****************************************************************************/ /* * This program is free software; you can redistribute it and/or modify @@ -24,62 +26,119 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - #ifndef PIOS_CONFIG_H #define PIOS_CONFIG_H -/* Major features */ -#define PIOS_INCLUDE_FREERTOS -#define PIOS_INCLUDE_BL_HELPER +/* + * Below is a complete list of PIOS configurable options. + * Please do not remove or rearrange them. Only comment out + * unused options in the list. See main pios.h header for more + * details. + */ -/* Enable/Disable PiOS Modules */ -#define PIOS_INCLUDE_ADC +/* #define PIOS_INCLUDE_DEBUG_CONSOLE */ +/* #define DEBUG_LEVEL 0 */ + +/* PIOS FreeRTOS support */ +#define PIOS_INCLUDE_FREERTOS + +/* PIOS bootloader helper */ +#define PIOS_INCLUDE_BL_HELPER +/* #define PIOS_INCLUDE_BL_HELPER_WRITE_SUPPORT */ + +/* PIOS system functions */ #define PIOS_INCLUDE_DELAY -#define PIOS_INCLUDE_I2C -#define PIOS_INCLUDE_IRQ -#define PIOS_INCLUDE_LED -#define PIOS_INCLUDE_IAP -//#define PIOS_INCLUDE_SERVO -#define PIOS_INCLUDE_SPI +#define PIOS_INCLUDE_INITCALL #define PIOS_INCLUDE_SYS + +/* PIOS hardware peripherals */ +#define PIOS_INCLUDE_IRQ +#define PIOS_INCLUDE_RTC +#define PIOS_INCLUDE_TIM #define PIOS_INCLUDE_USART -//#define PIOS_INCLUDE_GPIO +#define PIOS_INCLUDE_ADC +#define PIOS_INCLUDE_I2C +#define PIOS_INCLUDE_SPI +/* #define PIOS_INCLUDE_GPIO */ +#define PIOS_INCLUDE_EXTI +#define PIOS_INCLUDE_WDG + +/* PIOS USB functions */ #define PIOS_INCLUDE_USB #define PIOS_INCLUDE_USB_HID -#define PIOS_INCLUDE_EXTI -#define PIOS_INCLUDE_RTC -#define PIOS_INCLUDE_WDG -#define PIOS_INCLUDE_VIDEO +/* #define PIOS_INCLUDE_USB_CDC */ +/* #define PIOS_INCLUDE_USB_RCTX */ -/* Com systems to include */ -#define PIOS_INCLUDE_COM -#define PIOS_INCLUDE_COM_TELEM -#define PIOS_INCLUDE_COM_AUX -#define PIOS_INCLUDE_GPS -//#define PIOS_OVERO_SPI -#define PIOS_INCLUDE_BMP085 +/* PIOS sensor interfaces */ +/* #define PIOS_INCLUDE_ADXL345 */ +/* #define PIOS_INCLUDE_BMA180 */ +/* #define PIOS_INCLUDE_L3GD20 */ +/* #define PIOS_INCLUDE_MPU6000 */ +/* #define PIOS_MPU6000_ACCEL */ +/* #define PIOS_INCLUDE_HMC5843 */ #define PIOS_INCLUDE_HMC5883 +/* #define PIOS_HMC5883_HAS_GPIOS */ +#define PIOS_INCLUDE_BMP085 +/* #define PIOS_INCLUDE_MS5611 */ +/* #define PIOS_INCLUDE_MPXV */ +/* #define PIOS_INCLUDE_ETASV3 */ +/* #define PIOS_INCLUDE_HCSR04 */ + +/* PIOS receiver drivers */ +/* #define PIOS_INCLUDE_PWM */ +/* #define PIOS_INCLUDE_PPM */ +/* #define PIOS_INCLUDE_PPM_FLEXI */ +/* #define PIOS_INCLUDE_DSM */ +/* #define PIOS_INCLUDE_SBUS */ +/* #define PIOS_INCLUDE_GCSRCVR */ + +/* PIOS abstract receiver interface */ +/* #define PIOS_INCLUDE_RCVR */ + +/* PIOS common peripherals */ +#define PIOS_INCLUDE_LED +#define PIOS_INCLUDE_IAP +/* #define PIOS_INCLUDE_SERVO */ +/* #define PIOS_INCLUDE_I2C_ESC */ +/* #define PIOS_INCLUDE_OVERO */ +/* #define PIOS_OVERO_SPI */ #define PIOS_INCLUDE_SDCARD -//#define PIOS_INCLUDE_WAVE -/* Supported receiver interfaces */ -//#define PIOS_INCLUDE_RCVR -//#define PIOS_INCLUDE_DSM -//#define PIOS_INCLUDE_SBUS -//#define PIOS_INCLUDE_PPM -//#define PIOS_INCLUDE_PWM -//#define PIOS_INCLUDE_GCSRCVR +#define LOG_FILENAME "startup.log" +/* #define PIOS_INCLUDE_FLASH */ +/* #define PIOS_INCLUDE_FLASH_SECTOR_SETTINGS */ +/* #define FLASH_FREERTOS */ +/* #define PIOS_INCLUDE_FLASH_EEPROM */ -//#define PIOS_INCLUDE_SETTINGS -//#define PIOS_INCLUDE_FLASH -/* A really shitty setting saving implementation */ -//#define PIOS_INCLUDE_FLASH_SECTOR_SETTINGS +/* PIOS radio modules */ +/* #define PIOS_INCLUDE_RFM22B */ +/* #define PIOS_INCLUDE_RFM22B_COM */ +/* #define PIOS_INCLUDE_RFM22B_RCVR */ +/* #define PIOS_INCLUDE_PPM_OUT */ +/* #define PIOS_RFM22B_DEBUG_ON_TELEM */ -#define PIOS_INCLUDE_INITCALL /* Include init call structures */ -#define PIOS_TELEM_PRIORITY_QUEUE /* Enable a priority queue in telemetry */ -#define PIOS_QUATERNION_STABILIZATION /* Stabilization options */ -#define PIOS_GPS_SETS_HOMELOCATION /* GPS options */ -#define PIOS_INCLUDE_GPS_NMEA_PARSER /* Include the NMEA protocol parser */ -#define PIOS_INCLUDE_GPS_UBX_PARSER /* Include the UBX protocol parser */ +#define PIOS_INCLUDE_VIDEO +/* #define PIOS_INCLUDE_WAVE */ +/* #define PIOS_INCLUDE_UDP */ + +/* PIOS abstract comms interface with options */ +#define PIOS_INCLUDE_COM +/* #define PIOS_INCLUDE_COM_MSG */ +/* #define PIOS_INCLUDE_TELEMETRY_RF */ +#define PIOS_INCLUDE_COM_TELEM +/* #define PIOS_INCLUDE_COM_FLEXI */ +#define PIOS_INCLUDE_COM_AUX +#define PIOS_TELEM_PRIORITY_QUEUE +#define PIOS_INCLUDE_GPS +/* #define PIOS_GPS_MINIMAL */ +#define PIOS_INCLUDE_GPS_NMEA_PARSER +#define PIOS_INCLUDE_GPS_UBX_PARSER +#define PIOS_GPS_SETS_HOMELOCATION + +/* Stabilization options */ +#define PIOS_QUATERNION_STABILIZATION + +/* Performance counters */ +#define IDLE_COUNTS_PER_SEC_AT_NO_LOAD 8379692 /* Alarm Thresholds */ #define HEAP_LIMIT_WARNING 4000 @@ -89,8 +148,23 @@ #define CPULOAD_LIMIT_WARNING 80 #define CPULOAD_LIMIT_CRITICAL 95 -// This actually needs calibrating -#define IDLE_COUNTS_PER_SEC_AT_NO_LOAD (8379692) -#define LOG_FILENAME "PIOS.LOG" +/* Task stack sizes */ +/* #define PIOS_ACTUATOR_STACK_SIZE 1020 */ +/* #define PIOS_MANUAL_STACK_SIZE 800 */ +/* #define PIOS_SYSTEM_STACK_SIZE 660 */ +/* #define PIOS_STABILIZATION_STACK_SIZE 524 */ +/* #define PIOS_TELEM_STACK_SIZE 500 */ +/* #define PIOS_EVENTDISPATCHER_STACK_SIZE 130 */ + +/* This can't be too high to stop eventdispatcher thread overflowing */ +/* #define PIOS_EVENTDISAPTCHER_QUEUE 10 */ + +/* Revolution series */ +/* #define REVOLUTION */ #endif /* PIOS_CONFIG_H */ + +/** + * @} + * @} + */ diff --git a/flight/targets/OSD/System/osd.c b/flight/targets/OSD/System/osd.c index 5615925ca..f0d48a769 100644 --- a/flight/targets/OSD/System/osd.c +++ b/flight/targets/OSD/System/osd.c @@ -117,8 +117,8 @@ void processReset(void) if (RCC_GetFlagStatus(RCC_FLAG_IWDGRST) != RESET) { // Independant Watchdog Reset - #if defined(PIOS_COM_DEBUG) - DEBUG_PRINTF("\r\nINDEPENDANT WATCHDOG CAUSED A RESET\r\n"); + #if defined(PIOS_COM_DEBUG_CONSOLE) + DEBUG_PRINTF(0, "\r\nINDEPENDANT WATCHDOG CAUSED A RESET\r\n"); #endif // all led's ON @@ -136,7 +136,7 @@ void processReset(void) if (RCC_GetFlagStatus(RCC_FLAG_WWDGRST) != RESET) { // Window Watchdog Reset - DEBUG_PRINTF("\r\nWINDOW WATCHDOG CAUSED A REBOOT\r\n"); + DEBUG_PRINTF(0, "\r\nWINDOW WATCHDOG CAUSED A REBOOT\r\n"); // all led's ON USB_LED_ON; @@ -156,28 +156,28 @@ void processReset(void) if (RCC_GetFlagStatus(RCC_FLAG_PORRST) != RESET) { // Power-On Reset #if defined(PIOS_COM_DEBUG) - DEBUG_PRINTF("\r\nPOWER-ON-RESET\r\n"); + DEBUG_PRINTF(0, "\r\nPOWER-ON-RESET\r\n"); #endif } if (RCC_GetFlagStatus(RCC_FLAG_SFTRST) != RESET) { // Software Reset #if defined(PIOS_COM_DEBUG) - DEBUG_PRINTF("\r\nSOFTWARE RESET\r\n"); + DEBUG_PRINTF(0, "\r\nSOFTWARE RESET\r\n"); #endif } if (RCC_GetFlagStatus(RCC_FLAG_LPWRRST) != RESET) { // Low-Power Reset #if defined(PIOS_COM_DEBUG) - DEBUG_PRINTF("\r\nLOW POWER RESET\r\n"); + DEBUG_PRINTF(0, "\r\nLOW POWER RESET\r\n"); #endif } if (RCC_GetFlagStatus(RCC_FLAG_PINRST) != RESET) { // Pin Reset #if defined(PIOS_COM_DEBUG) - DEBUG_PRINTF("\r\nPIN RESET\r\n"); + DEBUG_PRINTF("0, \r\nPIN RESET\r\n"); #endif } diff --git a/flight/targets/PipXtreme/Makefile b/flight/targets/PipXtreme/Makefile index 3c9988b04..8eeb6195b 100644 --- a/flight/targets/PipXtreme/Makefile +++ b/flight/targets/PipXtreme/Makefile @@ -1,581 +1,62 @@ - ##### - # Project: OpenPilot - # - # - # Makefile for OpenPilot project build PiOS and the AP. - # - # The OpenPilot Team, http://www.openpilot.org, Copyright (C) 2009. - # - # - # 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 - -# Set developer code and compile options -# Set to YES to compile for debugging -DEBUG ?= NO - -# Include objects that are just nice information to show -STACK_DIAGNOSTICS ?= NO -MIXERSTATUS_DIAGNOSTICS ?= NO -RATEDESIRED_DIAGNOSTICS ?= NO -I2C_WDG_STATS_DIAGNOSTICS ?= NO -DIAG_TASKS ?= NO - -#Or just turn on all the above diagnostics. WARNING: This consumes massive amounts of memory. -ALL_DIGNOSTICS ?=NO - -# Set to YES to build a FW version that will erase all flash memory -ERASE_FLASH ?= NO -# Set to YES to use the Servo output pins for debugging via scope or logic analyser -ENABLE_DEBUG_PINS ?= NO - -# Set to Yes to enable the AUX UART which is mapped on the S1 (Tx) and S2 (Rx) servo outputs -ENABLE_AUX_UART ?= NO - -USE_GPS ?= NO - -USE_I2C ?= YES - -# Set to YES when using Code Sourcery toolchain -CODE_SOURCERY ?= NO - -# Remove command is different for Code Sourcery on Windows -ifeq ($(CODE_SOURCERY), YES) -REMOVE_CMD = cs-rm -else -REMOVE_CMD = rm -endif - -FLASH_TOOL = OPENOCD - -# List of modules to include -OPTMODULES = -MODULES = RadioComBridge - -# Paths -OPSYSTEM = ./System -OPSYSTEMINC = $(OPSYSTEM)/inc -OPUAVTALKINC = $(OPUAVTALK)/inc -OPUAVOBJINC = $(OPUAVOBJ)/inc -OPTESTS = ./Tests -FLIGHTLIBINC = $(FLIGHTLIB)/inc -RSCODEINC = $(FLIGHTLIB)/rscode -PIOSINC = $(PIOS)/inc -PIOSSTM32F10X = $(PIOS)/STM32F10x -PIOSCOMMON = $(PIOS)/Common -PIOSBOARDS = $(PIOS)/Boards -PIOSCOMMONLIB = $(PIOSCOMMON)/Libraries -APPLIBDIR = $(PIOSSTM32F10X)/Libraries -STMLIBDIR = $(APPLIBDIR) -STMSPDDIR = $(STMLIBDIR)/STM32F10x_StdPeriph_Driver -STMUSBDIR = $(STMLIBDIR)/STM32_USB-FS-Device_Driver -STMSPDSRCDIR = $(STMSPDDIR)/src -STMSPDINCDIR = $(STMSPDDIR)/inc -STMUSBSRCDIR = $(STMUSBDIR)/src -STMUSBINCDIR = $(STMUSBDIR)/inc -CMSISDIR = $(STMLIBDIR)/CMSIS/Core/CM3 -DOSFSDIR = $(APPLIBDIR)/dosfs -MSDDIR = $(APPLIBDIR)/msd -RTOSDIR = $(PIOSCOMMON)/Libraries/FreeRTOS -RTOSSRCDIR = $(RTOSDIR)/Source -RTOSINCDIR = $(RTOSSRCDIR)/include -RTOSPORTDIR = $(APPLIBDIR)/FreeRTOS/Source -PYMITE = $(FLIGHTLIB)/PyMite -PYMITELIB = $(PYMITE)/lib -PYMITEPLAT = $(PYMITE)/platform/openpilot -PYMITETOOLS = $(PYMITE)/tools -PYMITEVM = $(PYMITE)/vm -PYMITEINC = $(PYMITEVM) -PYMITEINC += $(PYMITEPLAT) -PYMITEINC += $(OUTDIR) -FLIGHTPLANLIB = $(OPMODULEDIR)/FlightPlan/lib -FLIGHTPLANS = $(OPMODULEDIR)/FlightPlan/flightplans - -# List C source files here. (C dependencies are automatically generated.) -# use file-extension c for "c-only"-files - -ifndef TESTAPP -## MODULES -SRC += ${foreach MOD, ${MODULES}, ${wildcard ${OPMODULEDIR}/${MOD}/*.c}} -## OPENPILOT CORE: -SRC += ${OPMODULEDIR}/PipXtreme/pipxtrememod.c -SRC += $(OPSYSTEM)/pipxtreme.c -SRC += $(OPSYSTEM)/pios_board.c -SRC += $(OPUAVTALK)/uavtalk.c -SRC += $(OPUAVOBJ)/uavobjectmanager.c -SRC += $(OPUAVOBJ)/eventdispatcher.c -else -## TESTCODE -SRC += $(OPTESTS)/test_common.c -SRC += $(OPTESTS)/$(TESTAPP).c -endif - -## UAVOBJECTS -ifndef TESTAPP -SRC += $(OPUAVSYNTHDIR)/gcsreceiver.c -SRC += $(OPUAVSYNTHDIR)/oplinkstatus.c -SRC += $(OPUAVSYNTHDIR)/oplinksettings.c -SRC += $(OPUAVSYNTHDIR)/objectpersistence.c - -endif - -## PIOS Hardware (STM32F10x) -include $(PIOS)/STM32F10x/library.mk -SRC += $(PIOSSTM32F10X)/pios_sys.c -SRC += $(PIOSSTM32F10X)/pios_led.c -SRC += $(PIOSSTM32F10X)/pios_delay.c -SRC += $(PIOSSTM32F10X)/pios_usart.c -SRC += $(PIOSSTM32F10X)/pios_irq.c -SRC += $(PIOSSTM32F10X)/pios_spi.c -SRC += $(PIOSSTM32F10X)/pios_ppm.c -SRC += $(PIOSSTM32F10X)/pios_ppm_out.c -SRC += $(PIOSSTM32F10X)/pios_debug.c -SRC += $(PIOSSTM32F10X)/pios_gpio.c -SRC += $(PIOSSTM32F10X)/pios_exti.c -SRC += $(PIOSSTM32F10X)/pios_rtc.c -SRC += $(PIOSSTM32F10X)/pios_wdg.c -SRC += $(PIOSSTM32F10X)/pios_tim.c -SRC += $(PIOSSTM32F10X)/pios_pwm.c -SRC += $(PIOSSTM32F10X)/pios_eeprom.c -SRC += $(PIOSSTM32F10X)/pios_bl_helper.c - -# PIOS USB related files (seperated to make code maintenance more easy) -SRC += $(PIOSSTM32F10X)/pios_usb.c -SRC += $(PIOSSTM32F10X)/pios_usbhook.c -SRC += $(PIOSSTM32F10X)/pios_usb_hid.c -SRC += $(PIOSSTM32F10X)/pios_usb_cdc.c -SRC += $(PIOSSTM32F10X)/pios_usb_hid_istr.c -SRC += $(PIOSSTM32F10X)/pios_usb_hid_pwr.c -SRC += $(OPSYSTEM)/pios_usb_board_data.c -SRC += $(PIOSCOMMON)/pios_usb_desc_hid_cdc.c -SRC += $(PIOSCOMMON)/pios_usb_desc_hid_only.c -SRC += $(PIOSCOMMON)/pios_usb_util.c - -## PIOS Hardware (Common) -SRC += $(PIOSCOMMON)/pios_crc.c -SRC += $(PIOSCOMMON)/pios_com.c -SRC += $(PIOSCOMMON)/pios_i2c_esc.c -SRC += $(PIOSCOMMON)/pios_rcvr.c -SRC += $(PIOSCOMMON)/printf-stdarg.c -SRC += $(PIOSCOMMON)/pios_rfm22b.c -SRC += $(PIOSCOMMON)/pios_rfm22b_com.c -## Libraries for flight calculations -SRC += $(FLIGHTLIB)/fifo_buffer.c -SRC += $(FLIGHTLIB)/CoordinateConversions.c -SRC += $(FLIGHTLIB)/taskmonitor.c -SRC += $(FLIGHTLIB)/aes.c -## The Reed-Solomon FEC library -SRC += $(FLIGHTLIB)/rscode/rs.c -SRC += $(FLIGHTLIB)/rscode/berlekamp.c -SRC += $(FLIGHTLIB)/rscode/galois.c - -## CMSIS for STM32 -SRC += $(CMSISDIR)/core_cm3.c -SRC += $(CMSISDIR)/system_stm32f10x.c - -## Used parts of the STM-Library -SRC += $(STMSPDSRCDIR)/stm32f10x_bkp.c -SRC += $(STMSPDSRCDIR)/stm32f10x_crc.c -SRC += $(STMSPDSRCDIR)/stm32f10x_dac.c -SRC += $(STMSPDSRCDIR)/stm32f10x_dma.c -SRC += $(STMSPDSRCDIR)/stm32f10x_exti.c -SRC += $(STMSPDSRCDIR)/stm32f10x_flash.c -SRC += $(STMSPDSRCDIR)/stm32f10x_gpio.c -SRC += $(STMSPDSRCDIR)/stm32f10x_i2c.c -SRC += $(STMSPDSRCDIR)/stm32f10x_pwr.c -SRC += $(STMSPDSRCDIR)/stm32f10x_rcc.c -SRC += $(STMSPDSRCDIR)/stm32f10x_rtc.c -SRC += $(STMSPDSRCDIR)/stm32f10x_spi.c -SRC += $(STMSPDSRCDIR)/stm32f10x_tim.c -SRC += $(STMSPDSRCDIR)/stm32f10x_usart.c -SRC += $(STMSPDSRCDIR)/stm32f10x_iwdg.c -SRC += $(STMSPDSRCDIR)/stm32f10x_dbgmcu.c -SRC += $(STMSPDSRCDIR)/misc.c - -## STM32 USB Library -SRC += $(STMUSBSRCDIR)/usb_core.c -SRC += $(STMUSBSRCDIR)/usb_init.c -SRC += $(STMUSBSRCDIR)/usb_int.c -SRC += $(STMUSBSRCDIR)/usb_mem.c -SRC += $(STMUSBSRCDIR)/usb_regs.c -SRC += $(STMUSBSRCDIR)/usb_sil.c - -## RTOS -SRC += $(RTOSSRCDIR)/list.c -SRC += $(RTOSSRCDIR)/queue.c -SRC += $(RTOSSRCDIR)/tasks.c - -## RTOS Portable -SRC += $(RTOSPORTDIR)/portable/GCC/ARM_CM3/port.c -SRC += $(RTOSPORTDIR)/portable/MemMang/heap_1.c - -# List C source files here which must be compiled in ARM-Mode (no -mthumb). -# use file-extension c for "c-only"-files -## just for testing, timer.c could be compiled in thumb-mode too -SRCARM = - -# List C++ source files here. -# use file-extension .cpp for C++-files (not .C) -CPPSRC = - -# List C++ source files here which must be compiled in ARM-Mode. -# use file-extension .cpp for C++-files (not .C) -#CPPSRCARM = $(TARGET).cpp -CPPSRCARM = - -# List Assembler source files here. -# Make them always end in a capital .S. Files ending in a lowercase .s -# will not be considered source files but generated files (assembler -# output from the compiler), and will be deleted upon "make clean"! -# Even though the DOS/Win* filesystem matches both .s and .S the same, -# it will preserve the spelling of the filenames, and gcc itself does -# care about how the name is spelled on its command-line. -ASRC = $(PIOSSTM32F10X)/startup_stm32f10x_$(MODEL)$(MODEL_SUFFIX).S - -# List Assembler source files here which must be assembled in ARM-Mode.. -ASRCARM = - -# List any extra directories to look for include files here. -# Each directory must be seperated by a space. -EXTRAINCDIRS += $(OPSYSTEM) -EXTRAINCDIRS += $(OPSYSTEMINC) -EXTRAINCDIRS += $(OPUAVTALK) -EXTRAINCDIRS += $(OPUAVTALKINC) -EXTRAINCDIRS += $(OPUAVOBJ) -EXTRAINCDIRS += $(OPUAVOBJINC) -EXTRAINCDIRS += $(OPUAVSYNTHDIR) -EXTRAINCDIRS += $(PIOS) -EXTRAINCDIRS += $(PIOSINC) -EXTRAINCDIRS += $(FLIGHTLIBINC) -EXTRAINCDIRS += $(RSCODEINC) -EXTRAINCDIRS += $(PIOSSTM32F10X) -EXTRAINCDIRS += $(PIOSCOMMON) -EXTRAINCDIRS += $(PIOSBOARDS) -EXTRAINCDIRS += $(STMSPDINCDIR) -EXTRAINCDIRS += $(STMUSBINCDIR) -EXTRAINCDIRS += $(CMSISDIR) -EXTRAINCDIRS += $(DOSFSDIR) -EXTRAINCDIRS += $(MSDDIR) -EXTRAINCDIRS += $(RTOSINCDIR) -EXTRAINCDIRS += $(APPLIBDIR) -EXTRAINCDIRS += $(RTOSPORTDIR)/portable/GCC/ARM_CM3 -EXTRAINCDIRS += $(PYMITEINC) -EXTRAINCDIRS += $(HWDEFSINC) - -EXTRAINCDIRS += ${foreach MOD, ${OPTMODULES} ${MODULES}, ${OPMODULEDIR}/${MOD}/inc} ${OPMODULEDIR}/System/inc - - -# List any extra directories to look for library files here. -# Also add directories where the linker should search for -# includes from linker-script to the list -# Each directory must be seperated by a space. -#EXTRA_LIBDIRS += - -# Extra Libraries -# Each library-name must be seperated by a space. -# i.e. to link with libxyz.a, libabc.a and libefsl.a: -# EXTRA_LIBS = xyz abc efsl -# for newlib-lpc (file: libnewlibc-lpc.a): -# EXTRA_LIBS = newlib-lpc -#EXTRA_LIBS += - -# Path to Linker-Scripts -LINKERSCRIPTPATH = $(PIOSSTM32F10X) - -# Optimization level, can be [0, 1, 2, 3, s]. -# 0 = turn off optimization. s = optimize for size. -# (Note: 3 is not always the best optimization level. See avr-libc FAQ.) - -ifeq ($(DEBUG),YES) -OPT = 1 -else -OPT = s -endif - -# Output format. (can be ihex or binary or both) -# binary to create a load-image in raw-binary format i.e. for SAM-BA, -# ihex to create a load-image in Intel hex format -#LOADFORMAT = ihex -#LOADFORMAT = binary -LOADFORMAT = both - -# Debugging format. -DEBUGF = dwarf-2 - -# Place project-specific -D (define) and/or -# -U options for C here. -CDEFS += -DSTM32F10X_$(MODEL) -CDEFS += -DUSE_STDPERIPH_DRIVER -CDEFS += -DUSE_$(BOARD) -ifeq ($(ENABLE_DEBUG_PINS), YES) -CDEFS += -DPIOS_ENABLE_DEBUG_PINS -endif -ifeq ($(ENABLE_AUX_UART), YES) -CDEFS += -DPIOS_ENABLE_AUX_UART -endif -ifeq ($(ERASE_FLASH), YES) -CDEFS += -DERASE_FLASH -endif - -ifneq ($(USE_GPS), NO) -CDEFS += -DUSE_GPS -endif - -ifeq ($(USE_I2C), YES) -CDEFS += -DUSE_I2C -endif - -# Place project-specific -D and/or -U options for -# Assembler with preprocessor here. -#ADEFS = -DUSE_IRQ_ASM_WRAPPER -ADEFS = -D__ASSEMBLY__ - -# Compiler flag to set the C Standard level. -# c89 - "ANSI" C -# gnu89 - c89 plus GCC extensions -# c99 - ISO C99 standard (not yet fully implemented) -# gnu99 - c99 plus GCC extensions -CSTANDARD = -std=gnu99 - -#----- - -# Compiler flags. - -# -g*: generate debugging information -# -O*: optimization level -# -f...: tuning, see GCC manual and avr-libc documentation -# -Wall...: warning level -# -Wa,...: tell GCC to pass this to the assembler. -# -adhlns...: create assembler listing # -# Flags for C and C++ (arm-elf-gcc/arm-elf-g++) +# Copyright (c) 2009-2013, The OpenPilot Team, http://www.openpilot.org +# +# 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 +# -ifeq ($(DEBUG),YES) -CFLAGS = -DDEBUG +ifndef OPENPILOT_IS_COOL + $(error Top level Makefile must be used to build this target) endif -ifneq (,$(filter YES,$(STACK_DIAGNOSTICS) $(ALL_DIGNOSTICS))) -CFLAGS += -DSTACK_DIAGNOSTICS -endif +include $(ROOT_DIR)/make/boards/$(BOARD_NAME)/board-info.mk +include $(ROOT_DIR)/make/firmware-defs.mk -ifneq (,$(filter YES,$(MIXERSTATUS_DIAGNOSTICS) $(ALL_DIGNOSTICS))) -CFLAGS += -DMIXERSTATUS_DIAGNOSTICS -endif +# ARM DSP library +override USE_DSP_LIB := NO -ifneq (,$(filter YES,$(RATEDESIRED_DIAGNOSTICS) $(ALL_DIGNOSTICS))) -CFLAGS += -DRATEDESIRED_DIAGNOSTICS -endif +# List of mandatory modules to include +MODULES += RadioComBridge -ifneq (,$(filter YES,$(I2C_WDG_STATS_DIAGNOSTICS) $(ALL_DIGNOSTICS))) -CFLAGS += -DI2C_WDG_STATS_DIAGNOSTICS -endif +# List of optional modules to include +OPTMODULES = -ifneq (,$(filter YES,$(DIAG_TASKS) $(ALL_DIGNOSTICS))) -CFLAGS += -DDIAG_TASKS -endif +# List C source files here (C dependencies are automatically generated). +# Use file-extension c for "c-only"-files +ifndef TESTAPP + ## Application Core + SRC += ${OPMODULEDIR}/PipXtreme/pipxtrememod.c + SRC += $(OPSYSTEM)/pipxtreme.c + SRC += $(OPSYSTEM)/pios_board.c + SRC += $(OPSYSTEM)/pios_usb_board_data.c + SRC += $(OPUAVTALK)/uavtalk.c + SRC += $(OPUAVOBJ)/uavobjectmanager.c + SRC += $(OPUAVOBJ)/eventdispatcher.c -CFLAGS += -g$(DEBUGF) -CFLAGS += -O$(OPT) -CFLAGS += -mcpu=$(MCU) -CFLAGS += $(CDEFS) -CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) -I. - -#CFLAGS += -fno-cprop-registers -fno-defer-pop -fno-guess-branch-probability -fno-section-anchors -#CFLAGS += -fno-if-conversion -fno-if-conversion2 -fno-ipa-pure-const -fno-ipa-reference -fno-merge-constants -#CFLAGS += -fno-split-wide-types -fno-tree-ccp -fno-tree-ch -fno-tree-copy-prop -fno-tree-copyrename -#CFLAGS += -fno-tree-dce -fno-tree-dominator-opts -fno-tree-dse -fno-tree-fre -fno-tree-sink -fno-tree-sra -#CFLAGS += -fno-tree-ter -#CFLAGS += -g$(DEBUGF) -DDEBUG - -CFLAGS += -mapcs-frame -CFLAGS += -fomit-frame-pointer -ifeq ($(CODE_SOURCERY), YES) -CFLAGS += -fpromote-loop-indices -endif - -CFLAGS += -Wall -CFLAGS += -Werror -CFLAGS += -Wa,-adhlns=$(addprefix $(OUTDIR)/, $(notdir $(addsuffix .lst, $(basename $<)))) -# Compiler flags to generate dependency files: -CFLAGS += -MD -MP -MF $(OUTDIR)/dep/$(@F).d - -# flags only for C -#CONLYFLAGS += -Wnested-externs -CONLYFLAGS += $(CSTANDARD) - -# Assembler flags. -# -Wa,...: tell GCC to pass this to the assembler. -# -ahlns: create listing -ASFLAGS = -mcpu=$(MCU) -I. -x assembler-with-cpp -ASFLAGS += $(ADEFS) -ASFLAGS += -Wa,-adhlns=$(addprefix $(OUTDIR)/, $(notdir $(addsuffix .lst, $(basename $<)))) -ASFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) - -MATH_LIB = -lm - -# Linker flags. -# -Wl,...: tell GCC to pass this to linker. -# -Map: create map file -# --cref: add cross reference to map file -LDFLAGS = -nostartfiles -Wl,-Map=$(OUTDIR)/$(TARGET).map,--cref,--gc-sections -LDFLAGS += $(patsubst %,-L%,$(EXTRA_LIBDIRS)) -LDFLAGS += -lc -LDFLAGS += $(patsubst %,-l%,$(EXTRA_LIBS)) -LDFLAGS += $(MATH_LIB) -LDFLAGS += -lc -lgcc - -# Set linker-script name depending on selected submodel name -LDFLAGS += -T$(LINKERSCRIPTPATH)/link_$(BOARD)_memory.ld -LDFLAGS += -T$(LINKERSCRIPTPATH)/link_$(BOARD)_sections.ld - -# Define programs and commands. -REMOVE = $(REMOVE_CMD) -f -PYTHON = python - -# List of all source files. -ALLSRC = $(ASRCARM) $(ASRC) $(SRCARM) $(SRC) $(CPPSRCARM) $(CPPSRC) -# List of all source files without directory and file-extension. -ALLSRCBASE = $(notdir $(basename $(ALLSRC))) - -# Define all object files. -ALLOBJ = $(addprefix $(OUTDIR)/, $(addsuffix .o, $(ALLSRCBASE))) - -# Define all listing files (used for make clean). -LSTFILES = $(addprefix $(OUTDIR)/, $(addsuffix .lst, $(ALLSRCBASE))) -# Define all depedency-files (used for make clean). -DEPFILES = $(addprefix $(OUTDIR)/dep/, $(addsuffix .o.d, $(ALLSRCBASE))) - -# Default target. -all: build - -ifeq ($(LOADFORMAT),ihex) -build: elf hex lss sym + ## UAVObjects + SRC += $(OPUAVSYNTHDIR)/gcsreceiver.c + SRC += $(OPUAVSYNTHDIR)/oplinkstatus.c + SRC += $(OPUAVSYNTHDIR)/oplinksettings.c + SRC += $(OPUAVSYNTHDIR)/objectpersistence.c else -ifeq ($(LOADFORMAT),binary) -build: elf bin lss sym -else -ifeq ($(LOADFORMAT),both) -build: elf hex bin lss sym -else -$(error "$(MSG_FORMATERROR) $(FORMAT)") -endif -endif + ## Test Code + SRC += $(OPTESTS)/test_common.c + SRC += $(OPTESTS)/$(TESTAPP).c endif -# Link: create ELF output file from object files. -$(eval $(call LINK_TEMPLATE, $(OUTDIR)/$(TARGET).elf, $(ALLOBJ), $(ALLLIB))) +# Optional component libraries +include $(FLIGHTLIB)/rscode/library.mk -# Assemble: create object files from assembler source files. -$(foreach src, $(ASRC), $(eval $(call ASSEMBLE_TEMPLATE, $(src)))) - -# Assemble: create object files from assembler source files. ARM-only -$(foreach src, $(ASRCARM), $(eval $(call ASSEMBLE_ARM_TEMPLATE, $(src)))) - -# Compile: create object files from C source files. -$(foreach src, $(SRC), $(eval $(call COMPILE_C_TEMPLATE, $(src)))) - -# Compile: create object files from C source files. ARM-only -$(foreach src, $(SRCARM), $(eval $(call COMPILE_C_ARM_TEMPLATE, $(src)))) - -# Compile: create object files from C++ source files. -$(foreach src, $(CPPSRC), $(eval $(call COMPILE_CPP_TEMPLATE, $(src)))) - -# Compile: create object files from C++ source files. ARM-only -$(foreach src, $(CPPSRCARM), $(eval $(call COMPILE_CPP_ARM_TEMPLATE, $(src)))) - -# Compile: create assembler files from C source files. ARM/Thumb -$(eval $(call PARTIAL_COMPILE_TEMPLATE, SRC)) - -# Compile: create assembler files from C source files. ARM only -$(eval $(call PARTIAL_COMPILE_ARM_TEMPLATE, SRCARM)) - -$(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),$(OPENOCD_JTAG_CONFIG),$(OPENOCD_CONFIG))) - -.PHONY: elf lss sym hex bin bino opfw -elf: $(OUTDIR)/$(TARGET).elf -lss: $(OUTDIR)/$(TARGET).lss -sym: $(OUTDIR)/$(TARGET).sym -hex: $(OUTDIR)/$(TARGET).hex -bin: $(OUTDIR)/$(TARGET).bin -bino: $(OUTDIR)/$(TARGET).bin.o -opfw: $(OUTDIR)/$(TARGET).opfw - -# Display sizes of sections. -$(eval $(call SIZE_TEMPLATE, $(OUTDIR)/$(TARGET).elf)) - -# Generate Doxygen documents -docs: - doxygen $(DOXYGENDIR)/doxygen.cfg - -# Install: install binary file with prefix/suffix into install directory -install: $(OUTDIR)/$(TARGET).opfw -ifneq ($(INSTALL_DIR),) - @echo $(MSG_INSTALLING) $(call toprel, $<) - $(V1) mkdir -p $(INSTALL_DIR) - $(V1) $(INSTALL) $< $(INSTALL_DIR)/$(INSTALL_PFX)$(TARGET)$(INSTALL_SFX).opfw -else - $(error INSTALL_DIR must be specified for $@) -endif - -# Target: clean project. -clean: clean_list - -clean_list : - @echo $(MSG_CLEANING) - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).map - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).elf - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).hex - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).bin - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).sym - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).lss - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).bin.o - $(V1) $(REMOVE) $(wildcard $(OUTDIR)/*.c) - $(V1) $(REMOVE) $(wildcard $(OUTDIR)/*.h) - $(V1) $(REMOVE) $(ALLOBJ) - $(V1) $(REMOVE) $(LSTFILES) - $(V1) $(REMOVE) $(DEPFILES) - $(V1) $(REMOVE) $(SRC:.c=.s) - $(V1) $(REMOVE) $(SRCARM:.c=.s) - $(V1) $(REMOVE) $(CPPSRC:.cpp=.s) - $(V1) $(REMOVE) $(CPPSRCARM:.cpp=.s) - - -# Create output files directory -# all known MS Windows OS define the ComSpec environment variable -ifdef ComSpec -$(shell md $(subst /,\\,$(OUTDIR)) 2>NUL) -else -$(shell mkdir -p $(OUTDIR) 2>/dev/null) -endif - -# Include the dependency files. -ifdef ComSpec --include $(shell md $(subst /,\\,$(OUTDIR))\dep 2>NUL) $(wildcard $(OUTDIR)/dep/*) -else --include $(shell mkdir -p $(OUTDIR) 2>/dev/null) $(shell mkdir $(OUTDIR)/dep 2>/dev/null) $(wildcard $(OUTDIR)/dep/*) -endif - -# Listing of phony targets. -.PHONY : all build clean clean_list install +include $(ROOT_DIR)/make/apps-defs.mk +include $(ROOT_DIR)/make/common-defs.mk diff --git a/flight/targets/PipXtreme/System/inc/FreeRTOSConfig.h b/flight/targets/PipXtreme/System/inc/FreeRTOSConfig.h index 0c515b7f7..d83deb7bb 100755 --- a/flight/targets/PipXtreme/System/inc/FreeRTOSConfig.h +++ b/flight/targets/PipXtreme/System/inc/FreeRTOSConfig.h @@ -76,7 +76,7 @@ NVIC value of 255. */ #endif /* Enable run time stats collection */ -#if defined(STACK_DIAGNOSTICS) +#if defined(DIAG_STACK) #define configCHECK_FOR_STACK_OVERFLOW 2 #define configGENERATE_RUN_TIME_STATS 1 diff --git a/flight/targets/PipXtreme/System/inc/op_config.h b/flight/targets/PipXtreme/System/inc/op_config.h deleted file mode 100755 index 97910f392..000000000 --- a/flight/targets/PipXtreme/System/inc/op_config.h +++ /dev/null @@ -1,39 +0,0 @@ -/** - ****************************************************************************** - * @addtogroup OpenPilotSystem OpenPilot System - * @{ - * @addtogroup OpenPilotCore OpenPilot Core - * @{ - * - * @file op_config.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief OpenPilot configuration header. - * Compile time config for OpenPilot Application - * @see The GNU Public License (GPL) Version 3 - * - *****************************************************************************/ -/* - * 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 - */ - - -#ifndef OP_CONFIG_H -#define OP_CONFIG_H - -#endif /* OP_CONFIG_H */ -/** - * @} - * @} - */ diff --git a/flight/targets/PipXtreme/System/inc/openpilot.h b/flight/targets/PipXtreme/System/inc/openpilot.h index 59ae76fd4..7f1ac3758 100755 --- a/flight/targets/PipXtreme/System/inc/openpilot.h +++ b/flight/targets/PipXtreme/System/inc/openpilot.h @@ -35,7 +35,6 @@ #include /* OpenPilot Libraries */ -#include "op_config.h" #include "utlist.h" #include "uavobjectmanager.h" #include "eventdispatcher.h" diff --git a/flight/targets/PipXtreme/System/inc/pios_config.h b/flight/targets/PipXtreme/System/inc/pios_config.h index 94893c54b..88feadc80 100755 --- a/flight/targets/PipXtreme/System/inc/pios_config.h +++ b/flight/targets/PipXtreme/System/inc/pios_config.h @@ -1,110 +1,167 @@ -/** - ****************************************************************************** - * @addtogroup OpenPilotSystem OpenPilot System - * @{ - * @addtogroup OpenPilotCore OpenPilot Core - * @{ - * - * @file pios_config.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief PiOS configuration header. - * Central compile time config for the project. - * In particular, pios_config.h is where you define which PiOS libraries - * and features are included in the firmware. - * @see The GNU Public License (GPL) Version 3 - * - *****************************************************************************/ -/* - * 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 - */ - -#ifndef PIOS_CONFIG_H -#define PIOS_CONFIG_H - -/* Enable/Disable PiOS Modules */ -#define PIOS_INCLUDE_DELAY -#define PIOS_INCLUDE_IRQ -#define PIOS_INCLUDE_LED -#define PIOS_INCLUDE_IAP -#define PIOS_INCLUDE_RFM22B -#define PIOS_INCLUDE_RFM22B_COM -#define PIOS_INCLUDE_RCVR -#define PIOS_INCLUDE_TIM - -/* Supported receiver interfaces */ -#define PIOS_INCLUDE_PPM - -/* Supported USART-based PIOS modules */ -#define PIOS_INCLUDE_SPI -#define PIOS_INCLUDE_SYS -#define PIOS_INCLUDE_USART -#define PIOS_INCLUDE_USB -#define PIOS_INCLUDE_USB_HID -#define PIOS_INCLUDE_USB_CDC -#define PIOS_INCLUDE_COM -#define PIOS_INCLUDE_SETTINGS -#define PIOS_INCLUDE_FREERTOS -#define PIOS_INCLUDE_GPIO -#define PIOS_INCLUDE_EXTI -#define PIOS_INCLUDE_RTC -#define PIOS_INCLUDE_WDG -#define PIOS_INCLUDE_BL_HELPER -#define PIOS_INCLUDE_FLASH_EEPROM -#define PIOS_INCLUDE_RFM22B -#define PIOS_INCLUDE_PACKET_HANDLER -#define PIOS_INCLUDE_PPM_OUT - -/* Defaults for Logging */ -#define LOG_FILENAME "PIOS.LOG" -#define STARTUP_LOG_ENABLED 1 - -/* COM Module */ -#define GPS_BAUDRATE 19200 -#define TELEM_BAUDRATE 19200 -#define AUXUART_ENABLED 0 -#define AUXUART_BAUDRATE 19200 - -/* Alarm Thresholds */ -#define HEAP_LIMIT_WARNING 220 -#define HEAP_LIMIT_CRITICAL 40 -#define IRQSTACK_LIMIT_WARNING 100 -#define IRQSTACK_LIMIT_CRITICAL 60 -#define CPULOAD_LIMIT_WARNING 85 -#define CPULOAD_LIMIT_CRITICAL 95 - -/* Task stack sizes */ -#define PIOS_ACTUATOR_STACK_SIZE 1020 -#define PIOS_MANUAL_STACK_SIZE 724 -#define PIOS_SYSTEM_STACK_SIZE 460 -#define PIOS_STABILIZATION_STACK_SIZE 524 -#define PIOS_TELEM_STACK_SIZE 500 -#define PIOS_EVENTDISPATCHER_STACK_SIZE 130 -#define IDLE_COUNTS_PER_SEC_AT_NO_LOAD 1995998 -//#define PIOS_QUATERNION_STABILIZATION - -// This can't be too high to stop eventdispatcher thread overflowing -#define PIOS_EVENTDISAPTCHER_QUEUE 10 - -/* PIOS Initcall infrastructure */ -#define PIOS_INCLUDE_INITCALL - -/* Turn on debugging signals on the telemetry port */ -//#define PIOS_RFM22B_DEBUG_ON_TELEM - -#endif /* PIOS_CONFIG_H */ -/** - * @} - * @} - */ +/** + ****************************************************************************** + * @addtogroup OpenPilotSystem OpenPilot System + * @{ + * @addtogroup OpenPilotCore OpenPilot Core + * @{ + * @file pios_config.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010-2013. + * @brief PiOS configuration header, the compile time config file for the PIOS. + * Defines which PiOS libraries and features are included in the firmware. + * @see The GNU Public License (GPL) Version 3 + *****************************************************************************/ +/* + * 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 + */ + +#ifndef PIOS_CONFIG_H +#define PIOS_CONFIG_H + +/* + * Below is a complete list of PIOS configurable options. + * Please do not remove or rearrange them. Only comment out + * unused options in the list. See main pios.h header for more + * details. + */ + +/* #define PIOS_INCLUDE_DEBUG_CONSOLE */ +/* #define DEBUG_LEVEL 0 */ + +/* PIOS FreeRTOS support */ +#define PIOS_INCLUDE_FREERTOS + +/* PIOS bootloader helper */ +#define PIOS_INCLUDE_BL_HELPER +/* #define PIOS_INCLUDE_BL_HELPER_WRITE_SUPPORT */ + +/* PIOS system functions */ +#define PIOS_INCLUDE_DELAY +#define PIOS_INCLUDE_INITCALL +#define PIOS_INCLUDE_SYS + +/* PIOS hardware peripherals */ +#define PIOS_INCLUDE_IRQ +#define PIOS_INCLUDE_RTC +#define PIOS_INCLUDE_TIM +#define PIOS_INCLUDE_USART +/* #define PIOS_INCLUDE_ADC */ +/* #define PIOS_INCLUDE_I2C */ +#define PIOS_INCLUDE_SPI +#define PIOS_INCLUDE_GPIO +#define PIOS_INCLUDE_EXTI +#define PIOS_INCLUDE_WDG + +/* PIOS USB functions */ +#define PIOS_INCLUDE_USB +#define PIOS_INCLUDE_USB_HID +#define PIOS_INCLUDE_USB_CDC +/* #define PIOS_INCLUDE_USB_RCTX */ + +/* PIOS sensor interfaces */ +/* #define PIOS_INCLUDE_ADXL345 */ +/* #define PIOS_INCLUDE_BMA180 */ +/* #define PIOS_INCLUDE_L3GD20 */ +/* #define PIOS_INCLUDE_MPU6000 */ +/* #define PIOS_MPU6000_ACCEL */ +/* #define PIOS_INCLUDE_HMC5843 */ +/* #define PIOS_INCLUDE_HMC5883 */ +/* #define PIOS_HMC5883_HAS_GPIOS */ +/* #define PIOS_INCLUDE_BMP085 */ +/* #define PIOS_INCLUDE_MS5611 */ +/* #define PIOS_INCLUDE_MPXV */ +/* #define PIOS_INCLUDE_ETASV3 */ +/* #define PIOS_INCLUDE_HCSR04 */ + +/* PIOS receiver drivers */ +/* #define PIOS_INCLUDE_PWM */ +#define PIOS_INCLUDE_PPM +/* #define PIOS_INCLUDE_PPM_FLEXI */ +/* #define PIOS_INCLUDE_DSM */ +/* #define PIOS_INCLUDE_SBUS */ +/* #define PIOS_INCLUDE_GCSRCVR */ + +/* PIOS abstract receiver interface */ +#define PIOS_INCLUDE_RCVR + +/* PIOS common peripherals */ +#define PIOS_INCLUDE_LED +#define PIOS_INCLUDE_IAP +/* #define PIOS_INCLUDE_SERVO */ +/* #define PIOS_INCLUDE_I2C_ESC */ +/* #define PIOS_INCLUDE_OVERO */ +/* #define PIOS_OVERO_SPI */ +/* #define PIOS_INCLUDE_SDCARD */ +/* #define LOG_FILENAME "startup.log" */ +/* #define PIOS_INCLUDE_FLASH */ +/* #define PIOS_INCLUDE_FLASH_SECTOR_SETTINGS */ +/* #define FLASH_FREERTOS */ +#define PIOS_INCLUDE_FLASH_EEPROM + +/* PIOS radio modules */ +#define PIOS_INCLUDE_RFM22B +#define PIOS_INCLUDE_RFM22B_COM +/* #define PIOS_INCLUDE_RFM22B_RCVR */ +#define PIOS_INCLUDE_PPM_OUT +/* #define PIOS_RFM22B_DEBUG_ON_TELEM */ + +/* PIOS misc peripherals */ +/* #define PIOS_INCLUDE_VIDEO */ +/* #define PIOS_INCLUDE_WAVE */ +/* #define PIOS_INCLUDE_UDP */ + +/* PIOS abstract comms interface with options */ +#define PIOS_INCLUDE_COM +/* #define PIOS_INCLUDE_COM_MSG */ +/* #define PIOS_INCLUDE_TELEMETRY_RF */ +/* #define PIOS_INCLUDE_COM_TELEM */ +/* #define PIOS_INCLUDE_COM_FLEXI */ +/* #define PIOS_INCLUDE_COM_AUX */ +/* #define PIOS_TELEM_PRIORITY_QUEUE */ +/* #define PIOS_INCLUDE_GPS */ +/* #define PIOS_GPS_MINIMAL */ +/* #define PIOS_INCLUDE_GPS_NMEA_PARSER */ +/* #define PIOS_INCLUDE_GPS_UBX_PARSER */ +/* #define PIOS_GPS_SETS_HOMELOCATION */ + +/* Stabilization options */ +/* #define PIOS_QUATERNION_STABILIZATION */ + +/* Performance counters */ +#define IDLE_COUNTS_PER_SEC_AT_NO_LOAD 1995998 + +/* Alarm Thresholds */ +#define HEAP_LIMIT_WARNING 220 +#define HEAP_LIMIT_CRITICAL 40 +#define IRQSTACK_LIMIT_WARNING 100 +#define IRQSTACK_LIMIT_CRITICAL 60 +#define CPULOAD_LIMIT_WARNING 85 +#define CPULOAD_LIMIT_CRITICAL 95 + +/* Task stack sizes */ +#define PIOS_ACTUATOR_STACK_SIZE 1020 +#define PIOS_MANUAL_STACK_SIZE 724 +#define PIOS_SYSTEM_STACK_SIZE 460 +#define PIOS_STABILIZATION_STACK_SIZE 524 +#define PIOS_TELEM_STACK_SIZE 500 +#define PIOS_EVENTDISPATCHER_STACK_SIZE 130 + +/* This can't be too high to stop eventdispatcher thread overflowing */ +#define PIOS_EVENTDISAPTCHER_QUEUE 10 + +#endif /* PIOS_CONFIG_H */ +/** + * @} + * @} + */ diff --git a/flight/targets/RevoMini/Makefile b/flight/targets/RevoMini/Makefile index 05d827f3d..f432a535a 100644 --- a/flight/targets/RevoMini/Makefile +++ b/flight/targets/RevoMini/Makefile @@ -1,11 +1,6 @@ -##### -# Project: OpenPilot Revolution Target -# -# -# Makefile for OpenPilot Revolution project -# -# The OpenPilot Team, http://www.openpilot.org, Copyright (C) 2013. # +# Copyright (c) 2009-2013, The OpenPilot Team, http://www.openpilot.org +# Copyright (c) 2012, PhoenixPilot, http://github.com/PhoenixPilot # # 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 @@ -22,462 +17,82 @@ # 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 - -# Set developer code and compile options -# Set to YES for debugging -DEBUG ?= NO - -# Set to YES when using Code Sourcery toolchain -CODE_SOURCERY ?= NO - -ifeq ($(CODE_SOURCERY), YES) -REMOVE_CMD = cs-rm -else -REMOVE_CMD = rm +ifndef OPENPILOT_IS_COOL + $(error Top level Makefile must be used to build this target) endif -FLASH_TOOL = OPENOCD +include $(ROOT_DIR)/make/boards/$(BOARD_NAME)/board-info.mk +include $(ROOT_DIR)/make/firmware-defs.mk -# List of modules to include -MODULES = Sensors -MODULES += Attitude/revolution -MODULES += ManualControl Stabilization Actuator -MODULES += Battery +# ARM DSP library +USE_DSP_LIB ?= NO + +# List of mandatory modules to include +MODULES += Sensors +MODULES += Attitude/revolution MODULES += Altitude/revolution -MODULES += GPS FirmwareIAP MODULES += Airspeed/revolution -MODULES += AltitudeHold FixedWingPathFollower PathPlanner TxPID -#MODULES += VtolPathFollower ## OP-700: VtolPathFollower disabled because its currently unsafe - remove this line once Sambas code has been merged +MODULES += AltitudeHold +MODULES += Stabilization +MODULES += ManualControl +MODULES += Actuator +MODULES += GPS +MODULES += TxPID MODULES += CameraStab -#MODULES += OveroSync +MODULES += Battery +MODULES += FirmwareIAP +MODULES += Radio +MODULES += PathPlanner +MODULES += FixedWingPathFollower MODULES += Telemetry -PYMODULES = -#FlightPlan +#MODULES += VtolPathFollower ## OP-700: VtolPathFollower disabled because its currently unsafe - remove this line once Sambas code has been merged -# Enable ARM DSP library -USE_DSP_LIB = NO +OPTMODULES = -# Paths -OPSYSTEM = ./System -OPSYSTEMINC = $(OPSYSTEM)/inc -OPUAVTALKINC = $(OPUAVTALK)/inc -OPUAVOBJINC = $(OPUAVOBJ)/inc -PIOSINC = $(PIOS)/inc -FLIGHTLIBINC = $(FLIGHTLIB)/inc -MATHLIB = $(FLIGHTLIB)/math -MATHLIBINC = $(FLIGHTLIB)/math -RSCODE = $(FLIGHTLIB)/rscode -RSCODEINC = $(FLIGHTLIB)/rscode -PIOSSTM32F4XX = $(PIOS)/STM32F4xx -PIOSCOMMON = $(PIOS)/Common -PIOSBOARDS = $(PIOS)/Boards -PIOSCOMMONLIB = $(PIOSCOMMON)/Libraries -APPLIBDIR = $(PIOSSTM32F4XX)/Libraries -STMLIBDIR = $(APPLIBDIR) -STMSPDDIR = $(STMLIBDIR)/STM32F4xx_StdPeriph_Driver -STMSPDSRCDIR = $(STMSPDDIR)/src -STMSPDINCDIR = $(STMSPDDIR)/inc -OPUAVOBJINC = $(OPUAVOBJ)/inc -FLIGHTPLANLIB = $(OPMODULEDIR)/FlightPlan/lib -FLIGHTPLANS = $(OPMODULEDIR)/FlightPlan/flightplans +# Include all camera options +CDEFS += -DUSE_INPUT_LPF -DUSE_GIMBAL_LPF -DUSE_GIMBAL_FF -SRC = -# optional component libraries -include $(PIOSCOMMONLIB)/FreeRTOS/library.mk -#include $(PIOSCOMMONLIB)/dosfs/library.mk -include $(PIOSCOMMONLIB)/msheap/library.mk - -## PYMite support -#include $(FLIGHTLIB)/PyMite/pymite.mk - -## MODULES -SRC += ${foreach MOD, ${MODULES}, ${wildcard ${OPMODULEDIR}/${MOD}/*.c}} -## OPENPILOT CORE: -SRC += ${OPMODULEDIR}/System/systemmod.c -SRC += $(OPSYSTEM)/revolution.c -SRC += $(OPSYSTEM)/pios_board.c -SRC += $(OPSYSTEM)/pios_usb_board_data.c -SRC += $(OPSYSTEM)/alarms.c -SRC += $(OPUAVTALK)/uavtalk.c -SRC += $(OPUAVOBJ)/uavobjectmanager.c -SRC += $(OPUAVOBJ)/eventdispatcher.c - -#ifeq ($(DEBUG),YES) -SRC += $(OPSYSTEM)/dcc_stdio.c -SRC += $(OPSYSTEM)/cm3_fault_handlers.c -#endif - -SRC += $(FLIGHTLIB)/CoordinateConversions.c -SRC += $(FLIGHTLIB)/paths.c -SRC += $(FLIGHTLIB)/fifo_buffer.c -SRC += $(FLIGHTLIB)/WorldMagModel.c -SRC += $(FLIGHTLIB)/insgps13state.c -SRC += $(FLIGHTLIB)/taskmonitor.c -SRC += $(FLIGHTLIB)/sanitycheck.c - -SRC += $(MATHLIB)/sin_lookup.c -SRC += $(MATHLIB)/pid.c - -## For RFM22b -SRC += $(RSCODE)/berlekamp.c -SRC += $(RSCODE)/crcgen.c -SRC += $(RSCODE)/galois.c -SRC += $(RSCODE)/rs.c - -## PIOS Hardware (STM32F4xx) -include $(PIOS)/STM32F4xx/library.mk - -## PIOS Hardware (Common) -SRC += $(PIOSCOMMON)/pios_mpu6000.c -SRC += $(PIOSCOMMON)/pios_bma180.c -SRC += $(PIOSCOMMON)/pios_etasv3.c -SRC += $(PIOSCOMMON)/pios_mpxv.c -SRC += $(PIOSCOMMON)/pios_gcsrcvr.c -SRC += $(PIOSCOMMON)/pios_l3gd20.c -SRC += $(PIOSCOMMON)/pios_hmc5883.c -SRC += $(PIOSCOMMON)/pios_ms5611.c -SRC += $(PIOSCOMMON)/pios_crc.c -SRC += $(PIOSCOMMON)/pios_com.c -SRC += $(PIOSCOMMON)/pios_rfm22b.c -SRC += $(PIOSCOMMON)/pios_rfm22b_com.c -SRC += $(PIOSCOMMON)/pios_rfm22b_rcvr.c -SRC += $(PIOSCOMMON)/pios_rcvr.c -SRC += $(PIOSCOMMON)/pios_sbus.c -SRC += $(PIOSCOMMON)/pios_flash_jedec.c -SRC += $(PIOSCOMMON)/pios_flashfs_logfs.c -SRC += $(PIOSCOMMON)/printf-stdarg.c -SRC += $(PIOSCOMMON)/pios_usb_desc_hid_cdc.c -SRC += $(PIOSCOMMON)/pios_usb_desc_hid_only.c -SRC += $(PIOSCOMMON)/pios_usb_util.c - -include ./UAVObjects.inc -SRC += $(UAVOBJSRC) - -# List C source files here which must be compiled in ARM-Mode (no -mthumb). -# use file-extension c for "c-only"-files -## just for testing, timer.c could be compiled in thumb-mode too -SRCARM = - -# List C++ source files here. -# use file-extension .cpp for C++-files (not .C) -CPPSRC = - -# List C++ source files here which must be compiled in ARM-Mode. -# use file-extension .cpp for C++-files (not .C) -#CPPSRCARM = $(TARGET).cpp -CPPSRCARM = - -# List Assembler source files here. -# Make them always end in a capital .S. Files ending in a lowercase .s -# will not be considered source files but generated files (assembler -# output from the compiler), and will be deleted upon "make clean"! -# Even though the DOS/Win* filesystem matches both .s and .S the same, -# it will preserve the spelling of the filenames, and gcc itself does -# care about how the name is spelled on its command-line. - - -# List Assembler source files here which must be assembled in ARM-Mode.. -ASRCARM = - -# List any extra directories to look for include files here. -# Each directory must be seperated by a space. -EXTRAINCDIRS += $(PIOS) -EXTRAINCDIRS += $(PIOSINC) -EXTRAINCDIRS += $(OPSYSTEMINC) -EXTRAINCDIRS += $(OPUAVTALK) -EXTRAINCDIRS += $(OPUAVTALKINC) -EXTRAINCDIRS += $(OPUAVOBJ) -EXTRAINCDIRS += $(OPUAVOBJINC) -EXTRAINCDIRS += $(OPUAVSYNTHDIR) -EXTRAINCDIRS += $(FLIGHTLIBINC) -EXTRAINCDIRS += $(MATHLIBINC) -EXTRAINCDIRS += $(RSCODEINC) -EXTRAINCDIRS += $(PIOSSTM32F4XX) -EXTRAINCDIRS += $(PIOSCOMMON) -EXTRAINCDIRS += $(PIOSBOARDS) -EXTRAINCDIRS += $(STMSPDINCDIR) -EXTRAINCDIRS += $(CMSISDIR) -EXTRAINCDIRS += $(BOOTINC) -EXTRAINCDIRS += $(HWDEFSINC) - -EXTRAINCDIRS += ${foreach MOD, ${OPTMODULES} ${MODULES} ${PYMODULES}, $(OPMODULEDIR)/${MOD}/inc} ${OPMODULEDIR}/System/inc - -# List any extra directories to look for library files here. -# Also add directories where the linker should search for -# includes from linker-script to the list -# Each directory must be seperated by a space. -#EXTRA_LIBDIRS += - -# Extra Libraries -# Each library-name must be seperated by a space. -# i.e. to link with libxyz.a, libabc.a and libefsl.a: -# EXTRA_LIBS = xyz abc efsl -# for newlib-lpc (file: libnewlibc-lpc.a): -# EXTRA_LIBS = newlib-lpc -#EXTRA_LIBS += - -# Path to Linker-Scripts -LINKERSCRIPTPATH = $(PIOSSTM32F4XX) - -# Optimization level, can be [0, 1, 2, 3, s]. -# 0 = turn off optimization. s = optimize for size. -# (Note: 3 is not always the best optimization level. See avr-libc FAQ.) - -ifeq ($(DEBUG),YES) -CFLAGS += -O0 -CFLAGS += -DGENERAL_COV -CFLAGS += -finstrument-functions -ffixed-r10 -else -CFLAGS += -Os -endif - - - -# common architecture-specific flags from the device-specific library makefile -CFLAGS += $(ARCHFLAGS) - -CFLAGS += -DSTACK_DIAGNOSTICS -CFLAGS += -DMIXERSTATUS_DIAGNOSTICS -CFLAGS += -DRATEDESIRED_DIAGNOSTICS -CFLAGS += -DI2C_WDG_STATS_DIAGNOSTICS -CFLAGS += -DDIAGNOSTICS -CFLAGS += -DDIAG_TASKS - -# This is not the best place for these. Really should abstract out -# to the board file or something -CFLAGS += -DSTM32F4XX -CFLAGS += -DMEM_SIZE=1024000000 - -# Output format. (can be ihex or binary or both) -# binary to create a load-image in raw-binary format i.e. for SAM-BA, -# ihex to create a load-image in Intel hex format -#LOADFORMAT = ihex -#LOADFORMAT = binary -LOADFORMAT = both - -# Debugging format. -DEBUGF = dwarf-2 - -# Place project-specific -D (define) and/or -# -U options for C here. -CDEFS += -DHSE_VALUE=$(OSCILLATOR_FREQ) -CDEFS += -DSYSCLK_FREQ=$(SYSCLK_FREQ) -CDEFS += -DUSE_STDPERIPH_DRIVER -CDEFS += -DUSE_$(BOARD) -ifeq ($(ENABLE_DEBUG_CONSOLE), YES) -CDEFS += -DPIOS_INCLUDE_DEBUG_CONSOLE -endif - -# Declare all non-optional modules as built-in to force inclusion -CDEFS += $(foreach MOD, $(notdir $(MODULES)), -DMODULE_$(MOD)_BUILTIN) - -# Place project-specific -D and/or -U options for -# Assembler with preprocessor here. -#ADEFS = -DUSE_IRQ_ASM_WRAPPER -ADEFS = -D__ASSEMBLY__ - -# Compiler flag to set the C Standard level. -# c89 - "ANSI" C -# gnu89 - c89 plus GCC extensions -# c99 - ISO C99 standard (not yet fully implemented) -# gnu99 - c99 plus GCC extensions -CSTANDARD = -std=gnu99 - -#----- - -# Compiler flags. - -# -g*: generate debugging information -# -O*: optimization level -# -f...: tuning, see GCC manual and avr-libc documentation -# -Wall...: warning level -# -Wa,...: tell GCC to pass this to the assembler. -# -adhlns...: create assembler listing -# -# Flags for C and C++ (arm-elf-gcc/arm-elf-g++) - -CFLAGS += -g$(DEBUGF) +# Some diagnostics +CDEFS += -DDIAG_TASKS +# Misc options CFLAGS += -ffast-math -CFLAGS += -mcpu=$(MCU) -CFLAGS += $(CDEFS) -CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) -I. +# List C source files here (C dependencies are automatically generated). +# Use file-extension c for "c-only"-files +ifndef TESTAPP + ## Application Core + SRC += ${OPMODULEDIR}/System/systemmod.c + SRC += $(OPSYSTEM)/revolution.c + SRC += $(OPSYSTEM)/pios_board.c + SRC += $(OPSYSTEM)/pios_usb_board_data.c + SRC += $(OPSYSTEM)/alarms.c + SRC += $(OPUAVTALK)/uavtalk.c + SRC += $(OPUAVOBJ)/uavobjectmanager.c + SRC += $(OPUAVOBJ)/eventdispatcher.c -CFLAGS += -mapcs-frame -CFLAGS += -fomit-frame-pointer -ifeq ($(CODE_SOURCERY), YES) -CFLAGS += -fpromote-loop-indices -endif + #ifeq ($(DEBUG), YES) + SRC += $(OPSYSTEM)/dcc_stdio.c + SRC += $(OPSYSTEM)/cm3_fault_handlers.c + #endif -CFLAGS += -Wall -#CFLAGS += -Werror -CFLAGS += -Wa,-adhlns=$(addprefix $(OUTDIR)/, $(notdir $(addsuffix .lst, $(basename $<)))) -# Compiler flags to generate dependency files: -CFLAGS += -MD -MP -MF $(OUTDIR)/dep/$(@F).d + ## Misc library functions + SRC += $(FLIGHTLIB)/paths.c + SRC += $(FLIGHTLIB)/WorldMagModel.c + SRC += $(FLIGHTLIB)/insgps13state.c -# flags only for C -#CONLYFLAGS += -Wnested-externs -CONLYFLAGS += $(CSTANDARD) - -# Assembler flags. -# -Wa,...: tell GCC to pass this to the assembler. -# -ahlns: create listing -ASFLAGS = $(ARCHFLAGS) -mthumb -I. -x assembler-with-cpp -ASFLAGS += $(ADEFS) -ASFLAGS += -Wa,-adhlns=$(addprefix $(OUTDIR)/, $(notdir $(addsuffix .lst, $(basename $<)))) -ASFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) - -MATH_LIB = -lm - -# Linker flags. -# -Wl,...: tell GCC to pass this to linker. -# -Map: create map file -# --cref: add cross reference to map file -LDFLAGS = -nostartfiles -Wl,-Map=$(OUTDIR)/$(TARGET).map,--cref,--gc-sections -LDFLAGS += $(patsubst %,-L%,$(EXTRA_LIBDIRS)) -LDFLAGS += -lc -LDFLAGS += $(patsubst %,-l%,$(EXTRA_LIBS)) -LDFLAGS += $(MATH_LIB) -LDFLAGS += -lc -lgcc - -#Linker scripts -LDFLAGS += $(addprefix -T,$(LINKER_SCRIPTS_APP)) - - -# Define programs and commands. -REMOVE = $(REMOVE_CMD) -f -PYTHON = python - -# List of all source files. -ALLSRC = $(ASRCARM) $(ASRC) $(SRCARM) $(SRC) $(CPPSRCARM) $(CPPSRC) -# List of all source files without directory and file-extension. -ALLSRCBASE = $(notdir $(basename $(ALLSRC))) - -# Define all object files. -ALLOBJ = $(addprefix $(OUTDIR)/, $(addsuffix .o, $(ALLSRCBASE))) - -# Define all listing files (used for make clean). -LSTFILES = $(addprefix $(OUTDIR)/, $(addsuffix .lst, $(ALLSRCBASE))) -# Define all depedency-files (used for make clean). -DEPFILES = $(addprefix $(OUTDIR)/dep/, $(addsuffix .o.d, $(ALLSRCBASE))) - -# Default target. -all: gccversion build - -ifeq ($(LOADFORMAT),ihex) -build: elf hex lss sym + ## UAVObjects + include ./UAVObjects.inc + SRC += $(UAVOBJSRC) else -ifeq ($(LOADFORMAT),binary) -build: elf bin lss sym -else -ifeq ($(LOADFORMAT),both) -build: elf hex bin lss sym -else -$(error "$(MSG_FORMATERROR) $(FORMAT)") -endif -endif + ## Test Code + SRC += $(OPTESTS)/test_common.c + SRC += $(OPTESTS)/$(TESTAPP).c endif +# Optional component libraries +include $(FLIGHTLIB)/rscode/library.mk +#include $(FLIGHTLIB)/PyMite/pymite.mk -# Link: create ELF output file from object files. -$(eval $(call LINK_TEMPLATE, $(OUTDIR)/$(TARGET).elf, $(ALLOBJ), $(ALLLIB))) - -# Assemble: create object files from assembler source files. -$(foreach src, $(ASRC), $(eval $(call ASSEMBLE_TEMPLATE, $(src)))) - -# Assemble: create object files from assembler source files. ARM-only -$(foreach src, $(ASRCARM), $(eval $(call ASSEMBLE_ARM_TEMPLATE, $(src)))) - -# Compile: create object files from C source files. -$(foreach src, $(SRC), $(eval $(call COMPILE_C_TEMPLATE, $(src)))) - -# Compile: create object files from C source files. ARM-only -$(foreach src, $(SRCARM), $(eval $(call COMPILE_C_ARM_TEMPLATE, $(src)))) - -# Compile: create object files from C++ source files. -$(foreach src, $(CPPSRC), $(eval $(call COMPILE_CPP_TEMPLATE, $(src)))) - -# Compile: create object files from C++ source files. ARM-only -$(foreach src, $(CPPSRCARM), $(eval $(call COMPILE_CPP_ARM_TEMPLATE, $(src)))) - -# Compile: create assembler files from C source files. ARM/Thumb -$(eval $(call PARTIAL_COMPILE_TEMPLATE, SRC)) - -# Compile: create assembler files from C source files. ARM only -$(eval $(call PARTIAL_COMPILE_ARM_TEMPLATE, SRCARM)) - -$(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),$(OPENOCD_JTAG_CONFIG),$(OPENOCD_CONFIG))) - -.PHONY: elf lss sym hex bin bino opfw -elf: $(OUTDIR)/$(TARGET).elf -lss: $(OUTDIR)/$(TARGET).lss -sym: $(OUTDIR)/$(TARGET).sym -hex: $(OUTDIR)/$(TARGET).hex -bin: $(OUTDIR)/$(TARGET).bin -bino: $(OUTDIR)/$(TARGET).bin.o -opfw: $(OUTDIR)/$(TARGET).opfw - -# Display sizes of sections. -$(eval $(call SIZE_TEMPLATE, $(OUTDIR)/$(TARGET).elf)) - -# Generate Doxygen documents -docs: - doxygen $(DOXYGENDIR)/doxygen.cfg - -# Install: install binary file with prefix/suffix into install directory -install: $(OUTDIR)/$(TARGET).opfw -ifneq ($(INSTALL_DIR),) - @echo $(MSG_INSTALLING) $(call toprel, $<) - $(V1) mkdir -p $(INSTALL_DIR) - $(V1) $(INSTALL) $< $(INSTALL_DIR)/$(INSTALL_PFX)$(TARGET)$(INSTALL_SFX).opfw -else - $(error INSTALL_DIR must be specified for $@) -endif - -# Target: clean project. -clean: clean_list - -clean_list : - @echo $(MSG_CLEANING) - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).map - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).elf - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).hex - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).bin - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).sym - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).lss - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).bin.o - $(V1) $(REMOVE) $(ALLOBJ) - $(V1) $(REMOVE) $(LSTFILES) - $(V1) $(REMOVE) $(DEPFILES) - $(V1) $(REMOVE) $(SRC:.c=.s) - $(V1) $(REMOVE) $(SRCARM:.c=.s) - $(V1) $(REMOVE) $(CPPSRC:.cpp=.s) - $(V1) $(REMOVE) $(CPPSRCARM:.cpp=.s) - -# Create output files directory -# all known MS Windows OS define the ComSpec environment variable -ifdef ComSpec -$(shell md $(subst /,\\,$(OUTDIR)) 2>NUL) -else -$(shell mkdir -p $(OUTDIR) 2>/dev/null) -endif - -# Include the dependency files. -ifdef ComSpec --include $(shell md $(subst /,\\,$(OUTDIR))\dep 2>NUL) $(wildcard $(OUTDIR)/dep/*) -else --include $(shell mkdir $(OUTDIR) 2>/dev/null) $(shell mkdir $(OUTDIR)/dep 2>/dev/null) $(wildcard $(OUTDIR)/dep/*) -endif - -# Listing of phony targets. -.PHONY : all build clean clean_list install +include $(ROOT_DIR)/make/apps-defs.mk +include $(ROOT_DIR)/make/common-defs.mk diff --git a/flight/targets/RevoMini/Makefile.osx b/flight/targets/RevoMini/Makefile.osx index 7241ceeb7..8786bd7c1 100644 --- a/flight/targets/RevoMini/Makefile.osx +++ b/flight/targets/RevoMini/Makefile.osx @@ -308,7 +308,6 @@ ifeq ($(DEBUG),YES) CFLAGS = -g$(DEBUGF) -DDEBUG endif -CFLAGS += -DDIAGNOSTICS CFLAGS += -DDIAG_TASKS CFLAGS += $(CFLAGS_UAVOBJECTS) @@ -362,17 +361,14 @@ LDFLAGS += -L$(OUTDIR) # Define programs and commands. -CC = $(TCHAIN_PREFIX)gcc -CPP = $(TCHAIN_PREFIX)g++ -AR = $(TCHAIN_PREFIX)ar -OBJCOPY = $(TCHAIN_PREFIX)objcopy -OBJDUMP = $(TCHAIN_PREFIX)objdump -SIZE = $(TCHAIN_PREFIX)size -NM = $(TCHAIN_PREFIX)nm -REMOVE = $(REMOVE_CMD) -f -PYTHON = python -###SHELL = sh -###COPY = cp +CC = $(ARM_SDK_PREFIX)gcc +CPP = $(ARM_SDK_PREFIX)g++ +AR = $(ARM_SDK_PREFIX)ar +OBJCOPY = $(ARM_SDK_PREFIX)objcopy +OBJDUMP = $(ARM_SDK_PREFIX)objdump +SIZE = $(ARM_SDK_PREFIX)size +NM = $(ARM_SDK_PREFIX)nm +REMOVE = $(RM) -f @@ -438,14 +434,6 @@ endif endif endif -# Test if quotes are needed for the echo-command -result = ${shell echo "test"} -ifeq (${result}, test) - quote = ' -else - quote = -endif - # Generate intermediate code gencode: ${OUTDIR}/InitMods.c ${OUTDIR}/pmlib_img.c ${OUTDIR}/pmlib_nat.c ${OUTDIR}/pmlibusr_img.c ${OUTDIR}/pmlibusr_nat.c ${OUTDIR}/pmfeatures.h diff --git a/flight/targets/RevoMini/System/inc/op_config.h b/flight/targets/RevoMini/System/inc/op_config.h deleted file mode 100644 index 97910f392..000000000 --- a/flight/targets/RevoMini/System/inc/op_config.h +++ /dev/null @@ -1,39 +0,0 @@ -/** - ****************************************************************************** - * @addtogroup OpenPilotSystem OpenPilot System - * @{ - * @addtogroup OpenPilotCore OpenPilot Core - * @{ - * - * @file op_config.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief OpenPilot configuration header. - * Compile time config for OpenPilot Application - * @see The GNU Public License (GPL) Version 3 - * - *****************************************************************************/ -/* - * 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 - */ - - -#ifndef OP_CONFIG_H -#define OP_CONFIG_H - -#endif /* OP_CONFIG_H */ -/** - * @} - * @} - */ diff --git a/flight/targets/RevoMini/System/inc/openpilot.h b/flight/targets/RevoMini/System/inc/openpilot.h index 59ae76fd4..7f1ac3758 100644 --- a/flight/targets/RevoMini/System/inc/openpilot.h +++ b/flight/targets/RevoMini/System/inc/openpilot.h @@ -35,7 +35,6 @@ #include /* OpenPilot Libraries */ -#include "op_config.h" #include "utlist.h" #include "uavobjectmanager.h" #include "eventdispatcher.h" diff --git a/flight/targets/RevoMini/System/inc/pios_board_sim.h b/flight/targets/RevoMini/System/inc/pios_board_sim.h index 30a3d3d37..8f551cab9 100644 --- a/flight/targets/RevoMini/System/inc/pios_board_sim.h +++ b/flight/targets/RevoMini/System/inc/pios_board_sim.h @@ -60,7 +60,7 @@ extern uint32_t pios_com_spectrum_id; #ifdef PIOS_ENABLE_AUX_UART #define PIOS_COM_AUX (pios_com_aux_id) -#define PIOS_COM_DEBUG (PIOS_COM_AUX +#define PIOS_COM_DEBUG (PIOS_COM_AUX) #endif #define PIOS_GCSRCVR_TIMEOUT_MS 200 diff --git a/flight/targets/RevoMini/System/inc/pios_config.h b/flight/targets/RevoMini/System/inc/pios_config.h index 6ea05446c..4a92e7965 100644 --- a/flight/targets/RevoMini/System/inc/pios_config.h +++ b/flight/targets/RevoMini/System/inc/pios_config.h @@ -1,127 +1,171 @@ -/** - ****************************************************************************** - * @addtogroup OpenPilotSystem OpenPilot System - * @{ - * @addtogroup OpenPilotCore OpenPilot Core - * @{ - * - * @file pios_config.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief PiOS configuration header. - * Central compile time config for the project. - * In particular, pios_config.h is where you define which PiOS libraries - * and features are included in the firmware. - * @see The GNU Public License (GPL) Version 3 - * - *****************************************************************************/ -/* - * 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 - */ - - -#ifndef PIOS_CONFIG_H -#define PIOS_CONFIG_H - -/* Major features */ -#define PIOS_INCLUDE_FREERTOS -#define PIOS_INCLUDE_BL_HELPER - -/* Enable/Disable PiOS Modules */ -#define PIOS_INCLUDE_ADC -#define PIOS_INCLUDE_DELAY -#define PIOS_INCLUDE_I2C -#define PIOS_INCLUDE_IRQ -#define PIOS_INCLUDE_LED -#define PIOS_INCLUDE_IAP -#define PIOS_INCLUDE_SERVO -#define PIOS_INCLUDE_SPI -#define PIOS_INCLUDE_SYS -#define PIOS_INCLUDE_USART -#define PIOS_INCLUDE_USB -#define PIOS_INCLUDE_USB_HID -//#define PIOS_INCLUDE_GPIO -#define PIOS_INCLUDE_EXTI -#define PIOS_INCLUDE_RTC -#define PIOS_INCLUDE_WDG - -/* Variables related to the RFM22B functionality */ -#define PIOS_INCLUDE_RFM22B -#define PIOS_INCLUDE_RFM22B_COM -#define PIOS_INCLUDE_RFM22B_RCVR - -/* Select the sensors to include */ -#define PIOS_INCLUDE_HMC5883 -#define PIOS_HMC5883_HAS_GPIOS -#define PIOS_INCLUDE_MPU6000 -#define PIOS_MPU6000_ACCEL -#define PIOS_INCLUDE_MS5611 -#define PIOS_INCLUDE_ETASV3 -#define PIOS_INCLUDE_MPXV -//#define PIOS_INCLUDE_HCSR04 -#define FLASH_FREERTOS -/* Com systems to include */ -#define PIOS_INCLUDE_COM -#define PIOS_INCLUDE_COM_TELEM -#define PIOS_INCLUDE_COM_FLEXI - -#define PIOS_INCLUDE_GPS -#define PIOS_INCLUDE_GPS_NMEA_PARSER -#define PIOS_INCLUDE_GPS_UBX_PARSER -#define PIOS_GPS_SETS_HOMELOCATION - -/* Supported receiver interfaces */ -#define PIOS_INCLUDE_RCVR -#define PIOS_INCLUDE_DSM -#define PIOS_INCLUDE_SBUS -#define PIOS_INCLUDE_PPM -#define PIOS_INCLUDE_PWM -#define PIOS_INCLUDE_GCSRCVR - -#define PIOS_INCLUDE_SETTINGS -#define PIOS_INCLUDE_FLASH -/* A really shitty setting saving implementation */ -#define PIOS_INCLUDE_FLASH_SECTOR_SETTINGS - -//#define PIOS_INCLUDE_DEBUG_CONSOLE - -/* Other Interfaces */ -//#define PIOS_INCLUDE_I2C_ESC - -//#define PIOS_OVERO_SPI - -/* Flags that alter behaviors - mostly to lower resources for CC */ -#define PIOS_INCLUDE_INITCALL /* Include init call structures */ -#define PIOS_TELEM_PRIORITY_QUEUE /* Enable a priority queue in telemetry */ -//#define PIOS_QUATERNION_STABILIZATION /* Stabilization options */ -#define PIOS_GPS_SETS_HOMELOCATION /* GPS options */ - -/* Alarm Thresholds */ -#define HEAP_LIMIT_WARNING 1000 -#define HEAP_LIMIT_CRITICAL 500 -#define IRQSTACK_LIMIT_WARNING 150 -#define IRQSTACK_LIMIT_CRITICAL 80 -#define CPULOAD_LIMIT_WARNING 80 -#define CPULOAD_LIMIT_CRITICAL 95 - -// This actually needs calibrating -#define IDLE_COUNTS_PER_SEC_AT_NO_LOAD (8379692) - -#define REVOLUTION - -#endif /* PIOS_CONFIG_H */ -/** - * @} - * @} - */ +/** + ****************************************************************************** + * @addtogroup OpenPilotSystem OpenPilot System + * @{ + * @addtogroup OpenPilotCore OpenPilot Core + * @{ + * @file pios_config.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010-2013. + * @brief PiOS configuration header, the compile time config file for the PIOS. + * Defines which PiOS libraries and features are included in the firmware. + * @see The GNU Public License (GPL) Version 3 + *****************************************************************************/ +/* + * 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 + */ + +#ifndef PIOS_CONFIG_H +#define PIOS_CONFIG_H + +/* + * Below is a complete list of PIOS configurable options. + * Please do not remove or rearrange them. Only comment out + * unused options in the list. See main pios.h header for more + * details. + */ + +/* #define PIOS_INCLUDE_DEBUG_CONSOLE */ +/* #define DEBUG_LEVEL 0 */ + +/* PIOS FreeRTOS support */ +#define PIOS_INCLUDE_FREERTOS + +/* PIOS bootloader helper */ +#define PIOS_INCLUDE_BL_HELPER +/* #define PIOS_INCLUDE_BL_HELPER_WRITE_SUPPORT */ + +/* PIOS system functions */ +#define PIOS_INCLUDE_DELAY +#define PIOS_INCLUDE_INITCALL +#define PIOS_INCLUDE_SYS + +/* PIOS hardware peripherals */ +#define PIOS_INCLUDE_IRQ +#define PIOS_INCLUDE_RTC +#define PIOS_INCLUDE_TIM +#define PIOS_INCLUDE_USART +#define PIOS_INCLUDE_ADC +#define PIOS_INCLUDE_I2C +#define PIOS_INCLUDE_SPI +/* #define PIOS_INCLUDE_GPIO */ +#define PIOS_INCLUDE_EXTI +#define PIOS_INCLUDE_WDG + +/* PIOS USB functions */ +#define PIOS_INCLUDE_USB +#define PIOS_INCLUDE_USB_HID +/* #define PIOS_INCLUDE_USB_CDC */ +/* #define PIOS_INCLUDE_USB_RCTX */ + +/* PIOS sensor interfaces */ +/* #define PIOS_INCLUDE_ADXL345 */ +/* #define PIOS_INCLUDE_BMA180 */ +/* #define PIOS_INCLUDE_L3GD20 */ +#define PIOS_INCLUDE_MPU6000 +#define PIOS_MPU6000_ACCEL +/* #define PIOS_INCLUDE_HMC5843 */ +#define PIOS_INCLUDE_HMC5883 +#define PIOS_HMC5883_HAS_GPIOS +/* #define PIOS_INCLUDE_BMP085 */ +#define PIOS_INCLUDE_MS5611 +#define PIOS_INCLUDE_MPXV +#define PIOS_INCLUDE_ETASV3 +/* #define PIOS_INCLUDE_HCSR04 */ + +/* PIOS receiver drivers */ +#define PIOS_INCLUDE_PWM +#define PIOS_INCLUDE_PPM +/* #define PIOS_INCLUDE_PPM_FLEXI */ +#define PIOS_INCLUDE_DSM +#define PIOS_INCLUDE_SBUS +#define PIOS_INCLUDE_GCSRCVR + +/* PIOS abstract receiver interface */ +#define PIOS_INCLUDE_RCVR + +/* PIOS common peripherals */ +#define PIOS_INCLUDE_LED +#define PIOS_INCLUDE_IAP +#define PIOS_INCLUDE_SERVO +/* #define PIOS_INCLUDE_I2C_ESC */ +/* #define PIOS_INCLUDE_OVERO */ +/* #define PIOS_OVERO_SPI */ +/* #define PIOS_INCLUDE_SDCARD */ +/* #define LOG_FILENAME "startup.log" */ +#define PIOS_INCLUDE_FLASH +#define PIOS_INCLUDE_FLASH_SECTOR_SETTINGS +#define FLASH_FREERTOS +/* #define PIOS_INCLUDE_FLASH_EEPROM */ + +/* PIOS radio modules */ +#define PIOS_INCLUDE_RFM22B +#define PIOS_INCLUDE_RFM22B_COM +#define PIOS_INCLUDE_RFM22B_RCVR +/* #define PIOS_INCLUDE_PPM_OUT */ +/* #define PIOS_RFM22B_DEBUG_ON_TELEM */ + +/* PIOS misc peripherals */ +/* #define PIOS_INCLUDE_VIDEO */ +/* #define PIOS_INCLUDE_WAVE */ +/* #define PIOS_INCLUDE_UDP */ + +/* PIOS abstract comms interface with options */ +#define PIOS_INCLUDE_COM +/* #define PIOS_INCLUDE_COM_MSG */ +/* #define PIOS_INCLUDE_TELEMETRY_RF */ +#define PIOS_INCLUDE_COM_TELEM +#define PIOS_INCLUDE_COM_FLEXI +/* #define PIOS_INCLUDE_COM_AUX */ +#define PIOS_TELEM_PRIORITY_QUEUE +#define PIOS_INCLUDE_GPS +/* #define PIOS_GPS_MINIMAL */ +#define PIOS_INCLUDE_GPS_NMEA_PARSER +#define PIOS_INCLUDE_GPS_UBX_PARSER +#define PIOS_GPS_SETS_HOMELOCATION + +/* Stabilization options */ +/* #define PIOS_QUATERNION_STABILIZATION */ + +/* Performance counters */ +#define IDLE_COUNTS_PER_SEC_AT_NO_LOAD 8379692 + +/* Alarm Thresholds */ +#define HEAP_LIMIT_WARNING 1000 +#define HEAP_LIMIT_CRITICAL 500 +#define IRQSTACK_LIMIT_WARNING 150 +#define IRQSTACK_LIMIT_CRITICAL 80 +#define CPULOAD_LIMIT_WARNING 80 +#define CPULOAD_LIMIT_CRITICAL 95 + +/* Task stack sizes */ +/* #define PIOS_ACTUATOR_STACK_SIZE 1020 */ +/* #define PIOS_MANUAL_STACK_SIZE 800 */ +/* #define PIOS_SYSTEM_STACK_SIZE 660 */ +/* #define PIOS_STABILIZATION_STACK_SIZE 524 */ +/* #define PIOS_TELEM_STACK_SIZE 500 */ +/* #define PIOS_EVENTDISPATCHER_STACK_SIZE 130 */ + +/* This can't be too high to stop eventdispatcher thread overflowing */ +#define PIOS_EVENTDISAPTCHER_QUEUE 10 + +/* Revolution series */ +#define REVOLUTION + +#endif /* PIOS_CONFIG_H */ + +/** + * @} + * @} + */ diff --git a/flight/targets/RevoMini/UAVObjects.inc b/flight/targets/RevoMini/UAVObjects.inc index 2ed6f31b3..56f708ebe 100644 --- a/flight/targets/RevoMini/UAVObjects.inc +++ b/flight/targets/RevoMini/UAVObjects.inc @@ -1,10 +1,6 @@ -##### -# Project: OpenPilot # -# Makefile for OpenPilot UAVObject code +# Copyright (c) 2009-2013, The OpenPilot Team, http://www.openpilot.org # -# The OpenPilot Team, http://www.openpilot.org, Copyright (C) 2011. -# # 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 @@ -18,11 +14,10 @@ # 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 -##### +# # These are the UAVObjects supposed to be build as part of the OpenPilot target # (all architectures) - UAVOBJSRCFILENAMES = UAVOBJSRCFILENAMES += accessorydesired UAVOBJSRCFILENAMES += actuatorcommand diff --git a/flight/targets/Revolution/Makefile b/flight/targets/Revolution/Makefile index 5e85dc504..60ae27377 100644 --- a/flight/targets/Revolution/Makefile +++ b/flight/targets/Revolution/Makefile @@ -1,11 +1,6 @@ -##### -# Project: OpenPilot Revolution Target -# -# -# Makefile for OpenPilot Revolution project -# -# The OpenPilot Team, http://www.openpilot.org, Copyright (C) 2013. # +# Copyright (c) 2009-2013, The OpenPilot Team, http://www.openpilot.org +# Copyright (c) 2012, PhoenixPilot, http://github.com/PhoenixPilot # # 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 @@ -22,475 +17,81 @@ # 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 - -# Set developer code and compile options -# Set to YES for debugging -DEBUG ?= NO - -# Set to YES when using Code Sourcery toolchain -CODE_SOURCERY ?= NO - -ifeq ($(CODE_SOURCERY), YES) -REMOVE_CMD = cs-rm -else -REMOVE_CMD = rm +ifndef OPENPILOT_IS_COOL + $(error Top level Makefile must be used to build this target) endif -FLASH_TOOL = OPENOCD +include $(ROOT_DIR)/make/boards/$(BOARD_NAME)/board-info.mk +include $(ROOT_DIR)/make/firmware-defs.mk -# Optional module and driver defaults -USE_COMUSBBRIDGE ?= NO -USE_TXPID ?= NO -USE_I2C ?= NO -USE_ALTITUDE ?= NO -TEST_FAULTS ?= NO -USE_MAGBARO ?= NO +# ARM DSP library +USE_DSP_LIB ?= NO -# List of optional modules to include -OPTMODULES = -ifeq ($(USE_COMUSBBRIDGE), YES) -OPTMODULES += ComUsbBridge -endif -ifeq ($(USE_TXPID), YES) -OPTMODULES += TxPID -endif -ifeq ($(TEST_FAULTS), YES) -OPTMODULES += Fault -endif -ifeq ($(USE_MAGBARO), YES) -ifeq ($(USE_I2C), YES) -OPTMODULES += Extensions/MagBaro -else -$(error "MagBaro module (USE_MAGBARO=YES) requires i2c (USE_I2C=YES)") -endif -endif - -# List of modules to include -MODULES = Sensors Attitude/revolution ManualControl Stabilization Actuator -MODULES += Altitude/revolution FirmwareIAP +# List of mandatory modules to include +MODULES += Sensors +MODULES += Attitude/revolution +MODULES += Altitude/revolution MODULES += Airspeed/revolution -MODULES += GPS AltitudeHold FixedWingPathFollower PathPlanner -#MODULES += VtolPathFollower ## OP-700: VtolPathFollower disabled because its currently unsafe - remove this line once Sambas code has been merged +MODULES += AltitudeHold +MODULES += Stabilization +MODULES += ManualControl +MODULES += Actuator +MODULES += GPS MODULES += CameraStab +MODULES += FirmwareIAP +MODULES += PathPlanner +MODULES += FixedWingPathFollower MODULES += OveroSync MODULES += Telemetry -PYMODULES = -#FlightPlan +#MODULES += VtolPathFollower ## OP-700: VtolPathFollower disabled because its currently unsafe - remove this line once Sambas code has been merged +#MODULES += Battery +#MODULES += TxPID -# Enable ARM DSP library -USE_DSP_LIB = NO +OPTMODULES = -# Paths -OPSYSTEM = ./System -OPSYSTEMINC = $(OPSYSTEM)/inc -OPUAVTALKINC = $(OPUAVTALK)/inc -OPUAVOBJINC = $(OPUAVOBJ)/inc -PIOSINC = $(PIOS)/inc -FLIGHTLIBINC = $(FLIGHTLIB)/inc -MATHLIB = $(FLIGHTLIB)/math -MATHLIBINC = $(FLIGHTLIB)/math -PIOSSTM32F4XX = $(PIOS)/STM32F4xx -PIOSCOMMON = $(PIOS)/Common -PIOSBOARDS = $(PIOS)/Boards -PIOSCOMMONLIB = $(PIOSCOMMON)/Libraries -APPLIBDIR = $(PIOSSTM32F4XX)/Libraries -STMLIBDIR = $(APPLIBDIR) -STMSPDDIR = $(STMLIBDIR)/STM32F4xx_StdPeriph_Driver -STMSPDSRCDIR = $(STMSPDDIR)/src -STMSPDINCDIR = $(STMSPDDIR)/inc -FLIGHTPLANLIB = $(OPMODULEDIR)/FlightPlan/lib -FLIGHTPLANS = $(OPMODULEDIR)/FlightPlan/flightplans +# Include all camera options +CDEFS += -DUSE_INPUT_LPF -DUSE_GIMBAL_LPF -DUSE_GIMBAL_FF -SRC = -# optional component libraries -include $(PIOSCOMMONLIB)/FreeRTOS/library.mk -#include $(PIOSCOMMONLIB)/dosfs/library.mk -include $(PIOSCOMMONLIB)/msheap/library.mk - -## PYMite support -#include $(FLIGHTLIB)/PyMite/pymite.mk - -# List C source files here. (C dependencies are automatically generated.) -# use file-extension c for "c-only"-files - -## MODULES -SRC += ${foreach MOD, ${OPTMODULES}, ${wildcard ${OPMODULEDIR}/${MOD}/*.c}} -SRC += ${foreach MOD, ${MODULES}, ${wildcard ${OPMODULEDIR}/${MOD}/*.c}} -## OPENPILOT CORE: -SRC += ${OPMODULEDIR}/System/systemmod.c -SRC += $(OPSYSTEM)/revolution.c -SRC += $(OPSYSTEM)/pios_board.c -SRC += $(OPSYSTEM)/pios_usb_board_data.c -SRC += $(OPSYSTEM)/alarms.c -SRC += $(OPUAVTALK)/uavtalk.c -SRC += $(OPUAVOBJ)/uavobjectmanager.c -SRC += $(OPUAVOBJ)/eventdispatcher.c - -#ifeq ($(DEBUG),YES) -SRC += $(OPSYSTEM)/dcc_stdio.c -SRC += $(OPSYSTEM)/cm3_fault_handlers.c -#endif - -SRC += $(FLIGHTLIB)/CoordinateConversions.c -SRC += $(FLIGHTLIB)/paths.c -SRC += $(FLIGHTLIB)/fifo_buffer.c -SRC += $(FLIGHTLIB)/WorldMagModel.c -SRC += $(FLIGHTLIB)/insgps13state.c -SRC += $(FLIGHTLIB)/taskmonitor.c -SRC += $(FLIGHTLIB)/sanitycheck.c - -SRC += $(MATHLIB)/sin_lookup.c -SRC += $(MATHLIB)/pid.c - -## PIOS Hardware (STM32F4xx) -include $(PIOS)/STM32F4xx/library.mk - -## PIOS Hardware (Common) -SRC += $(PIOSCOMMON)/pios_mpu6000.c -SRC += $(PIOSCOMMON)/pios_bma180.c -SRC += $(PIOSCOMMON)/pios_etasv3.c -SRC += $(PIOSCOMMON)/pios_mpxv.c -SRC += $(PIOSCOMMON)/pios_gcsrcvr.c -SRC += $(PIOSCOMMON)/pios_l3gd20.c -SRC += $(PIOSCOMMON)/pios_hmc5883.c -SRC += $(PIOSCOMMON)/pios_ms5611.c -SRC += $(PIOSCOMMON)/pios_crc.c -SRC += $(PIOSCOMMON)/pios_com.c -SRC += $(PIOSCOMMON)/pios_rcvr.c -SRC += $(PIOSCOMMON)/pios_sbus.c -SRC += $(PIOSCOMMON)/pios_flash_jedec.c -SRC += $(PIOSCOMMON)/pios_flashfs_logfs.c -SRC += $(PIOSCOMMON)/printf-stdarg.c -SRC += $(PIOSCOMMON)/pios_usb_desc_hid_cdc.c -SRC += $(PIOSCOMMON)/pios_usb_desc_hid_only.c -SRC += $(PIOSCOMMON)/pios_usb_util.c - -include ./UAVObjects.inc -SRC += $(UAVOBJSRC) - -# List C source files here which must be compiled in ARM-Mode (no -mthumb). -# use file-extension c for "c-only"-files -## just for testing, timer.c could be compiled in thumb-mode too -SRCARM = - -# List C++ source files here. -# use file-extension .cpp for C++-files (not .C) -CPPSRC = - -# List C++ source files here which must be compiled in ARM-Mode. -# use file-extension .cpp for C++-files (not .C) -#CPPSRCARM = $(TARGET).cpp -CPPSRCARM = - -# List Assembler source files here. -# Make them always end in a capital .S. Files ending in a lowercase .s -# will not be considered source files but generated files (assembler -# output from the compiler), and will be deleted upon "make clean"! -# Even though the DOS/Win* filesystem matches both .s and .S the same, -# it will preserve the spelling of the filenames, and gcc itself does -# care about how the name is spelled on its command-line. - - -# List Assembler source files here which must be assembled in ARM-Mode.. -ASRCARM = - -# List any extra directories to look for include files here. -# Each directory must be seperated by a space. -EXTRAINCDIRS += $(PIOS) -EXTRAINCDIRS += $(PIOSINC) -EXTRAINCDIRS += $(OPSYSTEMINC) -EXTRAINCDIRS += $(OPUAVTALK) -EXTRAINCDIRS += $(OPUAVTALKINC) -EXTRAINCDIRS += $(OPUAVOBJ) -EXTRAINCDIRS += $(OPUAVOBJINC) -EXTRAINCDIRS += $(OPUAVSYNTHDIR) -EXTRAINCDIRS += $(FLIGHTLIBINC) -EXTRAINCDIRS += $(MATHLIBINC) -EXTRAINCDIRS += $(PIOSSTM32F4XX) -EXTRAINCDIRS += $(PIOSCOMMON) -EXTRAINCDIRS += $(PIOSBOARDS) -EXTRAINCDIRS += $(STMSPDINCDIR) -EXTRAINCDIRS += $(CMSISDIR) -EXTRAINCDIRS += $(BOOTINC) -EXTRAINCDIRS += $(HWDEFSINC) - -EXTRAINCDIRS += ${foreach MOD, ${OPTMODULES} ${MODULES} ${PYMODULES}, $(OPMODULEDIR)/${MOD}/inc} ${OPMODULEDIR}/System/inc - -# List any extra directories to look for library files here. -# Also add directories where the linker should search for -# includes from linker-script to the list -# Each directory must be seperated by a space. -#EXTRA_LIBDIRS += - -# Extra Libraries -# Each library-name must be seperated by a space. -# i.e. to link with libxyz.a, libabc.a and libefsl.a: -# EXTRA_LIBS = xyz abc efsl -# for newlib-lpc (file: libnewlibc-lpc.a): -# EXTRA_LIBS = newlib-lpc -#EXTRA_LIBS += - -# Path to Linker-Scripts -LINKERSCRIPTPATH = $(PIOSSTM32F4XX) - -# Optimization level, can be [0, 1, 2, 3, s]. -# 0 = turn off optimization. s = optimize for size. -# (Note: 3 is not always the best optimization level. See avr-libc FAQ.) - -ifeq ($(DEBUG),YES) -CFLAGS += -O0 -CFLAGS += -DGENERAL_COV -CFLAGS += -finstrument-functions -ffixed-r10 -else -CFLAGS += -Os -endif - - - -# common architecture-specific flags from the device-specific library makefile -CFLAGS += $(ARCHFLAGS) - -CFLAGS += -DSTACK_DIAGNOSTICS -CFLAGS += -DMIXERSTATUS_DIAGNOSTICS -CFLAGS += -DRATEDESIRED_DIAGNOSTICS -CFLAGS += -DI2C_WDG_STATS_DIAGNOSTICS -CFLAGS += -DDIAG_TASKS - -# This is not the best place for these. Really should abstract out -# to the board file or something -CFLAGS += -DSTM32F4XX -CFLAGS += -DMEM_SIZE=1024000000 - -# Output format. (can be ihex or binary or both) -# binary to create a load-image in raw-binary format i.e. for SAM-BA, -# ihex to create a load-image in Intel hex format -#LOADFORMAT = ihex -#LOADFORMAT = binary -LOADFORMAT = both - -# Debugging format. -DEBUGF = dwarf-2 - -# Place project-specific -D (define) and/or -# -U options for C here. -CDEFS += -DHSE_VALUE=$(OSCILLATOR_FREQ) -CDEFS += -DSYSCLK_FREQ=$(SYSCLK_FREQ) -CDEFS += -DUSE_STDPERIPH_DRIVER -CDEFS += -DUSE_$(BOARD) -ifeq ($(ENABLE_DEBUG_CONSOLE), YES) -CDEFS += -DPIOS_INCLUDE_DEBUG_CONSOLE -endif - -# Declare all non-optional modules as built-in to force inclusion -CDEFS += $(foreach MOD, $(notdir $(MODULES)), -DMODULE_$(MOD)_BUILTIN) - -# Place project-specific -D and/or -U options for -# Assembler with preprocessor here. -#ADEFS = -DUSE_IRQ_ASM_WRAPPER -ADEFS = -D__ASSEMBLY__ - -# Compiler flag to set the C Standard level. -# c89 - "ANSI" C -# gnu89 - c89 plus GCC extensions -# c99 - ISO C99 standard (not yet fully implemented) -# gnu99 - c99 plus GCC extensions -CSTANDARD = -std=gnu99 - -#----- - -# Compiler flags. - -# -g*: generate debugging information -# -O*: optimization level -# -f...: tuning, see GCC manual and avr-libc documentation -# -Wall...: warning level -# -Wa,...: tell GCC to pass this to the assembler. -# -adhlns...: create assembler listing -# -# Flags for C and C++ (arm-elf-gcc/arm-elf-g++) - -CFLAGS += -g$(DEBUGF) +# Some diagnostics +CDEFS += -DDIAG_TASKS +# Misc options CFLAGS += -ffast-math -CFLAGS += -mcpu=$(MCU) -CFLAGS += $(CDEFS) -CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) -I. +# List C source files here (C dependencies are automatically generated). +# Use file-extension c for "c-only"-files +ifndef TESTAPP + ## Application Core + SRC += ${OPMODULEDIR}/System/systemmod.c + SRC += $(OPSYSTEM)/revolution.c + SRC += $(OPSYSTEM)/pios_board.c + SRC += $(OPSYSTEM)/pios_usb_board_data.c + SRC += $(OPSYSTEM)/alarms.c + SRC += $(OPUAVTALK)/uavtalk.c + SRC += $(OPUAVOBJ)/uavobjectmanager.c + SRC += $(OPUAVOBJ)/eventdispatcher.c -CFLAGS += -mapcs-frame -CFLAGS += -fomit-frame-pointer -ifeq ($(CODE_SOURCERY), YES) -CFLAGS += -fpromote-loop-indices -endif + #ifeq ($(DEBUG), YES) + SRC += $(OPSYSTEM)/dcc_stdio.c + SRC += $(OPSYSTEM)/cm3_fault_handlers.c + #endif -CFLAGS += -Wall -#CFLAGS += -Werror -CFLAGS += -Wa,-adhlns=$(addprefix $(OUTDIR)/, $(notdir $(addsuffix .lst, $(basename $<)))) -# Compiler flags to generate dependency files: -CFLAGS += -MD -MP -MF $(OUTDIR)/dep/$(@F).d + ## Misc library functions + SRC += $(FLIGHTLIB)/paths.c + SRC += $(FLIGHTLIB)/WorldMagModel.c + SRC += $(FLIGHTLIB)/insgps13state.c -# flags only for C -#CONLYFLAGS += -Wnested-externs -CONLYFLAGS += $(CSTANDARD) - -# Assembler flags. -# -Wa,...: tell GCC to pass this to the assembler. -# -ahlns: create listing -ASFLAGS = $(ARCHFLAGS) -mthumb -I. -x assembler-with-cpp -ASFLAGS += $(ADEFS) -ASFLAGS += -Wa,-adhlns=$(addprefix $(OUTDIR)/, $(notdir $(addsuffix .lst, $(basename $<)))) -ASFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) - -MATH_LIB = -lm - -# Linker flags. -# -Wl,...: tell GCC to pass this to linker. -# -Map: create map file -# --cref: add cross reference to map file -LDFLAGS = -nostartfiles -Wl,-Map=$(OUTDIR)/$(TARGET).map,--cref,--gc-sections -LDFLAGS += $(patsubst %,-L%,$(EXTRA_LIBDIRS)) -LDFLAGS += -lc -LDFLAGS += $(patsubst %,-l%,$(EXTRA_LIBS)) -LDFLAGS += $(MATH_LIB) -LDFLAGS += -lc -lgcc - -#Linker scripts -LDFLAGS += $(addprefix -T,$(LINKER_SCRIPTS_APP)) - - -# Define programs and commands. -REMOVE = $(REMOVE_CMD) -f -PYTHON = python - -# List of all source files. -ALLSRC = $(ASRCARM) $(ASRC) $(SRCARM) $(SRC) $(CPPSRCARM) $(CPPSRC) -# List of all source files without directory and file-extension. -ALLSRCBASE = $(notdir $(basename $(ALLSRC))) - -# Define all object files. -ALLOBJ = $(addprefix $(OUTDIR)/, $(addsuffix .o, $(ALLSRCBASE))) - -# Define all listing files (used for make clean). -LSTFILES = $(addprefix $(OUTDIR)/, $(addsuffix .lst, $(ALLSRCBASE))) -# Define all depedency-files (used for make clean). -DEPFILES = $(addprefix $(OUTDIR)/dep/, $(addsuffix .o.d, $(ALLSRCBASE))) - -# Default target. -all: gccversion build - -ifeq ($(LOADFORMAT),ihex) -build: elf hex lss sym + ## UAVObjects + include ./UAVObjects.inc + SRC += $(UAVOBJSRC) else -ifeq ($(LOADFORMAT),binary) -build: elf bin lss sym -else -ifeq ($(LOADFORMAT),both) -build: elf hex bin lss sym -else -$(error "$(MSG_FORMATERROR) $(FORMAT)") -endif -endif + ## Test Code + SRC += $(OPTESTS)/test_common.c + SRC += $(OPTESTS)/$(TESTAPP).c endif +# Optional component libraries +#include $(FLIGHTLIB)/PyMite/pymite.mk -# Link: create ELF output file from object files. -$(eval $(call LINK_TEMPLATE, $(OUTDIR)/$(TARGET).elf, $(ALLOBJ), $(ALLLIB))) - -# Assemble: create object files from assembler source files. -$(foreach src, $(ASRC), $(eval $(call ASSEMBLE_TEMPLATE, $(src)))) - -# Assemble: create object files from assembler source files. ARM-only -$(foreach src, $(ASRCARM), $(eval $(call ASSEMBLE_ARM_TEMPLATE, $(src)))) - -# Compile: create object files from C source files. -$(foreach src, $(SRC), $(eval $(call COMPILE_C_TEMPLATE, $(src)))) - -# Compile: create object files from C source files. ARM-only -$(foreach src, $(SRCARM), $(eval $(call COMPILE_C_ARM_TEMPLATE, $(src)))) - -# Compile: create object files from C++ source files. -$(foreach src, $(CPPSRC), $(eval $(call COMPILE_CPP_TEMPLATE, $(src)))) - -# Compile: create object files from C++ source files. ARM-only -$(foreach src, $(CPPSRCARM), $(eval $(call COMPILE_CPP_ARM_TEMPLATE, $(src)))) - -# Compile: create assembler files from C source files. ARM/Thumb -$(eval $(call PARTIAL_COMPILE_TEMPLATE, SRC)) - -# Compile: create assembler files from C source files. ARM only -$(eval $(call PARTIAL_COMPILE_ARM_TEMPLATE, SRCARM)) - -$(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),$(OPENOCD_JTAG_CONFIG),$(OPENOCD_CONFIG))) - -.PHONY: elf lss sym hex bin bino opfw -elf: $(OUTDIR)/$(TARGET).elf -lss: $(OUTDIR)/$(TARGET).lss -sym: $(OUTDIR)/$(TARGET).sym -hex: $(OUTDIR)/$(TARGET).hex -bin: $(OUTDIR)/$(TARGET).bin -bino: $(OUTDIR)/$(TARGET).bin.o -opfw: $(OUTDIR)/$(TARGET).opfw - -# Display sizes of sections. -$(eval $(call SIZE_TEMPLATE, $(OUTDIR)/$(TARGET).elf)) - -# Generate Doxygen documents -docs: - doxygen $(DOXYGENDIR)/doxygen.cfg - -# Install: install binary file with prefix/suffix into install directory -install: $(OUTDIR)/$(TARGET).opfw -ifneq ($(INSTALL_DIR),) - @echo $(MSG_INSTALLING) $(call toprel, $<) - $(V1) mkdir -p $(INSTALL_DIR) - $(V1) $(INSTALL) $< $(INSTALL_DIR)/$(INSTALL_PFX)$(TARGET)$(INSTALL_SFX).opfw -else - $(error INSTALL_DIR must be specified for $@) -endif - -# Target: clean project. -clean: clean_list - -clean_list : - @echo $(MSG_CLEANING) - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).map - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).elf - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).hex - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).bin - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).sym - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).lss - $(V1) $(REMOVE) $(OUTDIR)/$(TARGET).bin.o - $(V1) $(REMOVE) $(ALLOBJ) - $(V1) $(REMOVE) $(LSTFILES) - $(V1) $(REMOVE) $(DEPFILES) - $(V1) $(REMOVE) $(SRC:.c=.s) - $(V1) $(REMOVE) $(SRCARM:.c=.s) - $(V1) $(REMOVE) $(CPPSRC:.cpp=.s) - $(V1) $(REMOVE) $(CPPSRCARM:.cpp=.s) - -# Create output files directory -# all known MS Windows OS define the ComSpec environment variable -ifdef ComSpec -$(shell md $(subst /,\\,$(OUTDIR)) 2>NUL) -else -$(shell mkdir -p $(OUTDIR) 2>/dev/null) -endif - -# Include the dependency files. -ifdef ComSpec --include $(shell md $(subst /,\\,$(OUTDIR))\dep 2>NUL) $(wildcard $(OUTDIR)/dep/*) -else --include $(shell mkdir $(OUTDIR) 2>/dev/null) $(shell mkdir $(OUTDIR)/dep 2>/dev/null) $(wildcard $(OUTDIR)/dep/*) -endif - -# Listing of phony targets. -.PHONY : all build clean clean_list install +include $(ROOT_DIR)/make/apps-defs.mk +include $(ROOT_DIR)/make/common-defs.mk diff --git a/flight/targets/Revolution/Makefile.osx b/flight/targets/Revolution/Makefile.osx index 06cb0a506..180b3b3df 100644 --- a/flight/targets/Revolution/Makefile.osx +++ b/flight/targets/Revolution/Makefile.osx @@ -23,7 +23,7 @@ ##### BOARD_NAME=revolution -TCHAIN_PREFIX ?= +ARM_SDK_PREFIX ?= WHEREAMI := $(dir $(lastword $(MAKEFILE_LIST))) TOP := $(realpath $(WHEREAMI)/../../) include $(TOP)/make/boards/$(BOARD_NAME)/board-info.mk @@ -311,7 +311,6 @@ ifeq ($(DEBUG),YES) CFLAGS += -g$(DEBUGF) -DDEBUG endif -CFLAGS += -DDIAGNOSTICS CFLAGS += -DDIAG_TASKS CFLAGS += $(CFLAGS_UAVOBJECTS) @@ -364,17 +363,14 @@ LDFLAGS += -L$(OUTDIR) # Define programs and commands. -CC = $(TCHAIN_PREFIX)gcc -CPP = $(TCHAIN_PREFIX)g++ -AR = $(TCHAIN_PREFIX)ar -OBJCOPY = $(TCHAIN_PREFIX)objcopy -OBJDUMP = $(TCHAIN_PREFIX)objdump -SIZE = $(TCHAIN_PREFIX)size -NM = $(TCHAIN_PREFIX)nm -REMOVE = $(REMOVE_CMD) -f -PYTHON = python -###SHELL = sh -###COPY = cp +CC = $(ARM_SDK_PREFIX)gcc +CPP = $(ARM_SDK_PREFIX)g++ +AR = $(ARM_SDK_PREFIX)ar +OBJCOPY = $(ARM_SDK_PREFIX)objcopy +OBJDUMP = $(ARM_SDK_PREFIX)objdump +SIZE = $(ARM_SDK_PREFIX)size +NM = $(ARM_SDK_PREFIX)nm +REMOVE = $(RM) -f @@ -450,14 +446,6 @@ endif endif endif -# Test if quotes are needed for the echo-command -result = ${shell echo "test"} -ifeq (${result}, test) - quote = ' -else - quote = -endif - # Generate intermediate code gencode: ${OUTDIR}/InitMods.c ${OUTDIR}/pmlib_img.c ${OUTDIR}/pmlib_nat.c ${OUTDIR}/pmlibusr_img.c ${OUTDIR}/pmlibusr_nat.c ${OUTDIR}/pmfeatures.h diff --git a/flight/targets/Revolution/System/inc/op_config.h b/flight/targets/Revolution/System/inc/op_config.h deleted file mode 100644 index 97910f392..000000000 --- a/flight/targets/Revolution/System/inc/op_config.h +++ /dev/null @@ -1,39 +0,0 @@ -/** - ****************************************************************************** - * @addtogroup OpenPilotSystem OpenPilot System - * @{ - * @addtogroup OpenPilotCore OpenPilot Core - * @{ - * - * @file op_config.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief OpenPilot configuration header. - * Compile time config for OpenPilot Application - * @see The GNU Public License (GPL) Version 3 - * - *****************************************************************************/ -/* - * 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 - */ - - -#ifndef OP_CONFIG_H -#define OP_CONFIG_H - -#endif /* OP_CONFIG_H */ -/** - * @} - * @} - */ diff --git a/flight/targets/Revolution/System/inc/openpilot.h b/flight/targets/Revolution/System/inc/openpilot.h index 59ae76fd4..7f1ac3758 100644 --- a/flight/targets/Revolution/System/inc/openpilot.h +++ b/flight/targets/Revolution/System/inc/openpilot.h @@ -35,7 +35,6 @@ #include /* OpenPilot Libraries */ -#include "op_config.h" #include "utlist.h" #include "uavobjectmanager.h" #include "eventdispatcher.h" diff --git a/flight/targets/Revolution/System/inc/pios_config.h b/flight/targets/Revolution/System/inc/pios_config.h index 8ac4b2109..575017d73 100644 --- a/flight/targets/Revolution/System/inc/pios_config.h +++ b/flight/targets/Revolution/System/inc/pios_config.h @@ -1,123 +1,175 @@ -/** - ****************************************************************************** - * @addtogroup OpenPilotSystem OpenPilot System - * @{ - * @addtogroup OpenPilotCore OpenPilot Core - * @{ - * - * @file pios_config.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief PiOS configuration header. - * Central compile time config for the project. - * In particular, pios_config.h is where you define which PiOS libraries - * and features are included in the firmware. - * @see The GNU Public License (GPL) Version 3 - * - *****************************************************************************/ -/* - * 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 - */ - - -#ifndef PIOS_CONFIG_H -#define PIOS_CONFIG_H - -/* Major features */ -#define PIOS_INCLUDE_FREERTOS -#define PIOS_INCLUDE_BL_HELPER - -/* Enable/Disable PiOS Modules */ -#define PIOS_INCLUDE_ADC -#define PIOS_INCLUDE_DELAY -#define PIOS_INCLUDE_I2C -#define PIOS_INCLUDE_IRQ -#define PIOS_INCLUDE_LED -#define PIOS_INCLUDE_IAP -#define PIOS_INCLUDE_SERVO -#define PIOS_INCLUDE_SPI -#define PIOS_INCLUDE_SYS -#define PIOS_INCLUDE_USART -#define PIOS_INCLUDE_USB -#define PIOS_INCLUDE_USB_HID -//#define PIOS_INCLUDE_GPIO -#define PIOS_INCLUDE_EXTI -#define PIOS_INCLUDE_RTC -#define PIOS_INCLUDE_WDG - -/* Select the sensors to include */ -#define PIOS_INCLUDE_BMA180 -#define PIOS_INCLUDE_HMC5883 +/** + ****************************************************************************** + * @addtogroup OpenPilotSystem OpenPilot System + * @{ + * @addtogroup OpenPilotCore OpenPilot Core + * @{ + * @file pios_config.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010-2013. + * @brief PiOS configuration header, the compile time config file for the PIOS. + * Defines which PiOS libraries and features are included in the firmware. + * @see The GNU Public License (GPL) Version 3 + *****************************************************************************/ +/* + * 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 + */ + +#ifndef PIOS_CONFIG_H +#define PIOS_CONFIG_H + +/* + * Below is a complete list of PIOS configurable options. + * Please do not remove or rearrange them. Only comment out + * unused options in the list. See main pios.h header for more + * details. + */ + +/* #define PIOS_INCLUDE_DEBUG_CONSOLE */ +/* #define DEBUG_LEVEL 0 */ + +/* PIOS FreeRTOS support */ +#define PIOS_INCLUDE_FREERTOS + +/* PIOS bootloader helper */ +#define PIOS_INCLUDE_BL_HELPER +/* #define PIOS_INCLUDE_BL_HELPER_WRITE_SUPPORT */ + +/* PIOS system functions */ +#define PIOS_INCLUDE_DELAY +#define PIOS_INCLUDE_INITCALL +#define PIOS_INCLUDE_SYS + +/* PIOS hardware peripherals */ +#define PIOS_INCLUDE_IRQ +#define PIOS_INCLUDE_RTC +#define PIOS_INCLUDE_TIM +#define PIOS_INCLUDE_USART +#define PIOS_INCLUDE_ADC +#define PIOS_INCLUDE_I2C +#define PIOS_INCLUDE_SPI +/* #define PIOS_INCLUDE_GPIO */ +#define PIOS_INCLUDE_EXTI +#define PIOS_INCLUDE_WDG + +/* PIOS USB functions */ +#define PIOS_INCLUDE_USB +#define PIOS_INCLUDE_USB_HID +/* #define PIOS_INCLUDE_USB_CDC */ +/* #define PIOS_INCLUDE_USB_RCTX */ + +/* PIOS sensor interfaces */ +/* #define PIOS_INCLUDE_ADXL345 */ +#define PIOS_INCLUDE_BMA180 +#define PIOS_INCLUDE_L3GD20 +#define PIOS_INCLUDE_MPU6000 +#define PIOS_MPU6000_ACCEL +/* #define PIOS_INCLUDE_HMC5843 */ +#define PIOS_INCLUDE_HMC5883 #define PIOS_HMC5883_HAS_GPIOS -#define PIOS_INCLUDE_MPU6000 -#define PIOS_MPU6000_ACCEL -#define PIOS_INCLUDE_L3GD20 -#define PIOS_INCLUDE_MS5611 -#define PIOS_INCLUDE_ETASV3 -#define PIOS_INCLUDE_MPXV -//#define PIOS_INCLUDE_HCSR04 -#define PIOS_FLASH_ON_ACCEL /* true for second revo */ -#define FLASH_FREERTOS -/* Com systems to include */ -#define PIOS_INCLUDE_COM -#define PIOS_INCLUDE_COM_TELEM -#define PIOS_INCLUDE_COM_AUX -#define PIOS_INCLUDE_COM_AUXSBUS -#define PIOS_INCLUDE_COM_FLEXI - -#define PIOS_INCLUDE_GPS -#define PIOS_INCLUDE_GPS_NMEA_PARSER -#define PIOS_INCLUDE_GPS_UBX_PARSER -#define PIOS_GPS_SETS_HOMELOCATION - -#define PIOS_OVERO_SPI -/* Supported receiver interfaces */ -#define PIOS_INCLUDE_RCVR -#define PIOS_INCLUDE_DSM -//#define PIOS_INCLUDE_SBUS -#define PIOS_INCLUDE_PPM -#define PIOS_INCLUDE_PWM -#define PIOS_INCLUDE_GCSRCVR - -#define PIOS_INCLUDE_SETTINGS -#define PIOS_INCLUDE_FLASH -/* A really shitty setting saving implementation */ -#define PIOS_INCLUDE_FLASH_SECTOR_SETTINGS - -/* Other Interfaces */ -//#define PIOS_INCLUDE_I2C_ESC - -/* Flags that alter behaviors - mostly to lower resources for CC */ -#define PIOS_INCLUDE_INITCALL /* Include init call structures */ -#define PIOS_TELEM_PRIORITY_QUEUE /* Enable a priority queue in telemetry */ -//#define PIOS_QUATERNION_STABILIZATION /* Stabilization options */ - -/* Alarm Thresholds */ -#define HEAP_LIMIT_WARNING 1000 -#define HEAP_LIMIT_CRITICAL 500 -#define IRQSTACK_LIMIT_WARNING 150 -#define IRQSTACK_LIMIT_CRITICAL 80 -#define CPULOAD_LIMIT_WARNING 80 -#define CPULOAD_LIMIT_CRITICAL 95 - -// This actually needs calibrating -#define IDLE_COUNTS_PER_SEC_AT_NO_LOAD (8379692) - -#define REVOLUTION - -#endif /* PIOS_CONFIG_H */ -/** - * @} - * @} - */ +/* #define PIOS_INCLUDE_BMP085 */ +#define PIOS_INCLUDE_MS5611 +#define PIOS_INCLUDE_MPXV +#define PIOS_INCLUDE_ETASV3 +/* #define PIOS_INCLUDE_HCSR04 */ + +/* PIOS receiver drivers */ +#define PIOS_INCLUDE_PWM +#define PIOS_INCLUDE_PPM +/* #define PIOS_INCLUDE_PPM_FLEXI */ +#define PIOS_INCLUDE_DSM +#define PIOS_INCLUDE_SBUS +#define PIOS_INCLUDE_GCSRCVR + +/* PIOS abstract receiver interface */ +#define PIOS_INCLUDE_RCVR + +/* PIOS common peripherals */ +#define PIOS_INCLUDE_LED +#define PIOS_INCLUDE_IAP +#define PIOS_INCLUDE_SERVO +/* #define PIOS_INCLUDE_I2C_ESC */ +#define PIOS_INCLUDE_OVERO +#define PIOS_OVERO_SPI +/* #define PIOS_INCLUDE_SDCARD */ +/* #define LOG_FILENAME "startup.log" */ +#define PIOS_INCLUDE_FLASH +#define PIOS_INCLUDE_FLASH_SECTOR_SETTINGS +#define FLASH_FREERTOS +/* #define PIOS_INCLUDE_FLASH_EEPROM */ + +/* PIOS radio modules */ +/* #define PIOS_INCLUDE_RFM22B */ +/* #define PIOS_INCLUDE_RFM22B_COM */ +/* #define PIOS_INCLUDE_RFM22B_RCVR */ +/* #define PIOS_INCLUDE_PPM_OUT */ +/* #define PIOS_RFM22B_DEBUG_ON_TELEM */ + +/* PIOS misc peripherals */ +/* #define PIOS_INCLUDE_VIDEO */ +/* #define PIOS_INCLUDE_WAVE */ +/* #define PIOS_INCLUDE_UDP */ + +/* PIOS abstract comms interface with options */ +#define PIOS_INCLUDE_COM +/* #define PIOS_INCLUDE_COM_MSG */ +/* #define PIOS_INCLUDE_TELEMETRY_RF */ +#define PIOS_INCLUDE_COM_TELEM +#define PIOS_INCLUDE_COM_FLEXI +#define PIOS_INCLUDE_COM_AUX +#define PIOS_TELEM_PRIORITY_QUEUE +#define PIOS_INCLUDE_GPS +/* #define PIOS_GPS_MINIMAL */ +#define PIOS_INCLUDE_GPS_NMEA_PARSER +#define PIOS_INCLUDE_GPS_UBX_PARSER +#define PIOS_GPS_SETS_HOMELOCATION + +/* Stabilization options */ +/* #define PIOS_QUATERNION_STABILIZATION */ + +/* Performance counters */ +#define IDLE_COUNTS_PER_SEC_AT_NO_LOAD 8379692 + +/* Alarm Thresholds */ +#define HEAP_LIMIT_WARNING 1000 +#define HEAP_LIMIT_CRITICAL 500 +#define IRQSTACK_LIMIT_WARNING 150 +#define IRQSTACK_LIMIT_CRITICAL 80 +#define CPULOAD_LIMIT_WARNING 80 +#define CPULOAD_LIMIT_CRITICAL 95 + +/* Task stack sizes */ +/* #define PIOS_ACTUATOR_STACK_SIZE 1020 */ +/* #define PIOS_MANUAL_STACK_SIZE 800 */ +/* #define PIOS_SYSTEM_STACK_SIZE 660 */ +/* #define PIOS_STABILIZATION_STACK_SIZE 524 */ +/* #define PIOS_TELEM_STACK_SIZE 500 */ +/* #define PIOS_EVENTDISPATCHER_STACK_SIZE 130 */ + +/* This can't be too high to stop eventdispatcher thread overflowing */ +#define PIOS_EVENTDISAPTCHER_QUEUE 10 + +/* Revolution series */ +#define REVOLUTION + +/* OBSOLETE */ +#define PIOS_INCLUDE_COM_AUXSBUS +#define PIOS_FLASH_ON_ACCEL /* true for second revo */ + +#endif /* PIOS_CONFIG_H */ + +/** + * @} + * @} + */ diff --git a/flight/targets/SimPosix/Makefile b/flight/targets/SimPosix/Makefile index 80ba93a58..47b90c6ec 100644 --- a/flight/targets/SimPosix/Makefile +++ b/flight/targets/SimPosix/Makefile @@ -1,8 +1,6 @@ ##### -# Project: OpenPilot INS # -# -# Makefile for OpenPilot INS project +# TODO: This file should be reworked. It will be done as a part of sim target refactoring. # # The OpenPilot Team, http://www.openpilot.org, Copyright (C) 2009. # @@ -22,35 +20,16 @@ # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ##### -WHEREAMI := $(dir $(lastword $(MAKEFILE_LIST))) -TOP := $(realpath $(WHEREAMI)/../../../) - -override TCHAIN_PREFIX := +override ARM_SDK_PREFIX := override THUMB := -include $(TOP)/make/firmware-defs.mk -include $(TOP)/make/boards/$(BOARD_NAME)/board-info.mk -# Target file name (without extension). -TARGET := fw_$(BOARD_NAME) - -# Directory for output files (lst, obj, dep, elf, sym, map, hex, bin etc.) -OUTDIR := $(TOP)/build/$(TARGET) +include $(ROOT_DIR)/make/firmware-defs.mk +include $(ROOT_DIR)/make/boards/$(BOARD_NAME)/board-info.mk # Set developer code and compile options # Set to YES for debugging DEBUG ?= YES -# Set to YES when using Code Sourcery toolchain -CODE_SOURCERY ?= NO - -ifeq ($(CODE_SOURCERY), YES) -REMOVE_CMD = cs-rm -else -REMOVE_CMD = rm -endif - -FLASH_TOOL = OPENOCD - # List of modules to include MODULES = ManualControl Stabilization GPS MODULES += PathPlanner @@ -60,17 +39,14 @@ MODULES += CameraStab MODULES += Telemetry MODULES += FirmwareIAP #MODULES += OveroSync -PYMODULES = -#FlightPlan # Paths OPSYSTEM = ./System OPSYSTEMINC = $(OPSYSTEM)/inc -OPUAVTALK = ../../UAVTalk +OPUAVTALK = ../UAVTalk OPUAVTALKINC = $(OPUAVTALK)/inc -OPUAVOBJ = ../../UAVObjects +OPUAVOBJ = ../UAVObjects OPUAVOBJINC = $(OPUAVOBJ)/inc -PIOS = ../../PiOS.posix PIOSINC = $(PIOS)/inc OPMODULEDIR = ../../Modules FLIGHTLIB = ../../Libraries @@ -80,25 +56,17 @@ MATHLIBINC = $(FLIGHTLIB)/math PIOSPOSIX = $(PIOS)/posix PIOSCOMMON = $(PIOS)/posix PIOSBOARDS = $(PIOS)/Boards -PIOSCOMMONLIB = $(PIOSCOMMON)/Libraries -#APPLIBDIR = $(PIOSSTM32F4XX)/Libraries -OPUAVOBJ = ../../UAVObjects +PIOSCOMMONLIB = $(PIOS)/Common/Libraries +OPUAVOBJ = ../UAVObjects OPUAVOBJINC = $(OPUAVOBJ)/inc BOOT = BOOTINC = -FLIGHTPLANLIB = $(OPMODULEDIR)/FlightPlan/lib -FLIGHTPLANS = $(OPMODULEDIR)/FlightPlan/flightplans HWDEFSINC = ../board_hw_defs/$(BOARD_NAME) UAVOBJSYNTHDIR = $(OUTDIR)/../uavobject-synthetics/flight -SRC = # optional component libraries -include $(PIOSCOMMONLIB)/FreeRTOS/library.mk -#include $(PIOSCOMMONLIB)/dosfs/library.mk -#include $(PIOSCOMMONLIB)/msheap/library.mk - -## PYMite support -#include $(FLIGHTLIB)/PyMite/pymite.mk +include $(PIOS)/Common/Libraries/FreeRTOS/library.mk +include $(FLIGHTLIB)/PyMite/pymite.mk # List C source files here. (C dependencies are automatically generated.) # use file-extension c for "c-only"-files @@ -127,53 +95,12 @@ SRC += $(FLIGHTLIB)/sanitycheck.c SRC += $(MATHLIB)/sin_lookup.c SRC += $(MATHLIB)/pid.c -## PIOS Hardware (STM32F4xx) +## PIOS Hardware include $(PIOS)/posix/library.mk -## PIOS Hardware (Common) -#SRC += $(PIOSCOMMON)/pios_mpu6000.c -#SRC += $(PIOSCOMMON)/pios_bma180.c -#SRC += $(PIOSCOMMON)/pios_l3gd20.c -#SRC += $(PIOSCOMMON)/pios_hmc5883.c -#SRC += $(PIOSCOMMON)/pios_ms5611.c -#SRC += $(PIOSCOMMON)/pios_crc.c -#SRC += $(PIOSCOMMON)/pios_com.c -#SRC += $(PIOSCOMMON)/pios_rcvr.c -#SRC += $(PIOSCOMMON)/pios_flash_jedec.c -#SRC += $(PIOSCOMMON)/pios_flashfs_objlist.c -#SRC += $(PIOSCOMMON)/printf-stdarg.c -#SRC += $(PIOSCOMMON)/pios_usb_desc_hid_cdc.c -#SRC += $(PIOSCOMMON)/pios_usb_desc_hid_only.c - include ./UAVObjects.inc SRC += $(UAVOBJSRC) -# List C source files here which must be compiled in ARM-Mode (no -mthumb). -# use file-extension c for "c-only"-files -## just for testing, timer.c could be compiled in thumb-mode too -SRCARM = - -# List C++ source files here. -# use file-extension .cpp for C++-files (not .C) -CPPSRC = - -# List C++ source files here which must be compiled in ARM-Mode. -# use file-extension .cpp for C++-files (not .C) -#CPPSRCARM = $(TARGET).cpp -CPPSRCARM = - -# List Assembler source files here. -# Make them always end in a capital .S. Files ending in a lowercase .s -# will not be considered source files but generated files (assembler -# output from the compiler), and will be deleted upon "make clean"! -# Even though the DOS/Win* filesystem matches both .s and .S the same, -# it will preserve the spelling of the filenames, and gcc itself does -# care about how the name is spelled on its command-line. - - -# List Assembler source files here which must be assembled in ARM-Mode.. -ASRCARM = - # List any extra directories to look for include files here. # Each directory must be seperated by a space. EXTRAINCDIRS += $(PIOS) @@ -186,38 +113,14 @@ EXTRAINCDIRS += $(OPUAVOBJINC) EXTRAINCDIRS += $(UAVOBJSYNTHDIR) EXTRAINCDIRS += $(FLIGHTLIBINC) EXTRAINCDIRS += $(MATHLIBINC) -#EXTRAINCDIRS += $(PIOSSTM32F4XX) EXTRAINCDIRS += $(PIOSCOMMON) EXTRAINCDIRS += $(PIOSBOARDS) -#EXTRAINCDIRS += $(STMSPDINCDIR) EXTRAINCDIRS += $(CMSISDIR) EXTRAINCDIRS += $(OPUAVSYNTHDIR) EXTRAINCDIRS += $(BOOTINC) EXTRAINCDIRS += $(HWDEFSINC) -EXTRAINCDIRS += ${foreach MOD, ${MODULES} ${PYMODULES}, $(OPMODULEDIR)/${MOD}/inc} ${OPMODULEDIR}/System/inc - -# List any extra directories to look for library files here. -# Also add directories where the linker should search for -# includes from linker-script to the list -# Each directory must be seperated by a space. -#EXTRA_LIBDIRS += - -# Extra Libraries -# Each library-name must be seperated by a space. -# i.e. to link with libxyz.a, libabc.a and libefsl.a: -# EXTRA_LIBS = xyz abc efsl -# for newlib-lpc (file: libnewlibc-lpc.a): -# EXTRA_LIBS = newlib-lpc -#EXTRA_LIBS += - -# Path to Linker-Scripts -#LINKERSCRIPTPATH = $(PIOSSTM32F4XX) - -# Optimization level, can be [0, 1, 2, 3, s]. -# 0 = turn off optimization. s = optimize for size. -# (Note: 3 is not always the best optimization level. See avr-libc FAQ.) - +EXTRAINCDIRS += ${foreach MOD, ${MODULES}, $(OPMODULEDIR)/${MOD}/inc} ${OPMODULEDIR}/System/inc BLONLY_CDEFS += -DBOARD_TYPE=$(BOARD_TYPE) BLONLY_CDEFS += -DBOARD_REVISION=$(BOARD_REVISION) @@ -238,19 +141,19 @@ CFLAGS += -finstrument-functions -ffixed-r10 else CFLAGS += -Os endif - - # common architecture-specific flags from the device-specific library makefile CFLAGS += $(ARCHFLAGS) CFLAGS += $(UAVOBJDEFINE) -CFLAGS += -DSTACK_DIAGNOSTICS -CFLAGS += -DMIXERSTATUS_DIAGNOSTICS -CFLAGS += -DRATEDESIRED_DIAGNOSTICS -CFLAGS += -DI2C_WDG_STATS_DIAGNOSTICS +CFLAGS += -DDIAG_STACK +CFLAGS += -DDIA_MIXERSTATUS +CFLAGS += -DDIAG_RATEDESIRED +CFLAGS += -DDIAG_I2C_WDG_STATS CFLAGS += -DDIAG_TASKS +# Or all of above: +#CFLAGS += -DDIAG_ALL # This is not the best place for these. Really should abstract out # to the board file or something @@ -350,7 +253,7 @@ LDFLAGS += $(addprefix -T,$(LINKER_SCRIPTS_APP)) # Define programs and commands. -REMOVE = $(REMOVE_CMD) -f +REMOVE = $(RM) -f # List of all source files. ALLSRC = $(ASRCARM) $(ASRC) $(SRCARM) $(SRC) $(CPPSRCARM) $(CPPSRC) @@ -384,7 +287,7 @@ endif # Link: create ELF output file from object files. -$(eval $(call LINK_TEMPLATE, $(OUTDIR)/$(TARGET).elf, $(ALLOBJ), $(ALLLIB))) +$(eval $(call LINK_TEMPLATE, $(OUTDIR)/$(TARGET).elf, $(ALLOBJ))) # Assemble: create object files from assembler source files. $(foreach src, $(ASRC), $(eval $(call ASSEMBLE_TEMPLATE, $(src)))) @@ -483,29 +386,21 @@ endif #create compile-time module auto-initialisation MODNAMES = ${notdir $(subst /revolution,,$(MODULES))} -# Test if quotes are needed for the echo-command -result = ${shell echo "test"} -ifeq (${result}, test) - quote = ' -else - quote = -endif - # Generate intermediate code gencode: ${OUTDIR}/InitMods.c ${OUTDIR}/pmlib_img.c ${OUTDIR}/pmlib_nat.c ${OUTDIR}/pmlibusr_img.c ${OUTDIR}/pmlibusr_nat.c ${OUTDIR}/pmfeatures.h # Generate code for module initialization ${OUTDIR}/InitMods.c: Makefile - @echo ${MSG_MODINIT} - @echo ${quote}// Autogenerated file${quote} > ${OUTDIR}/InitMods.c - @echo ${quote}${foreach MOD, ${MODNAMES}, extern unsigned int ${MOD}Initialize(void);}${quote} >> ${OUTDIR}/InitMods.c - @echo ${quote}${foreach MOD, ${MODNAMES}, extern unsigned int ${MOD}Start(void);}${quote} >> ${OUTDIR}/InitMods.c - @echo ${quote}void InitModules() {${quote} >> ${OUTDIR}/InitMods.c - @echo ${quote}${foreach MOD, ${MODNAMES}, ${MOD}Initialize();}${quote} >> ${OUTDIR}/InitMods.c - @echo ${quote}}${quote} >> ${OUTDIR}/InitMods.c - @echo ${quote}void StartModules() {${quote} >> ${OUTDIR}/InitMods.c - @echo ${quote}${foreach MOD, ${MODNAMES}, ${MOD}Start();}${quote} >> ${OUTDIR}/InitMods.c - @echo ${quote}}${quote} >> ${OUTDIR}/InitMods.c + $(V1) $(ECHO) $(MSG_MODINIT $(call toprel, $@)) + $(V1) $(ECHO) $(QUOTE)// Autogenerated file$(QUOTE) > ${OUTDIR}/InitMods.c + $(V1) $(ECHO) $(QUOTE)${foreach MOD, ${MODNAMES}, extern unsigned int ${MOD}Initialize(void);}$(QUOTE) >> ${OUTDIR}/InitMods.c + $(V1) $(ECHO) $(QUOTE)${foreach MOD, ${MODNAMES}, extern unsigned int ${MOD}Start(void);}$(QUOTE) >> ${OUTDIR}/InitMods.c + $(V1) $(ECHO) $(QUOTE)void InitModules() {$(QUOTE) >> ${OUTDIR}/InitMods.c + $(V1) $(ECHO) $(QUOTE)${foreach MOD, ${MODNAMES}, ${MOD}Initialize();}$(QUOTE) >> ${OUTDIR}/InitMods.c + $(V1) $(ECHO) $(QUOTE)}$(QUOTE) >> ${OUTDIR}/InitMods.c + $(V1) $(ECHO) $(QUOTE)void StartModules() {$(QUOTE) >> ${OUTDIR}/InitMods.c + $(V1) $(ECHO) $(QUOTE)${foreach MOD, ${MODNAMES}, ${MOD}Start();}$(QUOTE) >> ${OUTDIR}/InitMods.c + $(V1) $(ECHO) $(QUOTE)}$(QUOTE) >> ${OUTDIR}/InitMods.c # Listing of phony targets. .PHONY : all build clean clean_list install diff --git a/flight/targets/SimPosix/System/inc/op_config.h b/flight/targets/SimPosix/System/inc/op_config.h deleted file mode 100644 index 0fe9e2bdc..000000000 --- a/flight/targets/SimPosix/System/inc/op_config.h +++ /dev/null @@ -1,39 +0,0 @@ -/** - ****************************************************************************** - * @addtogroup OpenPilotSystem OpenPilot System - * @{ - * @addtogroup OpenPilotCore OpenPilot Core - * @{ - * - * @file op_config.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief OpenPilot configuration header. - * Compile time config for OpenPilot Application - * @see The GNU Public License (GPL) Version 3 - * - *****************************************************************************/ -/* - * 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 - */ - - -#ifndef OP_CONFIG_H -#define OP_CONFIG_H - -#endif /* OP_CONFIG_H */ -/** - * @} - * @} - */ diff --git a/flight/targets/SimPosix/System/inc/openpilot.h b/flight/targets/SimPosix/System/inc/openpilot.h index 0bbdf971b..5cad3ec7a 100644 --- a/flight/targets/SimPosix/System/inc/openpilot.h +++ b/flight/targets/SimPosix/System/inc/openpilot.h @@ -35,7 +35,6 @@ #include /* OpenPilot Libraries */ -#include "op_config.h" #include "utlist.h" #include "uavobjectmanager.h" #include "eventdispatcher.h" diff --git a/ground/openpilotgcs/src/app/gcsversioninfo.pri b/ground/openpilotgcs/src/app/gcsversioninfo.pri index 70bb8e475..c052a0d31 100644 --- a/ground/openpilotgcs/src/app/gcsversioninfo.pri +++ b/ground/openpilotgcs/src/app/gcsversioninfo.pri @@ -8,7 +8,7 @@ # Since debug_and_release option is set, we need this !debug_and_release|build_pass { ROOT_DIR = $$GCS_SOURCE_TREE/../.. - VERSION_INFO_HEADER = $$GCS_BUILD_TREE/gcsversioninfo.h + VERSION_INFO_HEADER = $$GCS_BUILD_TREE/../gcsversioninfo.h VERSION_INFO_SCRIPT = $$ROOT_DIR/make/scripts/version-info.py VERSION_INFO_TEMPLATE = $$ROOT_DIR/make/templates/gcsversioninfotemplate.h VERSION_INFO_COMMAND = python \"$$VERSION_INFO_SCRIPT\" diff --git a/ground/openpilotgcs/src/plugins/hitl/aerosimrc/src/plugin.pro b/ground/openpilotgcs/src/plugins/hitl/aerosimrc/src/plugin.pro index 2037bf0d5..27684421b 100644 --- a/ground/openpilotgcs/src/plugins/hitl/aerosimrc/src/plugin.pro +++ b/ground/openpilotgcs/src/plugins/hitl/aerosimrc/src/plugin.pro @@ -11,7 +11,7 @@ TEMPLATE = lib TARGET = plugin_AeroSIMRC RES_DIR = $${PWD}/resources -SIM_DIR = $$GCS_BUILD_TREE/../AeroSIM-RC +SIM_DIR = $$GCS_BUILD_TREE/misc/AeroSIM-RC PLUGIN_DIR = $$SIM_DIR/Plugin/CopterControl DLLDESTDIR = $$PLUGIN_DIR diff --git a/ground/openpilotgcs/src/plugins/uavobjects/uavobjects_dependencies.pri b/ground/openpilotgcs/src/plugins/uavobjects/uavobjects_dependencies.pri index 6dc1ed1a8..c6a079a29 100644 --- a/ground/openpilotgcs/src/plugins/uavobjects/uavobjects_dependencies.pri +++ b/ground/openpilotgcs/src/plugins/uavobjects/uavobjects_dependencies.pri @@ -2,7 +2,7 @@ include(../../plugins/coreplugin/coreplugin.pri) include(../../libs/utils/utils.pri) # Provide the path to the auto-generated uavobject source files for the GCS. -UAVOBJECT_SYNTHETICS=$${GCS_BUILD_TREE}/../../uavobject-synthetics/gcs +UAVOBJECT_SYNTHETICS=$${GCS_BUILD_TREE}/../../../uavobject-synthetics/gcs #message(UAVOBJECT_SYNTHETICS is $$UAVOBJECT_SYNTHETICS) # Add the include path to the auto-generated uavobject include files. diff --git a/ground/openpilotgcs/src/plugins/uploader/uploadergadgetwidget.cpp b/ground/openpilotgcs/src/plugins/uploader/uploadergadgetwidget.cpp index 1b6ae9f6b..2dd5ce8ea 100755 --- a/ground/openpilotgcs/src/plugins/uploader/uploadergadgetwidget.cpp +++ b/ground/openpilotgcs/src/plugins/uploader/uploadergadgetwidget.cpp @@ -491,7 +491,7 @@ void UploaderGadgetWidget::commonSystemBoot(bool safeboot) bool UploaderGadgetWidget::autoUpdateCapable() { - return QDir(":/build").exists(); + return QDir(":/firmware").exists(); } bool UploaderGadgetWidget::autoUpdate() @@ -560,20 +560,29 @@ bool UploaderGadgetWidget::autoUpdate() } QString filename; emit autoUpdateSignal(LOADING_FW,QVariant()); - switch (dfu->devices[0].ID) - { - case 0x401: - filename="fw_coptercontrol"; + switch (dfu->devices[0].ID) { + case 0x301: + filename = "fw_pipxtreme"; break; + case 0x401: case 0x402: - filename="fw_coptercontrol"; + filename = "fw_coptercontrol"; + break; + case 0x501: + filename = "fw_osd"; + break; + case 0x902: + filename = "fw_revolution"; + break; + case 0x903: + filename = "fw_revomini"; break; default: emit autoUpdateSignal(FAILURE,QVariant()); return false; break; } - filename=":/build/"+filename+"/"+filename+".opfw"; + filename = ":/firmware/" + filename + ".opfw"; QByteArray firmware; if(!QFile::exists(filename)) { diff --git a/make/apps-defs.mk b/make/apps-defs.mk new file mode 100644 index 000000000..3e2c86b37 --- /dev/null +++ b/make/apps-defs.mk @@ -0,0 +1,177 @@ +# +# Copyright (c) 2009-2013, The OpenPilot Team, http://www.openpilot.org +# +# 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 +# + +ifndef OPENPILOT_IS_COOL + $(error Top level Makefile must be used to build this target) +endif + +# Paths +TOPDIR = . +OPSYSTEM = $(TOPDIR)/System +OPSYSTEMINC = $(OPSYSTEM)/inc +PIOSINC = $(PIOS)/inc +PIOSCOMMON = $(PIOS)/Common +PIOSBOARDS = $(PIOS)/Boards +FLIGHTLIBINC = $(FLIGHTLIB)/inc + +## UAVTalk and UAVObject manager +OPUAVOBJINC = $(OPUAVOBJ)/inc +OPUAVTALKINC = $(OPUAVTALK)/inc + +## Math +MATHLIB = $(FLIGHTLIB)/math +MATHLIBINC = $(FLIGHTLIB)/math + +## FreeRTOS support +FREERTOS_DIR = $(PIOSCOMMON)/Libraries/FreeRTOS +include $(FREERTOS_DIR)/library.mk + +## Misc +DOXYGENDIR = $(ROOT_DIR)/flight/Doc/Doxygen +OPTESTS = $(TOPDIR)/Tests + +## PIOS Hardware +ifeq ($(MCU),cortex-m3) + include $(PIOS)/STM32F10x/library.mk +else ifeq ($(MCU),cortex-m4) + include $(PIOS)/STM32F4xx/library.mk +else + $(error Unsupported MCU: $(MCU)) +endif + +# List C source files here (C dependencies are automatically generated). +# Use file-extension c for "c-only"-files + +## PIOS Hardware (Common Peripherals) +SRC += $(PIOSCOMMON)/pios_adxl345.c +SRC += $(PIOSCOMMON)/pios_bma180.c +SRC += $(PIOSCOMMON)/pios_bmp085.c +SRC += $(PIOSCOMMON)/pios_etasv3.c +SRC += $(PIOSCOMMON)/pios_gcsrcvr.c +SRC += $(PIOSCOMMON)/pios_hcsr04.c +SRC += $(PIOSCOMMON)/pios_hmc5843.c +SRC += $(PIOSCOMMON)/pios_hmc5883.c +SRC += $(PIOSCOMMON)/pios_i2c_esc.c +SRC += $(PIOSCOMMON)/pios_l3gd20.c +SRC += $(PIOSCOMMON)/pios_mpu6000.c +SRC += $(PIOSCOMMON)/pios_mpxv.c +SRC += $(PIOSCOMMON)/pios_ms5611.c +SRC += $(PIOSCOMMON)/pios_video.c +SRC += $(PIOSCOMMON)/pios_wavplay.c + +## PIOS Hardware (Common) +SRC += $(PIOSCOMMON)/pios_com.c +SRC += $(PIOSCOMMON)/pios_com_msg.c +SRC += $(PIOSCOMMON)/pios_crc.c +SRC += $(PIOSCOMMON)/pios_flashfs_logfs.c +SRC += $(PIOSCOMMON)/pios_flash_jedec.c +SRC += $(PIOSCOMMON)/pios_rcvr.c +SRC += $(PIOSCOMMON)/pios_rfm22b.c +SRC += $(PIOSCOMMON)/pios_rfm22b_com.c +SRC += $(PIOSCOMMON)/pios_rfm22b_rcvr.c +SRC += $(PIOSCOMMON)/pios_sbus.c +SRC += $(PIOSCOMMON)/pios_sdcard.c + +## PIOS USB related files +SRC += $(PIOSCOMMON)/pios_usb_desc_hid_cdc.c +SRC += $(PIOSCOMMON)/pios_usb_desc_hid_only.c +SRC += $(PIOSCOMMON)/pios_usb_util.c + +## Misc library functions +SRC += $(FLIGHTLIB)/fifo_buffer.c +SRC += $(FLIGHTLIB)/taskmonitor.c +SRC += $(FLIGHTLIB)/sanitycheck.c +SRC += $(FLIGHTLIB)/CoordinateConversions.c +SRC += $(MATHLIB)/sin_lookup.c +SRC += $(MATHLIB)/pid.c + +## Modules +SRC += $(foreach mod, $(MODULES), $(wildcard $(OPMODULEDIR)/$(mod)/*.c)) +SRC += $(foreach mod, $(OPTMODULES), $(wildcard $(OPMODULEDIR)/$(mod)/*.c)) + +# Declare all non-optional modules as built-in to force inclusion. +# Built-in modules are always enabled and cannot be disabled. +MODNAMES := $(notdir $(subst /revolution,,$(MODULES))) +MODULES_BUILTIN := $(foreach mod, $(MODNAMES), -DMODULE_$(shell $(ECHO) $(mod) | tr '[:lower:]' '[:upper:]')_BUILTIN) +CDEFS += $(MODULES_BUILTIN) + +# List C source files here which must be compiled in ARM-Mode (no -mthumb). +# Use file-extension c for "c-only"-files +SRCARM += + +# List C++ source files here. +# Use file-extension .cpp for C++-files (not .C) +CPPSRC += + +# List C++ source files here which must be compiled in ARM-Mode. +# Use file-extension .cpp for C++-files (not .C) +CPPSRCARM += + +# List Assembler source files here. +# Make them always end in a capital .S. Files ending in a lowercase .s +# will not be considered source files but generated files (assembler +# output from the compiler), and will be deleted upon "make clean"! +# Even though the DOS/Win* filesystem matches both .s and .S the same, +# it will preserve the spelling of the filenames, and gcc itself does +# care about how the name is spelled on its command-line. +ASRC += + +# List Assembler source files here which must be assembled in ARM-Mode. +ASRCARM += + +# List any extra directories to look for include files here. +# Each directory must be seperated by a space. +EXTRAINCDIRS += $(PIOS) +EXTRAINCDIRS += $(PIOSINC) +EXTRAINCDIRS += $(FLIGHTLIBINC) +EXTRAINCDIRS += $(PIOSCOMMON) +EXTRAINCDIRS += $(PIOSBOARDS) +EXTRAINCDIRS += $(HWDEFSINC) +EXTRAINCDIRS += $(OPSYSTEMINC) +EXTRAINCDIRS += $(MATHLIBINC) +EXTRAINCDIRS += $(OPUAVOBJINC) +EXTRAINCDIRS += $(OPUAVTALKINC) +EXTRAINCDIRS += $(OPUAVSYNTHDIR) + +# Modules +EXTRAINCDIRS += $(foreach mod, $(OPTMODULES) $(MODULES), $(OPMODULEDIR)/$(mod)/inc) $(OPMODULEDIR)/System/inc + +# List any extra directories to look for library files here. +# Also add directories where the linker should search for +# includes from linker-script to the list +# Each directory must be seperated by a space. +EXTRA_LIBDIRS += + +# Extra Libraries +# Each library-name must be seperated by a space. +# i.e. to link with libxyz.a, libabc.a and libefsl.a: +# EXTRA_LIBS = xyz abc efsl +# for newlib-lpc (file: libnewlibc-lpc.a): +# EXTRA_LIBS = newlib-lpc +EXTRA_LIBS += m + +# Compiler flags +CFLAGS += + +# Set linker-script name depending on selected submodel name +ifeq ($(MCU),cortex-m3) + LDFLAGS += -T$(LINKER_SCRIPTS_PATH)/link_$(BOARD)_memory.ld + LDFLAGS += -T$(LINKER_SCRIPTS_PATH)/link_$(BOARD)_sections.ld +else ifeq ($(MCU),cortex-m4) + LDFLAGS += $(addprefix -T,$(LINKER_SCRIPTS_APP)) +endif diff --git a/make/boards/ahrs/board-info.mk b/make/boards/ahrs/board-info.mk deleted file mode 100644 index 85135ea25..000000000 --- a/make/boards/ahrs/board-info.mk +++ /dev/null @@ -1,20 +0,0 @@ -BOARD_TYPE := 0x02 -BOARD_REVISION := 0x01 -BOOTLOADER_VERSION := 0x00 -HW_TYPE := 0x00 - -MCU := cortex-m3 -CHIP := STM32F103CBT -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 -FW_BANK_BASE := 0x08002000 # Start of firmware flash -FW_BANK_SIZE := 0x0001E000 # Should include FW_DESC_SIZE - -FW_DESC_SIZE := 0x00000064 diff --git a/make/boot-defs.mk b/make/boot-defs.mk new file mode 100644 index 000000000..5c0bbf32e --- /dev/null +++ b/make/boot-defs.mk @@ -0,0 +1,128 @@ +# +# Copyright (c) 2009-2013, The OpenPilot Team, http://www.openpilot.org +# +# 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 +# + +ifndef OPENPILOT_IS_COOL + $(error Top level Makefile must be used to build this target) +endif + +# Paths +TOPDIR = . +OPSYSTEM = $(TOPDIR) +OPSYSTEMINC = $(OPSYSTEM)/inc +PIOSINC = $(PIOS)/inc +PIOSCOMMON = $(PIOS)/Common +PIOSBOARDS = $(PIOS)/Boards +FLIGHTLIBINC = $(FLIGHTLIB)/inc + +# ARM DSP library +override USE_DSP_LIB := NO + +## PIOS Hardware +ifeq ($(MCU),cortex-m3) + include $(PIOS)/STM32F10x/library.mk +else ifeq ($(MCU),cortex-m4) + include $(PIOS)/STM32F4xx/library.mk +else + $(error Unsupported MCU: $(MCU)) +endif + +# List C source files here (C dependencies are automatically generated). +# Use file-extension c for "c-only"-files + +## Bootloader Core +SRC += $(OPSYSTEM)/main.c +SRC += $(OPSYSTEM)/pios_board.c +SRC += $(OPSYSTEM)/pios_usb_board_data.c +SRC += $(OPSYSTEM)/op_dfu.c + +## PIOS Hardware (Common) +SRC += $(PIOSCOMMON)/pios_board_info.c +SRC += $(PIOSCOMMON)/pios_com_msg.c +SRC += $(PIOSCOMMON)/pios_usb_desc_hid_only.c +SRC += $(PIOSCOMMON)/pios_usb_util.c + +## Misc library functions +SRC += $(FLIGHTLIB)/printf-stdarg.c + +# List C source files here which must be compiled in ARM-Mode (no -mthumb). +# Use file-extension c for "c-only"-files +SRCARM += + +# List C++ source files here. +# Use file-extension .cpp for C++-files (not .C) +CPPSRC += + +# List C++ source files here which must be compiled in ARM-Mode. +# Use file-extension .cpp for C++-files (not .C) +CPPSRCARM += + +# List Assembler source files here. +# Make them always end in a capital .S. Files ending in a lowercase .s +# will not be considered source files but generated files (assembler +# output from the compiler), and will be deleted upon "make clean"! +# Even though the DOS/Win* filesystem matches both .s and .S the same, +# it will preserve the spelling of the filenames, and gcc itself does +# care about how the name is spelled on its command-line. +ASRC += + +# List Assembler source files here which must be assembled in ARM-Mode. +ASRCARM += + +# List any extra directories to look for include files here. +# Each directory must be seperated by a space. +EXTRAINCDIRS += $(PIOS) +EXTRAINCDIRS += $(PIOSINC) +EXTRAINCDIRS += $(FLIGHTLIBINC) +EXTRAINCDIRS += $(PIOSCOMMON) +EXTRAINCDIRS += $(PIOSBOARDS) +EXTRAINCDIRS += $(HWDEFSINC) +EXTRAINCDIRS += $(OPSYSTEMINC) + +# List any extra directories to look for library files here. +# Also add directories where the linker should search for +# includes from linker-script to the list +# Each directory must be seperated by a space. +EXTRA_LIBDIRS += + +# Extra Libraries +# Each library-name must be seperated by a space. +# i.e. to link with libxyz.a, libabc.a and libefsl.a: +# EXTRA_LIBS = xyz abc efsl +# for newlib-lpc (file: libnewlibc-lpc.a): +# 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) + +# Set linker-script name depending on selected submodel name +ifeq ($(MCU),cortex-m3) + LDFLAGS += -T$(LINKER_SCRIPTS_PATH)/link_$(BOARD)_memory.ld + LDFLAGS += -T$(LINKER_SCRIPTS_PATH)/link_$(BOARD)_BL_sections.ld +else ifeq ($(MCU),cortex-m4) + LDFLAGS += $(addprefix -T,$(LINKER_SCRIPTS_BL)) +endif diff --git a/make/common-defs.mk b/make/common-defs.mk new file mode 100644 index 000000000..60be74a6f --- /dev/null +++ b/make/common-defs.mk @@ -0,0 +1,279 @@ +# +# Copyright (c) 2009-2013, The OpenPilot Team, http://www.openpilot.org +# +# 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 +# + +ifndef OPENPILOT_IS_COOL + $(error Top level Makefile must be used to build this target) +endif + +# Set to YES to compile for debugging +DEBUG ?= NO + +# Set to YES to use the Servo output pins for debugging via scope or logic analyser +ENABLE_DEBUG_PINS ?= NO + +# Set to YES to enable the AUX UART which is mapped on the S1 (Tx) and S2 (Rx) servo outputs +ENABLE_AUX_UART ?= NO + +# Include objects that are just nice information to show +DIAG_STACK ?= NO +DIAG_MIXERSTATUS ?= NO +DIAG_RATEDESIRED ?= NO +DIAG_I2C_WDG_STATS ?= NO +DIAG_TASKS ?= NO + +# Or just turn on all the above diagnostics. WARNING: this consumes massive amounts of memory. +DIAG_ALL ?= NO + +# Optimization level, can be [0, 1, 2, 3, s]. +# 0 = turn off optimization. s = optimize for size. +# Note: 3 is not always the best optimization level. +ifeq ($(DEBUG), YES) + OPT = 0 +else + OPT = s +endif + +# Output format (can be ihex or binary or both). +# binary to create a load-image in raw-binary format i.e. for SAM-BA, +# ihex to create a load-image in Intel hex format +#LOADFORMAT = ihex +#LOADFORMAT = binary +LOADFORMAT = both + +# Debugging format. +DEBUGF = dwarf-2 + +# Place project-specific -D (define) and/or -U options for C here. +CDEFS += -DUSE_$(BOARD) + +ifeq ($(ENABLE_DEBUG_PINS), YES) + CDEFS += -DPIOS_ENABLE_DEBUG_PINS +endif + +ifeq ($(ENABLE_AUX_UART), YES) + CDEFS += -DPIOS_ENABLE_AUX_UART +endif + +# The following Makefile command, ifneq (,$(filter) $(A), $(B) $(C)) +# is equivalent to the pseudocode `if (A == B || A == C)` +ifneq (,$(filter YES,$(DIAG_STACK) $(DIAG_ALL))) + CFLAGS += -DDIAG_STACK +endif + +ifneq (,$(filter YES,$(DIAG_MIXERSTATUS) $(DIAG_ALL))) + CFLAGS += -DDIAG_MIXERSTATUS +endif + +ifneq (,$(filter YES,$(DIAG_RATEDESIRED) $(DIAG_ALL))) + CFLAGS += -DDIAG_RATEDESIRED +endif + +ifneq (,$(filter YES,$(DIAG_I2C_WDG_STATS) $(DIAG_ALL))) + CFLAGS += -DDIAG_I2C_WDG_STATS +endif + +ifneq (,$(filter YES,$(DIAG_TASKS) $(DIAG_ALL))) + CFLAGS += -DDIAG_TASKS +endif + +# Place project-specific -D and/or -U options for Assembler with preprocessor here. +#ADEFS = -DUSE_IRQ_ASM_WRAPPER +ADEFS = -D__ASSEMBLY__ + +# Compiler flag to set the C Standard level. +# c89 - "ANSI" C +# gnu89 - c89 plus GCC extensions +# c99 - ISO C99 standard (not yet fully implemented) +# gnu99 - c99 plus GCC extensions +CSTANDARD = -std=gnu99 + +# Compiler flags. +# +# -g*: generate debugging information +# -O*: optimization level +# -f...: tuning, see GCC manual and avr-libc documentation +# -Wall...: warning level +# -Wa,...: tell GCC to pass this to the assembler. +# -adhlns...: create assembler listing + +# Common architecture-specific flags from the device-specific library makefile +CFLAGS += $(ARCHFLAGS) +CFLAGS += $(CDEFS) +CFLAGS += -O$(OPT) +CFLAGS += -g$(DEBUGF) +CFLAGS += -mapcs-frame +CFLAGS += -fomit-frame-pointer +CFLAGS += -Wall +CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) -I. +CFLAGS += -Wa,-adhlns=$(addprefix $(OUTDIR)/, $(notdir $(addsuffix .lst, $(basename $<)))) + +# FIXME: STM32F4xx library raises strict aliasing and const qualifier warnings +ifneq ($(MCU),cortex-m4) + CFLAGS += -Werror +endif + +ifeq ($(DEBUG), YES) + CFLAGS += -DDEBUG +else + CFLAGS += -fdata-sections -ffunction-sections +endif + +# Compiler flags to generate dependency files +CFLAGS += -MD -MP -MF $(OUTDIR)/dep/$(@F).d + +# Flags only for C +#CONLYFLAGS += -Wnested-externs +CONLYFLAGS += $(CSTANDARD) + +# Assembler flags. +# -Wa,...: tell GCC to pass this to the assembler. +# -ahlns: create listing +ASFLAGS = -mcpu=$(MCU) -I. -x assembler-with-cpp +ASFLAGS += $(ADEFS) +ASFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) +ASFLAGS += -Wa,-adhlns=$(addprefix $(OUTDIR)/, $(notdir $(addsuffix .lst, $(basename $<)))) + +# Linker flags. +# -Wl,...: tell GCC to pass this to linker. +# -Map: create map file +# --cref: add cross reference to map file +LDFLAGS += -nostartfiles +LDFLAGS += -Wl,--warn-common,--fatal-warnings,--gc-sections +LDFLAGS += -Wl,-Map=$(OUTDIR)/$(TARGET).map,--cref +LDFLAGS += $(patsubst %,-L%,$(EXTRA_LIBDIRS)) +LDFLAGS += $(patsubst %,-l%,$(EXTRA_LIBS)) +LDFLAGS += -lc -lgcc + +ifneq ($(DEBUG), YES) + LDFLAGS += -Wl,-static +endif + +# List of all source files. +ALLSRC = $(ASRCARM) $(ASRC) $(SRCARM) $(SRC) $(CPPSRCARM) $(CPPSRC) +# List of all source files without directory and file-extension. +ALLSRCBASE = $(notdir $(basename $(ALLSRC))) + +# Define all object files. +ALLOBJ = $(addprefix $(OUTDIR)/, $(addsuffix .o, $(ALLSRCBASE))) $(EXTRAOBJ) + +# Define all listing files (used for make clean). +LSTFILES = $(addprefix $(OUTDIR)/, $(addsuffix .lst, $(ALLSRCBASE))) +# Define all depedency-files (used for make clean). +DEPFILES = $(addprefix $(OUTDIR)/dep/, $(addsuffix .o.d, $(ALLSRCBASE))) + +# Default target. +all: build + +ifeq ($(LOADFORMAT),ihex) +build: elf hex sym +else ifeq ($(LOADFORMAT),binary) +build: elf bin sym +else ifeq ($(LOADFORMAT),both) +build: elf hex bin sym +else + $(error "$(MSG_FORMATERROR) $(FORMAT)") +endif + +# Generate code for PyMite +# $(OUTDIR)/pmlib_img.c $(OUTDIR)/pmlib_nat.c $(OUTDIR)/pmlibusr_img.c $(OUTDIR)/pmlibusr_nat.c $(OUTDIR)/pmfeatures.h: $(wildcard $(PYMITELIB)/*.py) $(wildcard $(PYMITEPLAT)/*.py) $(wildcard $(FLIGHTPLANLIB)/*.py) $(wildcard $(FLIGHTPLANS)/*.py) +# @$(ECHO) $(MSG_PYMITEINIT) $(call toprel, $@) +# @$(PYTHON) $(PYMITETOOLS)/pmImgCreator.py -f $(PYMITEPLAT)/pmfeatures.py -c -s --memspace=flash -o $(OUTDIR)/pmlib_img.c --native-file=$(OUTDIR)/pmlib_nat.c $(PYMITELIB)/list.py $(PYMITELIB)/dict.py $(PYMITELIB)/__bi.py $(PYMITELIB)/sys.py $(PYMITELIB)/string.py $(wildcard $(FLIGHTPLANLIB)/*.py) +# @$(PYTHON) $(PYMITETOOLS)/pmGenPmFeatures.py $(PYMITEPLAT)/pmfeatures.py > $(OUTDIR)/pmfeatures.h +# @$(PYTHON) $(PYMITETOOLS)/pmImgCreator.py -f $(PYMITEPLAT)/pmfeatures.py -c -u -o $(OUTDIR)/pmlibusr_img.c --native-file=$(OUTDIR)/pmlibusr_nat.c $(FLIGHTPLANS)/test.py + +# Link: create ELF output file from object files. +$(eval $(call LINK_TEMPLATE, $(OUTDIR)/$(TARGET).elf, $(ALLOBJ), $(ALLLIB))) + +# Assemble: create object files from assembler source files. +$(foreach src, $(ASRC), $(eval $(call ASSEMBLE_TEMPLATE, $(src)))) + +# Assemble: create object files from assembler source files. ARM-only +$(foreach src, $(ASRCARM), $(eval $(call ASSEMBLE_ARM_TEMPLATE, $(src)))) + +# Compile: create object files from C source files. +$(foreach src, $(SRC), $(eval $(call COMPILE_C_TEMPLATE, $(src)))) + +# Compile: create object files from C source files. ARM-only +$(foreach src, $(SRCARM), $(eval $(call COMPILE_C_ARM_TEMPLATE, $(src)))) + +# Compile: create object files from C++ source files. +$(foreach src, $(CPPSRC), $(eval $(call COMPILE_CPP_TEMPLATE, $(src)))) + +# Compile: create object files from C++ source files. ARM-only +$(foreach src, $(CPPSRCARM), $(eval $(call COMPILE_CPP_ARM_TEMPLATE, $(src)))) + +# Compile: create assembler files from C source files. ARM/Thumb +$(eval $(call PARTIAL_COMPILE_TEMPLATE, SRC)) + +# Compile: create assembler files from C source files. ARM only +$(eval $(call PARTIAL_COMPILE_ARM_TEMPLATE, SRCARM)) + +$(OUTDIR)/$(TARGET).bin.o: $(OUTDIR)/$(TARGET).bin + +# Add opfw target +$(eval $(call OPFW_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(BOARD_TYPE),$(BOARD_REVISION))) + +# Add jtag targets (program and wipe) +$(eval $(call JTAG_TEMPLATE,$(OUTDIR)/$(TARGET).bin,$(BL_BANK_BASE),$(BL_BANK_SIZE),$(OPENOCD_JTAG_CONFIG),$(OPENOCD_CONFIG))) + +.PHONY: elf lss sym hex bin bino opfw +elf: $(OUTDIR)/$(TARGET).elf +lss: $(OUTDIR)/$(TARGET).lss +sym: $(OUTDIR)/$(TARGET).sym +hex: $(OUTDIR)/$(TARGET).hex +bin: $(OUTDIR)/$(TARGET).bin +bino: $(OUTDIR)/$(TARGET).bin.o +opfw: $(OUTDIR)/$(TARGET).opfw + +# Display sizes of sections. +$(eval $(call SIZE_TEMPLATE, $(OUTDIR)/$(TARGET).elf)) + +# Generate Doxygen documents +docs: + doxygen $(DOXYGENDIR)/doxygen.cfg + +# Target: clean project +clean: + @echo $(MSG_CLEANING) + $(V1) $(RM) -f $(OUTDIR)/$(TARGET).map + $(V1) $(RM) -f $(OUTDIR)/$(TARGET).elf + $(V1) $(RM) -f $(OUTDIR)/$(TARGET).hex + $(V1) $(RM) -f $(OUTDIR)/$(TARGET).bin + $(V1) $(RM) -f $(OUTDIR)/$(TARGET).sym + $(V1) $(RM) -f $(OUTDIR)/$(TARGET).lss + $(V1) $(RM) -f $(OUTDIR)/$(TARGET).bin.o + $(V1) $(RM) -f $(OUTDIR)/$(TARGET).opfw + $(V1) $(RM) -f $(wildcard $(OUTDIR)/*.c) + $(V1) $(RM) -f $(wildcard $(OUTDIR)/*.h) + $(V1) $(RM) -f $(ALLOBJ) + $(V1) $(RM) -f $(LSTFILES) + $(V1) $(RM) -f $(DEPFILES) + $(V1) $(RM) -f $(SRC:.c=.s) + $(V1) $(RM) -f $(SRCARM:.c=.s) + $(V1) $(RM) -f $(CPPSRC:.cpp=.s) + $(V1) $(RM) -f $(CPPSRCARM:.cpp=.s) + +# Create output files directory +# all known MS Windows OS define the ComSpec environment variable +$(shell $(MKDIR) -p $(OUTDIR) 2>/dev/null) + +# Include the dependency files. +-include $(shell $(MKDIR) -p $(OUTDIR)/dep 2>/dev/null) $(wildcard $(OUTDIR)/dep/*) + +# Listing of phony targets. +.PHONY: all build clean install diff --git a/make/firmware-defs.mk b/make/firmware-defs.mk index 62eee394a..6da1281ef 100644 --- a/make/firmware-defs.mk +++ b/make/firmware-defs.mk @@ -1,93 +1,103 @@ -# Toolchain prefix (i.e arm-elf- -> arm-elf-gcc.exe) -TCHAIN_PREFIX ?= arm-none-eabi- +# +# Copyright (c) 2010-2013, The OpenPilot Team, http://www.openpilot.org +# +# 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 +# + +ifndef OPENPILOT_IS_COOL + $(error Top level Makefile must be used to build this target) +endif # Define toolchain component names. -CC = $(TCHAIN_PREFIX)gcc -CXX = $(TCHAIN_PREFIX)g++ -AR = $(TCHAIN_PREFIX)ar -OBJCOPY = $(TCHAIN_PREFIX)objcopy -OBJDUMP = $(TCHAIN_PREFIX)objdump -SIZE = $(TCHAIN_PREFIX)size -NM = $(TCHAIN_PREFIX)nm -STRIP = $(TCHAIN_PREFIX)strip -INSTALL = install +CC = $(ARM_SDK_PREFIX)gcc +CXX = $(ARM_SDK_PREFIX)g++ +AR = $(ARM_SDK_PREFIX)ar +OBJCOPY = $(ARM_SDK_PREFIX)objcopy +OBJDUMP = $(ARM_SDK_PREFIX)objdump +SIZE = $(ARM_SDK_PREFIX)size +NM = $(ARM_SDK_PREFIX)nm +STRIP = $(ARM_SDK_PREFIX)strip THUMB = -mthumb -# Test if quotes are needed for the echo-command -result = ${shell echo "test"} -ifeq (${result}, test) - quote = ' -# This line is just to clear out the single quote above ' -else - quote = -endif - # Add a board designator to the terse message text ifeq ($(ENABLE_MSG_EXTRA),yes) - MSG_EXTRA := [$(BUILD_TYPE)|$(BOARD_SHORT_NAME)] + MSG_EXTRA := [$(BUILD_TYPE)|$(BOARD_SHORT_NAME)] else - MSG_BOARD := + MSG_EXTRA := endif # Define Messages -# English -MSG_FORMATERROR = ${quote} Can not handle output-format${quote} -MSG_MODINIT = ${quote} MODINIT $(MSG_EXTRA) ${quote} -MSG_SIZE = ${quote} SIZE $(MSG_EXTRA) ${quote} -MSG_LOAD_FILE = ${quote} BIN/HEX $(MSG_EXTRA) ${quote} -MSG_BIN_OBJ = ${quote} BINO $(MSG_EXTRA) ${quote} -MSG_STRIP_FILE = ${quote} STRIP $(MSG_EXTRA) ${quote} -MSG_EXTENDED_LISTING = ${quote} LIS $(MSG_EXTRA) ${quote} -MSG_SYMBOL_TABLE = ${quote} NM $(MSG_EXTRA) ${quote} -MSG_ARCHIVING = ${quote} AR $(MSG_EXTRA) ${quote} -MSG_LINKING = ${quote} LD $(MSG_EXTRA) ${quote} -MSG_COMPILING = ${quote} CC ${MSG_EXTRA} ${quote} -MSG_COMPILING_ARM = ${quote} CC-ARM $(MSG_EXTRA) ${quote} -MSG_COMPILINGCXX = ${quote} CXX $(MSG_EXTRA) ${quote} -MSG_COMPILINGCXX_ARM = ${quote} CXX-ARM $(MSG_EXTRA) ${quote} -MSG_ASSEMBLING = ${quote} AS $(MSG_EXTRA) ${quote} -MSG_ASSEMBLING_ARM = ${quote} AS-ARM $(MSG_EXTRA) ${quote} -MSG_CLEANING = ${quote} CLEAN $(MSG_EXTRA) ${quote} -MSG_ASMFROMC = ${quote} AS(C) $(MSG_EXTRA) ${quote} -MSG_ASMFROMC_ARM = ${quote} AS(C)-ARM $(MSG_EXTRA) ${quote} -MSG_PYMITEINIT = ${quote} PY $(MSG_EXTRA) ${quote} -MSG_INSTALLING = ${quote} INSTALL $(MSG_EXTRA) ${quote} -MSG_OPFIRMWARE = ${quote} OPFW $(MSG_EXTRA) ${quote} -MSG_FWINFO = ${quote} FWINFO $(MSG_EXTRA) ${quote} -MSG_JTAG_PROGRAM = ${quote} JTAG-PGM $(MSG_EXTRA) ${quote} -MSG_JTAG_WIPE = ${quote} JTAG-WIPE $(MSG_EXTRA) ${quote} -MSG_PADDING = ${quote} PADDING $(MSG_EXTRA) ${quote} -MSG_FLASH_IMG = ${quote} FLASH_IMG $(MSG_EXTRA) ${quote} +MSG_FORMATERROR = $(QUOTE) Can not handle output-format$(QUOTE) +MSG_MODINIT = $(QUOTE) MODINIT $(MSG_EXTRA) $(QUOTE) +MSG_SIZE = $(QUOTE) SIZE $(MSG_EXTRA) $(QUOTE) +MSG_LOAD_FILE = $(QUOTE) BIN/HEX $(MSG_EXTRA) $(QUOTE) +MSG_BIN_OBJ = $(QUOTE) BINO $(MSG_EXTRA) $(QUOTE) +MSG_STRIP_FILE = $(QUOTE) STRIP $(MSG_EXTRA) $(QUOTE) +MSG_EXTENDED_LISTING = $(QUOTE) LIS $(MSG_EXTRA) $(QUOTE) +MSG_SYMBOL_TABLE = $(QUOTE) NM $(MSG_EXTRA) $(QUOTE) +MSG_ARCHIVING = $(QUOTE) AR $(MSG_EXTRA) $(QUOTE) +MSG_LINKING = $(QUOTE) LD $(MSG_EXTRA) $(QUOTE) +MSG_COMPILING = $(QUOTE) CC $(MSG_EXTRA) $(QUOTE) +MSG_COMPILING_ARM = $(QUOTE) CC-ARM $(MSG_EXTRA) $(QUOTE) +MSG_COMPILINGCXX = $(QUOTE) CXX $(MSG_EXTRA) $(QUOTE) +MSG_COMPILINGCXX_ARM = $(QUOTE) CXX-ARM $(MSG_EXTRA) $(QUOTE) +MSG_ASSEMBLING = $(QUOTE) AS $(MSG_EXTRA) $(QUOTE) +MSG_ASSEMBLING_ARM = $(QUOTE) AS-ARM $(MSG_EXTRA) $(QUOTE) +MSG_CLEANING = $(QUOTE) CLEAN $(MSG_EXTRA) $(QUOTE) +MSG_ASMFROMC = $(QUOTE) AS(C) $(MSG_EXTRA) $(QUOTE) +MSG_ASMFROMC_ARM = $(QUOTE) AS(C)-ARM $(MSG_EXTRA) $(QUOTE) +MSG_PYMITEINIT = $(QUOTE) PY $(MSG_EXTRA) $(QUOTE) +MSG_INSTALLING = $(QUOTE) INSTALL $(MSG_EXTRA) $(QUOTE) +MSG_OPFIRMWARE = $(QUOTE) OPFW $(MSG_EXTRA) $(QUOTE) +MSG_FWINFO = $(QUOTE) FWINFO $(MSG_EXTRA) $(QUOTE) +MSG_JTAG_PROGRAM = $(QUOTE) JTAG-PGM $(MSG_EXTRA) $(QUOTE) +MSG_JTAG_WIPE = $(QUOTE) JTAG-WIPE $(MSG_EXTRA) $(QUOTE) +MSG_PADDING = $(QUOTE) PADDING $(MSG_EXTRA) $(QUOTE) +MSG_FLASH_IMG = $(QUOTE) FLASH_IMG $(MSG_EXTRA) $(QUOTE) -toprel = $(subst $(realpath $(TOP))/,,$(abspath $(1))) +# Function for converting an absolute path to one relative +# to the top of the source tree. +toprel = $(subst $(realpath $(ROOT_DIR))/,,$(abspath $(1))) # Display compiler version information. .PHONY: gccversion -gccversion : +gccversion: @$(CC) --version # Create final output file (.hex) from ELF output file. %.hex: %.elf - @echo $(MSG_LOAD_FILE) $(call toprel, $@) + @$(ECHO) $(MSG_LOAD_FILE) $(call toprel, $@) $(V1) $(OBJCOPY) -O ihex $< $@ # Create stripped output file (.elf.stripped) from ELF output file. %.elf.stripped: %.elf - @echo $(MSG_STRIP_FILE) $(call toprel, $@) + @$(ECHO) $(MSG_STRIP_FILE) $(call toprel, $@) $(V1) $(STRIP) --strip-unneeded $< -o $@ # Create final output file (.bin) from ELF output file. %.bin: %.elf - @echo $(MSG_LOAD_FILE) $(call toprel, $@) + @$(ECHO) $(MSG_LOAD_FILE) $(call toprel, $@) $(V1) $(OBJCOPY) -O binary $< $@ %.bin: %.o - @echo $(MSG_LOAD_FILE) $(call toprel, $@) + @$(ECHO) $(MSG_LOAD_FILE) $(call toprel, $@) $(V1) $(OBJCOPY) -O binary $< $@ %.bin.o: %.bin - @echo $(MSG_BIN_OBJ) $(call toprel, $@) + @$(ECHO) $(MSG_BIN_OBJ) $(call toprel, $@) $(V1) $(OBJCOPY) -I binary -O elf32-littlearm --binary-architecture arm \ --rename-section .data=.rodata,alloc,load,readonly,data,contents \ --wildcard \ @@ -99,12 +109,12 @@ gccversion : # Create extended listing file/disassambly from ELF output file. # using objdump testing: option -C %.lss: %.elf - @echo $(MSG_EXTENDED_LISTING) $(call toprel, $@) + @$(ECHO) $(MSG_EXTENDED_LISTING) $(call toprel, $@) $(V1) $(OBJDUMP) -h -S -C -r $< > $@ # Create a symbol table from ELF output file. %.sym: %.elf - @echo $(MSG_SYMBOL_TABLE) $(call toprel, $@) + @$(ECHO) $(MSG_SYMBOL_TABLE) $(call toprel, $@) $(V1) $(NM) -n $< > $@ define SIZE_TEMPLATE @@ -113,7 +123,7 @@ size: $(1)_size .PHONY: $(1)_size $(1)_size: $(1) - @echo $(MSG_SIZE) $$(call toprel, $$<) + @$(ECHO) $(MSG_SIZE) $$(call toprel, $$<) $(V1) $(SIZE) -A $$< endef @@ -124,63 +134,62 @@ endef define OPFW_TEMPLATE FORCE: -$(1).firmwareinfo.c: $(1) $(TOP)/make/templates/firmwareinfotemplate.c FORCE - @echo $(MSG_FWINFO) $$(call toprel, $$@) - $(V1) python $(TOP)/make/scripts/version-info.py \ - --path=$(TOP) \ - --template=$(TOP)/make/templates/firmwareinfotemplate.c \ +$(1).firmwareinfo.c: $(1) $(ROOT_DIR)/make/templates/firmwareinfotemplate.c FORCE + @$(ECHO) $(MSG_FWINFO) $$(call toprel, $$@) + $(V1) $(VERSION_INFO) \ + --template=$(ROOT_DIR)/make/templates/firmwareinfotemplate.c \ --outfile=$$@ \ --image=$(1) \ --type=$(2) \ --revision=$(3) \ - --uavodir=$(TOP)/shared/uavobjectdefinition + --uavodir=$(ROOT_DIR)/shared/uavobjectdefinition $(eval $(call COMPILE_C_TEMPLATE, $(1).firmwareinfo.c)) $(OUTDIR)/$(notdir $(basename $(1))).opfw : $(1) $(1).firmwareinfo.bin - @echo $(MSG_OPFIRMWARE) $$(call toprel, $$@) - $(V1) cat $(1) $(1).firmwareinfo.bin > $$@ + @$(ECHO) $(MSG_OPFIRMWARE) $$(call toprel, $$@) + $(V1) $(CAT) $(1) $(1).firmwareinfo.bin > $$@ endef # Assemble: create object files from assembler source files. define ASSEMBLE_TEMPLATE $(OUTDIR)/$(notdir $(basename $(1))).o : $(1) - @echo $(MSG_ASSEMBLING) $$(call toprel, $$<) + @$(ECHO) $(MSG_ASSEMBLING) $$(call toprel, $$<) $(V1) $(CC) -c $(THUMB) $$(ASFLAGS) $$< -o $$@ endef # Assemble: create object files from assembler source files. ARM-only define ASSEMBLE_ARM_TEMPLATE $(OUTDIR)/$(notdir $(basename $(1))).o : $(1) - @echo $(MSG_ASSEMBLING_ARM) $$(call toprel, $$<) + @$(ECHO) $(MSG_ASSEMBLING_ARM) $$(call toprel, $$<) $(V1) $(CC) -c $$(ASFLAGS) $$< -o $$@ endef # Compile: create object files from C source files. define COMPILE_C_TEMPLATE $(OUTDIR)/$(notdir $(basename $(1))).o : $(1) - @echo $(MSG_COMPILING) $$(call toprel, $$<) + @$(ECHO) $(MSG_COMPILING) $$(call toprel, $$<) $(V1) $(CC) -c $(THUMB) $$(CFLAGS) $$(CONLYFLAGS) $$< -o $$@ endef # Compile: create object files from C source files. ARM-only define COMPILE_C_ARM_TEMPLATE $(OUTDIR)/$(notdir $(basename $(1))).o : $(1) - @echo $(MSG_COMPILING_ARM) $$(call toprel, $$<) + @$(ECHO) $(MSG_COMPILING_ARM) $$(call toprel, $$<) $(V1) $(CC) -c $$(CFLAGS) $$(CONLYFLAGS) $$< -o $$@ endef # Compile: create object files from C++ source files. define COMPILE_CXX_TEMPLATE $(OUTDIR)/$(notdir $(basename $(1))).o : $(1) - @echo $(MSG_COMPILINGCXX) $$(call toprel, $$<) + @$(ECHO) $(MSG_COMPILINGCXX) $$(call toprel, $$<) $(V1) $(CXX) -c $(THUMB) $$(CFLAGS) $$(CPPFLAGS) $$(CXXFLAGS) $$< -o $$@ endef # Compile: create object files from C++ source files. ARM-only define COMPILE_CXX_ARM_TEMPLATE $(OUTDIR)/$(notdir $(basename $(1))).o : $(1) - @echo $(MSG_COMPILINGCXX_ARM) $$(call toprel, $$<) + @$(ECHO) $(MSG_COMPILINGCXX_ARM) $$(call toprel, $$<) $(V1) $(CPP) -c $$(CFLAGS) $$(CPPFLAGS) $$(CXXFLAGS) $$< -o $$@ endef @@ -192,7 +201,7 @@ define ARCHIVE_TEMPLATE .SECONDARY : $(1) .PRECIOUS : $(2) $(1): $(2) - @echo $(MSG_ARCHIVING) $$(call toprel, $$@) + @$(ECHO) $(MSG_ARCHIVING) $$(call toprel, $$@) ifeq ($(3),) $(V1) $(AR) rcs $$@ $(2) else @@ -200,9 +209,10 @@ else # limitation. It is assumed that if the object files directory # is given, all object files are in that directory. $(V1) ( \ - pushd $(3) >/dev/null && \ + pwd=`pwd` && \ + cd $(3) && \ $(AR) rcs $$@ $(notdir $(2)) && \ - popd >/dev/null \ + cd $$$${pwd} >/dev/null \ ) endif endef @@ -215,7 +225,7 @@ define LINK_TEMPLATE .SECONDARY : $(1) .PRECIOUS : $(2) $(3) $(1): $(2) $(3) - @echo $(MSG_LINKING) $$(call toprel, $$@) + @$(ECHO) $(MSG_LINKING) $$(call toprel, $$@) $(V1) $(CC) $(THUMB) $$(CFLAGS) $(2) $(3) --output $$@ $$(LDFLAGS) endef @@ -226,21 +236,21 @@ define LINK_CXX_TEMPLATE .SECONDARY : $(1) .PRECIOUS : $(2) $(1): $(2) - @echo $(MSG_LINKING) $$(call toprel, $$@) + @$(ECHO) $(MSG_LINKING) $$(call toprel, $$@) $(V1) $(CXX) $(THUMB) $$(CFLAGS) $(2) --output $$@ $$(LDFLAGS) endef # Compile: create assembler files from C source files. ARM/Thumb define PARTIAL_COMPILE_TEMPLATE $($(1):.c=.s) : %.s : %.c - @echo $(MSG_ASMFROMC) $$(call toprel, $$<) + @$(ECHO) $(MSG_ASMFROMC) $$(call toprel, $$<) $(V1) $(CC) $(THUMB) -S $$(CFLAGS) $$(CONLYFLAGS) $$< -o $$@ endef # Compile: create assembler files from C source files. ARM only define PARTIAL_COMPILE_ARM_TEMPLATE $($(1):.c=.s) : %.s : %.c - @echo $(MSG_ASMFROMC_ARM) $$(call toprel, $$<) + @$(ECHO) $(MSG_ASMFROMC_ARM) $$(call toprel, $$<) $(V1) $(CC) -S $$(CFLAGS) $$(CONLYFLAGS) $$< -o $$@ endef @@ -254,13 +264,10 @@ define JTAG_TEMPLATE # 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 += -s $(ROOT_DIR)/flight/Project/OpenOCD OOCD_JTAG_SETUP += -f $(4) -f $(5) # initialize @@ -272,8 +279,8 @@ OOCD_BOARD_RESET += -c "reset halt" .PHONY: program program: $(1) - @echo $(MSG_JTAG_PROGRAM) $$(call toprel, $$<) - $(V1) $(OOCD_EXE) \ + @$(ECHO) $(MSG_JTAG_PROGRAM) $$(call toprel, $$<) + $(V1) $(OPENOCD) \ $$(OOCD_JTAG_SETUP) \ $$(OOCD_BOARD_RESET) \ -c "flash write_image erase $$< $(2) bin" \ @@ -283,12 +290,11 @@ program: $(1) .PHONY: wipe wipe: - @echo $(MSG_JTAG_WIPE) wiping $(3) bytes starting from $(2) - $(V1) $(OOCD_EXE) \ + @$(ECHO) $(MSG_JTAG_WIPE) wiping $(3) bytes starting from $(2) + $(V1) $(OPENOCD) \ $$(OOCD_JTAG_SETUP) \ $$(OOCD_BOARD_RESET) \ -c "flash erase_address pad $(2) $(3)" \ -c "reset run" \ -c "shutdown" endef - diff --git a/make/scripts/version-info.py b/make/scripts/version-info.py index 1d9187467..6dd025fe8 100644 --- a/make/scripts/version-info.py +++ b/make/scripts/version-info.py @@ -41,8 +41,8 @@ class Repo: def _exec(self, cmd): """Execute git using cmd as arguments""" self._git = 'git' - git = Popen(self._git + " " + cmd, cwd=self._path, - shell=True, stdout=PIPE, stderr=PIPE) + git = Popen(self._git + " " + cmd, cwd = self._path, + shell = True, stdout = PIPE, stderr = PIPE) self._out, self._err = git.communicate() self._rc = git.poll() @@ -262,15 +262,15 @@ def xtrim(string, suffix, length): if len(string) + len(suffix) <= length: return ''.join([string, suffix]) else: - n = length-1-len(suffix) + n = length - 1 - len(suffix) assert n > 0, "length of truncated string+suffix exceeds maximum length" return ''.join([string[:n], '+', suffix]) -def GetHashofDirs(directory, verbose=0, raw=0): +def get_hash_of_dirs(directory, verbose = 0, raw = 0): """Return hash of XML files from UAVObject definition directory""" import hashlib, os SHAhash = hashlib.sha1() - if not os.path.exists (directory): + if not os.path.exists(directory): return -1 try: @@ -288,7 +288,6 @@ def GetHashofDirs(directory, verbose=0, raw=0): f1 = open(filepath, 'rU') except: # You can't open the file for some reason - f1.close() continue # Compute file hash. Same as running "sha1sum ". @@ -296,7 +295,8 @@ def GetHashofDirs(directory, verbose=0, raw=0): while 1: # Read file in as little chunks buf = f1.read(4096) - if not buf : break + if not buf: + break f1hash.update(buf) f1.close() @@ -412,8 +412,8 @@ string given. BOARD_TYPE = args.type, BOARD_REVISION = args.revision, SHA1 = sha1(args.image), - UAVOSHA1TXT = GetHashofDirs(args.uavodir, verbose=0, raw=1), - UAVOSHA1 = GetHashofDirs(args.uavodir, verbose=0, raw=0), + UAVOSHA1TXT = get_hash_of_dirs(args.uavodir, verbose = 0, raw = 1), + UAVOSHA1 = get_hash_of_dirs(args.uavodir, verbose = 0, raw = 0), ) # Process positional arguments in the form of: diff --git a/make/tools.mk b/make/tools.mk index 5dec32f58..402a4b1a3 100644 --- a/make/tools.mk +++ b/make/tools.mk @@ -27,7 +27,7 @@ endif qt_sdk_install : | $(DL_DIR) $(TOOLS_DIR) qt_sdk_install: qt_sdk_clean # download the source only if it's newer than what we already have - $(V1) wget -N --content-disposition -P "$(DL_DIR)" "$(QT_SDK_URL)" + $(V1) $(WGET) -N --content-disposition -P "$(DL_DIR)" "$(QT_SDK_URL)" # tell the user exactly which path they should select in the GUI $(V1) echo "*** NOTE NOTE NOTE ***" $(V1) echo "*" @@ -54,7 +54,7 @@ arm_sdk_install: ARM_SDK_FILE := $(notdir $(ARM_SDK_URL)) arm_sdk_install: | $(DL_DIR) $(TOOLS_DIR) arm_sdk_install: arm_sdk_clean # download the source only if it's newer than what we already have - $(V1) wget --no-check-certificate -N -P "$(DL_DIR)" "$(ARM_SDK_URL)" + $(V1) $(WGET) --no-check-certificate -N -P "$(DL_DIR)" "$(ARM_SDK_URL)" # binary only release so just extract it $(V1) tar -C $(TOOLS_DIR) -xjf "$(DL_DIR)/$(ARM_SDK_FILE)" @@ -74,7 +74,7 @@ openocd_install: OPENOCD_URL := http://sourceforge.net/projects/openocd/files/o openocd_install: OPENOCD_FILE := openocd-0.6.1.tar.bz2 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)" + $(V1) $(WGET) -N -P "$(DL_DIR)" --trust-server-name "$(OPENOCD_URL)" # extract the source $(V1) [ ! -d "$(OPENOCD_BUILD_DIR)" ] || $(RM) -r "$(OPENOCD_BUILD_DIR)" @@ -111,7 +111,7 @@ ftd2xx_install: FTD2XX_FILE := CDM20817.zip ftd2xx_install: ftd2xx_clean # download the file only if it's newer than what we already have $(V0) @echo " DOWNLOAD $(FTD2XX_URL)" - $(V1) wget -q -N -P "$(DL_DIR)" "$(FTD2XX_URL)" + $(V1) $(WGET) -q -N -P "$(DL_DIR)" "$(FTD2XX_URL)" # extract the source $(V0) @echo " EXTRACT $(FTD2XX_FILE) -> $(FTD2XX_DIR)" @@ -133,7 +133,7 @@ libusb_win_install: LIBUSB_WIN_FILE := libusb-win32-bin-1.2.6.0.zip libusb_win_install: libusb_win_clean # download the file only if it's newer than what we already have $(V0) @echo " DOWNLOAD $(LIBUSB_WIN_URL)" - $(V1) wget -q -N -P "$(DL_DIR)" --trust-server-name "$(LIBUSB_WIN_URL)" + $(V1) $(WGET) -q -N -P "$(DL_DIR)" --trust-server-name "$(LIBUSB_WIN_URL)" # extract the source $(V0) @echo " EXTRACT $(LIBUSB_WIN_FILE) -> $(LIBUSB_WIN_DIR)" @@ -269,7 +269,7 @@ dfuutil_install: | $(DL_DIR) $(TOOLS_DIR) dfuutil_install: dfuutil_clean # download the source $(V0) @echo " DOWNLOAD $(DFUUTIL_URL)" - $(V1) wget -N -P "$(DL_DIR)" "$(DFUUTIL_URL)" + $(V1) $(WGET) -N -P "$(DL_DIR)" "$(DFUUTIL_URL)" # extract the source $(V0) @echo " EXTRACT $(DFUUTIL_FILE)" @@ -302,7 +302,7 @@ android_sdk_install: | $(DL_DIR) $(TOOLS_DIR) android_sdk_install: android_sdk_clean # download the source only if it's newer than what we already have $(V0) @echo " DOWNLOAD $(ANDROID_SDK_URL)" - $(V1) wget --no-check-certificate -N -P "$(DL_DIR)" "$(ANDROID_SDK_URL)" + $(V1) $(WGET) --no-check-certificate -N -P "$(DL_DIR)" "$(ANDROID_SDK_URL)" # binary only release so just extract it $(V0) @echo " EXTRACT $(ANDROID_SDK_FILE)" @@ -329,7 +329,7 @@ gtest_install: gtest_clean # download the file unconditionally since google code gives back 404 # for HTTP HEAD requests which are used when using the wget -N option $(V1) [ ! -f "$(DL_DIR)/$(GTEST_FILE)" ] || $(RM) -f "$(DL_DIR)/$(GTEST_FILE)" - $(V1) wget -P "$(DL_DIR)" --trust-server-name "$(GTEST_URL)" + $(V1) $(WGET) -P "$(DL_DIR)" --trust-server-name "$(GTEST_URL)" # extract the source $(V1) [ ! -d "$(GTEST_DIR)" ] || $(RM) -rf "$(GTEST_DIR)" @@ -340,4 +340,3 @@ gtest_install: gtest_clean gtest_clean: $(V0) @echo " CLEAN $(GTEST_DIR)" $(V1) [ ! -d "$(GTEST_DIR)" ] || $(RM) -rf "$(GTEST_DIR)" - diff --git a/package/Makefile.osx b/package/Darwin.mk similarity index 57% rename from package/Makefile.osx rename to package/Darwin.mk index 132f9f2c7..1ada9f4c2 100644 --- a/package/Makefile.osx +++ b/package/Darwin.mk @@ -1,8 +1,15 @@ # -# MacOSX-specific packaging +# MacOSX-specific packaging script # -osx_package: gcs package_flight +ifndef OPENPILOT_IS_COOL + $(error Top level Makefile must be used to build this target) +endif + +FW_DIR := $(PACKAGE_DIR)/firmware + +.PHONY: package +package: ( \ ROOT_DIR="$(ROOT_DIR)" \ BUILD_DIR="$(BUILD_DIR)" \ @@ -13,10 +20,3 @@ osx_package: gcs package_flight FW_DIR="$(FW_DIR)" \ "$(ROOT_DIR)/package/osx/package" \ ) - -gcs: uavobjects - $(V1) $(MAKE) -C $(ROOT_DIR) GCS_BUILD_CONF=release $@ - -ground_package: | osx_package - -.PHONY: gcs ground_package osx_package diff --git a/package/Makefile.linux b/package/Linux.mk similarity index 86% rename from package/Makefile.linux rename to package/Linux.mk index 16bcb8817..66d3c284e 100644 --- a/package/Makefile.linux +++ b/package/Linux.mk @@ -1,18 +1,24 @@ # -# Linux-specific packaging +# Linux-specific packaging script # +ifndef OPENPILOT_IS_COOL + $(error Top level Makefile must be used to build this target) +endif + +FW_DIR := $(PACKAGE_DIR)/firmware + # Update this number for every formal release. The Deb packaging system relies on this to know to update a # package or not. Otherwise, the user has to uninstall first. # Until we do that, package name does NOT include $(VERNUM) and uses $(PACKAGE_LBL) only -VERNUM := 0.1.0 +VERNUM := 0.1.0 VERSION_FULL := $(VERNUM)-$(PACKAGE_LBL) DEB_BUILD_DIR := $(ROOT_DIR)/debian SED_DATE_STRG = $(shell date -R) SED_SCRIPT = s//$(VERNUM)/;s//$(SED_DATE_STRG)/ -DEB_CFG_CMN := $(ROOT_DIR)/package/linux/deb_common +DEB_CFG_CMN := $(ROOT_DIR)/package/linux/deb_common DEB_CFG_I386_DIR := $(ROOT_DIR)/package/linux/deb_i386 DEB_CFG_AMD64_DIR := $(ROOT_DIR)/package/linux/deb_amd64 DEB_CFG_CMN_FILES := $(shell ls $(DEB_CFG_CMN)) @@ -34,7 +40,8 @@ FULL_PACKAGE_NAME := $(PACKAGE_NAME)$(PACKAGE_SEP)$(PACKAGE_LBL)$(PACKAGE_SEP)$( ALL_DEB_FILES = $(foreach f, $(DEB_CFG_CMN_FILES), $(DEB_BUILD_DIR)/$(f)) ALL_DEB_FILES += $(foreach f, $(DEB_MACHINE_FILES), $(DEB_BUILD_DIR)/$(f)) -linux_deb_package: $(ALL_DEB_FILES) gcs package_flight +.PHONY: package +package: $(ALL_DEB_FILES) $(V1) echo "Building Linux package, please wait..." $(V1) mkdir -p $(DEB_BUILD_DIR) $(V1)$(shell echo $(FW_DIR) > $(BUILD_DIR)/package_dir) @@ -44,8 +51,6 @@ linux_deb_package: $(ALL_DEB_FILES) gcs package_flight $(V1) mv $(ROOT_DIR)/../$(DEB_PACKAGE_NAME).changes $(BUILD_DIR)/$(FULL_PACKAGE_NAME).changes $(V1) rm -rf $(DEB_BUILD_DIR) -$(ALL_DEB_FILES): | uavobjects - define CP_DEB_FILES_TEMPLATE .PHONY: $(2)/$(1) $(2)/$(1): $(3)/$(1) @@ -55,10 +60,3 @@ endef $(foreach cpfile, $(DEB_CFG_CMN_FILES), $(eval $(call CP_DEB_FILES_TEMPLATE,$(cpfile),$(DEB_BUILD_DIR),$(DEB_CFG_CMN)))) $(foreach cpfile, $(DEB_MACHINE_FILES), $(eval $(call CP_DEB_FILES_TEMPLATE,$(cpfile),$(DEB_BUILD_DIR),$(DEB_MACHINE_DIR)))) - -gcs: uavobjects - $(V1) $(MAKE) -C $(ROOT_DIR) GCS_BUILD_CONF=release $@ - -ground_package: | linux_deb_package - -.PHONY: gcs ground_package linux_deb_package diff --git a/package/Makefile b/package/Makefile deleted file mode 100644 index 2a661d5b6..000000000 --- a/package/Makefile +++ /dev/null @@ -1,159 +0,0 @@ -# Set up a default goal -.DEFAULT_GOAL := help - -# Tried the best to support parallel (-j) builds. But since this Makefile -# uses other Makefiles to build few targets which in turn have similar -# dependencies on uavobjects and other generated files, it is difficult -# to support parallel builds perfectly. But at least it was tested with -# -j (unlimited job number) on Windows and Linux. - -# Locate the root of the tree -WHEREAMI := $(dir $(lastword $(MAKEFILE_LIST))) -ROOT_DIR := $(realpath $(WHEREAMI)/../) - -# Set up some macros -BUILD_DIR := $(ROOT_DIR)/build -VERSION_CMD := python $(ROOT_DIR)/make/scripts/version-info.py --path="$(ROOT_DIR)" -PACKAGE_LBL := $(shell $(VERSION_CMD) --format=\$${LABEL}) -PACKAGE_DIR := $(BUILD_DIR)/package-$(PACKAGE_LBL) -PACKAGE_NAME := OpenPilot -PACKAGE_SEP := - -FW_DIR := $(PACKAGE_DIR)/firmware-$(PACKAGE_LBL) -BL_DIR := $(FW_DIR)/bootloaders -BU_DIR := $(FW_DIR)/bootloader-updaters - -# Clean build options (recommended for package testing only) -ifeq ($(CLEAN_BUILD), NO) -CLEAN_GROUND := NO -CLEAN_FLIGHT := NO -else -CLEAN_GROUND := YES -CLEAN_FLIGHT := YES -endif - -# Set up targets -ALL_BOARDS := coptercontrol pipxtreme revolution revomini osd -ALL_BOARDS_BU := coptercontrol pipxtreme -FW_TARGETS := $(addprefix fw_, $(ALL_BOARDS)) -FW_TARGETS_TOOLS := $(addprefix fw_, $(ALL_BOARDS)) -BL_TARGETS := $(addprefix bl_, $(ALL_BOARDS)) -BU_TARGETS := $(addprefix bu_, $(ALL_BOARDS_BU)) - -help: - @echo - @echo " This Makefile is known to work on Linux and Mac in a standard shell environment." - @echo " It also works on Windows by following the instructions in ../make/winx86/README.txt." - @echo - @echo " Here is a summary of the available targets:" - @echo - @echo " [Packaging]" - @echo " package - Build and package the OpenPilot distributable" - @echo " package_flight - Build and package the OpenPilot flight firmware only" - @echo - @echo " Notes:" - @echo " - package will be placed in $(PACKAGE_DIR)" - @echo - @echo " - the build directory will be removed first on every run unless" - @echo " CLEAN_BUILD=NO is defined. It means no clean before build." - @echo " This usually is safe." - @echo - -# Clean and build uavobjects since all parts depend on them -uavobjects: all_clean - $(V1) $(MAKE) -C $(ROOT_DIR) $@ - -all_clean: -ifneq ($(CLEAN_GROUND), NO) - $(V1) $(MAKE) -C $(ROOT_DIR) $@ -endif - -# Install template: -# $1 = target -# $2 = dependencies -# $3 = install directory (must be defined) -# $4 = installed file name prefix (optional) -# $5 = installed file name suffix (optional) -# $6 = extra make options (for instance, USE_SPEKTRUM=YES) -# $7 = optional 'clean' string to clean target before rebuild -# $8 = list of targets to install (without _install suffix) -# $9 = inner make target (usually install, but can be other to just build) -define INSTALL_TEMPLATE -$(1): $(2) -ifeq ($(7),clean) -ifneq ($$(CLEAN_FLIGHT), NO) - $$(V1) +$(MAKE) -C $(ROOT_DIR) $(6) $(addsuffix _$(7), $(8)) -endif -endif - $$(V1) +$(MAKE) -C $(ROOT_DIR) INSTALL_DIR=$(3) INSTALL_PFX=$(4) INSTALL_SFX=$(5) $(6) $(addsuffix _$(9), $(8)) -.PHONY: $(1) -endef - -# Firmware -$(eval $(call INSTALL_TEMPLATE,all_fw,uavobjects,$(FW_DIR),,-$(PACKAGE_LBL),,,$(FW_TARGETS),install)) - -# Bootloaders (change 'install' to 'bin' if you don't want to install bootloaders) -$(eval $(call INSTALL_TEMPLATE,all_bl,uavobjects,$(BL_DIR),,-$(PACKAGE_LBL),,,$(BL_TARGETS),install)) - -# Bootloader updaters -$(eval $(call INSTALL_TEMPLATE,all_bu,all_bl,$(BU_DIR),,-$(PACKAGE_LBL),,,$(BU_TARGETS),install)) - -# Order-only dependencies -package_flight: | all_fw all_bu - -package_ground: | ground_package - -package: | package_flight package_ground - -.PHONY: help uavobjects all_clean package_flight package_ground package - -# opfw_resource must be generated before the ground package, -# and it depends on flight firmware images -ground_package: | opfw_resource - -opfw_resource: | all_fw - -# Decide on a verbosity level based on the V= parameter -export AT := @ - -ifndef V -export V0 := -export V1 := $(AT) -else ifeq ($(V), 0) -export V0 := $(AT) -export V1 := $(AT) -else ifeq ($(V), 1) -endif - -ifneq ($(V),1) -MAKEFLAGS += --no-print-directory -endif - -# Platform-dependent stuff -PLATFORM := winx86 -UNAME := $(shell uname) -ifeq ($(UNAME), Linux) - PLATFORM := linux -endif -ifeq ($(UNAME), Darwin) - PLATFORM := osx -endif - -toprel = $(subst $(realpath $(ROOT_DIR))/,,$(abspath $(1))) -OPFW_FILES := $(foreach fw_targ, $(FW_TARGETS), $(call toprel, $(BUILD_DIR)/$(fw_targ)/$(fw_targ).opfw)) -OPFW_CONTENTS := \ - \ - \ - $(foreach fw_file, $(OPFW_FILES), $(fw_file)) \ - \ - - -.PHONY: opfw_resource -opfw_resource: - @echo Generating OPFW resource file $(call toprel, $(BUILD_DIR)/ground/$@) - $(V1) mkdir -p $(BUILD_DIR)/ground/$@ - $(V1) mkdir -p $(BUILD_DIR)/ground/$@/build - $(V1) echo '$(OPFW_CONTENTS)' > $(BUILD_DIR)/ground/$@/opfw_resource.qrc - $(V1) $(foreach fw_targ, $(FW_TARGETS), mkdir -p $(BUILD_DIR)/ground/$@/build/$(fw_targ);) - $(V1)$(foreach fw_targ, $(FW_TARGETS), cp $(BUILD_DIR)/$(fw_targ)/$(fw_targ).opfw $(BUILD_DIR)/ground/$@/build/$(fw_targ)/;) - -include $(WHEREAMI)/Makefile.$(PLATFORM) diff --git a/package/Makefile.winx86 b/package/Windows.mk similarity index 75% rename from package/Makefile.winx86 rename to package/Windows.mk index a2602ec3b..ec2c3c955 100644 --- a/package/Makefile.winx86 +++ b/package/Windows.mk @@ -1,7 +1,14 @@ # -# Windows-specific packaging +# Windows-specific packaging script # +ifndef OPENPILOT_IS_COOL + $(error Top level Makefile must be used to build this target) +endif + +VERSION_CMD := $(VERSION_INFO) +FW_DIR := $(PACKAGE_DIR)/firmware + NSIS_CMD := makensis.exe NSIS_OPTS := /V3 NSIS_DIR := $(ROOT_DIR)/package/winx86 @@ -9,7 +16,8 @@ NSIS_SCRIPT := $(NSIS_DIR)/openpilotgcs.nsi NSIS_TEMPLATE := $(NSIS_DIR)/openpilotgcs.tpl NSIS_HEADER := $(BUILD_DIR)/ground/openpilotgcs/openpilotgcs.nsh -win_package: gcs package_flight +.PHONY: package +package: $(V1) mkdir -p "$(dir $(NSIS_HEADER))" $(VERSION_CMD) \ --template="$(NSIS_TEMPLATE)" \ @@ -21,10 +29,3 @@ win_package: gcs package_flight $(V1) echo "If you have a script error in line 1 - use Unicode NSIS 2.46+" $(V1) echo " http://www.scratchpaper.com" $(NSIS_CMD) $(NSIS_OPTS) $(NSIS_SCRIPT) - -gcs: uavobjects - $(V1) $(MAKE) -C $(ROOT_DIR) GCS_BUILD_CONF=release $@ - -ground_package: | win_package - -.PHONY: gcs ground_package win_package diff --git a/package/linux/deb_common/rules b/package/linux/deb_common/rules index ba22c1e9c..4f0fcdf26 100644 --- a/package/linux/deb_common/rules +++ b/package/linux/deb_common/rules @@ -33,10 +33,10 @@ install: dh_installdirs dh_installudev --priority=45 # Add here commands to install the package into debian/ - cp -arp build/ground/openpilotgcs/bin debian/openpilot/usr/local/OpenPilot - cp -arp build/ground/openpilotgcs/lib debian/openpilot/usr/local/OpenPilot - cp -arp build/ground/openpilotgcs/share debian/openpilot/usr/local/OpenPilot - cp -arp build/ground/openpilotgcs/.obj debian/openpilot/usr/local/OpenPilot + cp -arp build/ground/openpilotgcs/release/bin debian/openpilot/usr/local/OpenPilot + cp -arp build/ground/openpilotgcs/release/lib debian/openpilot/usr/local/OpenPilot + cp -arp build/ground/openpilotgcs/release/share debian/openpilot/usr/local/OpenPilot + cp -arp build/ground/openpilotgcs/release/.obj debian/openpilot/usr/local/OpenPilot cp -arp build/ground/openpilotgcs/gcsversioninfo.h debian/openpilot/usr/local/OpenPilot cp -arp package/linux/openpilot.desktop debian/openpilot/usr/share/applications cp -arp package/linux/openpilot.png debian/openpilot/usr/share/pixmaps @@ -44,7 +44,7 @@ install: cp -arp package/linux/openpilot_menu.menu debian/openpilot/etc/xdg/menus/applications-merged cp -arp package/linux/openpilot_menu.directory debian/openpilot/usr/share/desktop-directories ifdef PACKAGE_DIR - cp -a $(PACKAGE_DIR)/*.opfw debian/openpilot/usr/local/OpenPilot/firmware/ + cp -a $(PACKAGE_DIR)/* debian/openpilot/usr/local/OpenPilot/firmware/ else $(error PACKAGE_DIR not defined! $(PACKAGE_DIR)) endif diff --git a/package/osx/package b/package/osx/package index 2731b540c..0faf1c618 100755 --- a/package/osx/package +++ b/package/osx/package @@ -4,7 +4,7 @@ : ${ROOT_DIR?} ${BUILD_DIR?} ${PACKAGE_LBL?} ${PACKAGE_DIR?} ${FW_DIR?} ${PACKAGE_NAME?} ${PACKAGE_SEP?} # more variables -APP_PATH="${BUILD_DIR}/ground/openpilotgcs/bin/OpenPilot GCS.app" +APP_PATH="${BUILD_DIR}/ground/openpilotgcs/release/bin/OpenPilot GCS.app" TEMP_FILE="${PACKAGE_DIR}/OpenPilot-temp.dmg" OUT_FILE="${PACKAGE_DIR}/../${PACKAGE_NAME}${PACKAGE_SEP}${PACKAGE_LBL}${PACKAGE_SEP}osx.dmg" VOL_NAME="OpenPilot" @@ -20,14 +20,8 @@ device=$(hdiutil attach "${TEMP_FILE}" | \ # packaging goes here cp -r "${APP_PATH}" "/Volumes/${VOL_NAME}" -#cp -r "${FW_DIR}" "/Volumes/${VOL_NAME}/firmware" -cp "${FW_DIR}/fw_coptercontrol-${PACKAGE_LBL}.opfw" "/Volumes/${VOL_NAME}/Firmware" -cp "${FW_DIR}/fw_revomini-${PACKAGE_LBL}.opfw" "/Volumes/${VOL_NAME}/Firmware" -cp "${FW_DIR}/fw_pipxtreme-${PACKAGE_LBL}.opfw" "/Volumes/${VOL_NAME}/Firmware" -cp "${FW_DIR}/fw_revolution-${PACKAGE_LBL}.opfw" "/Volumes/${VOL_NAME}/Firmware" - +ls "${FW_DIR}" | xargs -n 1 -I {} cp "${FW_DIR}/{}" "/Volumes/${VOL_NAME}/Firmware" cp "${BUILD_DIR}/uavobject-synthetics/matlab/OPLogConvert.m" "/Volumes/${VOL_NAME}/Utilities" - cp "${ROOT_DIR}/HISTORY.txt" "/Volumes/${VOL_NAME}" "${ROOT_DIR}/package/osx/libraries" \ diff --git a/package/winx86/openpilotgcs.nsi b/package/winx86/openpilotgcs.nsi index c870deae0..7d6dbbc69 100644 --- a/package/winx86/openpilotgcs.nsi +++ b/package/winx86/openpilotgcs.nsi @@ -1,7 +1,7 @@ # # Project: OpenPilot # NSIS configuration file for OpenPilot GCS -# The OpenPilot Team, http://www.openpilot.org, Copyright (C) 2010-2012. +# The OpenPilot Team, http://www.openpilot.org, Copyright (C) 2010-2013. # # 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 @@ -36,9 +36,9 @@ ; Tree root locations (relative to this script location) !define PROJECT_ROOT "..\.." !define NSIS_DATA_TREE "." - !define GCS_BUILD_TREE "..\..\build\ground\openpilotgcs" + !define GCS_BUILD_TREE "..\..\build\ground\openpilotgcs\release" !define UAVO_SYNTH_TREE "..\..\build\uavobject-synthetics" - !define AEROSIMRC_TREE "..\..\build\ground\AeroSIM-RC" + !define AEROSIMRC_TREE "${GCS_BUILD_TREE}\misc\AeroSIM-RC" ; Default installation folder InstallDir "$PROGRAMFILES\OpenPilot" @@ -61,7 +61,7 @@ ; !define PRODUCT_VERSION "0.0.0.0" ; !define FILE_VERSION "${TAG_OR_BRANCH}:${HASH8} ${DATETIME}" ; !define BUILD_DESCRIPTION "${TAG_OR_BRANCH}:${HASH8} built from ${ORIGIN}, committed ${DATETIME} as ${HASH}" - !include "${GCS_BUILD_TREE}\openpilotgcs.nsh" + !include "${GCS_BUILD_TREE}\..\openpilotgcs.nsh" Name "${PRODUCT_NAME}" OutFile "${PACKAGE_DIR}\..\${OUT_FILE}" @@ -72,7 +72,7 @@ VIAddVersionKey "Comments" "${INSTALLER_NAME}. ${BUILD_DESCRIPTION}" VIAddVersionKey "CompanyName" "The OpenPilot Team, http://www.openpilot.org" VIAddVersionKey "LegalTrademarks" "${PRODUCT_NAME} is a trademark of The OpenPilot Team" - VIAddVersionKey "LegalCopyright" "© 2010-2012 The OpenPilot Team" + VIAddVersionKey "LegalCopyright" "© 2010-2013 The OpenPilot Team" VIAddVersionKey "FileDescription" "${INSTALLER_NAME}" ;-------------------------------- @@ -93,7 +93,7 @@ ;-------------------------------- ; Branding - BrandingText "© 2010-2012 The OpenPilot Team, http://www.openpilot.org" + BrandingText "© 2010-2013 The OpenPilot Team, http://www.openpilot.org" !define MUI_ICON "${NSIS_DATA_TREE}\resources\openpilot.ico" !define MUI_HEADERIMAGE @@ -203,12 +203,8 @@ SectionEnd ; Copy firmware files Section "Firmware" InSecFirmware -; SetOutPath "$INSTDIR\firmware\${FIRMWARE_DIR}" -; File /r "${PACKAGE_DIR}\${FIRMWARE_DIR}\*" SetOutPath "$INSTDIR\firmware" - File "${PACKAGE_DIR}\${FIRMWARE_DIR}\fw_coptercontrol-${PACKAGE_LBL}.opfw" - File "${PACKAGE_DIR}\${FIRMWARE_DIR}\fw_pipxtreme-${PACKAGE_LBL}.opfw" - File "${PACKAGE_DIR}\${FIRMWARE_DIR}\fw_revomini-${PACKAGE_LBL}.opfw" + File /r "${PACKAGE_DIR}\${FIRMWARE_DIR}\*" SectionEnd ; Copy utility files diff --git a/package/winx86/openpilotgcs.tpl b/package/winx86/openpilotgcs.tpl index 3669096c0..65b38e11e 100644 --- a/package/winx86/openpilotgcs.tpl +++ b/package/winx86/openpilotgcs.tpl @@ -15,8 +15,8 @@ !define PACKAGE_LBL "${PACKAGE_LBL}" !define PACKAGE_NAME "${PACKAGE_NAME}" !define PACKAGE_SEP "${PACKAGE_SEP}" -!define PACKAGE_DIR "..\..\build\package-$${PACKAGE_LBL}" -!define FIRMWARE_DIR "firmware-$${PACKAGE_LBL}" +!define PACKAGE_DIR "..\..\build\package" +!define FIRMWARE_DIR "firmware" !define OUT_FILE "$${PACKAGE_NAME}$${PACKAGE_SEP}$${PACKAGE_LBL}$${PACKAGE_SEP}win32.exe" ; Installer version info