Compile using MAKEFILE - HowTo for rookies

News, Setup, Compiling, Flashing, Development

Compile using MAKEFILE - HowTo for rookies

Postby afernan » Tue Apr 08, 2014 2:23 pm

For those impatients and adventurous, lasts fw can be easily compiled using MAKEFILE included inside "onboard" folder (for instance, r372)

First you need to download the libraries "STM32F4xx_DSP_StdPeriph_Lib_V1.3.0" (http://www.st.com/web/en/catalog/tools/PF257901) that must be located at same level than the "build" folder (normally at same level than "onboard", etc). See as an example my folder arrangement in the image below

You need to edit only your particular compiler path at onboard/makefile, line 70. In my particular case I have:
Code: Select all
CC_PATH ?= C:\CW


Now open a command line (CMD windows prompt) starting at "onboard" level. Now execute the following (for a board rev0 and DIMU version 1.1 as an example)

make all BOARD_REV=0 DIMU_VER=11

You should get the hex file under "build/release": "aqv.r372.b1709-hwv6.0-dimu11.hex"

That´s it.

UPDATE I_________________________________________________
We can select three versions of DIMU: 10,11,20

Dimu 10 was development, probably without eeprom
Dimu 11 is dimu v1.01 (pre prod) & v1.11 (current prod)
Dimu 20 is not used, there was a time that dimu v1, v2 & v3 where used as reference.

UPDATE (II)________________________________________________

I´m just installed from scratch in a new PC (W7). To get all AQ compiling tools running you need only to do the following: (I guess you have all "CW" files already in your PC copied)
1.- Install "yagarto" tools (http://www.yagarto.de/#download) or simply copy the files from other PC
2.- Activate Path for yagarto : go to system variables and edit "path". Write at the end of the line:
Code: Select all
;c:\bin\yagarto\tools\bin;c:\bin\yagarto\toolchain\bin;

3.- RESTART. That´s it. Now you can run Makefile in a CMD window and compile AQ
Angel
Attachments
Captura.JPG
Captura.JPG (16.98 KiB) Viewed 8537 times
Last edited by afernan on Fri May 09, 2014 10:43 am, edited 3 times in total.
afernan
 
Posts: 1214
Joined: Sat Jul 07, 2012 5:24 pm
Location: Madrid, Spain

Re: Compile using MAKEFILE - HowTo for rookies

Postby flyrobot » Fri Apr 11, 2014 1:00 pm

Hi Afernan,

Yesterday, I just new to try compile AQ from source. I have some question (as really rookies) :
1. if its running in Windows, do I need install "GNUWIN32 make" ?
2. Do i need install CrossStudio first ?


Thanks,

John
flyrobot
 
Posts: 64
Joined: Thu Jun 06, 2013 6:04 pm

Re: Compile using MAKEFILE - HowTo for rookies

Postby skew » Fri Apr 11, 2014 2:38 pm

The easiest setup for windows
1.Download Yagarto Tools and install (this will install make,gawk and set your windows path)
https://code.google.com/p/csud/downloads/detail?name=yagarto-tools-20121018-setup.exe&can=2&q=
REBOOT computer

2. Install Crossworks and after its done copy everything under Program files\Rowley Associates Limited\CrossWorks for ARM 3.0 to c:\cw
skew
 
Posts: 181
Joined: Sun Oct 14, 2012 1:30 am
Location: Morehead, Ky

Re: Compile using MAKEFILE - HowTo for rookies

Postby flyrobot » Fri Apr 11, 2014 5:37 pm

Hi Skew,

Thank you for the info. I follow your guide, I got error :

Code: Select all
C:\CW\onboard>make all BOARD_REV=1 DIMU_VER=11
process_begin: CreateProcess(NULL, gawk "BEGIN { FS = \"[ \\\"]+\" }$2 ~ /FI(MR|
RM)WARE_VERSION/{print $3}" ./getbuildnum.h, ...) failed.
process_begin: CreateProcess(NULL, gawk "$2 ~ /REVISION/{print $4}" ./buildnum.h
, ...) failed.
process_begin: CreateProcess(NULL, gawk "$2 ~ /BUILDNUMBER/{print $NF}" ./buildn
um.h, ...) failed.
Attempting to create build folders...
mkdir -p ../build/Release/obj
mkdir -p ../build/Release/obj/STM32SYS
mkdir -p ../build/Release/obj/STM32DSPLIB
/usr/bin/sh: gawk: command not found
Incrementing Build Number
## Compiling 1wire.c -> ../build/Release/obj/1wire.o ##
C:\CW/gcc/arm-unknown-eabi/bin/cc1 -mcpu=cortex-m4 -mthumb -mlittle-endian -mfpu
=fpv4-sp-d16 -mfloat-abi=hard -nostdinc -fsingle-precision-constant -Wall -finli
ne-functions -Wdouble-promotion -std=c99 -fno-dwarf2-cfi-asm -fno-builtin -ffunc
tion-sections -fdata-sections -fno-common -fmessage-length=0 -quiet -I. -I../STM
32/include -I../STM32F4xx_DSP_StdPeriph_Lib_V1.3.0/Libraries/STM32F4xx_StdPeriph
_Driver/inc -I../STM32F4xx_DSP_StdPeriph_Lib_V1.3.0/Libraries/CMSIS/Include -I..
/mavlink/include/autoquad -IC:\CW/include  -D__ARM_ARCH_7EM__ -D__CROSSWORKS_ARM
 -D__ARM_ARCH_FPV4_SP_D16__ -D__TARGET_PROCESSOR=STM32F407VG -D__TARGET_F4XX= -D
STM32F4XX= -DSTM32F40_41xxx -D__FPU_PRESENT -DARM_MATH_CM4 -D__THUMB -DNESTED_IN
TERRUPTS -DCTL_TASKING -DUSE_STDPERIPH_DRIVER -DBOARD_VERSION=6 -DBOARD_REVISION
=1 -DDIMU_VERSION=11 -DNDEBUG -DSTARTUP_FROM_RESET -O2 -MD ../build/Release/obj/
1wire.d -MQ ../build/Release/obj/1wire.o 1wire.c -o ../build/Release/obj/1wire.l
st
process_begin: CreateProcess(NULL, C:\CW/gcc/arm-unknown-eabi/bin/cc1 -mcpu=cort
ex-m4 -mthumb -mlittle-endian -mfpu=fpv4-sp-d16 -mfloat-abi=hard -nostdinc -fsin
gle-precision-constant -Wall -finline-functions -Wdouble-promotion -std=c99 -fno
-dwarf2-cfi-asm -fno-builtin -ffunction-sections -fdata-sections -fno-common -fm
essage-length=0 -quiet -I. -I../STM32/include -I../STM32F4xx_DSP_StdPeriph_Lib_V
1.3.0/Libraries/STM32F4xx_StdPeriph_Driver/inc -I../STM32F4xx_DSP_StdPeriph_Lib_
V1.3.0/Libraries/CMSIS/Include -I../mavlink/include/autoquad -IC:\CW/include -D_
_ARM_ARCH_7EM__ -D__CROSSWORKS_ARM -D__ARM_ARCH_FPV4_SP_D16__ -D__TARGET_PROCESS
OR=STM32F407VG -D__TARGET_F4XX= -DSTM32F4XX= -DSTM32F40_41xxx -D__FPU_PRESENT -D
ARM_MATH_CM4 -D__THUMB -DNESTED_INTERRUPTS -DCTL_TASKING -DUSE_STDPERIPH_DRIVER
-DBOARD_VERSION=6 -DBOARD_REVISION=1 -DDIMU_VERSION=11 -DNDEBUG -DSTARTUP_FROM_R
ESET -O2 -MD ../build/Release/obj/1wire.d -MQ ../build/Release/obj/1wire.o 1wire
.c -o ../build/Release/obj/1wire.lst, ...) failed.
make (e=2): The system cannot find the file specified.
[size=85]make: *** [../build/Release/obj/1wire.o] Error 2

I see this "/usr/bin/sh: gawk: command not found " and I saw there no gawk on yagarto tools

"Unix tools: cp, make, mkdir, rm, sh, touch
Source: http://www.yagarto.de/#download
Version: 20121018

Thanks

John
flyrobot
 
Posts: 64
Joined: Thu Jun 06, 2013 6:04 pm

Re: Compile using MAKEFILE - HowTo for rookies

Postby Max » Fri Apr 11, 2014 6:41 pm

Read notes at top of Makefile.

Code: Select all
# Windows needs some core GNU tools in your %PATH% (probably same place your "make" is).
#    Required: gawk, mv, echo, rm
#    Optional: mkdir (auto-create build folders),  zip (to compress hex files using "make pack")
#   Also see EXE_MKDIR variable below -- due to a naming conflict with the Windows "mkdir", you may need to specify a full path for it.
#   Recommend GnuWin32 CoreUtils http://gnuwin32.sourceforge.net/packages/coreutils.htm
#


-Max
Max
 
Posts: 2814
Joined: Mon Aug 13, 2012 9:45 pm
Location: Near Ithaca, NY, USA

Re: Compile using MAKEFILE - HowTo for rookies

Postby flyrobot » Fri Apr 11, 2014 7:39 pm

Hi Max,

Thank you for the clue. I install the GnuWin32 coreutils and the installation is on this folder :
C:\Program Files\GnuWin32\

I modify the makefile :

Code: Select all
# Makefile for AutoQuad Flight Controller firmware
#
# ! Use of this makefile requires setup of a compatible development environment.
# ! For latest development recommendations, check here: http://autoquad.org/wiki/wiki/development/
# ! This file is ignored when building with CrossWorks Studio.
#
# All paths are relative to Makefile location.  Possible make targets:
#  all         build firmware .elf and .hex binaries
#  flash       attempt to build ../ground/loader and flash firmware to board (linux only)
#  pack        create .zip archive of generated .hex file (requires GNU zip)
#  clean       delete all built objects (not binaries or archives)
#  clean-bin   delete all binaries created in build folder (*.elf, *.bin, *.hex)
#  clean-pack  delete all archives in build folder (*.zip)
#  clean-all   run all the above clean* steps.
#
# Read comments below under "External libraries required by AQ" for dependency details.
#
# Usage examples:
#   make all                              # default Release type builds .hex and .elf binaries
#   make all BUILD_TYPE=Debug             # build with compiler debugging flags/options enabled
#   make all BOARD_REV=1 INCR_BUILDNUM=0  # build for rev 1 (post Oct-2012) hardware, don't increment the buildnumber
#
# Windows needs some core GNU tools in your %PATH% (probably same place your "make" is).
#    Required: gawk, mv, echo, rm
#    Optional: mkdir (auto-create build folders),  zip (to compress hex files using "make pack")
#   Also see EXE_MKDIR variable below -- due to a naming conflict with the Windows "mkdir", you may need to specify a full path for it.
#   Recommend GnuWin32 CoreUtils http://gnuwin32.sourceforge.net/packages/coreutils.htm
#

# Include user-specific settings file, if any, in regular Makefile format.
# This file can set any default variable values you wish to override (all defaults are listed below).
# The .user file is not included with the source code distribution, so it will not be overwritten.
-include Makefile.user

# Defaults - modify here, on command line, or in Makefile.user
#
# Output folder name; Use 'Debug' to set debug compiler options;
BUILD_TYPE ?= Release
# Path to source files - no trailing slash
SRC_PATH ?= .
# Board version to build for (6|7|8(mx))
BOARD_VER ?= 6
# Board revision to build for (0 = v6 initial release revision, 1 = v6 Oct. 2012 revision)
BOARD_REV ?= 1
# Specify a DIMU version number to enable DIMU support in AQ, zero to disable (eg. DIMU_VER=1.1)
DIMU_VER ?= 1.1
# Increment build number? (0|1)  This is automatically disabled for debug builds.
INCR_BUILDNUM ?= 1
# Use the single-folder source file organization from AQ repo? (0|1)
FLAT_SRC ?= 1
# Produced binaries file name prefix (version/revision/build/hardware info will be automatically appended)
BIN_NAME ?= aq
# Build debug version? (0|1; true by default if build_type contains the word "debug")
ifeq ($(findstring Debug, $(BUILD_TYPE)), Debug)
   DEBUG_BUILD ?= 1
else
   DEBUG_BUILD ?= 0
endif
# Flashing interface (Linux only)
USB_DEVICE ?= /dev/ttyUSB0

# You may also use BIN_SUFFIX to append text
# to generated bin file name after version string;
# BIN_SUFFIX =


# System-specific folder paths and commands
#
# compiler base path
CC_PATH ?= C:\CW
#CC_PATH ?= C:/devel/gcc/crossworks_for_arm_2.3

# shell commands
EXE_AWK ?= C:\Program Files\GnuWin32\bin\awk
EXE_MKDIR ?= C:\Program Files\GnuWin32\bin\mkdir
#EXE_MKDIR = C:/cygwin/bin/mkdir
EXE_ZIP ?= zip
# file extention for compressed files (gz for gzip, etc)
ZIP_EXT ?= zip

# Path to libraries/includes
# see "External libraries required by AQ" below
AQLIB_PATH ?= ..
#AQLIB_PATH = C:/devel/AQ/lib

# Where to put the built objects and binaries.
# A sub-folder is created along this path, named as the BUILD_TYPE (eg. build/Release).
#BUILD_PATH ?= .
BUILD_PATH ?= ../build

# Add preprocessor definitions here (eg. CC_VARS=-DCOMM_DISABLE_FLOW_CONTROL1 to disable flow control on USART 1)
CC_VARS ?=


# defaults end

#
## probably don't need to change anything below here ##
#

# build/object directory
OBJ_PATH = $(BUILD_PATH)/$(BUILD_TYPE)/obj
# bin file(s) output path
BIN_PATH = $(BUILD_PATH)/$(BUILD_TYPE)

# command to execute (later, if necessary) for increasing build number in buildnum.h
CMD_BUILDNUMBER = $(shell $(EXE_AWK) '$$2 ~ /BUILDNUMBER/{ $$NF=$$NF+1 } 1' $(SRC_PATH)/buildnum.h > $(SRC_PATH)/tmp_buildnum.h && mv $(SRC_PATH)/tmp_buildnum.h $(SRC_PATH)/buildnum.h)

# get current revision and build numbers
FW_VER := $(shell $(EXE_AWK) 'BEGIN { FS = "[ \"]+" }$$2 ~ /FI(MR|RM)WARE_VERSION/{print $$3}' $(SRC_PATH)/getbuildnum.h)
REV_NUM := $(shell $(EXE_AWK) '$$2 ~ /REVISION/{print $$4}' $(SRC_PATH)/buildnum.h)
BUILD_NUM := $(shell $(EXE_AWK) '$$2 ~ /BUILDNUMBER/{print $$NF}' $(SRC_PATH)/buildnum.h)
ifeq ($(INCR_BUILDNUM), 1)
   BUILD_NUM := $(shell echo $$[$(BUILD_NUM)+1])
endif

# Resulting bin file names before extension
ifeq ($(DEBUG_BUILD), 1)
   # debug build gets a consistent name to simplify dev setup
   BIN_NAME := $(BIN_NAME)-debug
   INCR_BUILDNUM = 0
else
   BIN_NAME := $(BIN_NAME)v$(FW_VER).r$(REV_NUM).b$(BUILD_NUM)-hwv$(BOARD_VER).$(BOARD_REV)
   ifneq ($(DIMU_VER), 0)
      BIN_NAME := $(BIN_NAME)-dimu$(DIMU_VER)
   endif
   ifdef BIN_SUFFIX
      BIN_NAME := $(BIN_NAME)-$(BIN_SUFFIX)
   endif
endif

# Compiler-specific paths
CC_BIN_PATH = $(CC_PATH)/gcc/arm-unknown-eabi/bin
CC_LIB_PATH = $(CC_PATH)/lib
CC_INC_PATH = $(CC_PATH)/include
CC = $(CC_BIN_PATH)/cc1
AS = $(CC_BIN_PATH)/as
LD = $(CC_BIN_PATH)/ld
OBJCP = $(CC_BIN_PATH)/objcopy

#
## External libraries required by AQ
#
# Generated MAVLink header files (https://github.com/AutoQuad/mavlink/tree/master/include)
MAVINC_PATH = $(AQLIB_PATH)/mavlink/include/autoquad
# Files from Crossworks SMT32 package: autoquad.ld (STM32f4.ld), STM32F40_41xxx.vec, STM32_Startup.s, & the /include folder
STMLIB_PATH = $(AQLIB_PATH)/STM32
# STM32F4 libs from ST (http://www.st.com/web/en/catalog/tools/PF257901)
STM32DRIVER_PATH = $(AQLIB_PATH)/STM32F4xx_DSP_StdPeriph_Lib_V1.3.0/Libraries/STM32F4xx_StdPeriph_Driver
STM32CMSIS_PATH = $(AQLIB_PATH)/STM32F4xx_DSP_StdPeriph_Lib_V1.3.0/Libraries/CMSIS

# all include flags for the compiler
CC_INCLUDES :=  -I$(SRC_PATH) -I$(STMLIB_PATH)/include -I$(STM32DRIVER_PATH)/inc -I$(STM32CMSIS_PATH)/Include -I$(MAVINC_PATH) -I$(CC_INC_PATH)

# compiler flags
CC_OPTS = -mcpu=cortex-m4 -mthumb -mlittle-endian -mfpu=fpv4-sp-d16 -mfloat-abi=hard -nostdinc -fsingle-precision-constant -Wall -finline-functions -Wdouble-promotion -std=c99 \
   -fno-dwarf2-cfi-asm -fno-builtin -ffunction-sections -fdata-sections -fno-common -fmessage-length=0 -quiet

# macro definitions to pass via compiler command line
#
CC_VARS += -D__ARM_ARCH_7EM__ -D__CROSSWORKS_ARM -D__ARM_ARCH_FPV4_SP_D16__ -D__TARGET_PROCESSOR=STM32F407VG -D__TARGET_F4XX= -DSTM32F4XX= -DSTM32F40_41xxx -D__FPU_PRESENT \
   -DARM_MATH_CM4 -D__THUMB -DNESTED_INTERRUPTS -DCTL_TASKING -DUSE_STDPERIPH_DRIVER
   
# set AQ hardware version and revision
CC_VARS += -DBOARD_VERSION=$(BOARD_VER) -DBOARD_REVISION=$(BOARD_REV)

# build AQ with specific digital IMU version, if specified (fall back to AIMU on v6 hardware)
ifneq ($(DIMU_VER), 0)
   CC_VARS += -DDIMU_VERSION=$(subst .,,$(DIMU_VER))
endif

# Additional target(s) to build based on conditionals
#
EXTRA_TARGETS =
ifeq ($(INCR_BUILDNUM), 1)
   EXTRA_TARGETS = BUILDNUMBER
endif

# build type flags/defs (debug vs. release)
# (exclude STARTUP_FROM_RESET in debug builds if using Rowley debugger)
ifeq ($(DEBUG_BUILD), 1)
   BT_CFLAGS = -DDEBUG -DUSE_FULL_ASSERT -O1 -ggdb -g2
   BT_CFLAGS += -DSTARTUP_FROM_RESET
else
   BT_CFLAGS = -DNDEBUG -DSTARTUP_FROM_RESET -O2
endif


# all compiler options
CFLAGS = $(CC_OPTS) $(CC_INCLUDES) $(CC_VARS) $(BT_CFLAGS)

# assembler options
AS_OPTS = --traditional-format -mcpu=cortex-m4 -mthumb -EL -mfpu=fpv4-sp-d16 -mfloat-abi=hard

# linker (ld) options
LINKER_OPTS = -ereset_handler --omagic -defsym=__do_debug_operation=__do_debug_operation_mempoll -u__do_debug_operation_mempoll -defsym=__vfprintf=__vfprintf_double_long_long -u__vfprintf_double_long_long \
   -defsym=__vfscanf=__vfscanf_double_long_long -u__vfscanf_double_long_long --fatal-warnings -EL --gc-sections -T$(STMLIB_PATH)/autoquad.ld -Map $(OBJ_PATH)/autoquad.map -u_vectors

# eabi linker libs
# ! These are proprietary Rowley libraries, approved for personal use with the AQ project (see http://forum.autoquad.org/viewtopic.php?f=31&t=44&start=50#p8476 )
EXTRA_LIB_FILES = libm_v7em_fpv4_sp_d16_hard_t_le_eabi.a libc_v7em_fpv4_sp_d16_hard_t_le_eabi.a libcpp_v7em_fpv4_sp_d16_hard_t_le_eabi.a \
   libdebugio_v7em_fpv4_sp_d16_hard_t_le_eabi.a libc_targetio_impl_v7em_fpv4_sp_d16_hard_t_le_eabi.a libc_user_libc_v7em_fpv4_sp_d16_hard_t_le_eabi.a

EXTRA_LIBS := $(addprefix $(CC_LIB_PATH)/, $(EXTRA_LIB_FILES))


# AQ code objects to create (correspond to .c source to compile)
AQ_OBJS := 1wire.o adc.o algebra.o analog.o aq_init.o aq_mavlink.o aq_timer.o \
   comm.o command.o compass.o config.o control.o \
   can.o canCalib.o canOSD.o canSensors.o canUart.o \
   d_imu.o digital.o esc32.o eeprom.o \
   ff.o filer.o flash.o fpu.o futaba.o \
   gimbal.o gps.o getbuildnum.o grhott.o \
   hmc5983.o imu.o util.o logger.o \
   main_ctl.o mlinkrx.o motors.o mpu6000.o ms5611.o \
   nav.o nav_ukf.o pid.o ppm.o pwm.o \
   radio.o rotations.o rcc.o rtc.o run.o \
   sdio.o serial.o signaling.o spektrum.o spi.o srcdkf.o supervisor.o \
   telemetry.o ublox.o \
   system_stm32f4xx.o STM32_Startup.o thumb_crt0.o

# CoOS
COOS_OBJS = arch.o core.o event.o flag.o kernelHeap.o mbox.o mm.o mutex.o port.o queue.o sem.o serviceReq.o task.o time.o timer.o utility.o

# USB functions/drivers
USB_OBJS = usb.o usb_bsp.o usb_core.o usb_dcd.o usb_dcd_int.o \
   usbd_core.o  usbd_desc.o  usbd_ioreq.o  usbd_req.o usbd_storage_msd.o \
   usbd_cdc_msc_core.o usbd_msc_bot.o usbd_msc_data.o usbd_msc_scsi.o
#  usb_hcd.o usb_hcd_int.o

# STM32 drivers from STM32F4xx_StdPeriph_Driver/src/
STM32_SYS_OBJ_FILES =  misc.o stm32f4xx_adc.o stm32f4xx_can.o stm32f4xx_dma.o stm32f4xx_exti.o stm32f4xx_flash.o stm32f4xx_gpio.o stm32f4xx_hash.o stm32f4xx_hash_md5.o \
   stm32f4xx_pwr.o stm32f4xx_rcc.o stm32f4xx_rtc.o stm32f4xx_sdio.o stm32f4xx_spi.o stm32f4xx_syscfg.o stm32f4xx_tim.o stm32f4xx_usart.o
STM32_SYS_OBJS := $(addprefix STM32SYS/, $(STM32_SYS_OBJ_FILES))

# ARM drivers from CMSIS/DSP_Lib/Source/
DSPLIB_OBJ_FILES = BasicMathFunctions/arm_scale_f32.o \
   SupportFunctions/arm_fill_f32.o SupportFunctions/arm_copy_f32.o \
   MatrixFunctions/arm_mat_init_f32.o MatrixFunctions/arm_mat_inverse_f32.o MatrixFunctions/arm_mat_trans_f32.o \
   MatrixFunctions/arm_mat_mult_f32.o MatrixFunctions/arm_mat_add_f32.o MatrixFunctions/arm_mat_sub_f32.o \
   StatisticsFunctions/arm_mean_f32.o StatisticsFunctions/arm_std_f32.o
DSPLIB_OBJS := $(addprefix STM32DSPLIB/, $(DSPLIB_OBJ_FILES))


# all objects
C_OBJECTS := $(addprefix $(OBJ_PATH)/, $(AQ_OBJS) $(STM32_SYS_OBJS) $(DSPLIB_OBJS) $(COOS_OBJS) $(USB_OBJS))

# dependency files generated by previous make runs
DEPS := $(C_OBJECTS:.o=.d)


#
## Target definitions
#

.PHONY: all clean-all clean clean-bin clean-pack pack CREATE_BUILD_FOLDER BUILDNUMBER

all: CREATE_BUILD_FOLDER $(EXTRA_TARGETS) $(BIN_PATH)/$(BIN_NAME).hex

clean-all: clean clean-bin clean-pack

clean:
   -rm -fr $(OBJ_PATH)
   
clean-bin:
   -rm -f $(BIN_PATH)/*.elf
   -rm -f $(BIN_PATH)/*.bin
   -rm -f $(BIN_PATH)/*.hex

clean-pack:
   -rm -f $(BIN_PATH)/*.$(ZIP_EXT)
   
pack:
   @echo "Compressing binaries... "
   $(EXE_ZIP) $(BIN_PATH)/$(BIN_NAME).hex.$(ZIP_EXT) $(BIN_PATH)/$(BIN_NAME).hex

# include auto-generated depenency targets
-include $(DEPS)

$(OBJ_PATH)/%.o: $(SRC_PATH)/%.c
   @echo "## Compiling $< -> $@ ##"
   $(CC) $(CFLAGS) -MD $(basename $@).d -MQ $@ $< -o $(basename $@).lst
   @echo "## Assembling --> $@ ##"
   $(AS) $(AS_OPTS) $(basename $@).lst -o $@
   @rm -f $(basename $@).lst

$(OBJ_PATH)/STM32SYS/%.o: $(STM32DRIVER_PATH)/src/%.c
   @echo "## Compiling $< -> $@ ##"
   $(CC) $(CFLAGS) -MD $(basename $@).d -MQ $@ $< -o $(basename $@).lst
   @echo "## Assembling --> $@ ##"
   $(AS) $(AS_OPTS) $(basename $@).lst -o $@
   @rm -f $(basename $@).lst

$(OBJ_PATH)/STM32DSPLIB/%.o: $(STM32CMSIS_PATH)/DSP_Lib/Source/%.c
   $(EXE_MKDIR) -p $(@D)
   @echo "## Compiling $< -> $@ ##"
   $(CC) $(CFLAGS) -MD $(basename $@).d -MQ $@ $< -o $(basename $@).lst
   @echo "## Assembling --> $@ ##"
   $(AS) $(AS_OPTS) $(basename $@).lst -o $@
   @rm -f $(basename $@).lst

$(OBJ_PATH)/STM32_Startup.o: $(STMLIB_PATH)/STM32_Startup.s
   @echo "## Compiling $< -> $@ ##"
   $(CC) $(CFLAGS) -MD $(basename $@).d -MQ $@ -E -lang-asm $< -o $(basename $@).lst
   @echo "## Assembling --> $@ ##"
   $(AS) $(AS_OPTS) -gdwarf-2 $(basename $@).lst -o $@
   @rm -f $(basename $@).lst

$(OBJ_PATH)/thumb_crt0.o: $(SRC_PATH)/thumb_crt0.s
   @echo "## Compiling $< -> $@ ##"
   $(CC) $(CFLAGS) -MD $(basename $@).d -MQ $@ -E -lang-asm $< -o $(basename $@).lst
   @echo "## Assembling --> $@ ##"
   $(AS) $(AS_OPTS) -gdwarf-2 $(basename $@).lst -o $@
   @rm -f $(basename $@).lst

$(BIN_PATH)/$(BIN_NAME).elf: $(C_OBJECTS)
   @echo "## Linking --> $@ ##"
   $(LD) -X $(LINKER_OPTS) -o $@ --start-group $(C_OBJECTS) $(EXTRA_LIBS) --end-group

$(BIN_PATH)/$(BIN_NAME).bin: $(BIN_PATH)/$(BIN_NAME).elf
   @echo "## Objcopy $< --> $@ ##"
   $(OBJCP) -O binary $< $@

$(BIN_PATH)/$(BIN_NAME).hex: $(BIN_PATH)/$(BIN_NAME).elf
   @echo "## Objcopy $< --> $@ ##"
   $(OBJCP) -O ihex $< $@

CREATE_BUILD_FOLDER :
   @echo "Attempting to create build folders..."
   $(EXE_MKDIR) -p $(OBJ_PATH)
   $(EXE_MKDIR) -p $(OBJ_PATH)/STM32SYS
   $(EXE_MKDIR) -p $(OBJ_PATH)/STM32DSPLIB

BUILDNUMBER :
   @echo "Incrementing Build Number"
   $(CMD_BUILDNUMBER)

## Flash-Loader (Linux only)          ##
## Requires AQ ground tools sources   ##
$(SRC_PATH)/../ground/loader: $(SRC_PATH)/../ground/loader.c
   (cd $(SRC_PATH)/../ground/ ; make loader)

flash: $(SRC_PATH)/../ground/loader
   $(SRC_PATH)/../ground/loader -p $(USB_DEVICE) -b 115200 -f $(BIN_PATH)/$(BIN_NAME).hex


and I still has this error :

Code: Select all
C:\CW\onboard>make all BOARD_REV=1 DIMU_VER=11
Attempting to create build folders...
C:\Program Files\GnuWin32\bin\mkdir -p ../build/Release/obj
C:\Program Files\GnuWin32\bin\mkdir -p ../build/Release/obj/STM32SYS
C:\Program Files\GnuWin32\bin\mkdir -p ../build/Release/obj/STM32DSPLIB
/usr/bin/sh: C:Program: command not found
Incrementing Build Number
## Compiling 1wire.c -> ../build/Release/obj/1wire.o ##
C:\CW/gcc/arm-unknown-eabi/bin/cc1 -mcpu=cortex-m4 -mthumb -mlittle-endian -mfpu
=fpv4-sp-d16 -mfloat-abi=hard -nostdinc -fsingle-precision-constant -Wall -finli
ne-functions -Wdouble-promotion -std=c99 -fno-dwarf2-cfi-asm -fno-builtin -ffunc
tion-sections -fdata-sections -fno-common -fmessage-length=0 -quiet -I. -I../STM
32/include -I../STM32F4xx_DSP_StdPeriph_Lib_V1.3.0/Libraries/STM32F4xx_StdPeriph
_Driver/inc -I../STM32F4xx_DSP_StdPeriph_Lib_V1.3.0/Libraries/CMSIS/Include -I..
/mavlink/include/autoquad -IC:\CW/include  -D__ARM_ARCH_7EM__ -D__CROSSWORKS_ARM
 -D__ARM_ARCH_FPV4_SP_D16__ -D__TARGET_PROCESSOR=STM32F407VG -D__TARGET_F4XX= -D
STM32F4XX= -DSTM32F40_41xxx -D__FPU_PRESENT -DARM_MATH_CM4 -D__THUMB -DNESTED_IN
TERRUPTS -DCTL_TASKING -DUSE_STDPERIPH_DRIVER -DBOARD_VERSION=6 -DBOARD_REVISION
=1 -DDIMU_VERSION=11 -DNDEBUG -DSTARTUP_FROM_RESET -O2 -MD ../build/Release/obj/
1wire.d -MQ ../build/Release/obj/1wire.o 1wire.c -o ../build/Release/obj/1wire.l
st
process_begin: CreateProcess(NULL, C:\CW/gcc/arm-unknown-eabi/bin/cc1 -mcpu=cort
ex-m4 -mthumb -mlittle-endian -mfpu=fpv4-sp-d16 -mfloat-abi=hard -nostdinc -fsin
gle-precision-constant -Wall -finline-functions -Wdouble-promotion -std=c99 -fno
-dwarf2-cfi-asm -fno-builtin -ffunction-sections -fdata-sections -fno-common -fm
essage-length=0 -quiet -I. -I../STM32/include -I../STM32F4xx_DSP_StdPeriph_Lib_V
1.3.0/Libraries/STM32F4xx_StdPeriph_Driver/inc -I../STM32F4xx_DSP_StdPeriph_Lib_
V1.3.0/Libraries/CMSIS/Include -I../mavlink/include/autoquad -IC:\CW/include -D_
_ARM_ARCH_7EM__ -D__CROSSWORKS_ARM -D__ARM_ARCH_FPV4_SP_D16__ -D__TARGET_PROCESS
OR=STM32F407VG -D__TARGET_F4XX= -DSTM32F4XX= -DSTM32F40_41xxx -D__FPU_PRESENT -D
ARM_MATH_CM4 -D__THUMB -DNESTED_INTERRUPTS -DCTL_TASKING -DUSE_STDPERIPH_DRIVER
-DBOARD_VERSION=6 -DBOARD_REVISION=1 -DDIMU_VERSION=11 -DNDEBUG -DSTARTUP_FROM_R
ESET -O2 -MD ../build/Release/obj/1wire.d -MQ ../build/Release/obj/1wire.o 1wire
.c -o ../build/Release/obj/1wire.lst, ...) failed.
make (e=2): The system cannot find the file specified.
make: *** [../build/Release/obj/1wire.o] Error 2


How can I change the sh folder path ?
I think i missed something, I appreciate any help.

Thanks,

John
flyrobot
 
Posts: 64
Joined: Thu Jun 06, 2013 6:04 pm

Re: Compile using MAKEFILE - HowTo for rookies

Postby Max » Sat Apr 12, 2014 12:14 am

Hi John,

Install all the tools to a path with no space (eg. c:\devel\). Use forward slashes in the Makefile paths (/ instead of \).

-Max
Max
 
Posts: 2814
Joined: Mon Aug 13, 2012 9:45 pm
Location: Near Ithaca, NY, USA

Re: Compile using MAKEFILE - HowTo for rookies

Postby Max » Sat Apr 12, 2014 12:17 am

As an added tip, one can create a new file called Makefile.user (capital "M" -- case matters) in the same folder as Makefile, and make all your config changes there. This way your settings are preserved even if the Makefile in the repo changes, and you don't get bugged about conflicts when pulling a new version.

Any variable in the "Defaults" section of the Makefile can be overridden in Makefile.user.

eg. here's my Makefile.user (note that you can use environment vars in there ( $(VAR) ), and my gawk and mv are in my system %PATH% already, so those are commented out)
Code: Select all
BOARD_VER ?= 6
BOARD_REV ?= 0
INCR_BUILDNUM ?= 0

CC_PATH = $(DEVEL_APPS_ROOT)/Crossworks_arm_compiler
#EXE_AWK := $(DEVEL_APPS_ROOT)/cygwin/bin/gawk
#EXE_MV := $(DEVEL_APPS_ROOT)/cygwin/bin/mv
EXE_MKDIR := $(DEVEL_APPS_ROOT)/GnuWin32/bin/mkdir

AQLIB_PATH ?= ../../../lib
BUILD_PATH ?= ../build


-Max
Max
 
Posts: 2814
Joined: Mon Aug 13, 2012 9:45 pm
Location: Near Ithaca, NY, USA

Re: Compile using MAKEFILE - HowTo for rookies

Postby flyrobot » Sat Apr 12, 2014 3:56 am

Hi Max,

It seems my setup is still has problem.
The CC_PATH might wrong. I made like this CC_PATH ?= C:/CW (I put all crosswork installation "Program files\Rowley Associates Limited\CrossWorks for ARM 3.0" into "c:\cw") and no files in this folder except all only folder.
That is why i saw there is no file compiled (Its seems the makefile command to compile first file 1wire.c but fail)

Code: Select all
C:\CW\onboard>make all BOARD_REV=0 DIMU_VER=11
Attempting to create build folders...
C:/devel/mkdir -p ../build/Release/obj
C:/devel/mkdir -p ../build/Release/obj/STM32SYS
C:/devel/mkdir -p ../build/Release/obj/STM32DSPLIB
## Compiling 1wire.c -> ../build/Release/obj/1wire.o ##
C:/CW/gcc/arm-unknown-eabi/bin/cc1 -mcpu=cortex-m4 -mthumb -mlittle-endian -mfpu
=fpv4-sp-d16 -mfloat-abi=hard -nostdinc -fsingle-precision-constant -Wall -finli
ne-functions -Wdouble-promotion -std=c99 -fno-dwarf2-cfi-asm -fno-builtin -ffunc
tion-sections -fdata-sections -fno-common -fmessage-length=0 -quiet -I. -I../../
../lib/STM32/include -I../../../lib/STM32F4xx_DSP_StdPeriph_Lib_V1.3.0/Libraries
/STM32F4xx_StdPeriph_Driver/inc -I../../../lib/STM32F4xx_DSP_StdPeriph_Lib_V1.3.
0/Libraries/CMSIS/Include -I../../../lib/mavlink/include/autoquad -IC:/CW/includ
e  -D__ARM_ARCH_7EM__ -D__CROSSWORKS_ARM -D__ARM_ARCH_FPV4_SP_D16__ -D__TARGET_P
ROCESSOR=STM32F407VG -D__TARGET_F4XX= -DSTM32F4XX= -DSTM32F40_41xxx -D__FPU_PRES
ENT -DARM_MATH_CM4 -D__THUMB -DNESTED_INTERRUPTS -DCTL_TASKING -DUSE_STDPERIPH_D
RIVER -DBOARD_VERSION=6 -DBOARD_REVISION=0 -DDIMU_VERSION=11 -DNDEBUG -DSTARTUP_
FROM_RESET -O2 -MD ../build/Release/obj/1wire.d -MQ ../build/Release/obj/1wire.o
 1wire.c -o ../build/Release/obj/1wire.lst
process_begin: CreateProcess(NULL, C:/CW/gcc/arm-unknown-eabi/bin/cc1 -mcpu=cort
ex-m4 -mthumb -mlittle-endian -mfpu=fpv4-sp-d16 -mfloat-abi=hard -nostdinc -fsin
gle-precision-constant -Wall -finline-functions -Wdouble-promotion -std=c99 -fno
-dwarf2-cfi-asm -fno-builtin -ffunction-sections -fdata-sections -fno-common -fm
essage-length=0 -quiet -I. -I../../../lib/STM32/include -I../../../lib/STM32F4xx
_DSP_StdPeriph_Lib_V1.3.0/Libraries/STM32F4xx_StdPeriph_Driver/inc -I../../../li
b/STM32F4xx_DSP_StdPeriph_Lib_V1.3.0/Libraries/CMSIS/Include -I../../../lib/mavl
ink/include/autoquad -IC:/CW/include -D__ARM_ARCH_7EM__ -D__CROSSWORKS_ARM -D__A
RM_ARCH_FPV4_SP_D16__ -D__TARGET_PROCESSOR=STM32F407VG -D__TARGET_F4XX= -DSTM32F
4XX= -DSTM32F40_41xxx -D__FPU_PRESENT -DARM_MATH_CM4 -D__THUMB -DNESTED_INTERRUP
TS -DCTL_TASKING -DUSE_STDPERIPH_DRIVER -DBOARD_VERSION=6 -DBOARD_REVISION=0 -DD
IMU_VERSION=11 -DNDEBUG -DSTARTUP_FROM_RESET -O2 -MD ../build/Release/obj/1wire.
d -MQ ../build/Release/obj/1wire.o 1wire.c -o ../build/Release/obj/1wire.lst, ..
.) failed.
make (e=2): The system cannot find the file specified.
make: *** [../build/Release/obj/1wire.o] Error 2


I made makefile.user :

Code: Select all
BOARD_VER ?= 6
BOARD_REV ?= 1
INCR_BUILDNUM ?= 0

CC_PATH ?= C:/CW
EXE_AWK ?= C:/devel/gawk
EXE_MV ?= C:/devel/mv
EXE_MKDIR ?= C:/devel/mkdir

AQLIB_PATH ?= ../lib
BUILD_PATH ?= ../build


this is my folder C:/CW (attached)

I also use this guide :

Copy from --> to:

targets/CMSIS_3/Include/*.h --> STM32/include
targets/STM32/include/stm32f4xx.h & system_stm32f4xx.h --> STM32/include
targets/STM32/STM32_Startup.s & STM32F2XX.vec --> STM32


Anything I missed ?


Many Thanks,

John
Attachments
folder.PNG
folder.PNG (30.06 KiB) Viewed 8439 times
flyrobot
 
Posts: 64
Joined: Thu Jun 06, 2013 6:04 pm

Re: Compile using MAKEFILE - HowTo for rookies

Postby Max » Sat Apr 12, 2014 7:07 am

Not sure John... a couple of things though:

The lib and include paths in the generated command are three levels up "../../../lib" but you specified "../lib" in your config. Be sure to name your .user file Makefile.user (capital M). Not sure why else it would be wrong...

Your AQ libs actually appear to be at just ".." like in the default Makefile setting. And the CW install folder has its own "lib" folder. So something is off there. Try not changing the default AQLIB_PATH.

Haven't tried CW 3.0 -- they might have changed directory structure or who knows what. Is 2.x still available?

STM32F40_41xxx.vec is the file you need in STM32 folder. Not your problem yet, but it will be. :)

-Max
Max
 
Posts: 2814
Joined: Mon Aug 13, 2012 9:45 pm
Location: Near Ithaca, NY, USA

Next

Return to AQ Firmware

Who is online

Users browsing this forum: No registered users and 7 guests

cron