Index: OpenPilot/Makefile.x86 =================================================================== --- OpenPilot/Makefile.x86 (Revision 0) +++ OpenPilot/Makefile.x86 (Revision 0) @@ -0,0 +1,616 @@ + ##### + # 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 + ##### + + +# Set developer code and compile options +# Set to YES to compile for debugging +DEBUG ?= YES + +# 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_BOOTLOADER ?= NO + + +# Set to YES when using Code Sourcery toolchain +CODE_SOURCERY ?= NO + +# Toolchain prefix (i.e arm-elf- -> arm-elf-gcc.exe) +TCHAIN_PREFIX ?= "" + +# Remove command is different for Code Sourcery on Windows +REMOVE_CMD ?= rm + +FLASH_TOOL = OPENOCD + +# YES enables -mthumb option to flags for source-files listed +# in SRC and CPPSRC +USE_THUMB_MODE = YES + +# List of modules to include +MODULES = Telemetry Stabilization +#MODULES = Telemetry GPS ManualControl Actuator Altitude Attitude Stabilization +#MODULES = Telemetry Example +#MODULES = Telemetry MK/MKSerial + +#MODULES += Osd/OsdEtStd + + +# MCU name, submodel and board +# - MCU used for compiler-option (-mcpu) +# - MODEL used for linker-script name (-T) and passed as define +# - BOARD just passed as define (optional) +MCU = i686 +#CHIP = STM32F103RET +#BOARD = STM3210E_OP +ifeq ($(USE_BOOTLOADER), YES) +MODEL = HD_BL + +else +MODEL = HD_NB +endif + +# Directory for output files (lst, obj, dep, elf, sym, map, hex, bin etc.) +OUTDIR = Build + +# Target file name (without extension). +TARGET = OpenPilot + +# Paths +OPSYSTEM = ./System +OPSYSTEMINC = $(OPSYSTEM)/inc +OPUAVTALK = ./UAVTalk +OPUAVTALKINC = $(OPUAVTALK)/inc +OPUAVOBJ = ./UAVObjects +OPUAVOBJINC = $(OPUAVOBJ)/inc +OPTESTS = ./Tests +OPMODULEDIR = ./Modules +PIOS = ../PiOS.x86 +PIOSINC = $(PIOS)/inc +PIOSX86 = $(PIOS)/x86 +APPLIBDIR = $(PIOSX86)/Libraries +RTOSDIR = $(APPLIBDIR)/FreeRTOS +RTOSSRCDIR = $(RTOSDIR)/Source +RTOSINCDIR = $(RTOSSRCDIR)/include +DOXYGENDIR = ../Doc/Doxygen + +# List C source files here. (C dependencies are automatically generated.) +# use file-extension c for "c-only"-files + +MODNAMES = $(notdir ${MODULES}) + +ifndef TESTAPP +## MODULES +SRC += ${foreach MOD, ${MODULES}, ${wildcard ${OPMODULEDIR}/${MOD}/*.c}} +SRC += ${OUTDIR}/InitMods.c +## OPENPILOT CORE: +SRC += ${OPMODULEDIR}/System/systemmod.c +SRC += $(OPSYSTEM)/openpilot.c +SRC += $(OPSYSTEM)/pios_board_x86.c +SRC += $(OPSYSTEM)/alarms.c +SRC += $(OPUAVTALK)/uavtalk.c +SRC += $(OPUAVOBJ)/uavobjectmanager.c +SRC += $(OPUAVOBJ)/uavobjectsinit.c +SRC += $(OPUAVOBJ)/eventdispatcher.c +else +## TESTCODE +SRC += $(OPTESTS)/test_common.c +SRC += $(OPTESTS)/$(TESTAPP).c +endif + + + +## UAVOBJECTS +ifndef TESTAPP +SRC += $(OPUAVOBJ)/exampleobject1.c +SRC += $(OPUAVOBJ)/exampleobject2.c +SRC += $(OPUAVOBJ)/examplesettings.c +SRC += $(OPUAVOBJ)/objectpersistence.c +SRC += $(OPUAVOBJ)/positionactual.c +SRC += $(OPUAVOBJ)/gcstelemetrystats.c +SRC += $(OPUAVOBJ)/flighttelemetrystats.c +SRC += $(OPUAVOBJ)/systemstats.c +SRC += $(OPUAVOBJ)/systemalarms.c +SRC += $(OPUAVOBJ)/systemsettings.c +SRC += $(OPUAVOBJ)/telemetrysettings.c +SRC += $(OPUAVOBJ)/actuatorcommand.c +SRC += $(OPUAVOBJ)/actuatordesired.c +SRC += $(OPUAVOBJ)/actuatorsettings.c +SRC += $(OPUAVOBJ)/manualcontrolcommand.c +SRC += $(OPUAVOBJ)/manualcontrolsettings.c +SRC += $(OPUAVOBJ)/attitudedesired.c +SRC += $(OPUAVOBJ)/stabilizationsettings.c +SRC += $(OPUAVOBJ)/altitudeactual.c +SRC += $(OPUAVOBJ)/attitudeactual.c +SRC += $(OPUAVOBJ)/attitudesettings.c +SRC += $(OPUAVOBJ)/flightbatterystate.c +endif + +## PIOS Hardware (x86) +SRC += $(PIOSX86)/pios_sys.c +SRC += $(PIOSX86)/pios_led.c +SRC += $(PIOSX86)/pios_delay.c +SRC += $(PIOSX86)/pios_sdcard.c +SRC += $(PIOSX86)/pios_udp.c +SRC += $(PIOSX86)/pios_com.c +# +## RTOS +SRC += $(RTOSSRCDIR)/list.c +SRC += $(RTOSSRCDIR)/queue.c +SRC += $(RTOSSRCDIR)/tasks.c +# +## RTOS Portable +SRC += $(RTOSSRCDIR)/portable/GCC/Posix/port.c +SRC += $(RTOSSRCDIR)/portable/MemMang/heap_3.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 = $(OPSYSTEM) +EXTRAINCDIRS += $(OPSYSTEMINC) +EXTRAINCDIRS += $(OPUAVTALK) +EXTRAINCDIRS += $(OPUAVTALKINC) +EXTRAINCDIRS += $(OPUAVOBJ) +EXTRAINCDIRS += $(OPUAVOBJINC) +EXTRAINCDIRS += $(MODEXAMPLE) +EXTRAINCDIRS += $(MODEXAMPLEINC) +EXTRAINCDIRS += $(MODSYSTEMINC) +EXTRAINCDIRS += $(MODTELEMETRY) +EXTRAINCDIRS += $(MODTELEMETRYINC) +EXTRAINCDIRS += $(MODGPS) +EXTRAINCDIRS += $(MODGPSINC) +EXTRAINCDIRS += $(MODMANUALCONTROL) +EXTRAINCDIRS += $(MODMANUALCONTROLINC) +EXTRAINCDIRS += $(MODACTUATOR) +EXTRAINCDIRS += $(MODACTUATORINC) +EXTRAINCDIRS += $(MODALTITUDE) +EXTRAINCDIRS += $(MODALTITUDEINC) +EXTRAINCDIRS += $(MODATTITUDE) +EXTRAINCDIRS += $(MODATTITUDEINC) +EXTRAINCDIRS += $(PIOS) +EXTRAINCDIRS += $(PIOSINC) +EXTRAINCDIRS += $(PIOSX86) +EXTRAINCDIRS += $(MININIDIR) +EXTRAINCDIRS += $(RTOSINCDIR) +EXTRAINCDIRS += $(APPLIBDIR) +EXTRAINCDIRS += $(RTOSSRCDIR)/portable/GCC/Posix + +EXTRAINCDIRS += ${foreach MOD, ${MODULES}, Modules/${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 = 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. +ifeq ($(ENABLE_DEBUG_PINS), YES) +CDEFS += -DPIOS_ENABLE_DEBUG_PINS +endif +ifeq ($(ENABLE_AUX_UART), YES) +CDEFS += -DPIOS_ENABLE_AUX_UART +endif +ifeq ($(USE_BOOTLOADER), YES) +CDEFS += -DUSE_BOOTLOADER +endif + + + +# 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 = -g$(DEBUGF) -DDEBUG +endif + +CFLAGS += -DX86_WRAPPERS +CFLAGS += -O$(OPT) +CFLAGS += -mcpu=$(MCU) +CFLAGS += $(CDEFS) +CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) -I. + +CFLAGS += -fomit-frame-pointer +ifeq ($(CODE_SOURCERY), YES) +CFLAGS += -fpromote-loop-indices +endif + +CFLAGS += -Wall +CFLAGS += -Werror +# 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 += -lpthread +LDFLAGS += $(patsubst %,-L%,$(EXTRA_LIBDIRS)) +LDFLAGS += -lc +LDFLAGS += $(patsubst %,-l%,$(EXTRA_LIBS)) +LDFLAGS += $(MATH_LIB) +LDFLAGS += -lc -lgcc + + + + +# 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 +###SHELL = sh +###COPY = cp + + + +# Define Messages +# English +MSG_ERRORS_NONE = Errors: none +MSG_BEGIN = ${quote}-------- begin (mode: $(RUN_MODE)) --------${quote} +MSG_END = ${quote}-------- end --------${quote} +MSG_MODINIT = ${quote}**** Generating ModInit.c${quote} +MSG_SIZE_BEFORE = ${quote}Size before:${quote} +MSG_SIZE_AFTER = ${quote}Size after build:${quote} +MSG_LOAD_FILE = ${quote}Creating load file:${quote} +MSG_EXTENDED_LISTING = ${quote}Creating Extended Listing/Disassembly:${quote} +MSG_SYMBOL_TABLE = ${quote}Creating Symbol Table:${quote} +MSG_LINKING = ${quote}**** Linking :${quote} +MSG_COMPILING = ${quote}**** Compiling C :${quote} +MSG_COMPILING_ARM = ${quote}**** Compiling C (ARM-only):${quote} +MSG_COMPILINGCPP = ${quote}Compiling C++ :${quote} +MSG_COMPILINGCPP_ARM = ${quote}Compiling C++ (ARM-only):${quote} +MSG_ASSEMBLING = ${quote}**** Assembling:${quote} +MSG_ASSEMBLING_ARM = ${quote}****Assembling (ARM-only):${quote} +MSG_CLEANING = ${quote}Cleaning project:${quote} +MSG_FORMATERROR = ${quote}Can not handle output-format${quote} +MSG_ASMFROMC = ${quote}Creating asm-File from C-Source:${quote} +MSG_ASMFROMC_ARM = ${quote}Creating asm-File from C-Source (ARM-only):${quote} + +# 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))) + +elf: $(OUTDIR)/$(TARGET).elf +lss: $(OUTDIR)/$(TARGET).lss +sym: $(OUTDIR)/$(TARGET).sym +hex: $(OUTDIR)/$(TARGET).hex +bin: $(OUTDIR)/$(TARGET).bin + +# Default target. +#all: begin gccversion sizebefore build sizeafter finished end +#all: begin gccversion build sizeafter finished end +all: elf + +ifeq ($(LOADFORMAT),ihex) +build: elf hex lss sym +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 +endif + +# Test if quotes are needed for the echo-command +result = ${shell echo "test"} +ifeq (${result}, test) + quote = ' +else + quote = +endif + +${OUTDIR}/InitMods.c: Makefile.x86 + @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}void InitModules() {${quote} >> ${OUTDIR}/InitMods.c + @echo ${quote}${foreach MOD, ${MODNAMES}, ${MOD}Initialize();}${quote} >> ${OUTDIR}/InitMods.c + @echo ${quote}}${quote} >> ${OUTDIR}/InitMods.c + +# Eye candy. +begin: +## @echo + @echo $(MSG_BEGIN) + +finished: +## @echo $(MSG_ERRORS_NONE) + +end: + @echo $(MSG_END) +## @echo + +# Display sizes of sections. +ELFSIZE = $(SIZE) -A $(OUTDIR)/$(TARGET).elf +##ELFSIZE = $(SIZE) --format=Berkeley --common $(OUTDIR)/$(TARGET).elf +sizebefore: +# @if [ -f $(OUTDIR)/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); echo; fi + +sizeafter: +# @if [ -f $(OUTDIR)/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi + @echo $(MSG_SIZE_AFTER) + $(ELFSIZE) + +# Display compiler version information. +gccversion : + @$(CC) --version +# @echo $(ALLOBJ) + +# 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).elf + @echo ${quote}Programming with OPENOCD${quote} + $(OOCD_EXE) $(OOCD_CL) +endif + +# Create final output file (.hex) from ELF output file. +%.hex: %.elf +## @echo + @echo $(MSG_LOAD_FILE) $@ + $(OBJCOPY) -O ihex $< $@ + +# Create final output file (.bin) from ELF output file. +%.bin: %.elf +## @echo + @echo $(MSG_LOAD_FILE) $@ + $(OBJCOPY) -O binary $< $@ + +# Create extended listing file/disassambly from ELF output file. +# using objdump testing: option -C +%.lss: %.elf +## @echo + @echo $(MSG_EXTENDED_LISTING) $@ + $(OBJDUMP) -h -S -C -r $< > $@ +# $(OBJDUMP) -x -S $< > $@ + +# Create a symbol table from ELF output file. +%.sym: %.elf +## @echo + @echo $(MSG_SYMBOL_TABLE) $@ + $(NM) -n $< > $@ + +# Link: create ELF output file from object files. +.SECONDARY : $(TARGET).elf +.PRECIOUS : $(ALLOBJ) +%.elf: $(ALLOBJ) + @echo $(MSG_LINKING) $@ +# use $(CC) for C-only projects or $(CPP) for C++-projects: + $(CC) $(THUMB) $(CFLAGS) $(ALLOBJ) --output $@ $(LDFLAGS) +# $(CPP) $(THUMB) $(CFLAGS) $(ALLOBJ) --output $@ $(LDFLAGS) + + +# Assemble: create object files from assembler source files. +define ASSEMBLE_TEMPLATE +$(OUTDIR)/$(notdir $(basename $(1))).o : $(1) +## @echo + @echo $(MSG_ASSEMBLING) $$< to $$@ + $(CC) -c $(THUMB) $$(ASFLAGS) $$< -o $$@ +endef +$(foreach src, $(ASRC), $(eval $(call ASSEMBLE_TEMPLATE, $(src)))) + +# Assemble: create object files from assembler source files. ARM-only +define ASSEMBLE_ARM_TEMPLATE +$(OUTDIR)/$(notdir $(basename $(1))).o : $(1) +## @echo + @echo $(MSG_ASSEMBLING_ARM) $$< to $$@ + $(CC) -c $$(ASFLAGS) $$< -o $$@ +endef +$(foreach src, $(ASRCARM), $(eval $(call ASSEMBLE_ARM_TEMPLATE, $(src)))) + + +# Compile: create object files from C source files. +define COMPILE_C_TEMPLATE +$(OUTDIR)/$(notdir $(basename $(1))).o : $(1) +## @echo + @echo $(MSG_COMPILING) $$< to $$@ + $(CC) -c $(THUMB) $$(CFLAGS) $$(CONLYFLAGS) $$< -o $$@ +endef +$(foreach src, $(SRC), $(eval $(call COMPILE_C_TEMPLATE, $(src)))) + +# Compile: create object files from C source files. ARM-only +define COMPILE_C_ARM_TEMPLATE +$(OUTDIR)/$(notdir $(basename $(1))).o : $(1) +## @echo + @echo $(MSG_COMPILING_ARM) $$< to $$@ + $(CC) -c $$(CFLAGS) $$(CONLYFLAGS) $$< -o $$@ +endef +$(foreach src, $(SRCARM), $(eval $(call COMPILE_C_ARM_TEMPLATE, $(src)))) + + +# Compile: create object files from C++ source files. +define COMPILE_CPP_TEMPLATE +$(OUTDIR)/$(notdir $(basename $(1))).o : $(1) +## @echo + @echo $(MSG_COMPILINGCPP) $$< to $$@ + $(CC) -c $(THUMB) $$(CFLAGS) $$(CPPFLAGS) $$< -o $$@ +endef +$(foreach src, $(CPPSRC), $(eval $(call COMPILE_CPP_TEMPLATE, $(src)))) + +# Compile: create object files from C++ source files. ARM-only +define COMPILE_CPP_ARM_TEMPLATE +$(OUTDIR)/$(notdir $(basename $(1))).o : $(1) +## @echo + @echo $(MSG_COMPILINGCPP_ARM) $$< to $$@ + $(CC) -c $$(CFLAGS) $$(CPPFLAGS) $$< -o $$@ +endef +$(foreach src, $(CPPSRCARM), $(eval $(call COMPILE_CPP_ARM_TEMPLATE, $(src)))) + + +# Compile: create assembler files from C source files. ARM/Thumb +$(SRC:.c=.s) : %.s : %.c + @echo $(MSG_ASMFROMC) $< to $@ + $(CC) $(THUMB) -S $(CFLAGS) $(CONLYFLAGS) $< -o $@ + +# Compile: create assembler files from C source files. ARM only +$(SRCARM:.c=.s) : %.s : %.c + @echo $(MSG_ASMFROMC_ARM) $< to $@ + $(CC) -S $(CFLAGS) $(CONLYFLAGS) $< -o $@ + +# Generate Doxygen documents +docs: + doxygen $(DOXYGENDIR)/doxygen.cfg + +# Target: clean project. +clean: begin clean_list finished end + +clean_list : +## @echo + @echo $(MSG_CLEANING) + $(REMOVE) $(OUTDIR)/$(TARGET).map + $(REMOVE) $(OUTDIR)/$(TARGET).elf + $(REMOVE) $(OUTDIR)/$(TARGET).hex + $(REMOVE) $(OUTDIR)/$(TARGET).bin + $(REMOVE) $(OUTDIR)/$(TARGET).sym + $(REMOVE) $(OUTDIR)/$(TARGET).lss + $(REMOVE) $(ALLOBJ) + $(REMOVE) $(LSTFILES) + $(REMOVE) $(DEPFILES) + $(REMOVE) $(SRC:.c=.s) + $(REMOVE) $(SRCARM:.c=.s) + $(REMOVE) $(CPPSRC:.cpp=.s) + $(REMOVE) $(CPPSRCARM:.cpp=.s) + + +# Create output files directory +# all known MS Windows OS define the ComSpec environment variable +ifdef ComSpec +$(shell md $(OUTDIR) 2>NUL) +else +$(shell mkdir $(OUTDIR) 2>/dev/null) +endif + +# Include the dependency files. +ifdef ComSpec +-include $(shell md $(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 begin finish end sizebefore sizeafter gccversion \ +build elf hex bin lss sym clean clean_list program + Index: OpenPilot/System/pios_board_x86.c =================================================================== --- OpenPilot/System/pios_board_x86.c (Revision 0) +++ OpenPilot/System/pios_board_x86.c (Revision 0) @@ -0,0 +1,112 @@ +/** + ****************************************************************************** + * + * @file pios_board.c + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @brief Defines board specific static initializers for hardware for the OpenPilot board. + * @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 +#include + + +const struct pios_udp_cfg pios_udp0_cfg = { + .ip = "0.0.0.0", + .port = 9000, +}; +const struct pios_udp_cfg pios_udp1_cfg = { + .ip = "0.0.0.0", + .port = 9001, +}; +const struct pios_udp_cfg pios_udp2_cfg = { + .ip = "0.0.0.0", + .port = 9002, +}; + +#ifdef PIOS_COM_AUX +/* + * AUX USART + */ +const struct pios_udp_cfg pios_udp3_cfg = { + .ip = "0.0.0.0", + .port = 9003, +}; +#endif + +/* + * Board specific number of devices. + */ +struct pios_udp_dev pios_udp_devs[] = { +#define PIOS_UDP_TELEM 0 + { + .cfg = &pios_udp0_cfg, + }, +#define PIOS_UDP_GPS 1 + { + .cfg = &pios_udp1_cfg, + }, +#define PIOS_UDP_LOCAL 2 + { + .cfg = &pios_udp2_cfg, + }, +#ifdef PIOS_COM_AUX +#define PIOS_UDP_AUX 3 + { + .cfg = &pios_udp3_cfg, + }, +#endif +}; + +uint8_t pios_udp_num_devices = NELEMENTS(pios_udp_devs); + +/* + * COM devices + */ + +/* + * Board specific number of devices. + */ +extern const struct pios_com_driver pios_serial_com_driver; +extern const struct pios_com_driver pios_udp_com_driver; + +struct pios_com_dev pios_com_devs[] = { + { + .id = PIOS_UDP_TELEM, + .driver = &pios_udp_com_driver, + }, + { + .id = PIOS_UDP_GPS, + .driver = &pios_udp_com_driver, + }, + { + .id = PIOS_UDP_LOCAL, + .driver = &pios_udp_com_driver, + }, +#ifdef PIOS_COM_AUX + { + .id = PIOS_UDP_AUX, + .driver = &pios_udp_com_driver, + }, +#endif +}; + +const uint8_t pios_com_num_devices = NELEMENTS(pios_com_devs); + Index: OpenPilot/System/inc/pios_config.h =================================================================== --- OpenPilot/System/inc/pios_config.h (Revision 966) +++ OpenPilot/System/inc/pios_config.h (Arbeitskopie) @@ -53,6 +53,9 @@ #define PIOS_INCLUDE_FREERTOS #define PIOS_INCLUDE_GPIO #define PIOS_INCLUDE_EXTI +/* Only available on x86 so far */ +#define PIOS_INCLUDE_UDP +//#define PIOS_INCLUDE_SERIAL /* Defaults for Logging */ Index: OpenPilot/System/inc/pios_board_x86.h =================================================================== --- OpenPilot/System/inc/pios_board_x86.h (Revision 0) +++ OpenPilot/System/inc/pios_board_x86.h (Revision 0) @@ -0,0 +1,67 @@ +/** + ****************************************************************************** + * + * @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 PIOS_BOARD_H +#define PIOS_BOARD_H + + + + +//------------------------ +// PIOS_LED +//------------------------ +//#define PIOS_LED_LED1_GPIO_PORT GPIOC +//#define PIOS_LED_LED1_GPIO_PIN GPIO_Pin_12 +//#define PIOS_LED_LED1_GPIO_CLK RCC_APB2Periph_GPIOC +//#define PIOS_LED_LED2_GPIO_PORT GPIOC +//#define PIOS_LED_LED2_GPIO_PIN GPIO_Pin_13 +//#define PIOS_LED_LED2_GPIO_CLK RCC_APB2Periph_GPIOC +#define PIOS_LED_NUM 2 +//#define PIOS_LED_PORTS { PIOS_LED_LED1_GPIO_PORT, PIOS_LED_LED2_GPIO_PORT } +//#define PIOS_LED_PINS { PIOS_LED_LED1_GPIO_PIN, PIOS_LED_LED2_GPIO_PIN } +//#define PIOS_LED_CLKS { PIOS_LED_LED1_GPIO_CLK, PIOS_LED_LED2_GPIO_CLK } + + +//------------------------- +// COM +// +// See also pios_board_x86.c +//------------------------- +//#define PIOS_USART_TX_BUFFER_SIZE 256 +#define PIOS_COM_BUFFER_SIZE 1024 +#define PIOS_UDP_RX_BUFFER_SIZE PIOS_COM_BUFFER_SIZE + +#define PIOS_COM_TELEM_RF 0 +#define PIOS_COM_GPS 1 +#define PIOS_COM_TELEM_USB 2 + +#ifdef PIOS_ENABLE_AUX_UART +#define PIOS_COM_AUX 3 +#define PIOS_COM_DEBUG PIOS_COM_AUX +#endif + + +#endif /* PIOS_BOARD_H */ Index: OpenPilot/System/openpilot.c =================================================================== --- OpenPilot/System/openpilot.c (Revision 966) +++ OpenPilot/System/openpilot.c (Arbeitskopie) @@ -96,12 +96,14 @@ /* Delay system */ PIOS_DELAY_Init(); +#ifndef X86_WRAPPERS /* SPI Init */ PIOS_SPI_Init(); /* Enable and mount the SDCard */ PIOS_SDCARD_Init(); PIOS_SDCARD_MountFS(0); +#endif /* Initialize UAVObject libraries */ EventDispatcherInitialize(); @@ -113,6 +115,7 @@ /* Initialize the PiOS library */ PIOS_COM_Init(); +#ifndef X86_WRAPPERS PIOS_Servo_Init(); PIOS_ADC_Init(); PIOS_GPIO_Init(); @@ -127,6 +130,7 @@ #endif PIOS_USB_Init(0); PIOS_I2C_Init(); +#endif /*X86_WRAPPERS*/ /* Initialize modules */ InitModules(); Index: OpenPilot/UAVObjects/uavobjectmanager.c =================================================================== --- OpenPilot/UAVObjects/uavobjectmanager.c (Revision 966) +++ OpenPilot/UAVObjects/uavobjectmanager.c (Arbeitskopie) @@ -529,16 +529,28 @@ } // Write the object ID +#ifndef X86_WRAPPERS DFS_WriteFile(file, PIOS_SDCARD_Sector, (uint8_t*)&objEntry->id, &bytesWritten, 4); +#else + bytesWritten=fwrite((uint8_t*)&objEntry->id,1,4,*file); +#endif // Write the instance ID if (!objEntry->isSingleInstance) { +#ifndef X86_WRAPPERS DFS_WriteFile(file, PIOS_SDCARD_Sector, (uint8_t*)&instEntry->instId, &bytesWritten, 2); +#else + bytesWritten=fwrite((uint8_t*)&instEntry->instId,1,2,*file); +#endif } // Write the data and check that the write was successful +#ifndef X86_WRAPPERS DFS_WriteFile(file, PIOS_SDCARD_Sector, instEntry->data, &bytesWritten, objEntry->numBytes); +#else + bytesWritten=fwrite((uint8_t*)&instEntry->data,1,objEntry->numBytes,*file); +#endif if ( bytesWritten != objEntry->numBytes ) { xSemaphoreGiveRecursive(mutex); @@ -582,7 +594,11 @@ objectFilename(objEntry, filename); // Open file +#ifndef X86_WRAPPERS if ( DFS_OpenFile(&PIOS_SDCARD_VolInfo, (uint8_t *)filename, DFS_WRITE, PIOS_SDCARD_Sector, &file) != DFS_OK ) +#else + if ((file=fopen((char*)filename,"w"))==NULL) +#endif { xSemaphoreGiveRecursive(mutex); return -1; @@ -591,13 +607,21 @@ // Append object if ( UAVObjSaveToFile(obj, instId, &file) == -1 ) { +#ifndef X86_WRAPPERS DFS_Close(&file); +#else + fclose(file); +#endif xSemaphoreGiveRecursive(mutex); return -1; } // Done, close file and unlock +#ifndef X86_WRAPPERS DFS_Close(&file); +#else + fclose(file); +#endif xSemaphoreGiveRecursive(mutex); return 0; } @@ -626,7 +650,11 @@ xSemaphoreTakeRecursive(mutex, portMAX_DELAY); // Read the object ID +#ifndef X86_WRAPPERS if ( DFS_ReadFile(file, PIOS_SDCARD_Sector, (uint8_t*)&objId, &bytesRead, 4) != DFS_OK ) +#else + if ((bytesRead=fread((uint8_t*)&objId,1,4,*file))!=4) +#endif { xSemaphoreGiveRecursive(mutex); return 0; @@ -645,7 +673,11 @@ instId = 0; if ( !objEntry->isSingleInstance ) { +#ifndef X86_WRAPPERS if ( DFS_ReadFile(file, PIOS_SDCARD_Sector, (uint8_t*)&instId, &bytesRead, 2) != DFS_OK ) +#else + if ((bytesRead=fread((uint8_t*)&instId,1,2,*file))!=2) +#endif { xSemaphoreGiveRecursive(mutex); return 0; @@ -668,7 +700,11 @@ } // Read the instance data +#ifndef X86_WRAPPERS if ( DFS_ReadFile(file, PIOS_SDCARD_Sector, (uint8_t*)instEntry->data, &bytesRead, objEntry->numBytes) != DFS_OK ) +#else + if ((bytesRead=fread((uint8_t*)&instEntry->data,1,objEntry->numBytes,*file))!=objEntry->numBytes) +#endif { xSemaphoreGiveRecursive(mutex); return 0; @@ -714,7 +750,11 @@ objectFilename(objEntry, filename); // Open file +#ifndef X86_WRAPPERS if ( DFS_OpenFile(&PIOS_SDCARD_VolInfo, (uint8_t *)filename, DFS_WRITE, PIOS_SDCARD_Sector, &file) != DFS_OK ) +#else + if ((file=fopen((char*)filename,"r"))==NULL) +#endif { xSemaphoreGiveRecursive(mutex); return -1; @@ -724,7 +764,11 @@ loadedObj = UAVObjLoadFromFile(&file); if (loadedObj == 0) { +#ifndef X86_WRAPPERS DFS_Close(&file); +#else + fclose(file); +#endif xSemaphoreGiveRecursive(mutex); return -1; } @@ -733,13 +777,21 @@ loadedObjEntry = (ObjectList*)loadedObj; if ( loadedObjEntry->id != objEntry->id ) { +#ifndef X86_WRAPPERS DFS_Close(&file); +#else + fclose(file); +#endif xSemaphoreGiveRecursive(mutex); return -1; } // Done, close file and unlock +#ifndef X86_WRAPPERS DFS_Close(&file); +#else + fclose(file); +#endif xSemaphoreGiveRecursive(mutex); return 0; } @@ -771,7 +823,11 @@ objectFilename(objEntry, filename); // Delete file +#ifndef X86_WRAPPERS DFS_UnlinkFile(&PIOS_SDCARD_VolInfo, (uint8_t *)filename, PIOS_SDCARD_Sector); +#else + unlink((char*)filename); +#endif // Done xSemaphoreGiveRecursive(mutex); Index: OpenPilot/UAVObjects/inc/uavobjectmanager.h =================================================================== --- OpenPilot/UAVObjects/inc/uavobjectmanager.h (Revision 966) +++ OpenPilot/UAVObjects/inc/uavobjectmanager.h (Arbeitskopie) @@ -29,7 +29,11 @@ #define UAVOBJ_ALL_INSTANCES 0xFFFF #define UAVOBJ_MAX_INSTANCES 1000 +#ifndef X86_WRAPPERS typedef uint32_t UAVObjHandle; +#else +typedef size_t UAVObjHandle; /* on x86_64 pointers are not 32 bit */ +#endif /** * Object update mode, used by multiple modules (e.g. telemetry and logger) Index: OpenPilot/UAVTalk/uavtalk.c =================================================================== --- OpenPilot/UAVTalk/uavtalk.c (Revision 966) +++ OpenPilot/UAVTalk/uavtalk.c (Arbeitskopie) @@ -76,7 +76,7 @@ // Private functions static uint8_t updateCRC(uint8_t crc, const uint8_t* data, int32_t length); -static int32_t objectTransaction(uint32_t objectId, uint16_t instId, uint8_t type, int32_t timeout); +static int32_t objectTransaction(UAVObjHandle objectId, uint16_t instId, uint8_t type, int32_t timeout); static int32_t sendObject(UAVObjHandle obj, uint16_t instId, uint8_t type); static int32_t sendSingleObject(UAVObjHandle obj, uint16_t instId, uint8_t type); static int32_t receiveObject(uint8_t type, UAVObjHandle obj, uint16_t instId, uint8_t* data, int32_t length); Index: OpenPilot/Modules/System/systemmod.c =================================================================== --- OpenPilot/Modules/System/systemmod.c (Revision 966) +++ OpenPilot/Modules/System/systemmod.c (Arbeitskopie) @@ -208,7 +208,11 @@ // Get stats and update SystemStatsGet(&stats); stats.FlightTime = xTaskGetTickCount()*portTICK_RATE_MS; +#ifndef X86_WRAPPERS stats.HeapRemaining = xPortGetFreeHeapSize(); +#else + stats.HeapRemaining = 10240; +#endif stats.CPULoad = 100 - (uint8_t)round(100.0*((float)idleCounter/(float)(SYSTEM_UPDATE_PERIOD_MS/1000))/(float)IDLE_COUNTS_PER_SEC_AT_NO_LOAD); idleCounterClear = 1; SystemStatsSet(&stats);