1 # //******************************************************************
3 # // Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
5 # //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7 # // Licensed under the Apache License, Version 2.0 (the "License");
8 # // you may not use this file except in compliance with the License.
9 # // You may obtain a copy of the License at
11 # // http://www.apache.org/licenses/LICENSE-2.0
13 # // Unless required by applicable law or agreed to in writing, software
14 # // distributed under the License is distributed on an "AS IS" BASIS,
15 # // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # // See the License for the specific language governing permissions and
17 # // limitations under the License.
19 # //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
23 PLATFORM := arduinomega
24 ARDUINO_PORT := ttyACM0
26 # override with `make PLATFORM=arduinomega ARDUINOWIFI=1` to enable Arduino WiFi shield
31 ROOT_DIR = ../../../../..
32 LOGGER_DIR = $(ROOT_DIR)/logger
33 OC_LOG_DIR = $(ROOT_DIR)/../oc_logger
34 TBSTACK_DIR = $(ROOT_DIR)/stack
36 include $(ROOT_DIR)/local.properties
37 include $(ROOT_DIR)/$(PLATFORM).properties
39 VPATH := $(SDIR_ARD_PLATFORM)
42 LOGGER_DIR = $(ROOT_DIR)/logger
43 STACK_DIR = $(ROOT_DIR)/stack
44 INC_DIRS = -I$(OCSOCK_DIR)/include/ -I$(OC_LOG_DIR)/include -I$(LOGGER_DIR)/include -I$(STACK_DIR)/include
46 CC_FLAGS.debug := -O1 -g3 -Wall -c -fmessage-length=0 -pedantic -fpic
47 CC_FLAGS.release := -Os -Wall -c -fmessage-length=0 -fpic
49 CFLAGS := $(CC_FLAGS.$(BUILD)) -DTB_LOG
51 ifeq ($(ARDUINOWIFI),1)
52 CFLAGS += -DARDUINOWIFI
53 ARDUINO_SHIELD_TYPE := "/wifi_shield"
54 TRANSPORT_OBJS = $(WIFI_COBJ)
56 ARDUINO_SHIELD_TYPE := "/ethernet_shield"
57 TRANSPORT_OBJS = $(ETH_CPPOBJ) $(ETH_UTIL_CPPOBJ)
60 OUT_DIR := $(PLATFORM)$(ARDUINO_SHIELD_TYPE)/$(BUILD)
62 OBJ_DIR := $(OUT_DIR)/bin
64 all: prep_dirs core.a $(APP_NAME).o $(APP_NAME).elf $(APP_NAME).hex
66 core.a: $(PLATFORM_OBJS)
67 @cd $(OBJ_DIR) && $(AR) -x ../../../../$(ROOT_DIR)/$(PLATFORM)$(ARDUINO_SHIELD_TYPE)/$(BUILD)/liboctbstack.a
68 @cd $(OBJ_DIR) && $(AR) -x ../../../../$(ROOT_DIR)/connectivity/build/arduino/core.a
69 $(AR) rcs $(OBJ_DIR)/$@ $(foreach obj, $^, $(OBJ_DIR)/$(obj)) $(OBJ_DIR)/*.o
70 @cd $(OBJ_DIR) && $(RANLIB) $@
74 -mkdir $(PLATFORM)/$(ARDUINO_SHIELD_TYPE)
79 $(CC) $(CFLAGS) $(CFLAGS_PLATFORM) $(INC_DIRS) $(INC_DIR_PLATFORM) $< -o $(OBJ_DIR)/$@
82 $(CXX) $(CFLAGS) $(CFLAGS_PLATFORM) $(INC_DIRS) $(INC_DIR_PLATFORM) $< -o $(OBJ_DIR)/$@
84 $(APP_NAME).elf: $(APP_NAME).o core.a
85 ifeq ($(PLATFORM),arduinomega)
86 $(CC) -Os -Wl,--gc-sections,--relax $(CFLAGS_PLATFORM) $(foreach obj, $^, $(OBJ_DIR)/$(obj)) -lm -o $(OBJ_DIR)/$@
87 else ifeq ($(PLATFORM),arduinodue)
88 $(CXX) -Os -Wl,--gc-sections -mcpu=cortex-m3 -T/$(SDIR_ARD_CORE_3)/linker_scripts/gcc/flash.ld -Wl,-Map,$(APP_NAME).map -o $(OBJ_DIR)/$@ -lm -lgcc -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--entry=Reset_Handler -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -Wl,--warn-unresolved-symbols -Wl,--start-group $(foreach obj, $(APP_NAME).o $(SYSCALLS_SAM3_OBJ) $(SPI_OBJ) $(TRANSPORT_OBJS) $(VARIANT_OBJ) core.a, $(OBJ_DIR)/$(obj)) $(SDIR_ARD_CORE_3)/libsam_sam3x8e_gcc_rel.a -Wl,--end-group
90 $(error Wrong value for PLATFORM !!)
93 $(APP_NAME).hex: $(APP_NAME).elf
94 ifeq ($(PLATFORM),arduinomega)
95 $(AVR_OBJCOPY) -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 $(OBJ_DIR)/$< $(OBJ_DIR)/$(APP_NAME).eep
96 $(AVR_OBJCOPY) -O ihex -R .eeprom $(OBJ_DIR)/$< $(OUT_DIR)/$@
97 else ifeq ($(PLATFORM),arduinodue)
98 $(ARDUINO_TOOLS_DIR)/arm-none-eabi-objcopy -O binary $(OBJ_DIR)/$< $(OUT_DIR)/$@
100 $(error Wrong value for PLATFORM !!)
104 ifeq ($(PLATFORM),arduinomega)
105 $(AVR_PROGRAMMER) -C$(ARDUINO_DIR)/hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega2560 -cstk500v2 -P/dev/$(ARDUINO_PORT) -b115200 -D -Uflash:w:$(OUT_DIR)/$(APP_NAME).hex:i
106 else ifeq ($(PLATFORM),arduinodue)
107 stty -F /dev/$(ARDUINO_PORT) speed 1200 cs8 -cstopb -parenb
108 $(ARDUINO_DIR)/hardware/tools/bossac -i -d --port=$(ARDUINO_PORT) -U false -e -w -v -b $(OUT_DIR)/$(APP_NAME).hex -R
110 $(error Wrong value for PLATFORM !!)
121 @rm -f *.o *.d *.elf *.eep *.a *.hex *.bin *.map *-