From ece2b42f9b8aa7e829bf5e7958bd853077f0c371 Mon Sep 17 00:00:00 2001 From: Thibaut VIARD <thibaut.viard@atmel.com> Date: Mon, 28 Apr 2014 15:04:11 +0200 Subject: [PATCH] Fixed makefiles for validation --- cores/arduino/Arduino.h | 87 +++++++++++++-------- cores/arduino/validation/build_gcc/Makefile | 33 ++------ cores/arduino/validation/build_gcc/gcc.mk | 46 ++++++----- cores/arduino/validation/build_gcc/test.mk | 58 +++++--------- 4 files changed, 108 insertions(+), 116 deletions(-) diff --git a/cores/arduino/Arduino.h b/cores/arduino/Arduino.h index f86cc583..b3e6a53c 100644 --- a/cores/arduino/Arduino.h +++ b/cores/arduino/Arduino.h @@ -38,8 +38,8 @@ extern "C"{ #endif // __cplusplus -// Includes Atmel CMSIS -#include <chip.h> +// Include Atmel headers +#include "sam.h" #include "wiring_constants.h" @@ -100,40 +100,65 @@ typedef enum _EAnalogChannel typedef enum _EPWMChannel { NOT_ON_PWM=-1, - PWM_CH0=0, // todo - PWM_CH1, - PWM_CH2, - PWM_CH3, - PWM_CH4, - PWM_CH5, - PWM_CH6, - PWM_CH7 + // PWM_CH0=0, // todo + // PWM_CH1, + // PWM_CH2, + // PWM_CH3, + // PWM_CH4, + // PWM_CH5, + // PWM_CH6, + // PWM_CH7 } EPWMChannel ; // Definitions for TC channels typedef enum _ETCChannel { NOT_ON_TIMER=-1, - TC0_CHA0=0, // todo - TC0_CHB0, - TC0_CHA1, - TC0_CHB1, - TC0_CHA2, - TC0_CHB2, - TC1_CHA3, - TC1_CHB3, - TC1_CHA4, - TC1_CHB4, - TC1_CHA5, - TC1_CHB5, - TC2_CHA6, - TC2_CHB6, - TC2_CHA7, - TC2_CHB7, - TC2_CHA8, - TC2_CHB8 + // TC0_CHA0=0, // todo + // TC0_CHB0, + // TC0_CHA1, + // TC0_CHB1, + // TC0_CHA2, + // TC0_CHB2, + // TC1_CHA3, + // TC1_CHB3, + // TC1_CHA4, + // TC1_CHB4, + // TC1_CHA5, + // TC1_CHB5, + // TC2_CHA6, + // TC2_CHB6, + // TC2_CHA7, + // TC2_CHB7, + // TC2_CHA8, + // TC2_CHB8 } ETCChannel ; +#define PORTA (0ul) +#define PORTB (1ul) +#define PORTC (2ul) + +//A B C D E F G H +//EIC REF ADC AC PTC DAC SERCOM SERCOM_ALT TC/TCC TCC COM AC/GCLK + +typedef enum _EPioType +{ + PIO_NOT_A_PIN, /* Not under control of a peripheral. */ + PIO_DIGITAL, /* The pin is controlled by PORT. */ + PIO_EXTINT, /* The pin is controlled by the associated signal of peripheral A. */ + PIO_ANALOG, /* The pin is controlled by the associated signal of peripheral B. */ + PIO_SERCOM, /* The pin is controlled by the associated signal of peripheral C. */ + PIO_SERCOM_ALT, /* The pin is controlled by the associated signal of peripheral D. */ + PIO_TIMER, /* The pin is controlled by the associated signal of peripheral E. */ + PIO_TIMER_ALT, /* The pin is controlled by the associated signal of peripheral F. */ + PIO_COM, /* The pin is controlled by the associated signal of peripheral G. */ + PIO_AC_CLK, /* The pin is controlled by the associated signal of peripheral H. */ + + PIO_INPUT, /* The pin is an input. */ + PIO_OUTPUT_0, /* The pin is an output and has a default level of 0. */ + PIO_OUTPUT_1 /* The pin is an output and has a default level of 1. */ +} EPioType ; + /** * Pin Attributes to be OR-ed */ @@ -143,10 +168,10 @@ typedef enum _ETCChannel #define PIN_ATTR_PWM (1UL<<3) #define PIN_ATTR_TIMER (1UL<<4) -/* Types used for the tables below */ +/* Types used for the table below */ typedef struct _PinDescription { - Pio* pPort ; + void* pPort ; uint32_t ulPin ; uint32_t ulPeripheralId ; EPioType ulPinType ; @@ -174,7 +199,7 @@ extern const PinDescription g_APinDescription[] ; #endif // __cplusplus // Include board variant -#include "variant.h" +//#include "variant.h" #include "wiring.h" #include "wiring_digital.h" diff --git a/cores/arduino/validation/build_gcc/Makefile b/cores/arduino/validation/build_gcc/Makefile index 9794d9e9..c1d0994a 100644 --- a/cores/arduino/validation/build_gcc/Makefile +++ b/cores/arduino/validation/build_gcc/Makefile @@ -24,50 +24,27 @@ SUBMAKE_OPTIONS=--no-builtin-rules --no-builtin-variables --no-print-directory all: clean test -test: test_arduino_zero test_samd21_xpro +test: test_arduino_zero -clean: clean_arduino_zero clean_samd21_xpro +clean: clean_arduino_zero .PHONY: test_arduino_zero test_arduino_zero: @echo ------------------------------------------------------------------------------------ @echo --- Making test_arduino_zero - @$(MAKE) DEBUG=1 VARIANT=arduino_zero $(SUBMAKE_OPTIONS) -f test.mk + @$(MAKE) DEBUG=1 VARIANT=arduino_zero $(SUBMAKE_OPTIONS) -f test.mk test @echo ------------------------------------------------------------------------------------ .PHONY: clean_arduino_zero clean_arduino_zero: @echo ------------------------------------------------------------------------------------ @echo --- Cleaning test arduino_zero - @$(MAKE) DEBUG=1 VARIANT=arduino_zero $(SUBMAKE_OPTIONS) -f test.mk $@ + @$(MAKE) DEBUG=1 VARIANT=arduino_zero $(SUBMAKE_OPTIONS) -f test.mk clean @echo ------------------------------------------------------------------------------------ .PHONY: debug_arduino_zero debug_arduino_zero: @echo ------------------------------------------------------------------------------------ @echo --- Debugging test arduino_zero - @$(MAKE) DEBUG=1 VARIANT=arduino_zero $(SUBMAKE_OPTIONS) -f test.mk $@ - @echo ------------------------------------------------------------------------------------ - - - -.PHONY: test_samd21_xpro -test_samd21_xpro: - @echo ------------------------------------------------------------------------------------ - @echo --- Making test_samd21_xpro - @$(MAKE) DEBUG=1 VARIANT=samd21_xpro $(SUBMAKE_OPTIONS) -f test.mk - @echo ------------------------------------------------------------------------------------ - -.PHONY: clean_samd21_xpro -clean: - @echo ------------------------------------------------------------------------------------ - @echo --- Cleaning test samd21_xpro - @$(MAKE) DEBUG=1 VARIANT=samd21_xpro $(SUBMAKE_OPTIONS) -f test.mk $@ - @echo ------------------------------------------------------------------------------------ - -.PHONY: debug_samd21_xpro -debug_samd21_xpro: - @echo ------------------------------------------------------------------------------------ - @echo --- Debugging test samd21_xpro - @$(MAKE) DEBUG=1 VARIANT=samd21_xpro $(SUBMAKE_OPTIONS) -f test.mk $@ + @$(MAKE) DEBUG=1 VARIANT=arduino_zero $(SUBMAKE_OPTIONS) -f test.mk debug @echo ------------------------------------------------------------------------------------ diff --git a/cores/arduino/validation/build_gcc/gcc.mk b/cores/arduino/validation/build_gcc/gcc.mk index 014792ed..2af2174b 100644 --- a/cores/arduino/validation/build_gcc/gcc.mk +++ b/cores/arduino/validation/build_gcc/gcc.mk @@ -8,7 +8,7 @@ # # This library 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. +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public @@ -16,24 +16,18 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # -# Tool suffix when cross-compiling -CROSS_COMPILE = $(ARM_GCC_TOOLCHAIN)/arm-none-eabi- - # Compilation tools -AR = $(CROSS_COMPILE)ar -CC = $(CROSS_COMPILE)gcc -CXX = $(CROSS_COMPILE)g++ -AS = $(CROSS_COMPILE)as -GDB = $(CROSS_COMPILE)gdb -SIZE = $(CROSS_COMPILE)size -NM = $(CROSS_COMPILE)nm -OBJCOPY = $(CROSS_COMPILE)objcopy - -ifeq ($(OS),Windows_NT) -RM=cs-rm -Rf -else +AR = $(ARM_GCC_TOOLCHAIN)/arm-none-eabi-ar +CC = $(ARM_GCC_TOOLCHAIN)/arm-none-eabi-gcc +#CXX = $(ARM_GCC_TOOLCHAIN)/arm-none-eabi-g++ +CXX = $(ARM_GCC_TOOLCHAIN)/arm-none-eabi-gcc +AS = $(ARM_GCC_TOOLCHAIN)/arm-none-eabi-as +GDB = $(ARM_GCC_TOOLCHAIN)/arm-none-eabi-gdb +SIZE = $(ARM_GCC_TOOLCHAIN)/arm-none-eabi-size +NM = $(ARM_GCC_TOOLCHAIN)/arm-none-eabi-nm +OBJCOPY = $(ARM_GCC_TOOLCHAIN)/arm-none-eabi-objcopy + RM=rm -Rf -endif SEP=\\ @@ -52,12 +46,14 @@ CFLAGS += -Wpacked -Wredundant-decls -Wnested-externs -Winline -Wlong-long CFLAGS += -Wunreachable-code CFLAGS += -Wcast-align -CFLAGS += --param max-inline-insns-single=500 -mcpu=cortex-m3 -mthumb -mlong-calls -ffunction-sections -nostdlib -std=c99 +CFLAGS += --param max-inline-insns-single=500 -mcpu=cortex-m0plus -mthumb -mlong-calls -ffunction-sections -nostdlib -std=c99 CFLAGS += $(OPTIMIZATION) $(INCLUDES) -D$(CHIP) -D$(VARIANT) # To reduce application size use only integer printf function. CFLAGS += -Dprintf=iprintf + + # --------------------------------------------------------------------------------------- # CPP Flags @@ -71,13 +67,23 @@ CPPFLAGS += -Wformat -Wmissing-format-attribute -Wno-deprecated-declarations CPPFLAGS += -Wpacked -Wredundant-decls -Winline -Wlong-long #-fno-rtti -fno-exceptions -CPPFLAGS += --param max-inline-insns-single=500 -mcpu=cortex-m0p -mthumb -mlong-calls -ffunction-sections -fdata-sections -std=c++98 +CPPFLAGS += --param max-inline-insns-single=500 -mcpu=cortex-m0plus -mthumb -mlong-calls -ffunction-sections -fdata-sections -std=c++98 CPPFLAGS += $(OPTIMIZATION) $(INCLUDES) -D$(CHIP) # To reduce application size use only integer printf function. CPPFLAGS += -Dprintf=iprintf + + # --------------------------------------------------------------------------------------- # ASM Flags -ASFLAGS = -mcpu=cortex-m3 -mthumb -Wall -g $(OPTIMIZATION) $(INCLUDES) +ASFLAGS = -mcpu=cortex-m0plus -mthumb -Wall -g $(OPTIMIZATION) $(INCLUDES) + + + +# --------------------------------------------------------------------------------------- +# LD Flags + +LDFLAGS= -mcpu=cortex-m0plus -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--entry=Reset_Handler -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -Wl,--warn-unresolved-symbols + diff --git a/cores/arduino/validation/build_gcc/test.mk b/cores/arduino/validation/build_gcc/test.mk index f34e5a9e..eb7ce872 100644 --- a/cores/arduino/validation/build_gcc/test.mk +++ b/cores/arduino/validation/build_gcc/test.mk @@ -21,44 +21,39 @@ # putting default variant ifeq ("$(VARIANT)", "") -VARIANT=samd21_xpro -#VARIANT=arduino_zero +VARIANT=arduino_zero endif -ifeq ("$(VARIANT)", "samd21_xpro") -DEVICE=__SAMD21J18__ -VARIANT_PATH = ../../../../../../atmel/sam/variants/$(VARIANT) -else ifeq ("$(VARIANT)", "arduino_zero") +ifeq ("$(VARIANT)", "arduino_zero") DEVICE=__SAMD21G18__ -VARIANT_PATH = ../../../../../../atmel/sam/variants/$(VARIANT) endif -TOOLCHAIN=gcc - -#------------------------------------------------------------------------------- -# Path -#------------------------------------------------------------------------------- - -# Libraries -PROJECT_BASE_PATH = .. -SYSTEM_PATH = ../../../../system - ifeq ($(DEVICE), __SAMD21G18__) DEVICE_NAME=samd21g18 -DEVICE_SERIE=samd +DEVICE_SERIE=samd21 else ifeq ($(DEVICE), __SAMD21J18__) DEVICE_NAME=samd21j18 -DEVICE_SERIE=samd -else +DEVICE_SERIE=samd21 endif -CMSIS_ROOT_PATH = $(SYSTEM_PATH)/CMSIS +#------------------------------------------------------------------------------- +# Path +#------------------------------------------------------------------------------- +HARDWARE_PATH=../../../../../../ +ARCH_PATH=$(HARDWARE_PATH)/arduino/samd +ARDUINO_CORE_PATH=$(ARCH_PATH)/cores/arduino +ARDUINO_USB_PATH=$(ARDUINO_CORE_PATH)/USB +VARIANT_PATH = $(ARCH_PATH)/variants/$(VARIANT) +TOOLS_PATH = $(HARDWARE_PATH)/tools +CMSIS_ROOT_PATH=$(TOOLS_PATH)/CMSIS CMSIS_ARM_PATH=$(CMSIS_ROOT_PATH)/CMSIS/Include CMSIS_ATMEL_PATH=$(CMSIS_ROOT_PATH)/Device/ATMEL -CMSIS_DEVICE_PATH=$(CMSIS_ROOT_PATH)/Device/ATMEL/$(DEVICE_SERIE) +#CMSIS_DEVICE_PATH=$(CMSIS_ROOT_PATH)/Device/ATMEL/$(DEVICE_SERIE) + +PROJECT_BASE_PATH = .. + +TOOLCHAIN=gcc -ARDUINO_CORE_PATH=../../../../cores/arduino -ARDUINO_USB_PATH=$(ARDUINO_CORE_PATH)/USB # Output directories OUTPUT_PATH = debug_$(VARIANT) @@ -67,7 +62,6 @@ OUTPUT_PATH = debug_$(VARIANT) # Files #------------------------------------------------------------------------------- -#vpath %.h $(PROJECT_BASE_PATH)/.. $(PROJECT_BASE_PATH)/../USB $(VARIANT_PATH) $(SYSTEM_PATH) $(CMSIS_ARM_PATH) vpath %.cpp $(PROJECT_BASE_PATH) #VPATH+=$(PROJECT_BASE_PATH) @@ -112,8 +106,6 @@ LIB_PATH =-L$(PROJECT_BASE_PATH)/.. LIB_PATH+=-L=/lib/thumb2 #LIB_PATH+=-L=/../lib/gcc/arm-none-eabi/4.5.2/thumb2 -LDFLAGS= -mcpu=cortex-m0p -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--entry=Reset_Handler -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -Wl,--warn-unresolved-symbols - #------------------------------------------------------------------------------- # CPP source files and objects #------------------------------------------------------------------------------- @@ -161,8 +153,8 @@ create_output: $(addprefix $(OUTPUT_PATH)/,$(CPP_OBJ)): $(OUTPUT_PATH)/%.o: %.cpp @echo *** Current folder is $(shell cd) - @"$(CXX)" -c $(CPPFLAGS) $< -o $@ -# "$(CXX)" -v -c $(CPPFLAGS) $< -o $@ +# @"$(CXX)" -c $(CPPFLAGS) $< -o $@ + "$(CXX)" -v -c $(CPPFLAGS) $< -o $@ $(OUTPUT_BIN): $(addprefix $(OUTPUT_PATH)/, $(C_OBJ)) $(addprefix $(OUTPUT_PATH)/, $(CPP_OBJ)) $(addprefix $(OUTPUT_PATH)/, $(A_OBJ)) @"$(CC)" $(LIB_PATH) $(LDFLAGS) -T"$(VARIANT_PATH)/linker_scripts/gcc/flash.ld" -Wl,-Map,$(OUTPUT_PATH)/$@.map -o $(OUTPUT_PATH)/$@.elf $^ $(LIBS) @@ -176,14 +168,6 @@ clean: @echo --- Cleaning test files for $(VARIANT) -@$(RM) $(OUTPUT_PATH) 1>NUL 2>&1 @echo ------------------------------------------------------------------------------------ - @echo ------------------------------------------------------------------------------------ - @echo Sub-making clean for Arduino core - $(MAKE) -C $(ARDUINO_CORE_PATH)/build_gcc -f Makefile clean - @echo ------------------------------------------------------------------------------------ - @echo ------------------------------------------------------------------------------------ - @echo Sub-making clean for variant $(VARIANT) - $(MAKE) -C $(VARIANT_PATH)/build_gcc -f Makefile clean - @echo ------------------------------------------------------------------------------------ # -$(RM) $(OUTPUT_PATH)/test.o # -$(RM) $(OUTPUT_PATH)/$(OUTPUT_BIN).elf -- GitLab