53
53
54
54
ifndef CORE_VER
55
55
CORE_VER := $(wildcard $(ARDUINO_PACKAGE_DIR ) /$(ARDMK_VENDOR ) /hardware/$(ARCHITECTURE ) /1.* )
56
- ifdef CORE_VER
56
+ ifneq ($( CORE_VER),)
57
57
CORE_VER := $(shell basename $(CORE_VER ) )
58
58
$(call show_config_variable,CORE_VER,[AUTODETECTED],(from ARDUINO_PACKAGE_DIR))
59
59
endif
62
62
endif
63
63
64
64
ifndef CMSIS_VER
65
- CMSIS_VER := $(shell basename $(wildcard $(ARDUINO_PACKAGE_DIR ) /$(ARDMK_VENDOR ) /tools/CMSIS/4.* ) )
66
- $(call show_config_variable,CMSIS_VER,[AUTODETECTED],(from ARDUINO_PACKAGE_DIR))
65
+ CMSIS_VER := $(wildcard $(ARDUINO_PACKAGE_DIR ) /$(ARDMK_VENDOR ) /tools/CMSIS/4.* )
66
+ ifneq ($(CMSIS_VER),)
67
+ CMSIS_VER := $(shell basename $(CMSIS_VER ) )
68
+ $(call show_config_variable,CMSIS_VER,[AUTODETECTED],(from ARDUINO_PACKAGE_DIR))
69
+ endif
67
70
else
68
71
$(call show_config_variable,CMSIS_VER,[USER])
69
72
endif
70
73
71
74
ifndef CMSIS_ATMEL_VER
72
- CMSIS_ATMEL_VER := $(shell basename $(wildcard $(ARDUINO_PACKAGE_DIR ) /$(ARDMK_VENDOR ) /tools/CMSIS-Atmel/1.* ) )
73
- $(call show_config_variable,CMSIS_ATMEL_VER,[AUTODETECTED],(from ARDUINO_PACKAGE_DIR))
75
+ CMSIS_ATMEL_VER := $(wildcard $(ARDUINO_PACKAGE_DIR ) /$(ARDMK_VENDOR ) /tools/CMSIS-Atmel/1.* )
76
+ ifneq ($(CMSIS_ATMEL_VER),)
77
+ CMSIS_ATMEL_VER := $(shell basename $(CMSIS_ATMEL_VER ) )
78
+ $(call show_config_variable,CMSIS_ATMEL_VER,[AUTODETECTED],(from ARDUINO_PACKAGE_DIR))
79
+ endif
74
80
else
75
81
$(call show_config_variable,CMSIS_ATMEL_VER,[USER])
76
82
endif
77
83
78
84
ifndef CMSIS_DIR
79
- CMSIS_DIR := $(ARDUINO_PACKAGE_DIR ) /$(ARDMK_VENDOR ) /tools/CMSIS/$(CMSIS_VER ) /CMSIS
85
+ ifeq ($(findstring samd, $(strip $(ARCHITECTURE))), samd)
86
+ CMSIS_DIR := $(ARDUINO_PACKAGE_DIR ) /$(ARDMK_VENDOR ) /tools/CMSIS/$(CMSIS_VER ) /CMSIS
87
+ else
88
+ CMSIS_DIR = $(ALTERNATE_CORE_PATH ) /system/CMSIS/CMSIS
89
+ endif
80
90
$(call show_config_variable,CMSIS_DIR,[AUTODETECTED],(from ARDUINO_PACKAGE_DIR))
81
91
else
82
92
$(call show_config_variable,CMSIS_DIR,[USER])
83
93
endif
84
94
85
95
ifndef CMSIS_ATMEL_DIR
86
- CMSIS_ATMEL_DIR := $(ARDUINO_PACKAGE_DIR ) /$(ARDMK_VENDOR ) /tools/CMSIS-Atmel/$(CMSIS_ATMEL_VER ) /CMSIS
96
+ ifeq ($(findstring samd, $(strip $(ARCHITECTURE))), samd)
97
+ CMSIS_ATMEL_DIR := $(ARDUINO_PACKAGE_DIR ) /$(ARDMK_VENDOR ) /tools/CMSIS-Atmel/$(CMSIS_ATMEL_VER ) /CMSIS
98
+ else
99
+ CMSIS_ATMEL_DIR = $(ALTERNATE_CORE_PATH ) /system/CMSIS
100
+ endif
87
101
$(call show_config_variable,CMSIS_ATMEL_DIR,[AUTODETECTED],(from ARDUINO_PACKAGE_DIR))
88
102
else
89
103
$(call show_config_variable,CMSIS_ATMEL_DIR,[USER])
@@ -129,9 +143,27 @@ ifndef VARIANT
129
143
endif
130
144
131
145
# grab any sources in the variant core path (variant.cpp defines pin/port mapping on SAM devices)
132
- ALT_CORE_C_SRCS := $(wildcard $(ALTERNATE_CORE_PATH ) /variants/$(VARIANT ) /* .c)
133
- ALT_CORE_CPP_SRCS := $(wildcard $(ALTERNATE_CORE_PATH ) /variants/$(VARIANT ) /* .cpp)
134
- ALT_CORE_S_SRCS := $(wildcard $(ALTERNATE_CORE_PATH ) /variants/$(VARIANT ) /* .S)
146
+ ifndef SAM_CORE_PATH
147
+ SAM_CORE_PATH := $(ALTERNATE_CORE_PATH ) /variants/$(VARIANT )
148
+ endif
149
+ SAM_CORE_C_SRCS := $(wildcard $(SAM_CORE_PATH ) /* .c)
150
+ SAM_CORE_CPP_SRCS := $(wildcard $(SAM_CORE_PATH ) /* .cpp)
151
+ SAM_CORE_S_SRCS := $(wildcard $(SAM_CORE_PATH ) /* .S)
152
+
153
+ # due/sam specific paths hard define chip type for SystemInit function in system_CHIP.c as not included in core like samd
154
+ ifeq ($(findstring arduino_due, $(strip $(VARIANT ) ) ) , arduino_due)
155
+ ifndef SAM_SYSTEM_PATH
156
+ SAM_SYSTEM_PATH := $(CMSIS_ATMEL_DIR ) /Device/ATMEL/sam3xa
157
+ endif
158
+ ifndef SAM_LIBSAM_PATH
159
+ SAM_LIBSAM_PATH := $(ALTERNATE_CORE_PATH ) /system/libsam
160
+ endif
161
+ CPPFLAGS += -I$(SAM_SYSTEM_PATH ) /include
162
+ CPPFLAGS += -I$(SAM_LIBSAM_PATH )
163
+ CPPFLAGS += -I$(SAM_LIBSAM_PATH ) /include
164
+ SAM_CORE_C_SRCS += $(wildcard $(SAM_LIBSAM_PATH ) /source/* .c)
165
+ SAM_CORE_C_SRCS += $(wildcard $(SAM_SYSTEM_PATH ) /source/* .c)
166
+ endif
135
167
136
168
# Use arm-toolchain from Arduino install if exists and user has not defined global version
137
169
ifndef ARM_TOOLS_DIR
@@ -160,7 +192,7 @@ ifndef CC_NAME
160
192
endif
161
193
162
194
ifndef CXX_NAME
163
- CXX_NAME := $(call PARSE_BOARD,$(BOARD_TAG ) ,build.command.g+ +)
195
+ CXX_NAME := $(call PARSE_BOARD,$(BOARD_TAG ) ,build.command.g\+\ +)
164
196
ifndef CXX_NAME
165
197
CXX_NAME := arm-none-eabi-g++
166
198
else
@@ -330,6 +362,10 @@ endif
330
362
331
363
ifndef BOSSA_OPTS
332
364
BOSSA_OPTS += -d --info --erase --write --verify --reset
365
+ # Arduino Due forces RS-232 mode and boots from flash
366
+ ifeq ($(findstring arduino_due, $(strip $(VARIANT))), arduino_due)
367
+ BOSSA_OPTS += -U false -b
368
+ endif
333
369
endif
334
370
335
371
get_bootloader = $(shell $(RESET_CMD ) | tail -1)
@@ -340,7 +376,7 @@ ifndef ISP_PORT
340
376
ifeq ($(CURRENT_OS), WINDOWS)
341
377
BOSSA_OPTS += --port=$(COM_STYLE_MONITOR_PORT )
342
378
else
343
- BOSSA_OPTS += --port=$(call get_monitor_port)
379
+ BOSSA_OPTS += --port=$(notdir $( call get_monitor_port) )
344
380
endif
345
381
else
346
382
BOSSA_OPTS += --port=$(ISP_PORT )
@@ -460,11 +496,20 @@ CXXFLAGS += -fno-rtti -fno-threadsafe-statics -std=gnu++11
460
496
AMCU := $(call PARSE_BOARD,$(BOARD_TAG ) ,build.mcu)
461
497
BOARD_LINKER_SCRIPT := $(call PARSE_BOARD,$(BOARD_TAG ) ,build.ldscript)
462
498
OPENOCD_SCRIPT := $(call PARSE_BOARD,$(BOARD_TAG ) ,build.openocdscript)
463
- # TODO Hard defines Cortex M0 math lib - should be dynamic
464
- LDFLAGS += --specs=nano.specs --specs=nosys.specs -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -Wl,--start-group -L$(LIB_PATH ) -larm_cortexM0l_math -lm
465
499
LINKER_SCRIPTS := -T$(ALTERNATE_CORE_PATH ) /variants/$(VARIANT ) /$(BOARD_LINKER_SCRIPT )
466
500
OTHER_LIBS := $(call PARSE_BOARD,$(BOARD_TAG ) ,build.flags.libs)
467
501
502
+ # Due and SAMD boards have different flags/chip specific libs
503
+ ifeq ($(findstring arduino_due, $(strip $(VARIANT ) ) ) , arduino_due)
504
+ CPPFLAGS += -Dprintf=iprintf -DARDUINO_SAM_DUE
505
+ LDFLAGS += -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--entry=Reset_Handler -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -Wl,--start-group -u _sbrk -u link -u _close -u _fstat -u _isatty -u _lseek -u _read -u _write -u _exit -u kill -u _getpid
506
+ LDFLAGS += -L$(LIB_PATH ) -lm # -larm_cortexM3l_math # IDE doesn't include Cortex-M3 math lib on Due for some reason
507
+ OTHER_LIBS += $(ALTERNATE_CORE_PATH ) /variants/$(VARIANT ) /libsam_sam3x8e_gcc_rel.a
508
+ else
509
+ LDFLAGS += --specs=nano.specs --specs=nosys.specs -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -Wl,--start-group
510
+ LDFLAGS += -larm_cortexM0l_math -L$(LIB_PATH ) -lm
511
+ endif
512
+
468
513
# OpenOCD reset command only for now
469
514
ifeq ($(strip $(UPLOAD_TOOL ) ) , openocd)
470
515
RESET_CMD = $(OPENOCD ) $(OPENOCD_OPTS ) -c "telnet_port disabled; init; targets; reset run; shutdown"
@@ -479,3 +524,5 @@ endif
479
524
$(call show_separator)
480
525
$(call arduino_output,Arduino.mk Configuration :)
481
526
include $(ARDMK_DIR ) /Arduino.mk
527
+
528
+ print-% : ; @echo $* = $($* )
0 commit comments