diff --git a/hardware/arduino/sam/cores/sam/build_gcc/Makefile b/hardware/arduino/sam/cores/sam/build_gcc/Makefile index 53d2db633..bd4b95daf 100644 --- a/hardware/arduino/sam/cores/sam/build_gcc/Makefile +++ b/hardware/arduino/sam/cores/sam/build_gcc/Makefile @@ -1,9 +1,27 @@ +# +# Copyright (c) 2012 Arduino. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# 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. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# + ifeq ("$(VARIANTS)", "") -VARIANTS = arduino_due_x arduino_due_u sam3x_ek -#VARIANTS = sam3u_ek sam3s_ek +VARIANTS = arduino_due_x sam3x_ek adk2 +#VARIANTS = sam3u_ek sam3s_ek arduino_due_u endif -SUBMAKE_OPTIONS=--no-builtin-rules --no-builtin-variables +SUBMAKE_OPTIONS=--no-builtin-rules --no-builtin-variables --no-print-directory #------------------------------------------------------------------------------- # Rules @@ -13,36 +31,55 @@ all: $(VARIANTS) .PHONY: sam3s_ek sam3s_ek: + @echo ------------------------------------------------------------------------------------ @echo --- Making sam3s_ek @$(MAKE) DEBUG=1 $(SUBMAKE_OPTIONS) -f libarduino_sam3s_ek.mk # @$(MAKE) $(SUBMAKE_OPTIONS) -f libarduino_sam3s_ek.mk + @echo ------------------------------------------------------------------------------------ .PHONY: sam3u_ek sam3u_ek: + @echo ------------------------------------------------------------------------------------ @echo --- Making sam3u_ek @$(MAKE) DEBUG=1 $(SUBMAKE_OPTIONS) -f libarduino_sam3u_ek.mk # @$(MAKE) $(SUBMAKE_OPTIONS) -f libarduino_sam3u_ek.mk + @echo ------------------------------------------------------------------------------------ .PHONY: sam3x_ek sam3x_ek: + @echo ------------------------------------------------------------------------------------ @echo --- Making sam3x_ek @$(MAKE) DEBUG=1 $(SUBMAKE_OPTIONS) -f libarduino_sam3x_ek.mk # @$(MAKE) $(SUBMAKE_OPTIONS) -f libarduino_sam3x_ek.mk + @echo ------------------------------------------------------------------------------------ .PHONY: arduino_due_u arduino_due_u: + @echo ------------------------------------------------------------------------------------ @echo --- Making arduino_due_u @$(MAKE) DEBUG=1 $(SUBMAKE_OPTIONS) -f libarduino_arduino_due_u.mk # @$(MAKE) $(SUBMAKE_OPTIONS) -f libarduino_arduino_due_u.mk + @echo ------------------------------------------------------------------------------------ .PHONY: arduino_due_x arduino_due_x: + @echo ------------------------------------------------------------------------------------ @echo --- Making arduino_due_x @$(MAKE) DEBUG=1 $(SUBMAKE_OPTIONS) -f libarduino_arduino_due_x.mk # @$(MAKE) $(SUBMAKE_OPTIONS) -f libarduino_arduino_due_x.mk + @echo ------------------------------------------------------------------------------------ + +.PHONY: adk2 +adk2: + @echo ------------------------------------------------------------------------------------ + @echo --- Making adk2 + @$(MAKE) DEBUG=1 $(SUBMAKE_OPTIONS) -f libarduino_adk2.mk +# @$(MAKE) $(SUBMAKE_OPTIONS) -f libarduino_adk2.mk + @echo ------------------------------------------------------------------------------------ .PHONY: clean clean: + @echo ------------------------------------------------------------------------------------ @echo --- Cleaning sam3s_ek @$(MAKE) DEBUG=1 $(SUBMAKE_OPTIONS) -f libarduino_sam3s_ek.mk $@ # @$(MAKE) $(SUBMAKE_OPTIONS) -f libarduino_sam3s_ek.mk $@ @@ -63,4 +100,9 @@ clean: @$(MAKE) DEBUG=1 $(SUBMAKE_OPTIONS) -f libarduino_arduino_due_x.mk $@ # @$(MAKE) $(SUBMAKE_OPTIONS) -f libarduino_arduino_due_x.mk $@ + @echo --- Cleaning adk2 + @$(MAKE) DEBUG=1 $(SUBMAKE_OPTIONS) -f libarduino_adk2.mk $@ +# @$(MAKE) $(SUBMAKE_OPTIONS) -f libarduino_adk2.mk $@ + + @echo ------------------------------------------------------------------------------------ diff --git a/hardware/arduino/sam/cores/sam/build_gcc/libarduino_adk2.mk b/hardware/arduino/sam/cores/sam/build_gcc/libarduino_adk2.mk new file mode 100644 index 000000000..0df7ea912 --- /dev/null +++ b/hardware/arduino/sam/cores/sam/build_gcc/libarduino_adk2.mk @@ -0,0 +1,183 @@ +# +# Copyright (c) 2012 Arduino. All right reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# 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. +# See the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# + +# Makefile for compiling libArduino +.SUFFIXES: .o .a .c .s + +CHIP=__SAM3X8E__ +VARIANT=adk2 +LIBNAME=libarduino_$(VARIANT) +TOOLCHAIN=gcc + +#------------------------------------------------------------------------------- +# Path +#------------------------------------------------------------------------------- + +# Output directories +OUTPUT_BIN = .. + +# Libraries +PROJECT_BASE_PATH = .. +PROJECT_BASE_PATH_USB = ../USB +SYSTEM_PATH = ../../../system +CMSIS_ROOT_PATH = $(SYSTEM_PATH)/CMSIS +CMSIS_ARM_PATH=$(CMSIS_ROOT_PATH)/CMSIS/Include +CMSIS_ATMEL_PATH=$(CMSIS_ROOT_PATH)/Device/ATMEL +CMSIS_CHIP_PATH=$(CMSIS_ROOT_PATH)/Device/ATMEL/$(CHIP_SERIE) +VARIANT_PATH = ../../../../../google/sam/variants/$(VARIANT) + +#------------------------------------------------------------------------------- +# Files +#------------------------------------------------------------------------------- + +#vpath %.h $(PROJECT_BASE_PATH) $(PROJECT_BASE_PATH_USB) $(SYSTEM_PATH) $(VARIANT_PATH) +vpath %.c $(PROJECT_BASE_PATH) $(PROJECT_BASE_PATH_USB) $(VARIANT_PATH) +vpath %.cpp $(PROJECT_BASE_PATH) $(PROJECT_BASE_PATH_USB) + +VPATH+=$(PROJECT_BASE_PATH) + +INCLUDES = +INCLUDES += -I$(PROJECT_BASE_PATH) +INCLUDES += -I$(PROJECT_BASE_PATH_USB) +INCLUDES += -I$(VARIANT_PATH) +INCLUDES += -I$(CMSIS_ARM_PATH) +INCLUDES += -I$(CMSIS_ATMEL_PATH) +INCLUDES += -I$(SYSTEM_PATH) +INCLUDES += -I$(SYSTEM_PATH)/libsam + +#------------------------------------------------------------------------------- +ifdef DEBUG +include debug.mk +else +include release.mk +endif + +#------------------------------------------------------------------------------- +# Tools +#------------------------------------------------------------------------------- + +include $(TOOLCHAIN).mk + +CFLAGS += -DUSB_VID=0x2341 -DUSB_PID=0xcafe +CPPFLAGS += -DUSB_VID=0x2341 -DUSB_PID=0xcafe + +#------------------------------------------------------------------------------- +ifdef DEBUG +OUTPUT_OBJ=debug +OUTPUT_LIB=$(LIBNAME)_$(TOOLCHAIN)_dbg.a +else +OUTPUT_OBJ=release +OUTPUT_LIB=$(LIBNAME)_$(TOOLCHAIN)_rel.a +endif + +OUTPUT_PATH=$(OUTPUT_OBJ)_$(VARIANT) + +#------------------------------------------------------------------------------- +# C source files and objects +#------------------------------------------------------------------------------- +C_SRC=$(wildcard $(PROJECT_BASE_PATH)/*.c $(PROJECT_BASE_PATH_USB)/*.c) + +C_OBJ_TEMP = $(patsubst %.c, %.o, $(notdir $(C_SRC))) + +# during development, remove some files +C_OBJ_FILTER= + +C_OBJ=$(filter-out $(C_OBJ_FILTER), $(C_OBJ_TEMP)) + +#------------------------------------------------------------------------------- +# CPP source files and objects +#------------------------------------------------------------------------------- +CPP_SRC=$(wildcard $(PROJECT_BASE_PATH)/*.cpp $(PROJECT_BASE_PATH_USB)/*.cpp) + +CPP_OBJ_TEMP = $(patsubst %.cpp, %.o, $(notdir $(CPP_SRC))) + +# during development, remove some files +CPP_OBJ_FILTER= + +CPP_OBJ=$(filter-out $(CPP_OBJ_FILTER), $(CPP_OBJ_TEMP)) + +#------------------------------------------------------------------------------- +# Assembler source files and objects +#------------------------------------------------------------------------------- +A_SRC=$(wildcard $(PROJECT_BASE_PATH)/*.s) + +A_OBJ_TEMP=$(patsubst %.s, %.o, $(notdir $(A_SRC))) + +# during development, remove some files +A_OBJ_FILTER= + +A_OBJ=$(filter-out $(A_OBJ_FILTER), $(A_OBJ_TEMP)) + +#------------------------------------------------------------------------------- +# Rules +#------------------------------------------------------------------------------- +all: $(VARIANT) + +$(VARIANT): create_output $(OUTPUT_LIB) + +.PHONY: create_output +create_output: + @echo ------------------------------------------------------------------------------------ + @echo --- Preparing $(VARIANT) files in $(OUTPUT_PATH) $(OUTPUT_BIN) + @echo ------------------------------------------------------------------------------------ +# @echo *$(INCLUDES) +# @echo ------------------------- +# @echo *$(C_SRC) +# @echo ------------------------- +# @echo *$(C_OBJ) +# @echo ------------------------- +# @echo *$(addprefix $(OUTPUT_PATH)/, $(C_OBJ)) +# @echo ------------------------- +# @echo *$(CPP_SRC) +# @echo ------------------------- +# @echo *$(CPP_OBJ) +# @echo ------------------------- +# @echo *$(addprefix $(OUTPUT_PATH)/, $(CPP_OBJ)) +# @echo ------------------------- +# @echo *$(A_SRC) +# @echo ------------------------- + + -@mkdir $(OUTPUT_PATH) 1>NUL 2>&1 + @echo ------------------------------------------------------------------------------------ + +$(addprefix $(OUTPUT_PATH)/,$(C_OBJ)): $(OUTPUT_PATH)/%.o: %.c +# "$(CC)" -v -c $(CFLAGS) $< -o $@ + @"$(CC)" -c $(CFLAGS) $< -o $@ + +#$(addprefix $(OUTPUT_PATH)/,$(CPP_OBJ)): $(OUTPUT_PATH)/%.d: %.o +# "$(CC)" -M -MF $@.d -c $(CPPFLAGS) $< + +$(addprefix $(OUTPUT_PATH)/,$(CPP_OBJ)): $(OUTPUT_PATH)/%.o: %.cpp +# "$(CC)" -xc++ -c $(CPPFLAGS) $< -o $@ + @"$(CC)" -xc++ -c $(CPPFLAGS) $< -o $@ + +$(addprefix $(OUTPUT_PATH)/,$(A_OBJ)): $(OUTPUT_PATH)/%.o: %.s + @"$(AS)" -c $(ASFLAGS) $< -o $@ + +$(OUTPUT_LIB): $(addprefix $(OUTPUT_PATH)/, $(C_OBJ)) $(addprefix $(OUTPUT_PATH)/, $(CPP_OBJ)) $(addprefix $(OUTPUT_PATH)/, $(A_OBJ)) + @echo ------------------------------------------------------------------------------------ + @"$(AR)" -r "$(OUTPUT_BIN)/$@" $^ + @"$(NM)" "$(OUTPUT_BIN)/$@" > "$(OUTPUT_BIN)/$@.txt" + @echo ------------------------------------------------------------------------------------ + + +.PHONY: clean +clean: + @echo --- Cleaning $(VARIANT) files [$(OUTPUT_PATH)$(SEP)*.o] + -@$(RM) $(OUTPUT_PATH) 1>NUL 2>&1 + -@$(RM) $(OUTPUT_BIN)/$(OUTPUT_LIB) 1>NUL 2>&1 diff --git a/hardware/arduino/sam/cores/sam/build_gcc/libarduino_arduino_due_u.mk b/hardware/arduino/sam/cores/sam/build_gcc/libarduino_arduino_due_u.mk index 4e73d7289..e69adcbad 100644 --- a/hardware/arduino/sam/cores/sam/build_gcc/libarduino_arduino_due_u.mk +++ b/hardware/arduino/sam/cores/sam/build_gcc/libarduino_arduino_due_u.mk @@ -29,11 +29,11 @@ TOOLCHAIN=gcc #------------------------------------------------------------------------------- # Output directories -#OUTPUT_BIN = ../lib OUTPUT_BIN = .. # Libraries PROJECT_BASE_PATH = .. +PROJECT_BASE_PATH_USB = ../USB SYSTEM_PATH = ../../../system CMSIS_ROOT_PATH = $(SYSTEM_PATH)/CMSIS CMSIS_ARM_PATH=$(CMSIS_ROOT_PATH)/CMSIS/Include @@ -45,14 +45,15 @@ VARIANT_PATH = ../../../variants/$(VARIANT) # Files #------------------------------------------------------------------------------- -vpath %.h $(PROJECT_BASE_PATH) $(SYSTEM_PATH) $(VARIANT_PATH) -vpath %.c $(PROJECT_BASE_PATH) $(VARIANT_PATH) -vpath %.cpp $(PROJECT_BASE_PATH) $(PROJECT_BASE_PATH) +#vpath %.h $(PROJECT_BASE_PATH) $(PROJECT_BASE_PATH_USB) $(SYSTEM_PATH) $(VARIANT_PATH) +vpath %.c $(PROJECT_BASE_PATH) $(PROJECT_BASE_PATH_USB) $(VARIANT_PATH) +vpath %.cpp $(PROJECT_BASE_PATH) $(PROJECT_BASE_PATH_USB) VPATH+=$(PROJECT_BASE_PATH) INCLUDES = INCLUDES += -I$(PROJECT_BASE_PATH) +INCLUDES += -I$(PROJECT_BASE_PATH_USB) INCLUDES += -I$(VARIANT_PATH) INCLUDES += -I$(CMSIS_ARM_PATH) INCLUDES += -I$(CMSIS_ATMEL_PATH) @@ -72,6 +73,9 @@ endif include $(TOOLCHAIN).mk +CFLAGS += -DUSB_VID=0x2341 -DUSB_PID=0xcafe +CPPFLAGS += -DUSB_VID=0x2341 -DUSB_PID=0xcafe + #------------------------------------------------------------------------------- ifdef DEBUG OUTPUT_OBJ=debug @@ -87,6 +91,7 @@ OUTPUT_PATH=$(OUTPUT_OBJ)_$(VARIANT) # C source files and objects #------------------------------------------------------------------------------- C_SRC=$(wildcard $(PROJECT_BASE_PATH)/*.c) +#C_SRC=$(wildcard $(PROJECT_BASE_PATH)/*.c $(PROJECT_BASE_PATH_USB)/*.c) C_OBJ_TEMP = $(patsubst %.c, %.o, $(notdir $(C_SRC))) @@ -99,6 +104,7 @@ C_OBJ=$(filter-out $(C_OBJ_FILTER), $(C_OBJ_TEMP)) # CPP source files and objects #------------------------------------------------------------------------------- CPP_SRC=$(wildcard $(PROJECT_BASE_PATH)/*.cpp) +#CPP_SRC=$(wildcard $(PROJECT_BASE_PATH)/*.cpp $(PROJECT_BASE_PATH_USB)/*.cpp) CPP_OBJ_TEMP = $(patsubst %.cpp, %.o, $(notdir $(CPP_SRC))) @@ -128,9 +134,9 @@ $(VARIANT): create_output $(OUTPUT_LIB) .PHONY: create_output create_output: - @echo ------------------------- + @echo ------------------------------------------------------------------------------------ @echo --- Preparing $(VARIANT) files in $(OUTPUT_PATH) $(OUTPUT_BIN) - @echo ------------------------- + @echo ------------------------------------------------------------------------------------ # @echo *$(INCLUDES) # @echo ------------------------- # @echo *$(C_SRC) @@ -148,24 +154,28 @@ create_output: # @echo *$(A_SRC) # @echo ------------------------- -# -@mkdir $(subst /,$(SEP),$(OUTPUT_BIN)) 1>NUL 2>&1 - -mkdir $(subst /,$(SEP),$(OUTPUT_BIN)) -@mkdir $(OUTPUT_PATH) 1>NUL 2>&1 + @echo ------------------------------------------------------------------------------------ $(addprefix $(OUTPUT_PATH)/,$(C_OBJ)): $(OUTPUT_PATH)/%.o: %.c -# @"$(CC)" -v -c $(CFLAGS) $< -o $@ +# "$(CC)" -v -c $(CFLAGS) $< -o $@ @"$(CC)" -c $(CFLAGS) $< -o $@ +#$(addprefix $(OUTPUT_PATH)/,$(CPP_OBJ)): $(OUTPUT_PATH)/%.d: %.o +# "$(CC)" -M -MF $@.d -c $(CPPFLAGS) $< + $(addprefix $(OUTPUT_PATH)/,$(CPP_OBJ)): $(OUTPUT_PATH)/%.o: %.cpp -# @"$(CC)" -c $(CPPFLAGS) $< -o $@ +# "$(CC)" -xc++ -c $(CPPFLAGS) $< -o $@ @"$(CC)" -xc++ -c $(CPPFLAGS) $< -o $@ $(addprefix $(OUTPUT_PATH)/,$(A_OBJ)): $(OUTPUT_PATH)/%.o: %.s @"$(AS)" -c $(ASFLAGS) $< -o $@ $(OUTPUT_LIB): $(addprefix $(OUTPUT_PATH)/, $(C_OBJ)) $(addprefix $(OUTPUT_PATH)/, $(CPP_OBJ)) $(addprefix $(OUTPUT_PATH)/, $(A_OBJ)) - @"$(AR)" -v -r "$(OUTPUT_BIN)/$@" $^ + @echo ------------------------------------------------------------------------------------ + @"$(AR)" -r "$(OUTPUT_BIN)/$@" $^ @"$(NM)" "$(OUTPUT_BIN)/$@" > "$(OUTPUT_BIN)/$@.txt" + @echo ------------------------------------------------------------------------------------ .PHONY: clean diff --git a/hardware/arduino/sam/cores/sam/build_gcc/libarduino_arduino_due_x.mk b/hardware/arduino/sam/cores/sam/build_gcc/libarduino_arduino_due_x.mk index 736f8df23..ad7b9f480 100644 --- a/hardware/arduino/sam/cores/sam/build_gcc/libarduino_arduino_due_x.mk +++ b/hardware/arduino/sam/cores/sam/build_gcc/libarduino_arduino_due_x.mk @@ -29,7 +29,6 @@ TOOLCHAIN=gcc #------------------------------------------------------------------------------- # Output directories -#OUTPUT_BIN = ../lib OUTPUT_BIN = .. # Libraries @@ -46,9 +45,9 @@ VARIANT_PATH = ../../../variants/$(VARIANT) # Files #------------------------------------------------------------------------------- -vpath %.h $(PROJECT_BASE_PATH) $(PROJECT_BASE_PATH_USB) $(SYSTEM_PATH) $(VARIANT_PATH) +#vpath %.h $(PROJECT_BASE_PATH) $(PROJECT_BASE_PATH_USB) $(SYSTEM_PATH) $(VARIANT_PATH) vpath %.c $(PROJECT_BASE_PATH) $(PROJECT_BASE_PATH_USB) $(VARIANT_PATH) -vpath %.cpp $(PROJECT_BASE_PATH) $(PROJECT_BASE_PATH_USB) $(PROJECT_BASE_PATH) +vpath %.cpp $(PROJECT_BASE_PATH) $(PROJECT_BASE_PATH_USB) VPATH+=$(PROJECT_BASE_PATH) @@ -133,9 +132,9 @@ $(VARIANT): create_output $(OUTPUT_LIB) .PHONY: create_output create_output: - @echo ------------------------- + @echo ------------------------------------------------------------------------------------ @echo --- Preparing $(VARIANT) files in $(OUTPUT_PATH) $(OUTPUT_BIN) - @echo ------------------------- + @echo ------------------------------------------------------------------------------------ # @echo *$(INCLUDES) # @echo ------------------------- # @echo *$(C_SRC) @@ -153,9 +152,8 @@ create_output: # @echo *$(A_SRC) # @echo ------------------------- -# -@mkdir $(subst /,$(SEP),$(OUTPUT_BIN)) 1>NUL 2>&1 - -mkdir $(subst /,$(SEP),$(OUTPUT_BIN)) -@mkdir $(OUTPUT_PATH) 1>NUL 2>&1 + @echo ------------------------------------------------------------------------------------ $(addprefix $(OUTPUT_PATH)/,$(C_OBJ)): $(OUTPUT_PATH)/%.o: %.c # "$(CC)" -v -c $(CFLAGS) $< -o $@ @@ -165,15 +163,17 @@ $(addprefix $(OUTPUT_PATH)/,$(C_OBJ)): $(OUTPUT_PATH)/%.o: %.c # "$(CC)" -M -MF $@.d -c $(CPPFLAGS) $< $(addprefix $(OUTPUT_PATH)/,$(CPP_OBJ)): $(OUTPUT_PATH)/%.o: %.cpp - "$(CC)" -xc++ -c $(CPPFLAGS) $< -o $@ -# @"$(CC)" -xc++ -c $(CPPFLAGS) $< -o $@ +# "$(CC)" -xc++ -c $(CPPFLAGS) $< -o $@ + @"$(CC)" -xc++ -c $(CPPFLAGS) $< -o $@ $(addprefix $(OUTPUT_PATH)/,$(A_OBJ)): $(OUTPUT_PATH)/%.o: %.s @"$(AS)" -c $(ASFLAGS) $< -o $@ $(OUTPUT_LIB): $(addprefix $(OUTPUT_PATH)/, $(C_OBJ)) $(addprefix $(OUTPUT_PATH)/, $(CPP_OBJ)) $(addprefix $(OUTPUT_PATH)/, $(A_OBJ)) - @"$(AR)" -v -r "$(OUTPUT_BIN)/$@" $^ + @echo ------------------------------------------------------------------------------------ + @"$(AR)" -r "$(OUTPUT_BIN)/$@" $^ @"$(NM)" "$(OUTPUT_BIN)/$@" > "$(OUTPUT_BIN)/$@.txt" + @echo ------------------------------------------------------------------------------------ .PHONY: clean diff --git a/hardware/arduino/sam/cores/sam/build_gcc/libarduino_sam3s_ek.mk b/hardware/arduino/sam/cores/sam/build_gcc/libarduino_sam3s_ek.mk index f31d2a5fd..a8087bf35 100644 --- a/hardware/arduino/sam/cores/sam/build_gcc/libarduino_sam3s_ek.mk +++ b/hardware/arduino/sam/cores/sam/build_gcc/libarduino_sam3s_ek.mk @@ -29,30 +29,31 @@ TOOLCHAIN=gcc #------------------------------------------------------------------------------- # Output directories -#OUTPUT_BIN = ../lib OUTPUT_BIN = .. # Libraries PROJECT_BASE_PATH = .. +PROJECT_BASE_PATH_USB = ../USB SYSTEM_PATH = ../../../system CMSIS_ROOT_PATH = $(SYSTEM_PATH)/CMSIS CMSIS_ARM_PATH=$(CMSIS_ROOT_PATH)/CMSIS/Include CMSIS_ATMEL_PATH=$(CMSIS_ROOT_PATH)/Device/ATMEL CMSIS_CHIP_PATH=$(CMSIS_ROOT_PATH)/Device/ATMEL/$(CHIP_SERIE) -VARIANT_PATH = ../../../variants/$(VARIANT) +VARIANT_PATH = ../../../../../atmel/sam/variants/$(VARIANT) #------------------------------------------------------------------------------- # Files #------------------------------------------------------------------------------- -vpath %.h $(PROJECT_BASE_PATH) $(SYSTEM_PATH) $(VARIANT_PATH) -vpath %.c $(PROJECT_BASE_PATH) $(VARIANT_PATH) -vpath %.cpp $(PROJECT_BASE_PATH) $(PROJECT_BASE_PATH) +#vpath %.h $(PROJECT_BASE_PATH) $(PROJECT_BASE_PATH_USB) $(SYSTEM_PATH) $(VARIANT_PATH) +vpath %.c $(PROJECT_BASE_PATH) $(PROJECT_BASE_PATH_USB) $(VARIANT_PATH) +vpath %.cpp $(PROJECT_BASE_PATH) $(PROJECT_BASE_PATH_USB) VPATH+=$(PROJECT_BASE_PATH) INCLUDES = INCLUDES += -I$(PROJECT_BASE_PATH) +INCLUDES += -I$(PROJECT_BASE_PATH_USB) INCLUDES += -I$(VARIANT_PATH) INCLUDES += -I$(CMSIS_ARM_PATH) INCLUDES += -I$(CMSIS_ATMEL_PATH) @@ -72,6 +73,9 @@ endif include $(TOOLCHAIN).mk +CFLAGS += -DUSB_VID=0x2341 -DUSB_PID=0xcafe +CPPFLAGS += -DUSB_VID=0x2341 -DUSB_PID=0xcafe + #------------------------------------------------------------------------------- ifdef DEBUG OUTPUT_OBJ=debug @@ -86,7 +90,7 @@ OUTPUT_PATH=$(OUTPUT_OBJ)_$(VARIANT) #------------------------------------------------------------------------------- # C source files and objects #------------------------------------------------------------------------------- -C_SRC=$(wildcard $(PROJECT_BASE_PATH)/*.c) +C_SRC=$(wildcard $(PROJECT_BASE_PATH)/*.c $(PROJECT_BASE_PATH_USB)/*.c) C_OBJ_TEMP = $(patsubst %.c, %.o, $(notdir $(C_SRC))) @@ -98,7 +102,7 @@ C_OBJ=$(filter-out $(C_OBJ_FILTER), $(C_OBJ_TEMP)) #------------------------------------------------------------------------------- # CPP source files and objects #------------------------------------------------------------------------------- -CPP_SRC=$(wildcard $(PROJECT_BASE_PATH)/*.cpp) +CPP_SRC=$(wildcard $(PROJECT_BASE_PATH)/*.cpp $(PROJECT_BASE_PATH_USB)/*.cpp) CPP_OBJ_TEMP = $(patsubst %.cpp, %.o, $(notdir $(CPP_SRC))) @@ -128,9 +132,9 @@ $(VARIANT): create_output $(OUTPUT_LIB) .PHONY: create_output create_output: - @echo ------------------------- + @echo ------------------------------------------------------------------------------------ @echo --- Preparing $(VARIANT) files in $(OUTPUT_PATH) $(OUTPUT_BIN) - @echo ------------------------- + @echo ------------------------------------------------------------------------------------ # @echo *$(INCLUDES) # @echo ------------------------- # @echo *$(C_SRC) @@ -148,24 +152,28 @@ create_output: # @echo *$(A_SRC) # @echo ------------------------- -# -@mkdir $(subst /,$(SEP),$(OUTPUT_BIN)) 1>NUL 2>&1 - -mkdir $(subst /,$(SEP),$(OUTPUT_BIN)) -@mkdir $(OUTPUT_PATH) 1>NUL 2>&1 + @echo ------------------------------------------------------------------------------------ $(addprefix $(OUTPUT_PATH)/,$(C_OBJ)): $(OUTPUT_PATH)/%.o: %.c -# @"$(CC)" -v -c $(CFLAGS) $< -o $@ +# "$(CC)" -v -c $(CFLAGS) $< -o $@ @"$(CC)" -c $(CFLAGS) $< -o $@ +#$(addprefix $(OUTPUT_PATH)/,$(CPP_OBJ)): $(OUTPUT_PATH)/%.d: %.o +# "$(CC)" -M -MF $@.d -c $(CPPFLAGS) $< + $(addprefix $(OUTPUT_PATH)/,$(CPP_OBJ)): $(OUTPUT_PATH)/%.o: %.cpp -# @"$(CC)" -c $(CPPFLAGS) $< -o $@ +# "$(CC)" -xc++ -c $(CPPFLAGS) $< -o $@ @"$(CC)" -xc++ -c $(CPPFLAGS) $< -o $@ $(addprefix $(OUTPUT_PATH)/,$(A_OBJ)): $(OUTPUT_PATH)/%.o: %.s @"$(AS)" -c $(ASFLAGS) $< -o $@ $(OUTPUT_LIB): $(addprefix $(OUTPUT_PATH)/, $(C_OBJ)) $(addprefix $(OUTPUT_PATH)/, $(CPP_OBJ)) $(addprefix $(OUTPUT_PATH)/, $(A_OBJ)) - @"$(AR)" -v -r "$(OUTPUT_BIN)/$@" $^ + @echo ------------------------------------------------------------------------------------ + @"$(AR)" -r "$(OUTPUT_BIN)/$@" $^ @"$(NM)" "$(OUTPUT_BIN)/$@" > "$(OUTPUT_BIN)/$@.txt" + @echo ------------------------------------------------------------------------------------ .PHONY: clean diff --git a/hardware/arduino/sam/cores/sam/build_gcc/libarduino_sam3u_ek.mk b/hardware/arduino/sam/cores/sam/build_gcc/libarduino_sam3u_ek.mk index d698e7787..766cbc46f 100644 --- a/hardware/arduino/sam/cores/sam/build_gcc/libarduino_sam3u_ek.mk +++ b/hardware/arduino/sam/cores/sam/build_gcc/libarduino_sam3u_ek.mk @@ -29,30 +29,31 @@ TOOLCHAIN=gcc #------------------------------------------------------------------------------- # Output directories -#OUTPUT_BIN = ../lib OUTPUT_BIN = .. # Libraries PROJECT_BASE_PATH = .. +PROJECT_BASE_PATH_USB = ../USB SYSTEM_PATH = ../../../system CMSIS_ROOT_PATH = $(SYSTEM_PATH)/CMSIS CMSIS_ARM_PATH=$(CMSIS_ROOT_PATH)/CMSIS/Include CMSIS_ATMEL_PATH=$(CMSIS_ROOT_PATH)/Device/ATMEL CMSIS_CHIP_PATH=$(CMSIS_ROOT_PATH)/Device/ATMEL/$(CHIP_SERIE) -VARIANT_PATH = ../../../variants/$(VARIANT) +VARIANT_PATH = ../../../../../atmel/sam/variants/$(VARIANT) #------------------------------------------------------------------------------- # Files #------------------------------------------------------------------------------- -vpath %.h $(PROJECT_BASE_PATH) $(SYSTEM_PATH) $(VARIANT_PATH) -vpath %.c $(PROJECT_BASE_PATH) $(VARIANT_PATH) -vpath %.cpp $(PROJECT_BASE_PATH) $(PROJECT_BASE_PATH) +vpath %.h $(PROJECT_BASE_PATH) $(PROJECT_BASE_PATH_USB) $(SYSTEM_PATH) $(VARIANT_PATH) +vpath %.c $(PROJECT_BASE_PATH) $(PROJECT_BASE_PATH_USB) $(VARIANT_PATH) +vpath %.cpp $(PROJECT_BASE_PATH) $(PROJECT_BASE_PATH_USB) VPATH+=$(PROJECT_BASE_PATH) INCLUDES = INCLUDES += -I$(PROJECT_BASE_PATH) +INCLUDES += -I$(PROJECT_BASE_PATH_USB) INCLUDES += -I$(VARIANT_PATH) INCLUDES += -I$(CMSIS_ARM_PATH) INCLUDES += -I$(CMSIS_ATMEL_PATH) @@ -72,6 +73,9 @@ endif include $(TOOLCHAIN).mk +CFLAGS += -DUSB_VID=0x2341 -DUSB_PID=0xcafe +CPPFLAGS += -DUSB_VID=0x2341 -DUSB_PID=0xcafe + #------------------------------------------------------------------------------- ifdef DEBUG OUTPUT_OBJ=debug @@ -86,7 +90,7 @@ OUTPUT_PATH=$(OUTPUT_OBJ)_$(VARIANT) #------------------------------------------------------------------------------- # C source files and objects #------------------------------------------------------------------------------- -C_SRC=$(wildcard $(PROJECT_BASE_PATH)/*.c) +C_SRC=$(wildcard $(PROJECT_BASE_PATH)/*.c $(PROJECT_BASE_PATH_USB)/*.c) C_OBJ_TEMP = $(patsubst %.c, %.o, $(notdir $(C_SRC))) @@ -98,7 +102,7 @@ C_OBJ=$(filter-out $(C_OBJ_FILTER), $(C_OBJ_TEMP)) #------------------------------------------------------------------------------- # CPP source files and objects #------------------------------------------------------------------------------- -CPP_SRC=$(wildcard $(PROJECT_BASE_PATH)/*.cpp) +CPP_SRC=$(wildcard $(PROJECT_BASE_PATH)/*.cpp $(PROJECT_BASE_PATH_USB)/*.cpp) CPP_OBJ_TEMP = $(patsubst %.cpp, %.o, $(notdir $(CPP_SRC))) @@ -128,9 +132,9 @@ $(VARIANT): create_output $(OUTPUT_LIB) .PHONY: create_output create_output: - @echo ------------------------- + @echo ------------------------------------------------------------------------------------ @echo --- Preparing $(VARIANT) files in $(OUTPUT_PATH) $(OUTPUT_BIN) - @echo ------------------------- + @echo ------------------------------------------------------------------------------------ # @echo *$(INCLUDES) # @echo ------------------------- # @echo *$(C_SRC) @@ -149,21 +153,27 @@ create_output: # @echo ------------------------- -@mkdir $(OUTPUT_PATH) 1>NUL 2>&1 + @echo ------------------------------------------------------------------------------------ $(addprefix $(OUTPUT_PATH)/,$(C_OBJ)): $(OUTPUT_PATH)/%.o: %.c -# @"$(CC)" -v -c $(CFLAGS) $< -o $@ +# "$(CC)" -v -c $(CFLAGS) $< -o $@ @"$(CC)" -c $(CFLAGS) $< -o $@ +#$(addprefix $(OUTPUT_PATH)/,$(CPP_OBJ)): $(OUTPUT_PATH)/%.d: %.o +# "$(CC)" -M -MF $@.d -c $(CPPFLAGS) $< + $(addprefix $(OUTPUT_PATH)/,$(CPP_OBJ)): $(OUTPUT_PATH)/%.o: %.cpp -# @"$(CC)" -c $(CPPFLAGS) $< -o $@ +# "$(CC)" -xc++ -c $(CPPFLAGS) $< -o $@ @"$(CC)" -xc++ -c $(CPPFLAGS) $< -o $@ $(addprefix $(OUTPUT_PATH)/,$(A_OBJ)): $(OUTPUT_PATH)/%.o: %.s @"$(AS)" -c $(ASFLAGS) $< -o $@ $(OUTPUT_LIB): $(addprefix $(OUTPUT_PATH)/, $(C_OBJ)) $(addprefix $(OUTPUT_PATH)/, $(CPP_OBJ)) $(addprefix $(OUTPUT_PATH)/, $(A_OBJ)) - @"$(AR)" -v -r "$(OUTPUT_BIN)/$@" $^ + @echo ------------------------------------------------------------------------------------ + @"$(AR)" -r "$(OUTPUT_BIN)/$@" $^ @"$(NM)" "$(OUTPUT_BIN)/$@" > "$(OUTPUT_BIN)/$@.txt" + @echo ------------------------------------------------------------------------------------ .PHONY: clean diff --git a/hardware/arduino/sam/cores/sam/build_gcc/libarduino_sam3x_ek.mk b/hardware/arduino/sam/cores/sam/build_gcc/libarduino_sam3x_ek.mk index 81b688172..14b0186ad 100644 --- a/hardware/arduino/sam/cores/sam/build_gcc/libarduino_sam3x_ek.mk +++ b/hardware/arduino/sam/cores/sam/build_gcc/libarduino_sam3x_ek.mk @@ -29,11 +29,11 @@ TOOLCHAIN=gcc #------------------------------------------------------------------------------- # Output directories -#OUTPUT_BIN = ../lib OUTPUT_BIN = .. # Libraries PROJECT_BASE_PATH = .. +PROJECT_BASE_PATH_USB = ../USB SYSTEM_PATH = ../../../system CMSIS_ROOT_PATH = $(SYSTEM_PATH)/CMSIS CMSIS_ARM_PATH=$(CMSIS_ROOT_PATH)/CMSIS/Include @@ -45,14 +45,15 @@ VARIANT_PATH = ../../../../../atmel/sam/variants/$(VARIANT) # Files #------------------------------------------------------------------------------- -vpath %.h $(PROJECT_BASE_PATH) $(SYSTEM_PATH) $(VARIANT_PATH) -vpath %.c $(PROJECT_BASE_PATH) $(VARIANT_PATH) -vpath %.cpp $(PROJECT_BASE_PATH) $(PROJECT_BASE_PATH) +vpath %.h $(PROJECT_BASE_PATH) $(PROJECT_BASE_PATH_USB) $(SYSTEM_PATH) $(VARIANT_PATH) +vpath %.c $(PROJECT_BASE_PATH) $(PROJECT_BASE_PATH_USB) $(VARIANT_PATH) +vpath %.cpp $(PROJECT_BASE_PATH) $(PROJECT_BASE_PATH_USB) VPATH+=$(PROJECT_BASE_PATH) INCLUDES = INCLUDES += -I$(PROJECT_BASE_PATH) +INCLUDES += -I$(PROJECT_BASE_PATH_USB) INCLUDES += -I$(VARIANT_PATH) INCLUDES += -I$(CMSIS_ARM_PATH) INCLUDES += -I$(CMSIS_ATMEL_PATH) @@ -72,6 +73,9 @@ endif include $(TOOLCHAIN).mk +CFLAGS += -DUSB_VID=0x2341 -DUSB_PID=0xcafe +CPPFLAGS += -DUSB_VID=0x2341 -DUSB_PID=0xcafe + #------------------------------------------------------------------------------- ifdef DEBUG OUTPUT_OBJ=debug @@ -86,7 +90,7 @@ OUTPUT_PATH=$(OUTPUT_OBJ)_$(VARIANT) #------------------------------------------------------------------------------- # C source files and objects #------------------------------------------------------------------------------- -C_SRC=$(wildcard $(PROJECT_BASE_PATH)/*.c) +C_SRC=$(wildcard $(PROJECT_BASE_PATH)/*.c $(PROJECT_BASE_PATH_USB)/*.c) C_OBJ_TEMP = $(patsubst %.c, %.o, $(notdir $(C_SRC))) @@ -98,7 +102,7 @@ C_OBJ=$(filter-out $(C_OBJ_FILTER), $(C_OBJ_TEMP)) #------------------------------------------------------------------------------- # CPP source files and objects #------------------------------------------------------------------------------- -CPP_SRC=$(wildcard $(PROJECT_BASE_PATH)/*.cpp) +CPP_SRC=$(wildcard $(PROJECT_BASE_PATH)/*.cpp $(PROJECT_BASE_PATH_USB)/*.cpp) CPP_OBJ_TEMP = $(patsubst %.cpp, %.o, $(notdir $(CPP_SRC))) @@ -128,9 +132,9 @@ $(VARIANT): create_output $(OUTPUT_LIB) .PHONY: create_output create_output: - @echo ------------------------- + @echo ------------------------------------------------------------------------------------ @echo --- Preparing $(VARIANT) files in $(OUTPUT_PATH) $(OUTPUT_BIN) - @echo ------------------------- + @echo ------------------------------------------------------------------------------------ # @echo *$(INCLUDES) # @echo ------------------------- # @echo *$(C_SRC) @@ -149,21 +153,27 @@ create_output: # @echo ------------------------- -@mkdir $(OUTPUT_PATH) 1>NUL 2>&1 + @echo ------------------------------------------------------------------------------------ $(addprefix $(OUTPUT_PATH)/,$(C_OBJ)): $(OUTPUT_PATH)/%.o: %.c -# @"$(CC)" -v -c $(CFLAGS) $< -o $@ +# "$(CC)" -v -c $(CFLAGS) $< -o $@ @"$(CC)" -c $(CFLAGS) $< -o $@ +#$(addprefix $(OUTPUT_PATH)/,$(CPP_OBJ)): $(OUTPUT_PATH)/%.d: %.o +# "$(CC)" -M -MF $@.d -c $(CPPFLAGS) $< + $(addprefix $(OUTPUT_PATH)/,$(CPP_OBJ)): $(OUTPUT_PATH)/%.o: %.cpp -# @"$(CC)" -c $(CPPFLAGS) $< -o $@ +# "$(CC)" -xc++ -c $(CPPFLAGS) $< -o $@ @"$(CC)" -xc++ -c $(CPPFLAGS) $< -o $@ $(addprefix $(OUTPUT_PATH)/,$(A_OBJ)): $(OUTPUT_PATH)/%.o: %.s @"$(AS)" -c $(ASFLAGS) $< -o $@ $(OUTPUT_LIB): $(addprefix $(OUTPUT_PATH)/, $(C_OBJ)) $(addprefix $(OUTPUT_PATH)/, $(CPP_OBJ)) $(addprefix $(OUTPUT_PATH)/, $(A_OBJ)) - @"$(AR)" -v -r "$(OUTPUT_BIN)/$@" $^ + @echo ------------------------------------------------------------------------------------ + @"$(AR)" -r "$(OUTPUT_BIN)/$@" $^ @"$(NM)" "$(OUTPUT_BIN)/$@" > "$(OUTPUT_BIN)/$@.txt" + @echo ------------------------------------------------------------------------------------ .PHONY: clean diff --git a/hardware/arduino/sam/cores/sam/cortex_handlers.c b/hardware/arduino/sam/cores/sam/cortex_handlers.c index 7df048b81..924110b90 100644 --- a/hardware/arduino/sam/cores/sam/cortex_handlers.c +++ b/hardware/arduino/sam/cores/sam/cortex_handlers.c @@ -1,5 +1,5 @@ /* - Copyright (c) 2011 Arduino. All right reserved. + Copyright (c) 2012 Arduino. All right reserved. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -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 @@ -22,42 +22,42 @@ extern "C" { #endif -extern void NMI_Handler( void ) +void NMI_Handler( void ) { for ( ;; ) ; } -extern void HardFault_Handler( void ) +void HardFault_Handler( void ) { for ( ;; ) ; } -extern void MemManage_Handler( void ) +void MemManage_Handler( void ) { for ( ;; ) ; } -extern void BusFault_Handler( void ) +void BusFault_Handler( void ) { for ( ;; ) ; } -extern void UsageFault_Handler( void ) +void UsageFault_Handler( void ) { for ( ;; ) ; } -extern void SVC_Handler( void ) +void SVC_Handler( void ) { for ( ;; ) ; } -extern void DebugMon_Handler( void ) +void DebugMon_Handler( void ) { for ( ;; ) ; } -extern void PendSV_Handler( void ) +void PendSV_Handler( void ) { for ( ;; ) ; } diff --git a/hardware/arduino/sam/cores/sam/main.cpp b/hardware/arduino/sam/cores/sam/main.cpp index 4c6b43a0d..fdcf86fbe 100644 --- a/hardware/arduino/sam/cores/sam/main.cpp +++ b/hardware/arduino/sam/cores/sam/main.cpp @@ -22,11 +22,13 @@ /* * Cortex-M3 Systick IT handler */ +/* extern void SysTick_Handler( void ) { // Increment tick count each ms TimeTick_Increment() ; } +*/ /* * \brief Main entry point of Arduino application diff --git a/hardware/arduino/sam/cores/sam/validation/build_gcc/Makefile b/hardware/arduino/sam/cores/sam/validation/build_gcc/Makefile index 92bddee3e..0ca76782c 100644 --- a/hardware/arduino/sam/cores/sam/validation/build_gcc/Makefile +++ b/hardware/arduino/sam/cores/sam/validation/build_gcc/Makefile @@ -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,7 +16,7 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # -SUBMAKE_OPTIONS=--no-builtin-rules --no-builtin-variables +SUBMAKE_OPTIONS=--no-builtin-rules --no-builtin-variables --no-print-directory #------------------------------------------------------------------------------- # Rules @@ -24,18 +24,93 @@ SUBMAKE_OPTIONS=--no-builtin-rules --no-builtin-variables all: test -.PHONY: test -test: +test: test_arduino_due_x test_sam3x_ek test_adk2 + @echo ------------------------------------------------------------------------------------ @echo --- Making test - @$(MAKE) DEBUG=1 $(SUBMAKE_OPTIONS) -f test.mk + @$(MAKE) DEBUG=1 VARIANT=arduino_due_x $(SUBMAKE_OPTIONS) -f test.mk +# @$(MAKE) DEBUG=1 VARIANT=sam3s_ek $(SUBMAKE_OPTIONS) -f test.mk +# @$(MAKE) DEBUG=1 VARIANT=sam3u_ek $(SUBMAKE_OPTIONS) -f test.mk + @$(MAKE) DEBUG=1 VARIANT=sam3x_ek $(SUBMAKE_OPTIONS) -f test.mk + @$(MAKE) DEBUG=1 VARIANT=adk2 $(SUBMAKE_OPTIONS) -f test.mk + @echo ------------------------------------------------------------------------------------ + +.PHONY: test_arduino_due_x +test_arduino_due_x: + @echo ------------------------------------------------------------------------------------ + @echo --- Making test_arduino_due_x + @$(MAKE) DEBUG=1 VARIANT=arduino_due_x $(SUBMAKE_OPTIONS) -f test.mk + @echo ------------------------------------------------------------------------------------ + +.PHONY: test_adk2 +test_adk2: + @echo ------------------------------------------------------------------------------------ + @echo --- Making test_adk2 + @$(MAKE) DEBUG=1 VARIANT=adk2 $(SUBMAKE_OPTIONS) -f test.mk + @echo ------------------------------------------------------------------------------------ + +.PHONY: test_sam3s_ek +test_sam3s_ek: + @echo ------------------------------------------------------------------------------------ + @echo --- Making test_sam3s_ek + @$(MAKE) DEBUG=1 VARIANT=sam3s_ek $(SUBMAKE_OPTIONS) -f test.mk + @echo ------------------------------------------------------------------------------------ + +.PHONY: test_sam3u_ek +test_sam3u_ek: + @echo ------------------------------------------------------------------------------------ + @echo --- Making test_sam3u_ek + @$(MAKE) DEBUG=1 VARIANT=sam3u_ek $(SUBMAKE_OPTIONS) -f test.mk + @echo ------------------------------------------------------------------------------------ + +.PHONY: test_sam3x_ek +test_sam3x_ek: + @echo ------------------------------------------------------------------------------------ + @echo --- Making test_sam3x_ek + @$(MAKE) DEBUG=1 VARIANT=sam3x_ek $(SUBMAKE_OPTIONS) -f test.mk + @echo ------------------------------------------------------------------------------------ .PHONY: clean clean: + @echo ------------------------------------------------------------------------------------ @echo --- Cleaning test - @$(MAKE) DEBUG=1 $(SUBMAKE_OPTIONS) -f test.mk $@ + @$(MAKE) DEBUG=1 VARIANT=arduino_due_x $(SUBMAKE_OPTIONS) -f test.mk $@ + @$(MAKE) DEBUG=1 VARIANT=adk2 $(SUBMAKE_OPTIONS) -f test.mk $@ + @$(MAKE) DEBUG=1 VARIANT=sam3s_ek $(SUBMAKE_OPTIONS) -f test.mk $@ + @$(MAKE) DEBUG=1 VARIANT=sam3u_ek $(SUBMAKE_OPTIONS) -f test.mk $@ + @$(MAKE) DEBUG=1 VARIANT=sam3x_ek $(SUBMAKE_OPTIONS) -f test.mk $@ + @echo ------------------------------------------------------------------------------------ -.PHONY: debug -debug: - @echo --- Debugging test - @$(MAKE) DEBUG=1 $(SUBMAKE_OPTIONS) -f test.mk $@ +.PHONY: debug_arduino_due_x +debug_arduino_due_x: + @echo ------------------------------------------------------------------------------------ + @echo --- Debugging test arduino_due_x + @$(MAKE) DEBUG=1 VARIANT=arduino_due_x $(SUBMAKE_OPTIONS) -f test.mk $@ + @echo ------------------------------------------------------------------------------------ +.PHONY: debug_adk2 +debug_adk2: + @echo ------------------------------------------------------------------------------------ + @echo --- Debugging test adk2 + @$(MAKE) DEBUG=1 VARIANT=adk2 $(SUBMAKE_OPTIONS) -f test.mk $@ + @echo ------------------------------------------------------------------------------------ + +.PHONY: debug_sam3s_ek +debug_sam3s_ek: + @echo ------------------------------------------------------------------------------------ + @echo --- Debugging test sam3s_ek + @$(MAKE) DEBUG=1 VARIANT=sam3s_ek $(SUBMAKE_OPTIONS) -f test.mk $@ + @echo ------------------------------------------------------------------------------------ + +.PHONY: debug_sam3u_ek +debug_sam3u_ek: + @echo ------------------------------------------------------------------------------------ + @echo --- Debugging test sam3u_ek + @$(MAKE) DEBUG=1 VARIANT=sam3u_ek $(SUBMAKE_OPTIONS) -f test.mk $@ + @echo ------------------------------------------------------------------------------------ + +.PHONY: debug_sam3x_ek +debug_sam3x_ek: + @echo ------------------------------------------------------------------------------------ + @echo --- Debugging test sam3x_ek + @$(MAKE) DEBUG=1 VARIANT=sam3x_ek $(SUBMAKE_OPTIONS) -f test.mk $@ + @echo ------------------------------------------------------------------------------------ diff --git a/hardware/arduino/sam/cores/sam/validation/build_gcc/test.mk b/hardware/arduino/sam/cores/sam/validation/build_gcc/test.mk index f4c08a79f..8f2d89f63 100644 --- a/hardware/arduino/sam/cores/sam/validation/build_gcc/test.mk +++ b/hardware/arduino/sam/cores/sam/validation/build_gcc/test.mk @@ -16,14 +16,15 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # -# Makefile for compiling libArduino -.SUFFIXES: .o .a .c .s +# Makefile for compiling validation application +.SUFFIXES: .o .a .c .cpp .s # putting default variant ifeq ("$(VARIANT)", "") #VARIANT=sam3s_ek #VARIANT=sam3u_ek -VARIANT=sam3x_ek +#VARIANT=sam3x_ek +VARIANT=adk2 #VARIANT=arduino_due_x endif @@ -42,6 +43,9 @@ VARIANT_PATH = ../../../../variants/$(VARIANT) else ifeq ("$(VARIANT)", "arduino_due_x") CHIP=__SAM3X8E__ VARIANT_PATH = ../../../../variants/$(VARIANT) +else ifeq ("$(VARIANT)", "adk2") +CHIP=__SAM3X8E__ +VARIANT_PATH = ../../../../../../google/sam/variants/$(VARIANT) endif TOOLCHAIN=gcc @@ -51,7 +55,7 @@ TOOLCHAIN=gcc #------------------------------------------------------------------------------- # Libraries -PROJECT_BASE_PATH = ./.. +PROJECT_BASE_PATH = .. SYSTEM_PATH = ../../../../system ifeq ($(CHIP), __SAM3S4C__) @@ -77,8 +81,8 @@ CMSIS_ARM_PATH=$(CMSIS_ROOT_PATH)/CMSIS/Include CMSIS_ATMEL_PATH=$(CMSIS_ROOT_PATH)/Device/ATMEL CMSIS_CHIP_PATH=$(CMSIS_ROOT_PATH)/Device/ATMEL/$(CHIP_SERIE) -ARDUINO_CORE_PATH=$(PROJECT_BASE_PATH)/.. -ARDUINO_USB_PATH=$(PROJECT_BASE_PATH)/../USB +ARDUINO_CORE_PATH=../../../../cores/sam +ARDUINO_USB_PATH=$(ARDUINO_CORE_PATH)/USB # Output directories OUTPUT_PATH = debug_$(VARIANT) @@ -87,15 +91,14 @@ OUTPUT_PATH = debug_$(VARIANT) # Files #------------------------------------------------------------------------------- -vpath %.h $(PROJECT_BASE_PATH)/.. $(VARIANT_PATH) $(SYSTEM_PATH) $(CMSIS_ARM_PATH) +#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) +#VPATH+=$(PROJECT_BASE_PATH) -INCLUDES = -I$(PROJECT_BASE_PATH)/.. +INCLUDES = -I$(ARDUINO_CORE_PATH) +INCLUDES += -I$(ARDUINO_CORE_PATH)/USB INCLUDES += -I$(VARIANT_PATH) -#INCLUDES += -I$(VARIANT_PATH)/.. -#INCLUDES += -I$(SYSTEM_PATH) INCLUDES += -I$(SYSTEM_PATH)/libsam INCLUDES += -I$(CMSIS_ARM_PATH) INCLUDES += -I$(CMSIS_ATMEL_PATH) @@ -154,6 +157,7 @@ test: create_output libsam_$(CHIP_NAME)_$(TOOLCHAIN)_$(LIBS_POSTFIX).a libarduin .PHONY: create_output create_output: + @echo ------------------------------------------------------------------------------------ @echo --- Preparing $(VARIANT) files in $(OUTPUT_PATH) $(OUTPUT_BIN) # @echo ------------------------- # @echo *$(INCLUDES) @@ -174,11 +178,12 @@ create_output: # @echo ------------------------- -@mkdir $(OUTPUT_PATH) 1>NUL 2>&1 + @echo ------------------------------------------------------------------------------------ $(addprefix $(OUTPUT_PATH)/,$(CPP_OBJ)): $(OUTPUT_PATH)/%.o: %.cpp -# @"$(CC)" -c $(CPPFLAGS) $< -o $@ -# @"$(CXX)" -c $(CPPFLAGS) $< -o $@ - @"$(CXX)" -v -c $(CPPFLAGS) $< -o $@ + @echo *** Current folder is $(shell cd) + @"$(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) @@ -189,8 +194,22 @@ $(OUTPUT_BIN): $(addprefix $(OUTPUT_PATH)/, $(C_OBJ)) $(addprefix $(OUTPUT_PATH) .PHONY: clean clean: - @echo --- Cleaning test files + @echo ------------------------------------------------------------------------------------ + @echo --- Cleaning test files for $(VARIANT) -@$(RM) $(OUTPUT_PATH) 1>NUL 2>&1 + @echo ------------------------------------------------------------------------------------ + @echo ------------------------------------------------------------------------------------ + @echo Sub-making clean for libsam + @$(MAKE) -C $(SYSTEM_PATH)/libsam/build_gcc -f Makefile clean + @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 @@ -203,14 +222,20 @@ debug: test # @"$(GDB)" -w -x "$(VARIANT_PATH)/debug_scripts/gcc/$(VARIANT)_sram.gdb" -ex "reset" -readnow -se $(OUTPUT_PATH)/$(OUTPUT_BIN).elf libsam_$(CHIP_NAME)_$(TOOLCHAIN)_$(LIBS_POSTFIX).a: - @echo Building $@ + @echo ------------------------------------------------------------------------------------ + @echo Sub-making $@ @$(MAKE) -C $(SYSTEM_PATH)/libsam/build_gcc -f Makefile $@ + @echo ------------------------------------------------------------------------------------ libarduino_$(VARIANT)_$(TOOLCHAIN)_$(LIBS_POSTFIX).a: - @echo Building $@ + @echo ------------------------------------------------------------------------------------ + @echo Sub-making $@ $(MAKE) -C $(ARDUINO_CORE_PATH)/build_gcc -f Makefile $(VARIANT) + @echo ------------------------------------------------------------------------------------ libvariant_$(VARIANT)_$(TOOLCHAIN)_$(LIBS_POSTFIX).a: - @echo Building $@ + @echo ------------------------------------------------------------------------------------ + @echo Sub-making $@ $(MAKE) -C $(VARIANT_PATH)/build_gcc -f Makefile $(VARIANT) + @echo ------------------------------------------------------------------------------------ diff --git a/hardware/arduino/sam/cores/sam/validation/test.cpp b/hardware/arduino/sam/cores/sam/validation/test.cpp index f4f67e4b9..7368c5aca 100644 --- a/hardware/arduino/sam/cores/sam/validation/test.cpp +++ b/hardware/arduino/sam/cores/sam/validation/test.cpp @@ -16,12 +16,14 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "variant.h" +#include "Arduino.h" #ifdef _VARIANT_SAM3X_EK_ #define MAX_ANALOG A0 -#elif _VARIANT_ARDUINO_DUE_X_ +#elif defined _VARIANT_ARDUINO_DUE_X_ #define MAX_ANALOG A10 +#elif defined _VARIANT_ADK2_ +#define MAX_ANALOG A9 #endif void setup( void ) diff --git a/hardware/arduino/sam/cores/sam/wiring.c b/hardware/arduino/sam/cores/sam/wiring.c index 4e88e2752..93bbda5bb 100644 --- a/hardware/arduino/sam/cores/sam/wiring.c +++ b/hardware/arduino/sam/cores/sam/wiring.c @@ -57,11 +57,11 @@ void delayMicroseconds( uint32_t dwUs ) /* * Cortex-M3 Systick IT handler: MOVED TO MAIN DUE TO WEAK SYMBOL ISSUE NOT RESOLVED */ -/*extern void SysTick_Handler( void ) +void SysTick_Handler( void ) { // Increment tick count each ms TimeTick_Increment() ; -}*/ +} #if defined ( __ICCARM__ ) /* IAR Ewarm 5.41+ */ extern signed int putchar( signed int c ) ; diff --git a/hardware/arduino/sam/cores/sam/wiring_constants.h b/hardware/arduino/sam/cores/sam/wiring_constants.h index 3d8ba03e8..0555d71b0 100644 --- a/hardware/arduino/sam/cores/sam/wiring_constants.h +++ b/hardware/arduino/sam/cores/sam/wiring_constants.h @@ -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 @@ -56,8 +56,14 @@ extern "C"{ #undef abs #endif // abs +#ifndef min #define min(a,b) ((a)<(b)?(a):(b)) +#endif // min + +#ifndef max #define max(a,b) ((a)>(b)?(a):(b)) +#endif // max + #define abs(x) ((x)>0?(x):-(x)) #define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt))) #define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5)) diff --git a/hardware/arduino/sam/sam.bat b/hardware/arduino/sam/sam.bat index dce7ca12c..e142728c9 100644 --- a/hardware/arduino/sam/sam.bat +++ b/hardware/arduino/sam/sam.bat @@ -3,6 +3,8 @@ export Path start "libsam" /d"system\libsam\build_gcc" /max "cd" start "libarduino" /d"cores\sam\build_gcc" /max "cd" -start "libvariant Arduino Due U" /d"variants\arduino_due_u\build_gcc" /max "cd" +rem start "libvariant Arduino Due U" /d"variants\arduino_due_u\build_gcc" /max "cd" start "libvariant Arduino Due X" /d"variants\arduino_due_x\build_gcc" /max "cd" -start "test" /d"cores\sam\validation\build_gcc" /max "cd" \ No newline at end of file +start "libvariant ADK2" /d"..\..\google\sam\variants\adk2\build_gcc" /max "cd" +start "libvariant SAM3X-EK" /d"..\..\atmel\sam\variants\sam3x_ek\build_gcc" /max "cd" +start "test" /d"cores\sam\validation\build_gcc" /max "cd" diff --git a/hardware/arduino/sam/system/libsam/build_gcc/Makefile b/hardware/arduino/sam/system/libsam/build_gcc/Makefile index 7084b404c..63a124312 100644 --- a/hardware/arduino/sam/system/libsam/build_gcc/Makefile +++ b/hardware/arduino/sam/system/libsam/build_gcc/Makefile @@ -18,7 +18,7 @@ # Makefile for compiling libchip -SUBMAKE_OPTIONS=--no-builtin-rules --no-builtin-variables +SUBMAKE_OPTIONS=--no-builtin-rules --no-builtin-variables --no-print-directory #------------------------------------------------------------------------------- # Rules @@ -28,85 +28,86 @@ SUBMAKE_OPTIONS=--no-builtin-rules --no-builtin-variables all: libsam_sam3s4c_gcc_dbg.a libsam_sam3u4e_gcc_dbg.a libsam_sam3x8e_gcc_dbg.a libsam_sam3x8h_gcc_dbg.a arduino_due_u: - @echo --- - @echo --- + @echo ------------------------------------------------------------------------------------ @echo --- Making $@ @echo --- @$(MAKE) CHIP=__SAM3U4E__ $(SUBMAKE_OPTIONS) OUTPUT_BIN=../../../variants/arduino_due_u -f sam3.mk + @echo ------------------------------------------------------------------------------------ arduino_due_x: - @echo --- - @echo --- + @echo ------------------------------------------------------------------------------------ @echo --- Making $@ @echo --- @$(MAKE) CHIP=__SAM3X8E__ $(SUBMAKE_OPTIONS) OUTPUT_BIN=../../../variants/arduino_due_x -f sam3.mk + @echo ------------------------------------------------------------------------------------ .PHONY: libsam_sam3s4c_gcc_dbg.a libsam_sam3s4c_gcc_dbg.a: - @echo --- - @echo --- + @echo ------------------------------------------------------------------------------------ @echo --- Making $@ @echo --- @$(MAKE) CHIP=__SAM3S4C__ DEBUG=1 $(SUBMAKE_OPTIONS) -f sam3.mk + @echo ------------------------------------------------------------------------------------ .PHONY: libsam_sam3s4c_gcc_rel.a libsam_sam3s4c_gcc_rel.a: - @echo --- - @echo --- + @echo ------------------------------------------------------------------------------------ @echo --- Making $@ @echo --- @$(MAKE) CHIP=__SAM3S4C__ $(SUBMAKE_OPTIONS) -f sam3.mk + @echo ------------------------------------------------------------------------------------ .PHONY: libsam_sam3u4e_gcc_dbg.a libsam_sam3u4e_gcc_dbg.a: - @echo --- - @echo --- + @echo ------------------------------------------------------------------------------------ @echo --- Making $@ @echo --- @$(MAKE) CHIP=__SAM3U4E__ DEBUG=1 $(SUBMAKE_OPTIONS) -f sam3.mk + @echo ------------------------------------------------------------------------------------ .PHONY: libsam_sam3u4e_gcc_rel.a libsam_sam3u4e_gcc_rel.a: - @echo --- - @echo --- + @echo ------------------------------------------------------------------------------------ @echo --- Making $@ @echo --- @$(MAKE) CHIP=__SAM3U4E__ $(SUBMAKE_OPTIONS) -f sam3.mk + @echo ------------------------------------------------------------------------------------ .PHONY: libsam_sam3x8e_gcc_dbg.a libsam_sam3x8e_gcc_dbg.a: - @echo --- - @echo --- + @echo ------------------------------------------------------------------------------------ @echo --- Making $@ @echo --- @$(MAKE) CHIP=__SAM3X8E__ DEBUG=1 $(SUBMAKE_OPTIONS) -f sam3.mk + @echo ------------------------------------------------------------------------------------ .PHONY: libsam_sam3x8e_gcc_rel.a libsam_sam3x8e_gcc_rel.a: - @echo --- - @echo --- + @echo ------------------------------------------------------------------------------------ @echo --- Making $@ @echo --- @$(MAKE) CHIP=__SAM3X8E__ $(SUBMAKE_OPTIONS) -f sam3.mk + @echo ------------------------------------------------------------------------------------ .PHONY: libsam_sam3x8h_gcc_dbg.a libsam_sam3x8h_gcc_dbg.a: - @echo --- - @echo --- + @echo ------------------------------------------------------------------------------------ @echo --- Making $@ @echo --- @$(MAKE) CHIP=__SAM3X8H__ DEBUG=1 $(SUBMAKE_OPTIONS) -f sam3.mk + @echo ------------------------------------------------------------------------------------ .PHONY: libsam_sam3x8h_gcc_rel.a libsam_sam3x8h_gcc_rel.a: - @echo --- - @echo --- + @echo ------------------------------------------------------------------------------------ @echo --- Making $@ @echo --- @$(MAKE) CHIP=__SAM3X8H__ $(SUBMAKE_OPTIONS) -f sam3.mk + @echo ------------------------------------------------------------------------------------ .PHONY: clean clean: + @echo ------------------------------------------------------------------------------------ @echo --- Cleaning sam3s4c release and debug @$(MAKE) CHIP=__SAM3S4C__ $(SUBMAKE_OPTIONS) -f sam3.mk $@ @$(MAKE) CHIP=__SAM3S4C__ DEBUG=1 $(SUBMAKE_OPTIONS) -f sam3.mk $@ @@ -122,5 +123,6 @@ clean: @echo --- Cleaning sam3x8h release and debug @$(MAKE) CHIP=__SAM3X8H__ $(SUBMAKE_OPTIONS) -f sam3.mk $@ @$(MAKE) CHIP=__SAM3X8H__ DEBUG=1 $(SUBMAKE_OPTIONS) -f sam3.mk $@ + @echo ------------------------------------------------------------------------------------ diff --git a/hardware/arduino/sam/system/libsam/build_gcc/sam3.mk b/hardware/arduino/sam/system/libsam/build_gcc/sam3.mk index 825ceb4b7..aec6b70df 100644 --- a/hardware/arduino/sam/system/libsam/build_gcc/sam3.mk +++ b/hardware/arduino/sam/system/libsam/build_gcc/sam3.mk @@ -147,6 +147,7 @@ $(CHIP): create_output $(OUTPUT_LIB) .PHONY: create_output create_output: + @echo ------------------------------------------------------------------------------------ @echo --- Preparing $(CHIP) files $(OUTPUT_PATH) to $(OUTPUT_BIN) # @echo ------------------------- # @echo *$(C_SRC) @@ -160,6 +161,7 @@ create_output: -@mkdir $(subst /,$(SEP),$(OUTPUT_BIN)) 1>$(DEV_NUL) 2>&1 -@mkdir $(OUTPUT_PATH) 1>$(DEV_NUL) 2>&1 + @echo ------------------------------------------------------------------------------------ $(addprefix $(OUTPUT_PATH)/,$(C_OBJ)): $(OUTPUT_PATH)/%.o: %.c # "$(CC)" -v -c $(CFLAGS) -Wa,aln=$(subst .o,.s,$@) $< -o $@ @@ -175,10 +177,12 @@ $(OUTPUT_LIB): $(addprefix $(OUTPUT_PATH)/, $(C_OBJ)) $(addprefix $(OUTPUT_PATH) .PHONY: clean clean: + @echo ------------------------------------------------------------------------------------ @echo --- Cleaning $(CHIP) files $(OUTPUT_PATH) $(subst /,$(SEP),$(OUTPUT_BIN)/$(OUTPUT_LIB)) -@$(RM) $(OUTPUT_PATH) 1>$(DEV_NUL) 2>&1 -@$(RM) $(subst /,$(SEP),$(OUTPUT_BIN)/$(OUTPUT_LIB)) 1>$(DEV_NUL) 2>&1 -@$(RM) $(subst /,$(SEP),$(OUTPUT_BIN)/$(OUTPUT_LIB)).txt 1>$(DEV_NUL) 2>&1 + @echo ------------------------------------------------------------------------------------ # dependencies $(addprefix $(OUTPUT_PATH)/,$(C_OBJ)): $(OUTPUT_PATH)/%.o: $(PROJECT_BASE_PATH)/chip.h $(wildcard $(PROJECT_BASE_PATH)/include/*.h) $(wildcard $(CMSIS_BASE_PATH)/*.h) diff --git a/hardware/arduino/sam/variants/arduino_due_u/build_gcc/Makefile b/hardware/arduino/sam/variants/arduino_due_u/build_gcc/Makefile index 5532cbcfd..3b32c6528 100644 --- a/hardware/arduino/sam/variants/arduino_due_u/build_gcc/Makefile +++ b/hardware/arduino/sam/variants/arduino_due_u/build_gcc/Makefile @@ -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,10 +16,7 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # -# Makefile for compiling libboard -BOARD = - -SUBMAKE_OPTIONS=--no-builtin-rules --no-builtin-variables +SUBMAKE_OPTIONS=--no-builtin-rules --no-builtin-variables --no-print-directory #------------------------------------------------------------------------------- # Rules @@ -29,14 +26,17 @@ all: arduino_due_u .PHONY: arduino_due_u arduino_due_u: + @echo ------------------------------------------------------------------------------------ @echo --- Making arduino_due_u @$(MAKE) DEBUG=1 $(SUBMAKE_OPTIONS) -f libvariant_arduino_due_u.mk # @$(MAKE) $(SUBMAKE_OPTIONS) -f libvariant_arduino_due.mk + @echo ------------------------------------------------------------------------------------ .PHONY: clean clean: + @echo ------------------------------------------------------------------------------------ @echo --- Cleaning arduino_due_u @$(MAKE) DEBUG=1 $(SUBMAKE_OPTIONS) -f libvariant_arduino_due_u.mk $@ # @$(MAKE) $(SUBMAKE_OPTIONS) -f libvariant_arduino_due.mk $@ - + @echo ------------------------------------------------------------------------------------ diff --git a/hardware/arduino/sam/variants/arduino_due_u/build_gcc/libvariant_arduino_due_u.mk b/hardware/arduino/sam/variants/arduino_due_u/build_gcc/libvariant_arduino_due_u.mk index 24bb72f28..cca1e1c02 100644 --- a/hardware/arduino/sam/variants/arduino_due_u/build_gcc/libvariant_arduino_due_u.mk +++ b/hardware/arduino/sam/variants/arduino_due_u/build_gcc/libvariant_arduino_due_u.mk @@ -47,14 +47,15 @@ VARIANT_PATH = ../../../variants/$(VARIANT) # Files #------------------------------------------------------------------------------- -vpath %.h $(PROJECT_BASE_PATH) $(SYSTEM_PATH) $(VARIANT_PATH) -vpath %.cpp $(PROJECT_BASE_PATH) $(PROJECT_BASE_PATH) +#vpath %.h $(PROJECT_BASE_PATH) $(SYSTEM_PATH) $(VARIANT_PATH) +vpath %.cpp $(PROJECT_BASE_PATH) VPATH+=$(PROJECT_BASE_PATH) INCLUDES = #INCLUDES += -I$(PROJECT_BASE_PATH) INCLUDES += -I$(ARDUINO_PATH) +INCLUDES += -I$(ARDUINO_PATH)/USB INCLUDES += -I$(SYSTEM_PATH) INCLUDES += -I$(SYSTEM_PATH)/libsam INCLUDES += -I$(VARIANT_BASE_PATH) @@ -132,8 +133,9 @@ $(VARIANT): create_output $(OUTPUT_LIB) .PHONY: create_output create_output: + @echo ------------------------------------------------------------------------------------ @echo ------------------------- - @echo --- Preparing $(VARIANT) files in $(OUTPUT_PATH) $(OUTPUT_BIN) + @echo --- Preparing variant $(VARIANT) files in $(OUTPUT_PATH) $(OUTPUT_BIN) @echo ------------------------- # @echo *$(INCLUDES) # @echo ------------------------- @@ -153,6 +155,7 @@ create_output: # @echo ------------------------- -@mkdir $(OUTPUT_PATH) 1>NUL 2>&1 + @echo ------------------------------------------------------------------------------------ $(addprefix $(OUTPUT_PATH)/,$(C_OBJ)): $(OUTPUT_PATH)/%.o: %.c # @"$(CC)" -v -c $(CFLAGS) $< -o $@ @@ -172,6 +175,9 @@ $(OUTPUT_LIB): $(addprefix $(OUTPUT_PATH)/, $(C_OBJ)) $(addprefix $(OUTPUT_PATH) .PHONY: clean clean: + @echo ------------------------------------------------------------------------------------ @echo --- Cleaning $(VARIANT) files [$(OUTPUT_PATH)$(SEP)*.o] - -@"$(RM)" $(OUTPUT_PATH) 1>NUL 2>&1 - -@"$(RM)" $(OUTPUT_BIN)/$(OUTPUT_LIB) 1>NUL 2>&1 + -@$(RM) $(OUTPUT_PATH) 1>NUL 2>&1 + -@$(RM) $(OUTPUT_BIN)/$(OUTPUT_LIB) 1>NUL 2>&1 + @echo ------------------------------------------------------------------------------------ + diff --git a/hardware/arduino/sam/variants/arduino_due_u/variant.cpp b/hardware/arduino/sam/variants/arduino_due_u/variant.cpp index 136e6119b..4ccf4575b 100644 --- a/hardware/arduino/sam/variants/arduino_due_u/variant.cpp +++ b/hardware/arduino/sam/variants/arduino_due_u/variant.cpp @@ -110,6 +110,10 @@ */ +#ifdef __cplusplus +extern "C" { +#endif + /* * Pins descriptions */ @@ -261,6 +265,10 @@ extern const PinDescription g_APinDescription[]= { NULL, 0, 0, PIO_NOT_A_PIN, PIO_DEFAULT, 0, NO_ADC, NO_ADC, NO_PWM, NO_TC } } ; +#ifdef __cplusplus +} +#endif + /* * UART objects */ @@ -308,9 +316,6 @@ void USART2_Handler( void ) extern "C" { #endif -// Should be made in a better way... -extern void analogOutputInit(void); - /** * */ @@ -371,6 +376,7 @@ extern void init( void ) // Initialize analogOutput module analogOutputInit(); } + #ifdef __cplusplus } #endif diff --git a/hardware/arduino/sam/variants/arduino_due_u/variant.h b/hardware/arduino/sam/variants/arduino_due_u/variant.h index 15323b623..16ef8458d 100644 --- a/hardware/arduino/sam/variants/arduino_due_u/variant.h +++ b/hardware/arduino/sam/variants/arduino_due_u/variant.h @@ -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,19 +16,26 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef _VARIANT_ARDUINO_DUE_ -#define _VARIANT_ARDUINO_DUE_ +#ifndef _VARIANT_ARDUINO_DUE_U_ +#define _VARIANT_ARDUINO_DUE_U_ /*---------------------------------------------------------------------------- * Headers *----------------------------------------------------------------------------*/ +// We have native USB on this variant +//#define USBCON + #include "Arduino.h" #ifdef __cplusplus #include "UARTClass.h" #include "USARTClass.h" #endif +#ifdef __cplusplus +extern "C"{ +#endif // __cplusplus + /** * Libc porting layers */ @@ -42,8 +49,8 @@ /*----------------------------------------------------------------------------*/ -#ifndef arduino_due -#define arduino_due +#ifndef arduino_due_u +#define arduino_due_u #endif /** Name of the board */ @@ -156,6 +163,10 @@ static const uint8_t A13 = 67; #define TC_MAX_DUTY_CYCLE 255 #define TC_MIN_DUTY_CYCLE 0 +#ifdef __cplusplus +} +#endif + /*---------------------------------------------------------------------------- * Arduino objects - C++ only *----------------------------------------------------------------------------*/ @@ -170,5 +181,5 @@ extern USARTClass Serial4 ; #endif -#endif /* _VARIANT_ARDUINO_DUE_ */ +#endif /* _VARIANT_ARDUINO_DUE_U_ */ diff --git a/hardware/arduino/sam/variants/arduino_due_x/build_gcc/Makefile b/hardware/arduino/sam/variants/arduino_due_x/build_gcc/Makefile index 5b33fa458..4332f3608 100644 --- a/hardware/arduino/sam/variants/arduino_due_x/build_gcc/Makefile +++ b/hardware/arduino/sam/variants/arduino_due_x/build_gcc/Makefile @@ -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,10 +16,7 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # -# Makefile for compiling libboard -BOARD = - -SUBMAKE_OPTIONS=--no-builtin-rules --no-builtin-variables +SUBMAKE_OPTIONS=--no-builtin-rules --no-builtin-variables --no-print-directory #------------------------------------------------------------------------------- # Rules @@ -29,14 +26,17 @@ all: arduino_due_x .PHONY: arduino_due_x arduino_due_x: - @echo --- Making arduino_due_x + @echo ------------------------------------------------------------------------------------ + @echo --- Making variant arduino_due_x @$(MAKE) DEBUG=1 $(SUBMAKE_OPTIONS) -f libvariant_arduino_due_x.mk -# @$(MAKE) $(SUBMAKE_OPTIONS) -f libvariant_arduino_due.mk +# @$(MAKE) $(SUBMAKE_OPTIONS) -f libvariant_arduino_due_x.mk + @echo ------------------------------------------------------------------------------------ .PHONY: clean clean: - @echo --- Cleaning arduino_due_x + @echo ------------------------------------------------------------------------------------ + @echo --- Cleaning variant arduino_due_x @$(MAKE) DEBUG=1 $(SUBMAKE_OPTIONS) -f libvariant_arduino_due_x.mk $@ -# @$(MAKE) $(SUBMAKE_OPTIONS) -f libvariant_arduino_due.mk $@ - +# @$(MAKE) $(SUBMAKE_OPTIONS) -f libvariant_arduino_due_x.mk $@ + @echo ------------------------------------------------------------------------------------ diff --git a/hardware/arduino/sam/variants/arduino_due_x/build_gcc/libvariant_arduino_due_x.mk b/hardware/arduino/sam/variants/arduino_due_x/build_gcc/libvariant_arduino_due_x.mk index ec23a7742..df93700f4 100644 --- a/hardware/arduino/sam/variants/arduino_due_x/build_gcc/libvariant_arduino_due_x.mk +++ b/hardware/arduino/sam/variants/arduino_due_x/build_gcc/libvariant_arduino_due_x.mk @@ -47,8 +47,8 @@ VARIANT_PATH = ../../../variants/$(VARIANT) # Files #------------------------------------------------------------------------------- -vpath %.h $(PROJECT_BASE_PATH) $(SYSTEM_PATH) $(VARIANT_PATH) -vpath %.cpp $(PROJECT_BASE_PATH) $(PROJECT_BASE_PATH) +#vpath %.h $(PROJECT_BASE_PATH) $(SYSTEM_PATH) $(VARIANT_PATH) +vpath %.cpp $(PROJECT_BASE_PATH) VPATH+=$(PROJECT_BASE_PATH) @@ -133,8 +133,9 @@ $(VARIANT): create_output $(OUTPUT_LIB) .PHONY: create_output create_output: + @echo ------------------------------------------------------------------------------------ @echo ------------------------- - @echo --- Preparing $(VARIANT) files in $(OUTPUT_PATH) $(OUTPUT_BIN) + @echo --- Preparing variant $(VARIANT) files in $(OUTPUT_PATH) $(OUTPUT_BIN) @echo ------------------------- # @echo *$(INCLUDES) # @echo ------------------------- @@ -154,6 +155,7 @@ create_output: # @echo ------------------------- -@mkdir $(OUTPUT_PATH) 1>NUL 2>&1 + @echo ------------------------------------------------------------------------------------ $(addprefix $(OUTPUT_PATH)/,$(C_OBJ)): $(OUTPUT_PATH)/%.o: %.c # @"$(CC)" -v -c $(CFLAGS) $< -o $@ @@ -173,6 +175,9 @@ $(OUTPUT_LIB): $(addprefix $(OUTPUT_PATH)/, $(C_OBJ)) $(addprefix $(OUTPUT_PATH) .PHONY: clean clean: + @echo ------------------------------------------------------------------------------------ @echo --- Cleaning $(VARIANT) files [$(OUTPUT_PATH)$(SEP)*.o] -@$(RM) $(OUTPUT_PATH) 1>NUL 2>&1 -@$(RM) $(OUTPUT_BIN)/$(OUTPUT_LIB) 1>NUL 2>&1 + @echo ------------------------------------------------------------------------------------ + diff --git a/hardware/arduino/sam/variants/arduino_due_x/linker_scripts/gcc/sram.ld b/hardware/arduino/sam/variants/arduino_due_x/linker_scripts/gcc/sram.ld index 947b2f81e..2a0d54e17 100644 --- a/hardware/arduino/sam/variants/arduino_due_x/linker_scripts/gcc/sram.ld +++ b/hardware/arduino/sam/variants/arduino_due_x/linker_scripts/gcc/sram.ld @@ -142,3 +142,4 @@ SECTIONS . = ALIGN(4); _end = . ; } + diff --git a/hardware/arduino/sam/variants/arduino_due_x/variant.cpp b/hardware/arduino/sam/variants/arduino_due_x/variant.cpp index fbc0f4f0f..029b4b3d4 100644 --- a/hardware/arduino/sam/variants/arduino_due_x/variant.cpp +++ b/hardware/arduino/sam/variants/arduino_due_x/variant.cpp @@ -117,6 +117,10 @@ */ +#ifdef __cplusplus +extern "C" { +#endif + /* * Pins descriptions */ @@ -276,6 +280,10 @@ extern const PinDescription g_APinDescription[]= { NULL, 0, 0, PIO_NOT_A_PIN, PIO_DEFAULT, 0, NO_ADC, NO_ADC, NO_PWM, NO_TC } } ; +#ifdef __cplusplus +} +#endif + /* * UART objects */ @@ -381,8 +389,8 @@ extern void init( void ) // Initialize analogOutput module analogOutputInit(); - } + #ifdef __cplusplus } #endif diff --git a/hardware/arduino/sam/variants/arduino_due_x/variant.h b/hardware/arduino/sam/variants/arduino_due_x/variant.h index a47d4b3e4..6f11f1aab 100644 --- a/hardware/arduino/sam/variants/arduino_due_x/variant.h +++ b/hardware/arduino/sam/variants/arduino_due_x/variant.h @@ -32,6 +32,10 @@ #include "USARTClass.h" #endif +#ifdef __cplusplus +extern "C"{ +#endif // __cplusplus + /** * Libc porting layers */ @@ -52,11 +56,6 @@ /** Name of the board */ #define VARIANT_NAME "ARDUINO_DUE" -/* -#define VARIANT_REV_A -#define VARIANT_REV_B -*/ - /** Frequency of the board main oscillator */ #define VARIANT_MAINOSC 12000000 @@ -171,6 +170,10 @@ static const uint8_t A15 = 69; #define TC_MAX_DUTY_CYCLE 255 #define TC_MIN_DUTY_CYCLE 0 +#ifdef __cplusplus +} +#endif + /*---------------------------------------------------------------------------- * Arduino objects - C++ only *----------------------------------------------------------------------------*/ diff --git a/hardware/atmel/sam/platform.txt b/hardware/atmel/sam/platform.txt index 6f72ada2d..b61412eb2 100644 --- a/hardware/atmel/sam/platform.txt +++ b/hardware/atmel/sam/platform.txt @@ -1,16 +1,16 @@ # SAM3 compile variables -# --------------------- +# --------------------- name=Atmel SAM3 compiler.path={runtime.ide.path}/hardware/tools/g++_arm_none_eabi/bin/ compiler.c.cmd=arm-none-eabi-gcc -compiler.c.flags=-c -g -Os -w -mlong-calls -ffunction-sections -nostdlib --param max-inline-insns-single=500 -Dprintf=iprintf +compiler.c.flags=-c -g -Os -w -mlong-calls -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -Dprintf=iprintf compiler.c.elf.cmd=arm-none-eabi-gcc compiler.c.elf.flags=-Os -Wl,--gc-sections compiler.S.flags=-c -g -assembler-with-cpp compiler.cpp.cmd=arm-none-eabi-g++ -compiler.cpp.flags=-c -g -Os -w -mlong-calls -ffunction-sections -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -Dprintf=iprintf +compiler.cpp.flags=-c -g -Os -w -mlong-calls -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -Dprintf=iprintf compiler.ar.cmd=arm-none-eabi-ar compiler.ar.flags=rcs compiler.objcopy.cmd=arm-none-eabi-objcopy @@ -53,6 +53,7 @@ recipe.size.regex=\.text\s+([0-9]+).* # ------------------- tools.bossac.cmd=bossac +tools.bossac.cmd.windows=bossac.exe tools.bossac.path={runtime.ide.path}/hardware/tools tools.bossac.upload.params.verbose=-i -d diff --git a/hardware/atmel/sam/variants/sam3s_ek/build_gcc/Makefile b/hardware/atmel/sam/variants/sam3s_ek/build_gcc/Makefile index 80f9cc02c..715568f7a 100644 --- a/hardware/atmel/sam/variants/sam3s_ek/build_gcc/Makefile +++ b/hardware/atmel/sam/variants/sam3s_ek/build_gcc/Makefile @@ -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 @@ -17,9 +17,9 @@ # # Makefile for compiling libboard -BOARD = +BOARD = -SUBMAKE_OPTIONS=--no-builtin-rules --no-builtin-variables +SUBMAKE_OPTIONS=--no-builtin-rules --no-builtin-variables --no-print-directory #------------------------------------------------------------------------------- # Rules diff --git a/hardware/atmel/sam/variants/sam3u_ek/build_gcc/Makefile b/hardware/atmel/sam/variants/sam3u_ek/build_gcc/Makefile index 024445216..e231bd72d 100644 --- a/hardware/atmel/sam/variants/sam3u_ek/build_gcc/Makefile +++ b/hardware/atmel/sam/variants/sam3u_ek/build_gcc/Makefile @@ -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 @@ -17,9 +17,9 @@ # # Makefile for compiling libboard -BOARD = +BOARD = -SUBMAKE_OPTIONS=--no-builtin-rules --no-builtin-variables +SUBMAKE_OPTIONS=--no-builtin-rules --no-builtin-variables --no-print-directory #------------------------------------------------------------------------------- # Rules diff --git a/hardware/atmel/sam/variants/sam3u_ek/build_gcc/debug_sam3u_ek/variant.o b/hardware/atmel/sam/variants/sam3u_ek/build_gcc/debug_sam3u_ek/variant.o deleted file mode 100644 index e44ae2dd1..000000000 Binary files a/hardware/atmel/sam/variants/sam3u_ek/build_gcc/debug_sam3u_ek/variant.o and /dev/null differ diff --git a/hardware/atmel/sam/variants/sam3x_ek/build_gcc/Makefile b/hardware/atmel/sam/variants/sam3x_ek/build_gcc/Makefile index a2679d31b..9ec0ff604 100644 --- a/hardware/atmel/sam/variants/sam3x_ek/build_gcc/Makefile +++ b/hardware/atmel/sam/variants/sam3x_ek/build_gcc/Makefile @@ -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,10 +16,7 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # -# Makefile for compiling libboard -BOARD = - -SUBMAKE_OPTIONS=--no-builtin-rules --no-builtin-variables +SUBMAKE_OPTIONS=--no-builtin-rules --no-builtin-variables --no-print-directory #------------------------------------------------------------------------------- # Rules @@ -39,4 +36,3 @@ clean: @$(MAKE) DEBUG=1 $(SUBMAKE_OPTIONS) -f libvariant_sam3x_ek.mk $@ # @$(MAKE) $(SUBMAKE_OPTIONS) -f libvariant_sam3x_ek.mk $@ - diff --git a/hardware/atmel/sam/variants/sam3x_ek/build_gcc/libvariant_sam3x_ek.mk b/hardware/atmel/sam/variants/sam3x_ek/build_gcc/libvariant_sam3x_ek.mk index 297bfbd7c..59e7c0fbe 100644 --- a/hardware/atmel/sam/variants/sam3x_ek/build_gcc/libvariant_sam3x_ek.mk +++ b/hardware/atmel/sam/variants/sam3x_ek/build_gcc/libvariant_sam3x_ek.mk @@ -48,13 +48,14 @@ VARIANT_PATH = ../../../variants/$(VARIANT) #------------------------------------------------------------------------------- vpath %.h $(PROJECT_BASE_PATH) $(SYSTEM_PATH) $(VARIANT_PATH) -vpath %.cpp $(PROJECT_BASE_PATH) $(PROJECT_BASE_PATH) +vpath %.cpp $(PROJECT_BASE_PATH) VPATH+=$(PROJECT_BASE_PATH) INCLUDES = #INCLUDES += -I$(PROJECT_BASE_PATH) INCLUDES += -I$(ARDUINO_PATH) +INCLUDES += -I$(ARDUINO_PATH)/USB INCLUDES += -I$(SYSTEM_PATH) INCLUDES += -I$(SYSTEM_PATH)/libsam INCLUDES += -I$(VARIANT_BASE_PATH) @@ -166,8 +167,8 @@ $(addprefix $(OUTPUT_PATH)/,$(A_OBJ)): $(OUTPUT_PATH)/%.o: %.s @"$(AS)" -c $(ASFLAGS) $< -o $@ $(OUTPUT_LIB): $(addprefix $(OUTPUT_PATH)/, $(C_OBJ)) $(addprefix $(OUTPUT_PATH)/, $(CPP_OBJ)) $(addprefix $(OUTPUT_PATH)/, $(A_OBJ)) - "$(AR)" -v -r "$(OUTPUT_BIN)/$@" $^ - "$(NM)" "$(OUTPUT_BIN)/$@" > "$(OUTPUT_BIN)/$@.txt" + @"$(AR)" -v -r "$(OUTPUT_BIN)/$@" $^ + @"$(NM)" "$(OUTPUT_BIN)/$@" > "$(OUTPUT_BIN)/$@.txt" .PHONY: clean @@ -175,3 +176,4 @@ clean: @echo --- Cleaning $(VARIANT) files [$(OUTPUT_PATH)$(SEP)*.o] -@$(RM) $(OUTPUT_PATH) 1>NUL 2>&1 -@$(RM) $(OUTPUT_BIN)/$(OUTPUT_LIB) 1>NUL 2>&1 + diff --git a/hardware/atmel/sam/variants/sam3x_ek/linker_scripts/gcc/sram.ld b/hardware/atmel/sam/variants/sam3x_ek/linker_scripts/gcc/sram.ld index c8e21ad30..2a0d54e17 100644 --- a/hardware/atmel/sam/variants/sam3x_ek/linker_scripts/gcc/sram.ld +++ b/hardware/atmel/sam/variants/sam3x_ek/linker_scripts/gcc/sram.ld @@ -1,12 +1,12 @@ /* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support + * SAM Software Package License * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation + * Copyright (c) 2012, Atmel Corporation * * All rights reserved. * * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: + * modification, are permitted provided that the following condition is met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the disclaimer below. @@ -27,10 +27,6 @@ * ---------------------------------------------------------------------------- */ -/*------------------------------------------------------------------------------ - * Linker script for running in internal SRAM on the SAM3U4 - *----------------------------------------------------------------------------*/ - OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") OUTPUT_ARCH(arm) SEARCH_DIR(.) @@ -38,22 +34,20 @@ SEARCH_DIR(.) /* Memory Spaces Definitions */ MEMORY { - flash0 (W!RX) : ORIGIN = 0x00080000, LENGTH = 0x00020000 /* Flash0, 128K */ - flash1 (W!RX) : ORIGIN = 0x00100000, LENGTH = 0x00020000 /* Flash1, 128K */ - sram0 (W!RX) : ORIGIN = 0x20000000, LENGTH = 0x00008000 /* Sram0, 32K */ - sram1 (W!RX) : ORIGIN = 0x20080000, LENGTH = 0x00004000 /* Sram1, 16K */ - rom (rx) : ORIGIN = ORIGIN(flash1)-LENGTH(flash0), LENGTH = LENGTH(flash0)+LENGTH(flash1) /* Flash, 256K */ - ram (rwx) : ORIGIN = ORIGIN( sram1)-LENGTH( sram0), LENGTH = LENGTH( sram0)+LENGTH( sram1) /* sram, 48K */ + rom (rx) : ORIGIN = 0x00080000, LENGTH = 0x00080000 /* Flash, 512K */ + sram0 (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00010000 /* sram0, 64K */ + sram1 (rwx) : ORIGIN = 0x20080000, LENGTH = 0x00008000 /* sram1, 32K */ + ram (rwx) : ORIGIN = 0x20070000, LENGTH = 0x00018000 /* sram, 96K */ } /* The stack size used by the application. NOTE: you need to adjust */ -STACK_SIZE = 0x800; +STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : 0x2000 ; -/* Section Definitions */ -SECTIONS -{ - .text : - { +/* Section Definitions */ +SECTIONS +{ + .text : + { . = ALIGN(4); _sfixed = .; KEEP(*(.vectors .vectors.*)) @@ -99,9 +93,9 @@ SECTIONS . = ALIGN(4); _efixed = .; /* End of text section */ - } > sram0 + } > ram - . = ALIGN(4); + . = ALIGN(4); _etext = .; .relocate : AT (_etext) @@ -112,11 +106,11 @@ SECTIONS *(.data .data.*); . = ALIGN(4); _erelocate = .; - } > sram1 + } > ram - /* .bss section which is used for uninitialized data */ + /* .bss section which is used for uninitialized data */ .bss (NOLOAD) : - { + { . = ALIGN(4); _sbss = . ; _szero = .; @@ -125,26 +119,27 @@ SECTIONS . = ALIGN(4); _ebss = . ; _ezero = .; - } > sram1 + } > ram /* stack section */ .stack (NOLOAD): { . = ALIGN(8); - _sstack = .; + _sstack = .; . = . + STACK_SIZE; . = ALIGN(8); _estack = .; - } > sram1 + } > ram /* .ARM.exidx is sorted, so has to go in its own output section. */ PROVIDE_HIDDEN (__exidx_start = .); .ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) - } > sram1 + } > ram PROVIDE_HIDDEN (__exidx_end = .); - . = ALIGN(4); - _end = . ; + . = ALIGN(4); + _end = . ; } + diff --git a/hardware/atmel/sam/variants/sam3x_ek/variant.cpp b/hardware/atmel/sam/variants/sam3x_ek/variant.cpp index b1c03af63..087ce611f 100644 --- a/hardware/atmel/sam/variants/sam3x_ek/variant.cpp +++ b/hardware/atmel/sam/variants/sam3x_ek/variant.cpp @@ -156,7 +156,6 @@ extern void init( void ) // Initialize analogOutput module analogOutputInit(); - } #ifdef __cplusplus } diff --git a/hardware/atmel/sam/variants/sam3x_ek/variant.h b/hardware/atmel/sam/variants/sam3x_ek/variant.h index 43f375778..f8c300798 100644 --- a/hardware/atmel/sam/variants/sam3x_ek/variant.h +++ b/hardware/atmel/sam/variants/sam3x_ek/variant.h @@ -23,6 +23,9 @@ * Headers *----------------------------------------------------------------------------*/ +// We have native USB on this variant +#define USBCON + #include "Arduino.h" #ifdef __cplusplus #include "UARTClass.h" @@ -49,12 +52,6 @@ /** Name of the board */ #define VARIANT_NAME "SAM3X-EK" -/* -#define VARIANT_REV_A -#define VARIANT_REV_B -#define VARIANT_REV_C -#define VARIANT_REV_D -*/ /** Frequency of the board main oscillator */ #define VARIANT_MAINOSC 12000000 @@ -108,6 +105,7 @@ static const uint8_t A0 = 10; #define TC_FREQUENCY 1000 #define TC_MAX_DUTY_CYCLE 255 #define TC_MIN_DUTY_CYCLE 0 + /*---------------------------------------------------------------------------- * Arduino objects - C++ only *----------------------------------------------------------------------------*/ diff --git a/hardware/google/sam/platform.txt b/hardware/google/sam/platform.txt index 6f72ada2d..b61412eb2 100644 --- a/hardware/google/sam/platform.txt +++ b/hardware/google/sam/platform.txt @@ -1,16 +1,16 @@ # SAM3 compile variables -# --------------------- +# --------------------- name=Atmel SAM3 compiler.path={runtime.ide.path}/hardware/tools/g++_arm_none_eabi/bin/ compiler.c.cmd=arm-none-eabi-gcc -compiler.c.flags=-c -g -Os -w -mlong-calls -ffunction-sections -nostdlib --param max-inline-insns-single=500 -Dprintf=iprintf +compiler.c.flags=-c -g -Os -w -mlong-calls -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -Dprintf=iprintf compiler.c.elf.cmd=arm-none-eabi-gcc compiler.c.elf.flags=-Os -Wl,--gc-sections compiler.S.flags=-c -g -assembler-with-cpp compiler.cpp.cmd=arm-none-eabi-g++ -compiler.cpp.flags=-c -g -Os -w -mlong-calls -ffunction-sections -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -Dprintf=iprintf +compiler.cpp.flags=-c -g -Os -w -mlong-calls -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -Dprintf=iprintf compiler.ar.cmd=arm-none-eabi-ar compiler.ar.flags=rcs compiler.objcopy.cmd=arm-none-eabi-objcopy @@ -53,6 +53,7 @@ recipe.size.regex=\.text\s+([0-9]+).* # ------------------- tools.bossac.cmd=bossac +tools.bossac.cmd.windows=bossac.exe tools.bossac.path={runtime.ide.path}/hardware/tools tools.bossac.upload.params.verbose=-i -d diff --git a/hardware/google/sam/variants/adk2/build_gcc/Makefile b/hardware/google/sam/variants/adk2/build_gcc/Makefile index 26d86c6fb..53e76cec3 100644 --- a/hardware/google/sam/variants/adk2/build_gcc/Makefile +++ b/hardware/google/sam/variants/adk2/build_gcc/Makefile @@ -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,10 +16,7 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # -# Makefile for compiling libboard -BOARD = - -SUBMAKE_OPTIONS=--no-builtin-rules --no-builtin-variables +SUBMAKE_OPTIONS=--no-builtin-rules --no-builtin-variables --no-print-directory #------------------------------------------------------------------------------- # Rules @@ -29,14 +26,17 @@ all: adk2 .PHONY: adk2 adk2: - @echo --- Making adk2 + @echo ------------------------------------------------------------------------------------ + @echo --- Making variant adk2 @$(MAKE) DEBUG=1 $(SUBMAKE_OPTIONS) -f libvariant_adk2.mk # @$(MAKE) $(SUBMAKE_OPTIONS) -f libvariant_adk2.mk + @echo ------------------------------------------------------------------------------------ .PHONY: clean clean: - @echo --- Cleaning adk2 + @echo ------------------------------------------------------------------------------------ + @echo --- Cleaning variant adk2 @$(MAKE) DEBUG=1 $(SUBMAKE_OPTIONS) -f libvariant_adk2.mk $@ # @$(MAKE) $(SUBMAKE_OPTIONS) -f libvariant_adk2.mk $@ - + @echo ------------------------------------------------------------------------------------ diff --git a/hardware/google/sam/variants/adk2/build_gcc/_NUL b/hardware/google/sam/variants/adk2/build_gcc/_NUL deleted file mode 100644 index c9daddb51..000000000 --- a/hardware/google/sam/variants/adk2/build_gcc/_NUL +++ /dev/null @@ -1 +0,0 @@ -mkdir: cannot create directory `debug_adk2': File exists diff --git a/hardware/google/sam/variants/adk2/build_gcc/gcc.mk b/hardware/google/sam/variants/adk2/build_gcc/gcc.mk index 7f4459cfe..32f35d264 100644 --- a/hardware/google/sam/variants/adk2/build_gcc/gcc.mk +++ b/hardware/google/sam/variants/adk2/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 @@ -17,7 +17,6 @@ # # Tool suffix when cross-compiling -#CROSS_COMPILE = ../../../../tools/CodeSourcery_arm/bin/arm-none-eabi- CROSS_COMPILE = $(ARM_GCC_TOOLCHAIN)/arm-none-eabi- # Compilation tools @@ -25,11 +24,13 @@ AR = $(CROSS_COMPILE)ar CC = $(CROSS_COMPILE)gcc CXX = $(CROSS_COMPILE)g++ AS = $(CROSS_COMPILE)as -#LD = $(CROSS_COMPILE)ld -#SIZE = $(CROSS_COMPILE)size NM = $(CROSS_COMPILE)nm -#OBJCOPY = $(CROSS_COMPILE)objcopy +ifeq ($(OS),Windows_NT) RM=cs-rm -Rf +else +RM=rm -Rf +endif + SEP=\\ # --------------------------------------------------------------------------------------- @@ -49,7 +50,7 @@ CFLAGS += -Wcast-align #CFLAGS += -Wmissing-noreturn #CFLAGS += -Wconversion -CFLAGS += --param max-inline-insns-single=500 -mcpu=cortex-m3 -mthumb -mlong-calls -ffunction-sections -fdata-sections -nostdlib +CFLAGS += --param max-inline-insns-single=500 -mcpu=cortex-m3 -mthumb -mlong-calls -ffunction-sections -fdata-sections -nostdlib -std=c99 CFLAGS += $(OPTIMIZATION) $(INCLUDES) -D$(CHIP) -D$(VARIANT) # To reduce application size use only integer printf function. @@ -69,7 +70,7 @@ CPPFLAGS += -Wpacked -Wredundant-decls -Winline -Wlong-long #CPPFLAGS += -Wmissing-noreturn #CPPFLAGS += -Wconversion -CPPFLAGS += --param max-inline-insns-single=500 -mcpu=cortex-m3 -mthumb -mlong-calls -ffunction-sections -fno-rtti -fdata-sections -fno-exceptions +CPPFLAGS += --param max-inline-insns-single=500 -mcpu=cortex-m3 -mthumb -mlong-calls -ffunction-sections -fdata-sections -fno-rtti -fno-exceptions -std=c++98 CPPFLAGS += $(OPTIMIZATION) $(INCLUDES) -D$(CHIP) # To reduce application size use only integer printf function. diff --git a/hardware/google/sam/variants/adk2/build_gcc/libvariant_adk2.mk b/hardware/google/sam/variants/adk2/build_gcc/libvariant_adk2.mk index bdc78c123..395cb82be 100644 --- a/hardware/google/sam/variants/adk2/build_gcc/libvariant_adk2.mk +++ b/hardware/google/sam/variants/adk2/build_gcc/libvariant_adk2.mk @@ -29,17 +29,17 @@ TOOLCHAIN=gcc #------------------------------------------------------------------------------- # Output directories -OUTPUT_BIN = ../../../cores/sam +OUTPUT_BIN = ../../../../../arduino/sam/cores/sam # Libraries PROJECT_BASE_PATH = .. -SYSTEM_PATH = ../../../system +SYSTEM_PATH = ../../../../../arduino/sam/system CMSIS_ROOT_PATH = $(SYSTEM_PATH)/CMSIS CMSIS_ARM_PATH=$(CMSIS_ROOT_PATH)/CMSIS/Include CMSIS_ATMEL_PATH=$(CMSIS_ROOT_PATH)/Device/ATMEL #CMSIS_CHIP_PATH=$(CMSIS_ROOT_PATH)/Device/ATMEL/$(CHIP_SERIE) -ARDUINO_PATH = ../../../cores/sam +ARDUINO_PATH = ../../../../../arduino/sam/cores/sam VARIANT_BASE_PATH = ../../../variants VARIANT_PATH = ../../../variants/$(VARIANT) @@ -47,14 +47,15 @@ VARIANT_PATH = ../../../variants/$(VARIANT) # Files #------------------------------------------------------------------------------- -vpath %.h $(PROJECT_BASE_PATH) $(SYSTEM_PATH) $(VARIANT_PATH) -vpath %.cpp $(PROJECT_BASE_PATH) $(PROJECT_BASE_PATH) +#vpath %.h $(PROJECT_BASE_PATH) $(SYSTEM_PATH) $(VARIANT_PATH) +vpath %.cpp $(PROJECT_BASE_PATH) VPATH+=$(PROJECT_BASE_PATH) INCLUDES = #INCLUDES += -I$(PROJECT_BASE_PATH) INCLUDES += -I$(ARDUINO_PATH) +INCLUDES += -I$(ARDUINO_PATH)/USB INCLUDES += -I$(SYSTEM_PATH) INCLUDES += -I$(SYSTEM_PATH)/libsam INCLUDES += -I$(VARIANT_BASE_PATH) @@ -132,8 +133,9 @@ $(VARIANT): create_output $(OUTPUT_LIB) .PHONY: create_output create_output: + @echo ------------------------------------------------------------------------------------ @echo ------------------------- - @echo --- Preparing $(VARIANT) files in $(OUTPUT_PATH) $(OUTPUT_BIN) + @echo --- Preparing variant $(VARIANT) files in $(OUTPUT_PATH) $(OUTPUT_BIN) @echo ------------------------- # @echo *$(INCLUDES) # @echo ------------------------- @@ -153,6 +155,7 @@ create_output: # @echo ------------------------- -@mkdir $(OUTPUT_PATH) 1>NUL 2>&1 + @echo ------------------------------------------------------------------------------------ $(addprefix $(OUTPUT_PATH)/,$(C_OBJ)): $(OUTPUT_PATH)/%.o: %.c # @"$(CC)" -v -c $(CFLAGS) $< -o $@ @@ -172,6 +175,9 @@ $(OUTPUT_LIB): $(addprefix $(OUTPUT_PATH)/, $(C_OBJ)) $(addprefix $(OUTPUT_PATH) .PHONY: clean clean: + @echo ------------------------------------------------------------------------------------ @echo --- Cleaning $(VARIANT) files [$(OUTPUT_PATH)$(SEP)*.o] -@$(RM) $(OUTPUT_PATH) 1>NUL 2>&1 -@$(RM) $(OUTPUT_BIN)/$(OUTPUT_LIB) 1>NUL 2>&1 + @echo ------------------------------------------------------------------------------------ + diff --git a/hardware/google/sam/variants/adk2/debug_scripts/gcc/arduino_due_flash.gdb b/hardware/google/sam/variants/adk2/debug_scripts/gcc/adk2_flash.gdb similarity index 100% rename from hardware/google/sam/variants/adk2/debug_scripts/gcc/arduino_due_flash.gdb rename to hardware/google/sam/variants/adk2/debug_scripts/gcc/adk2_flash.gdb diff --git a/hardware/google/sam/variants/adk2/debug_scripts/gcc/arduino_due_sram.gdb b/hardware/google/sam/variants/adk2/debug_scripts/gcc/adk2_sram.gdb similarity index 100% rename from hardware/google/sam/variants/adk2/debug_scripts/gcc/arduino_due_sram.gdb rename to hardware/google/sam/variants/adk2/debug_scripts/gcc/adk2_sram.gdb diff --git a/hardware/google/sam/variants/adk2/debug_scripts/iar/arduino_due_flash.mac b/hardware/google/sam/variants/adk2/debug_scripts/iar/arduino_due_flash.mac deleted file mode 100644 index 959583582..000000000 --- a/hardware/google/sam/variants/adk2/debug_scripts/iar/arduino_due_flash.mac +++ /dev/null @@ -1,44 +0,0 @@ -// --------------------------------------------------------- -// ATMEL Microcontroller Software Support - ROUSSET - -// --------------------------------------------------------- -// The software is delivered "AS IS" without warranty or -// condition of any kind, either express, implied or -// statutory. This includes without limitation any warranty -// or condition with respect to merchantability or fitness -// for any particular purpose, or against the infringements of -// intellectual property rights of others. -// --------------------------------------------------------- -// File: at91sam3u-ek-flash.mac -// User setup file for CSPY debugger. -// --------------------------------------------------------- -__var __mac_i; -__var __mac_pt; - -/********************************************************************* -* -* execUserReset() -*/ -execUserReset() -{ - __message "------------------------------ execUserReset ---------------------------------"; - __message "-------------------------------Set PC Reset ----------------------------------"; - - __hwReset(0); - - // perpheral reset RSTC_CR - __writeMemory32(0xA5000004,0x400e1200,"Memory"); -} - -/********************************************************************* -* -* execUserPreload() -*/ -execUserPreload() -{ - __message "------------------------------ execUserPreload ---------------------------------"; - - __hwReset(0); //* Hardware Reset: CPU is automatically halted after the reset - - // perpheral reset RSTC_CR - __writeMemory32(0xA5000004,0x400e1200,"Memory"); -} diff --git a/hardware/google/sam/variants/adk2/debug_scripts/iar/arduino_due_sram.mac b/hardware/google/sam/variants/adk2/debug_scripts/iar/arduino_due_sram.mac deleted file mode 100644 index ba86029d3..000000000 --- a/hardware/google/sam/variants/adk2/debug_scripts/iar/arduino_due_sram.mac +++ /dev/null @@ -1,44 +0,0 @@ -// --------------------------------------------------------- -// ATMEL Microcontroller Software Support - ROUSSET - -// --------------------------------------------------------- -// The software is delivered "AS IS" without warranty or -// condition of any kind, either express, implied or -// statutory. This includes without limitation any warranty -// or condition with respect to merchantability or fitness -// for any particular purpose, or against the infringements of -// intellectual property rights of others. -// --------------------------------------------------------- -// File: at91sam3u-ek-sram.mac -// User setup file for CSPY debugger. -// --------------------------------------------------------- -__var __mac_i; -__var __mac_pt; - -/********************************************************************* -* -* execUserReset() -*/ -execUserReset() -{ - __message "------------------------------ execUserReset ---------------------------------"; - __message "-------------------------------Set PC Reset ----------------------------------"; - - //__hwReset(50); - - // perpheral reset RSTC_CR - __writeMemory32(0xA5000004,0x400e1200,"Memory"); -} - -/********************************************************************* -* -* execUserPreload() -*/ -execUserPreload() -{ - __message "------------------------------ execUserPreload ---------------------------------"; - - __hwReset(0); //* Hardware Reset: CPU is automatically halted after the reset - - // perpheral reset RSTC_CR - __writeMemory32(0xA5000004,0x400e1200,"Memory"); -} diff --git a/hardware/google/sam/variants/adk2/linker_scripts/gcc/flash.ld b/hardware/google/sam/variants/adk2/linker_scripts/gcc/flash.ld index c79e630a5..8d652b606 100644 --- a/hardware/google/sam/variants/adk2/linker_scripts/gcc/flash.ld +++ b/hardware/google/sam/variants/adk2/linker_scripts/gcc/flash.ld @@ -1,12 +1,12 @@ /* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support + * SAM Software Package License * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation + * Copyright (c) 2012, Atmel Corporation * * All rights reserved. * * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: + * modification, are permitted provided that the following condition is met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the disclaimer below. @@ -27,10 +27,6 @@ * ---------------------------------------------------------------------------- */ -/*------------------------------------------------------------------------------ - * Linker script for running in internal FLASH on the SAM3U4 - *----------------------------------------------------------------------------*/ - OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") OUTPUT_ARCH(arm) SEARCH_DIR(.) @@ -38,22 +34,20 @@ SEARCH_DIR(.) /* Memory Spaces Definitions */ MEMORY { - flash0 (W!RX) : ORIGIN = 0x00080000, LENGTH = 0x00020000 /* Flash0, 128K */ - flash1 (W!RX) : ORIGIN = 0x00100000, LENGTH = 0x00020000 /* Flash1, 128K */ - sram0 (W!RX) : ORIGIN = 0x20000000, LENGTH = 0x00008000 /* Sram0, 32K */ - sram1 (W!RX) : ORIGIN = 0x20080000, LENGTH = 0x00004000 /* Sram1, 16K */ - rom (rx) : ORIGIN = ORIGIN(flash1)-LENGTH(flash0), LENGTH = LENGTH(flash0)+LENGTH(flash1) /* Flash, 256K */ - ram (rwx) : ORIGIN = ORIGIN( sram1)-LENGTH( sram0), LENGTH = LENGTH( sram0)+LENGTH( sram1) /* sram, 48K */ + rom (rx) : ORIGIN = 0x00080000, LENGTH = 0x00080000 /* Flash, 512K */ + sram0 (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00010000 /* sram0, 64K */ + sram1 (rwx) : ORIGIN = 0x20080000, LENGTH = 0x00008000 /* sram1, 32K */ + ram (rwx) : ORIGIN = 0x20070000, LENGTH = 0x00018000 /* sram, 96K */ } /* The stack size used by the application. NOTE: you need to adjust */ -STACK_SIZE = 0x2000; +STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : 0x2000 ; -/* Section Definitions */ -SECTIONS -{ - .text : - { +/* Section Definitions */ +SECTIONS +{ + .text : + { . = ALIGN(4); _sfixed = .; KEEP(*(.vectors .vectors.*)) @@ -99,17 +93,17 @@ SECTIONS . = ALIGN(4); _efixed = .; /* End of text section */ - } > flash0 + } > rom /* .ARM.exidx is sorted, so has to go in its own output section. */ PROVIDE_HIDDEN (__exidx_start = .); .ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) - } > flash0 + } > rom PROVIDE_HIDDEN (__exidx_end = .); - . = ALIGN(4); + . = ALIGN(4); _etext = .; .relocate : AT (_etext) @@ -120,11 +114,11 @@ SECTIONS *(.data .data.*); . = ALIGN(4); _erelocate = .; - } > sram0 + } > ram - /* .bss section which is used for uninitialized data */ + /* .bss section which is used for uninitialized data */ .bss (NOLOAD) : - { + { . = ALIGN(4); _sbss = . ; _szero = .; @@ -133,18 +127,18 @@ SECTIONS . = ALIGN(4); _ebss = . ; _ezero = .; - } > sram0 + } > ram /* stack section */ .stack (NOLOAD): { . = ALIGN(8); - _sstack = .; + _sstack = .; . = . + STACK_SIZE; . = ALIGN(8); _estack = .; - } > sram1 + } > ram - . = ALIGN(4); - _end = . ; + . = ALIGN(4); + _end = . ; } diff --git a/hardware/google/sam/variants/adk2/linker_scripts/gcc/sram.ld b/hardware/google/sam/variants/adk2/linker_scripts/gcc/sram.ld index c8e21ad30..2a0d54e17 100644 --- a/hardware/google/sam/variants/adk2/linker_scripts/gcc/sram.ld +++ b/hardware/google/sam/variants/adk2/linker_scripts/gcc/sram.ld @@ -1,12 +1,12 @@ /* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support + * SAM Software Package License * ---------------------------------------------------------------------------- - * Copyright (c) 2009, Atmel Corporation + * Copyright (c) 2012, Atmel Corporation * * All rights reserved. * * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: + * modification, are permitted provided that the following condition is met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the disclaimer below. @@ -27,10 +27,6 @@ * ---------------------------------------------------------------------------- */ -/*------------------------------------------------------------------------------ - * Linker script for running in internal SRAM on the SAM3U4 - *----------------------------------------------------------------------------*/ - OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") OUTPUT_ARCH(arm) SEARCH_DIR(.) @@ -38,22 +34,20 @@ SEARCH_DIR(.) /* Memory Spaces Definitions */ MEMORY { - flash0 (W!RX) : ORIGIN = 0x00080000, LENGTH = 0x00020000 /* Flash0, 128K */ - flash1 (W!RX) : ORIGIN = 0x00100000, LENGTH = 0x00020000 /* Flash1, 128K */ - sram0 (W!RX) : ORIGIN = 0x20000000, LENGTH = 0x00008000 /* Sram0, 32K */ - sram1 (W!RX) : ORIGIN = 0x20080000, LENGTH = 0x00004000 /* Sram1, 16K */ - rom (rx) : ORIGIN = ORIGIN(flash1)-LENGTH(flash0), LENGTH = LENGTH(flash0)+LENGTH(flash1) /* Flash, 256K */ - ram (rwx) : ORIGIN = ORIGIN( sram1)-LENGTH( sram0), LENGTH = LENGTH( sram0)+LENGTH( sram1) /* sram, 48K */ + rom (rx) : ORIGIN = 0x00080000, LENGTH = 0x00080000 /* Flash, 512K */ + sram0 (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00010000 /* sram0, 64K */ + sram1 (rwx) : ORIGIN = 0x20080000, LENGTH = 0x00008000 /* sram1, 32K */ + ram (rwx) : ORIGIN = 0x20070000, LENGTH = 0x00018000 /* sram, 96K */ } /* The stack size used by the application. NOTE: you need to adjust */ -STACK_SIZE = 0x800; +STACK_SIZE = DEFINED(STACK_SIZE) ? STACK_SIZE : 0x2000 ; -/* Section Definitions */ -SECTIONS -{ - .text : - { +/* Section Definitions */ +SECTIONS +{ + .text : + { . = ALIGN(4); _sfixed = .; KEEP(*(.vectors .vectors.*)) @@ -99,9 +93,9 @@ SECTIONS . = ALIGN(4); _efixed = .; /* End of text section */ - } > sram0 + } > ram - . = ALIGN(4); + . = ALIGN(4); _etext = .; .relocate : AT (_etext) @@ -112,11 +106,11 @@ SECTIONS *(.data .data.*); . = ALIGN(4); _erelocate = .; - } > sram1 + } > ram - /* .bss section which is used for uninitialized data */ + /* .bss section which is used for uninitialized data */ .bss (NOLOAD) : - { + { . = ALIGN(4); _sbss = . ; _szero = .; @@ -125,26 +119,27 @@ SECTIONS . = ALIGN(4); _ebss = . ; _ezero = .; - } > sram1 + } > ram /* stack section */ .stack (NOLOAD): { . = ALIGN(8); - _sstack = .; + _sstack = .; . = . + STACK_SIZE; . = ALIGN(8); _estack = .; - } > sram1 + } > ram /* .ARM.exidx is sorted, so has to go in its own output section. */ PROVIDE_HIDDEN (__exidx_start = .); .ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) - } > sram1 + } > ram PROVIDE_HIDDEN (__exidx_end = .); - . = ALIGN(4); - _end = . ; + . = ALIGN(4); + _end = . ; } + diff --git a/hardware/google/sam/variants/adk2/variant.cpp b/hardware/google/sam/variants/adk2/variant.cpp index 987e4dfe2..96d93ba7f 100644 --- a/hardware/google/sam/variants/adk2/variant.cpp +++ b/hardware/google/sam/variants/adk2/variant.cpp @@ -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 @@ -102,6 +102,10 @@ */ +#ifdef __cplusplus +extern "C" { +#endif + /* * Pins descriptions */ @@ -236,21 +240,28 @@ extern const PinDescription g_APinDescription[]= // 74 - USART3 (Serial5) all pins { PIOD, PIO_PD5B_RXD3|PIO_PD4B_TXD3, ID_PIOD, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_COMBO), NO_ADC, NO_ADC, NO_PWM, NO_TC }, + // 75 - USB + { PIOB, PIO_PB11A_UOTGID|PIO_PB10A_UOTGVBOF, ID_PIOB, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL,NO_ADC, NO_ADC, NO_PWM, NO_TC }, // ID - VBOF + // END { NULL, 0, 0, PIO_NOT_A_PIN, PIO_DEFAULT, 0, NO_ADC, NO_ADC, NO_PWM, NO_TC } } ; +#ifdef __cplusplus +} +#endif + /* * UART objects */ RingBuffer rx_buffer1 ; -UARTClass Serial( UART, UART_IRQn, ID_UART, &rx_buffer1 ) ; +UARTClass Serial1( UART, UART_IRQn, ID_UART, &rx_buffer1 ) ; // IT handlers -void UART_IrqHandler(void) +void UART_Handler(void) { - Serial.IrqHandler() ; + Serial1.IrqHandler() ; } // ---------------------------------------------------------------------------- @@ -268,22 +279,22 @@ USARTClass Serial4( USART2, USART2_IRQn, ID_USART2, &rx_buffer4 ) ; USARTClass Serial5( USART3, USART3_IRQn, ID_USART3, &rx_buffer5 ) ; // IT handlers -void USART0_IrqHandler( void ) +void USART0_Handler( void ) { Serial2.IrqHandler() ; } -void USART1_IrqHandler( void ) +void USART1_Handler( void ) { Serial3.IrqHandler() ; } -void USART2_IrqHandler( void ) +void USART2_Handler( void ) { Serial4.IrqHandler() ; } -void USART3_IrqHandler( void ) +void USART3_Handler( void ) { Serial5.IrqHandler() ; } @@ -294,9 +305,6 @@ void USART3_IrqHandler( void ) extern "C" { #endif -// Should be made in a better way... -extern void analogOutputInit(void); - /** * */ @@ -343,27 +351,25 @@ extern void init( void ) g_APinDescription[PINS_USART3].ulPin, g_APinDescription[PINS_USART3].ulPinConfiguration); - + // Initialize USB + PIO_Configure( + g_APinDescription[PINS_USB].pPort, + g_APinDescription[PINS_USB].ulPinType, + g_APinDescription[PINS_USB].ulPin, + g_APinDescription[PINS_USB].ulPinConfiguration); // Initialize 10bit Analog Controller - PMC_EnablePeripheral( ID_ADC ) ; - adc_init( ADC, SystemCoreClock, ADC_FREQ_MAX, ADC_STARTUP ) ; - adc_configure_timing( ADC, 15, ADC_SETTLING_TIME_0, 15 ) ; // FIXME: Last two parameters (settling time and transfer time) need to be corrected! - adc_configure_trigger( ADC, ADC_TRIG_SW, ADC_MR_FREERUN_OFF ) ; - adc_disable_interrupt( ADC, 0xFFFFFFFF ) ; /* Disable all adc interrupt. */ - adc_disable_channel( ADC, ADC_ALL_CHANNEL ) ; - - // Initialize 12bit Analog Controller -// PMC_EnablePeripheral( ID_ADC12B ) ; -// adc12_init( ADC12B, SystemCoreClock, ADC12_FREQ_MAX, ADC12_STARTUP_FAST, 1 ) ; -// adc12_configure_timing( ADC12B, 15 ) ; -// adc12_configure_trigger( ADC12B, ADC_TRIG_SW ) ; -// adc12_disable_interrupt( ADC12B, 0xFFFFFFFF ) ; /* Disable all adc interrupt. */ -// adc12_disable_channel( ADC12B, ADC_ALL_CHANNEL ) ; + pmc_enable_periph_clk( ID_ADC ) ; + adc_init( ADC, SystemCoreClock, ADC_FREQ_MAX, ADC_STARTUP_FAST ) ; + adc_configure_timing(ADC, 0, ADC_SETTLING_TIME_3, 1); + adc_configure_trigger(ADC, ADC_TRIG_SW, 0); // Disable hardware trigger. + adc_disable_interrupt( ADC, 0xFFFFFFFF ) ; // Disable all ADC interrupts. + adc_disable_all_channel( ADC ) ; // Initialize analogOutput module analogOutputInit(); } + #ifdef __cplusplus } #endif diff --git a/hardware/google/sam/variants/adk2/variant.h b/hardware/google/sam/variants/adk2/variant.h index 2538e6b4d..266a84070 100644 --- a/hardware/google/sam/variants/adk2/variant.h +++ b/hardware/google/sam/variants/adk2/variant.h @@ -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 @@ -23,12 +23,19 @@ * Headers *----------------------------------------------------------------------------*/ +// We have native USB on this variant +#define USBCON + #include "Arduino.h" #ifdef __cplusplus #include "UARTClass.h" #include "USARTClass.h" #endif +#ifdef __cplusplus +extern "C"{ +#endif // __cplusplus + /** * Libc porting layers */ @@ -49,16 +56,11 @@ /** Name of the board */ #define VARIANT_NAME "ADK2" -/* -#define VARIANT_REV_A -#define VARIANT_REV_B -*/ - /** Frequency of the board main oscillator */ #define VARIANT_MAINOSC 12000000 /** Master clock frequency */ -#define VARIANT_MCK 96000000 +#define VARIANT_MCK 84000000 /*---------------------------------------------------------------------------- * Pins @@ -119,6 +121,12 @@ static const uint8_t SCK = 52 ; #define PINS_USART2 (73u) #define PINS_USART3 (74u) +/* + * USB Interfaces + */ +#define PINS_USB (75u) + + /* * Analog pins */ @@ -157,13 +165,17 @@ static const uint8_t A9 = 63; #define TC_MAX_DUTY_CYCLE 255 #define TC_MIN_DUTY_CYCLE 0 +#ifdef __cplusplus +} +#endif + /*---------------------------------------------------------------------------- * Arduino objects - C++ only *----------------------------------------------------------------------------*/ #ifdef __cplusplus -extern UARTClass Serial ; +extern UARTClass Serial1 ; extern USARTClass Serial2 ; extern USARTClass Serial3 ;