From 8c2b16ca28bbd20d2db25902e5ced386b069ce5c Mon Sep 17 00:00:00 2001 From: Jon Szymaniak Date: Mon, 1 Jul 2013 22:46:46 -0400 Subject: [PATCH] FX3 Firmware: Refactored build These changes fix a regression caused by changeset dc187e0640638b1895218299f47a4f392fdf05a7, which breaks the build under Windows. The firmware can now be built from the command line in both Linux and Windows. The Eclipse project files now use the same Makefile as the command line build, rather than generated Makefiles. As such, the generated Debug/ has been removed. Release builds are the default. To perform a debug build, run make with DEBUG=y. --- fx3_firmware/.cproject | 3914 +++++++++---------------- fx3_firmware/.project | 4 +- fx3_firmware/Debug/makefile | 75 - fx3_firmware/Debug/objects.mk | 7 - fx3_firmware/Debug/sources.mk | 22 - fx3_firmware/Debug/subdir.mk | 47 - fx3_firmware/make/toolchain.mk.sample | 147 +- fx3_firmware/makefile | 67 +- 8 files changed, 1507 insertions(+), 2776 deletions(-) delete mode 100644 fx3_firmware/Debug/makefile delete mode 100644 fx3_firmware/Debug/objects.mk delete mode 100644 fx3_firmware/Debug/sources.mk delete mode 100644 fx3_firmware/Debug/subdir.mk diff --git a/fx3_firmware/.cproject b/fx3_firmware/.cproject index fce47d9e..e8c15b43 100644 --- a/fx3_firmware/.cproject +++ b/fx3_firmware/.cproject @@ -1,2564 +1,1354 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fx3_firmware/.project b/fx3_firmware/.project index 7f5311e5..d3636b92 100644 --- a/fx3_firmware/.project +++ b/fx3_firmware/.project @@ -31,7 +31,7 @@ org.eclipse.cdt.make.core.buildLocation - ${workspace_loc:/BulkLoopAuto/Debug} + ${workspace_loc:/bladeRF} org.eclipse.cdt.make.core.cleanBuildTarget @@ -55,7 +55,7 @@ org.eclipse.cdt.make.core.fullBuildTarget - all + DEBUG=y all org.eclipse.cdt.make.core.stopOnError diff --git a/fx3_firmware/Debug/makefile b/fx3_firmware/Debug/makefile deleted file mode 100644 index 9d7651d2..00000000 --- a/fx3_firmware/Debug/makefile +++ /dev/null @@ -1,75 +0,0 @@ -################################################################################ -# Automatically-generated file. Do not edit! -################################################################################ - --include ../makefile.init - -RM := cs-rm -rf - -# All of the sources participating in the build are defined here --include sources.mk --include subdir.mk --include objects.mk - -ifneq ($(MAKECMDGOALS),clean) -ifneq ($(strip $(C_DEPS)),) --include $(C_DEPS) -endif -ifneq ($(strip $(ASM_DEPS)),) --include $(ASM_DEPS) -endif -ifneq ($(strip $(S_UPPER_DEPS)),) --include $(S_UPPER_DEPS) -endif -endif - --include ../makefile.defs - -# Add inputs and outputs from these tool invocations to the build variables -SECONDARY_LIST += \ -bladeRF.lst \ - -SECONDARY_SIZE += \ -bladeRF.siz \ - - -# All Target -all: bladeRF.elf secondary-outputs - -# Tool invocations -bladeRF.elf: $(OBJS) $(USER_OBJS) - @echo 'Building target: $@' - @echo 'Invoking: ARM Sourcery Windows GCC C Linker' - arm-none-eabi-gcc $(OBJS) $(USER_OBJS) $(LIBS) -T"C:\Cypress\EZ-USB FX3 SDK\1.2\/firmware/common/fx3.ld" -nostartfiles -Wl,-Map,bladeRF.map -Wl,-d -Wl,--no-wchar-size-warning -Wl,--entry,CyU3PFirmwareEntry "C:\Cypress\EZ-USB FX3 SDK\1.2\\firmware\u3p_firmware\lib\fx3_debug\cyfxapi.a" "C:\Cypress\EZ-USB FX3 SDK\1.2\\firmware\u3p_firmware\lib\fx3_debug\cyu3lpp.a" "C:\Cypress\EZ-USB FX3 SDK\1.2\\firmware\u3p_firmware\lib\fx3_debug\cyu3threadx.a" "C:\Cypress\EZ-USB FX3 SDK\1.2\\arm-none-eabi\lib\libc.a" "C:\Cypress\EZ-USB FX3 SDK\1.2\\lib\gcc\arm-none-eabi\4.5.2\libgcc.a" -mcpu=arm926ej-s -mthumb-interwork -g -gdwarf-2 -o"bladeRF.elf" - @echo 'Finished building target: $@' - @echo ' ' - $(MAKE) --no-print-directory post-build - -bladeRF.lst: bladeRF.elf - @echo 'Invoking: ARM Sourcery Windows GNU Create Listing' - arm-none-eabi-objdump -h -S bladeRF.elf >"bladeRF.lst" - @echo 'Finished building: $@' - @echo ' ' - -bladeRF.siz: bladeRF.elf - @echo 'Invoking: ARM Sourcery Windows GNU Print Size' - arm-none-eabi-size --format=berkeley bladeRF.elf - @echo 'Finished building: $@' - @echo ' ' - -# Other Targets -clean: - -$(RM) $(SECONDARY_SIZE)$(OBJS)$(C_DEPS)$(ASM_DEPS)$(EXECUTABLES)$(SECONDARY_LIST)$(S_UPPER_DEPS) bladeRF.elf - -@echo ' ' - -post-build: - -@echo 'Converting ELF to image (.img) format' - -"C:\Cypress\EZ-USB FX3 SDK\1.2\\util\elf2img\elf2img.exe" -i bladeRF.elf -o bladeRF.img - -@echo ' ' - -secondary-outputs: $(SECONDARY_LIST) $(SECONDARY_SIZE) - -.PHONY: all clean dependents -.SECONDARY: post-build - --include ../makefile.targets diff --git a/fx3_firmware/Debug/objects.mk b/fx3_firmware/Debug/objects.mk deleted file mode 100644 index dc028f6e..00000000 --- a/fx3_firmware/Debug/objects.mk +++ /dev/null @@ -1,7 +0,0 @@ -################################################################################ -# Automatically-generated file. Do not edit! -################################################################################ - -USER_OBJS := - -LIBS := diff --git a/fx3_firmware/Debug/sources.mk b/fx3_firmware/Debug/sources.mk deleted file mode 100644 index d92627d5..00000000 --- a/fx3_firmware/Debug/sources.mk +++ /dev/null @@ -1,22 +0,0 @@ -################################################################################ -# Automatically-generated file. Do not edit! -################################################################################ - -ELF_SRCS := -O_SRCS := -C_SRCS := -S_UPPER_SRCS := -OBJ_SRCS := -ASM_SRCS := -SECONDARY_SIZE := -OBJS := -C_DEPS := -ASM_DEPS := -EXECUTABLES := -SECONDARY_LIST := -S_UPPER_DEPS := - -# Every subdirectory with source files must be described here -SUBDIRS := \ -. \ - diff --git a/fx3_firmware/Debug/subdir.mk b/fx3_firmware/Debug/subdir.mk deleted file mode 100644 index 62c96ca2..00000000 --- a/fx3_firmware/Debug/subdir.mk +++ /dev/null @@ -1,47 +0,0 @@ -################################################################################ -# Automatically-generated file. Do not edit! -################################################################################ - -# Add inputs and outputs from these tool invocations to the build variables -C_SRCS += \ -../bladeRF.c \ -../cyfxbladeRFusbdscr.c \ -../cyfxtx.c \ -../spi_flash_lib.c - -S_UPPER_SRCS += \ -../cyfx_gcc_startup.S - -OBJS += \ -./bladeRF.o \ -./cyfx_gcc_startup.o \ -./cyfxbladeRFusbdscr.o \ -./cyfxtx.o \ -./spi_flash_lib.o - -C_DEPS += \ -./bladeRF.d \ -./cyfxbladeRFusbdscr.d \ -./cyfxtx.d \ -./spi_flash_lib.d - -S_UPPER_DEPS += \ -./cyfx_gcc_startup.d - - -# Each subdirectory must supply rules for building sources it contributes -%.o: ../%.c - @echo 'Building file: $<' - @echo 'Invoking: ARM Sourcery Windows GCC C Compiler' - arm-none-eabi-gcc -D__CYU3P_TX__=1 -I"C:\Cypress\EZ-USB FX3 SDK\1.2\\firmware\u3p_firmware\inc" -O0 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -mcpu=arm926ej-s -mthumb-interwork -g -gdwarf-2 -o"$@" "$<" - @echo 'Finished building: $<' - @echo ' ' - -%.o: ../%.S - @echo 'Building file: $<' - @echo 'Invoking: ARM Sourcery Windows GCC Assembler' - arm-none-eabi-gcc -x assembler-with-cpp -I"C:\Cypress\EZ-USB FX3 SDK\1.2\\firmware\u3p_firmware\inc" -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -mcpu=arm926ej-s -mthumb-interwork -g -gdwarf-2 -o"$@" "$<" - @echo 'Finished building: $<' - @echo ' ' - - diff --git a/fx3_firmware/make/toolchain.mk.sample b/fx3_firmware/make/toolchain.mk.sample index 1ef289b7..07130a16 100644 --- a/fx3_firmware/make/toolchain.mk.sample +++ b/fx3_firmware/make/toolchain.mk.sample @@ -1,36 +1,133 @@ -# Copy this file to toolchain.mk and fill FX3_ROOT appropriately +# Copy this file to toolchain.mk and ensure the following are filled in +# correctly for your system: +# +# FX3_ROOT - Path to FX3 SDK +# ARMGCC_INSTALL_PATH - Path to ARM GCC toolchain within the FX3 SDK +# ARMGCC_VERSION - Version number of GCC toolchain included in SDK +# FX3_FW_DIR - "firmware" directory in FX3 SDK +# +# If you edit this file, be wary of potential path-related issues. +# (Specifically, be careful will paths with spaces. These will likely appear +# in Windows-based builds if default install paths are used. ################################################################################ -# Grab this before CC is defined as the cross toolchain -HOST_CC := $(CC) - # Hack to check if we're in windows, otherwise assume *nix -# -# Note that the ARMGCC_INSTALL_PATH is assumed to be in the environment -# by the toolchain makefiles ifdef SystemRoot - FX3_ROOT ?= C:/Cypress/EZ-USB\ FX3\ SDK/1.2 - export ARMGCC_INSTALL_PATH ?= $(FX3_ROOT) -else - FX3_ROOT ?= /opt/cypress/fx3_sdk - export ARMGCC_INSTALL_PATH ?= $(FX3_ROOT)/arm-2011.03 + HOST_IS_WINDOWS := y endif -# This is needed by the FX3 toolchain makefiles to resolve the -# path to libgcc -ARMGCC_VERSION := 4.5.2 - +# Running into some issues with Windows paths, as back-escaped spaces in paths +# are needed for make, but this doesn't fly when executing external programs +# (e.g., gcc, ld) # -# Ensure the ARM toolchain is in our path -export PATH := $(PATH):$(ARMGCC_INSTALL_PATH)/bin +# This is a little hack to replace a paths with escaped spaces +# with a quoted, space-containing path. +# +# If anyone has any suggestions or advice on cleaning this up, +# please feel free to make some noise over at: +# www.github.com/jynik/bladeRF +pathfixup = $(if $(HOST_IS_WINDOWS),"$(subst /,\,$(subst \ , ,$(1)))",$(1)) -# The FX3 toolchain makefiles assume we've defined these variables -FX3FWROOT := $(FX3_ROOT)/cyfx3sdk/firmware -FX3PFWROOT := $(FX3FWROOT)/u3p_firmware +# These are the items that will likely vary system to system +ARMGCC_VERSION ?= 4.5.2 -# Path to ELF -> img conversion tool, provided by FX3 toolchain -ELF2IMG_PATH := $(FX3_ROOT)/cyfx3sdk/util/elf2img +################################ +# Paths +################################ -# Include build definitions from the toolchain -include $(FX3FWROOT)/common/fx3_build_config.mak +ifdef HOST_IS_WINDOWS + FX3_ROOT ?= C:/Program\ Files\ (x86)/Cypress/EZ-USB\ FX3\ SDK/1.2 + ARMGCC_INSTALL_PATH ?= $(FX3_ROOT) + FX3_FW_DIR := $(FX3_ROOT)/firmware + ELF2IMG_DIR := $(FX3_ROOT)/util/elf2img +else + FX3_ROOT ?= /opt/cypress/fx3_sdk + ARMGCC_INSTALL_PATH ?= $(FX3_ROOT)/arm-2011.03 + FX3_FW_DIR := $(FX3_ROOT)/cyfx3sdk/firmware + ELF2IMG_DIR := $(FX3_ROOT)/cyfx3sdk/util/elf2img +endif +# Target firmare directory +FX3_U3PFW_DIR := $(FX3_FW_DIR)/u3p_firmware + +# Header files for our target device +FX3_FWINC_DIR := $(FX3_U3PFW_DIR)/inc + +# Library directory +ifdef DEBUG + FX3_LIB_DIR := $(FX3_U3PFW_DIR)/lib/fx3_debug +else + FX3_LIB_DIR := $(FX3_U3PFW_DIR)/lib/fx3_release +endif + +# Path to some build depdencies - we'll need to compile/assemble a few items +# from this directory and link against them +TOOLCHAIN_DEPS_DIR := $(FX3_FW_DIR)/common + + +################################ +# Libraries +################################ + +FX3_LIBGCC := $(ARMGCC_INSTALL_PATH)/lib/gcc/arm-none-eabi/$(ARMGCC_VERSION)/libgcc.a +FX3_LIBC := $(ARMGCC_INSTALL_PATH)/arm-none-eabi/lib/libc.a + +# Careful if you're making changes here - remember that order matters. +FX3_LIBS := $(call pathfixup,$(FX3_LIB_DIR)/cyfxapi.a) \ + $(call pathfixup,$(FX3_LIB_DIR)/cyu3lpp.a) \ + $(call pathfixup,$(FX3_LIB_DIR)/cyu3threadx.a)\ + $(call pathfixup,$(FX3_LIBC)) \ + $(call pathfixup,$(FX3_LIBGCC)) + + +################################ +# Tools +################################ + +# Setup host and cross tools +CROSS_COMPILE ?= $(ARMGCC_INSTALL_PATH)/bin/arm-none-eabi- +HOST_CC := $(CC) +CC := $(call pathfixup,$(CROSS_COMPILE)gcc) +LD := $(call pathfixup,$(CROSS_COMPILE)ld) + +FW_INC := -I$(call pathfixup,$(FX3_FWINC_DIR)) +LINKER_FILE := $(call pathfixup,$(FX3_FW_DIR)/common/fx3.ld) + +ifdef HOST_IS_WINDOWS + RM := cs-rm +else + RM := rm +endif + +# Set up toolchain specific compiler and linker flags +TOOLCHAIN_CFLAGS := -DCYU3P_FX3=1 -D__CYU3P_TX__=1 \ + -mcpu=arm926ej-s -mthumb-interwork \ + $(FW_INC) + +ifdef DEBUG + TOOLCHAIN_CFLAGS += -DTX_ENABLE_EVENT_TRACE +endif + +TOOLCHAIN_LDFLAGS := --entry CyU3PFirmwareEntry \ + $(FX3_LIBS) \ + -T $(LINKER_FILE) -d --gc-sections \ + --no-wchar-size-warning + +################################ +# Dependencies +################################ +TOOLCHAIN_DEPS_SRC_C := $(TOOLCHAIN_DEPS_DIR)/cyfxtx.c +TOOLCHAIN_DEPS_SRC_A := $(TOOLCHAIN_DEPS_DIR)/cyfx_gcc_startup.S +TOOLCHAIN_DEPS_OBJ_C := $(notdir $(TOOLCHAIN_DEPS_SRC_C:.c=.o)) +TOOLCHAIN_DEPS_OBJ_A := $(notdir $(TOOLCHAIN_DEPS_SRC_A:.S=.o)) +TOOLCHAIN_DEPS_OBJ := $(TOOLCHAIN_DEPS_OBJ_C) $(TOOLCHAIN_DEPS_OBJ_A) + +ifdef HOST_IS_WINDOWS + ELF2IMG_SRC := + ELF2IMG := $(ELF2IMG_DIR)/elf2img.exe +else + ELF2IMG_SRC := $(call pathfixup,$(ELF2IMG_DIR)/elf2img.c) + ELF2IMG := ./elf2img +endif + +build_toolchain_dep = $(CC) $(call pathfixup,$(1)) $(CFLAGS) -c -o $(2) diff --git a/fx3_firmware/makefile b/fx3_firmware/makefile index a661b7d0..a8c9e9e0 100644 --- a/fx3_firmware/makefile +++ b/fx3_firmware/makefile @@ -8,54 +8,49 @@ $(error Copy make/toolchain.mk.sample to make/toolchain.mk and edit paths accord endif include make/toolchain.mk -TARGET := bladeRF - -# bladeRF code -BLADERF_SOURCE_C := $(wildcard *.c) -BLADERF_SOURCE_ASM := $(wildcard *.S) -BLADERF_OBJ_C := $(BLADERF_SOURCE_C:.c=.o) -BLADERF_OBJ_ASM := $(BLAERF_SOURCE__ASM:.S=.o) - -# Items provided in the toolchain -TOOLCHAIN_OBJ_C := $(notdir $(SOURCE:.c=.o)) -TOOLCHAIN_OBJ_ASM := $(notdir $(SOURCE_ASM:.S=.o)) - -OBJ := $(BLADERF_OBJ_C) $(BLADERF_OBJ_ASM) \ - $(TOOLCHAIN_OBJ_C) $(TOOLCHAIN_OBJ_ASM) - # Target files -ELF := $(TARGET).$(EXEEXT) +TARGET := bladeRF +ELF := $(TARGET).elf IMG := $(TARGET).img MAP := $(TARGET).map +SRC := $(wildcard *.c) +OBJ := $(SRC:.c=.o) $(TOOLCHAIN_DEPS_OBJ) + +CFLAGS := -Wall -Wextra -Wno-unused-parameter \ + $(TOOLCHAIN_CFLAGS) \ + $(EXTRA_CFLAGS) + +ifdef DEBUG + CFLAGS += -O0 -ggdb3 -DDEBUG +else + CFLAGS += -O2 -DNDEBUG +endif + +LDFLAGS := $(TOOLCHAIN_LDFLAGS) -Map $(MAP) + all: $(IMG) -$(ELF): $(OBJ) - $(LINK) +$(ELF): $(OBJ) + $(LD) $(OBJ) $(LDFLAGS) -o $@ -$(IMG): $(ELF) elf2img - ./elf2img -i $< -o $@ +$(IMG): $(ELF) $(ELF2IMG) + $(ELF2IMG) -i $< -o $@ -elf2img: $(ELF2IMG_PATH)/elf2img.c - $(HOST_CC) -Wall -O2 $^ -o $@ +$(ELF2IMG): $(ELF2IMG_SRC) + $(HOST_CC) $< -O2 -o $@ -$(BLADERF_OBJ_C): %.o : %.c - $(COMPILE) +# Build any toolchain dependencies. +$(TOOLCHAIN_DEPS_OBJ_C): %.o : $(TOOLCHAIN_DEPS_DIR)/%.c + $(call build_toolchain_dep,$<,$@) -$(TOOLCHAIN_OBJ_C): %.o : $(FX3FWROOT)/common/%.c - $(COMPILE) - -$(BLADERF_OBJ_A): %.o : %.S - $(ASSEMBLE) - -$(TOOLCHAIN_OBJ_ASM): %.o : $(FX3FWROOT)/common/%.S - $(ASSEMBLE) +$(TOOLCHAIN_DEPS_OBJ_A): %.o : $(TOOLCHAIN_DEPS_DIR)/%.S + $(call build_toolchain_dep,$<,$@) clean: - rm -f $(ELF) $(IMG) $(MAP) $(OBJ) + $(RM) -f $(ELF) $(IMG) $(MAP) $(OBJ) $(TOOLCHAIN_OBJ) realclean: clean - rm -f elf2img + $(RM) -f elf2img - -.PHONY: clean +.PHONY: clean realclean