-
Notifications
You must be signed in to change notification settings - Fork 449
/
OpenCM.mk
161 lines (126 loc) · 4.73 KB
/
OpenCM.mk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
########################################################################
#
# Support for Robotis OpenCM boards
#
# http://en.robotis.com/index/product.php?cate_code=131010
#
# You must install the OpenCM IDE for this Makefile to work:
#
# http://support.robotis.com/en/software/robotis_opencm/robotis_opencm.htm
#
# Based on work that is copyright Jeremy Shaw, Sudar, Nicholas Zambetti,
# David A. Mellis & Hernando Barragan.
#
# This file 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.
#
# Adapted from Teensy 3.x makefile which was adapted from Arduino 0011
# Makefile by M J Oldfield
#
# Original Arduino adaptation by mellis, eighthave, oli.keller
#
########################################################################
ifndef ARDMK_DIR
ARDMK_DIR := $(realpath $(dir $(realpath $(lastword $(MAKEFILE_LIST)))))
endif
# include Common.mk now we know where it is
include $(ARDMK_DIR)/Common.mk
ARDUINO_DIR = $(OPENCMIDE_DIR)
ifndef ARDMK_VENDOR
ARDMK_VENDOR = robotis
endif
ifndef ARDUINO_CORE_PATH
ARDUINO_CORE_PATH = $(ARDUINO_DIR)/hardware/robotis/cores/robotis
endif
ifndef BOARDS_TXT
BOARDS_TXT = $(ARDUINO_DIR)/hardware/$(ARDMK_VENDOR)/boards.txt
endif
ifndef F_CPU
F_CPU := $(call PARSE_BOARD,$(BOARD_TAG),build.f_cpu)
endif
# if boards.txt gets modified, look there, else hard code it
ARCHITECTURE = $(call PARSE_BOARD,$(BOARD_TAG),build.architecture)
ifeq ($(strip $(ARCHITECTURE)),)
ARCHITECTURE = arm
endif
AVR_TOOLS_DIR = $(call dir_if_exists,$(ARDUINO_DIR)/hardware/tools/$(ARCHITECTURE))
# Robotis has moved the platform lib dir to their root folder
ifndef ARDUINO_PLATFORM_LIB_PATH
ARDUINO_PLATFORM_LIB_PATH = $(ARDUINO_DIR)/libraries
$(call show_config_variable,ARDUINO_PLATFORM_LIB_PATH,[COMPUTED],(from ARDUINO_DIR))
endif
ifndef ARDUINO_HEADER
ARDUINO_HEADER = wirish.h
endif
########################################################################
# command names
TOOL_PREFIX = arm-none-eabi
# processor stuff
ifndef MCU
MCU := $(call PARSE_BOARD,$(BOARD_TAG),build.family)
endif
ifndef MCU_FLAG_NAME
MCU_FLAG_NAME=mcpu
endif
########################################################################
# FLAGS
ifndef USB_TYPE
USB_TYPE = USB_SERIAL
endif
CPPFLAGS += -DBOARD_$(call PARSE_BOARD,$(BOARD_TAG),build.board)
CPPFLAGS += -DMCU_$(call PARSE_BOARD,$(BOARD_TAG),build.mcu)
CPPFLAGS += -DSTM32_MEDIUM_DENSITY -DVECT_TAB_FLASH
CPPFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.option)
CXXFLAGS += -fno-rtti
CXXFLAGS += $(call PARSE_BOARD,$(BOARD_TAG),build.cppoption)
ifeq ("$(call PARSE_BOARD,$(BOARD_TAG),build.gnu0x)","true")
CXXFLAGS_STD += -std=gnu++0x
endif
ifeq ("$(call PARSE_BOARD,$(BOARD_TAG),build.elide_constructors)", "true")
CXXFLAGS += -felide-constructors
endif
CPPFLAGS += -mthumb -march=armv7-m -nostdlib -Wl,--gc-sections -Wall
LDFLAGS += -T$(ARDUINO_DIR)/hardware/robotis/cores/robotis/CM900/flash.ld
LDFLAGS += -L$(ARDUINO_CORE_PATH)
LDFLAGS += -mthumb -Xlinker --gc-sections -Wall
OTHER_LIBS += -lstdc++
########################################################################
# Reset is handled by upload script
override RESET_CMD =
########################################################################
# Object conversion & uploading magic, modified from Arduino.mk
override TARGET_HEX = $(OBJDIR)/$(TARGET).bin
ifndef AVRDUDE
AVRDUDE := $(shell which robotis-loader 2>/dev/null)
ifndef AVRDUDE
AVRDUDE = $(ARDMK_DIR)/bin/robotis-loader
endif
endif
override avr_size = $(SIZE) --target=binary $(2)
override AVRDUDE_COM_OPTS =
ifeq ($(CURRENT_OS), WINDOWS)
override AVRDUDE_ARD_OPTS = $(COM_STYLE_MONITOR_PORT)
else
override AVRDUDE_ARD_OPTS = $(call get_monitor_port)
endif
override AVRDUDE_UPLOAD_HEX = $(TARGET_HEX)
########################################################################
# automatically include Arduino.mk
include $(ARDMK_DIR)/Arduino.mk
########################################################################
# Object conversion & uploading magic, modified from Arduino.mk
$(OBJDIR)/%.bin: $(OBJDIR)/%.elf $(COMMON_DEPS)
@$(MKDIR) $(dir $@)
$(OBJCOPY) -v -Obinary $< $@
@$(ECHO) '\n'
$(call avr_size,$<,$@)
ifneq ($(strip $(HEX_MAXIMUM_SIZE)),)
@if [ `$(SIZE) --target=binary $@ | awk 'FNR == 2 {print $$2}'` -le $(HEX_MAXIMUM_SIZE) ]; then touch [email protected]; fi
else
@$(ECHO) "Maximum flash memory of $(BOARD_TAG) is not specified. Make sure the size of $@ is less then $(BOARD_TAG)\'s flash memory"
@touch [email protected]
endif
# link fails to plug _sbrk into libc if core is a lib, seems a bug in the linker
CORE_LIB = $(CORE_OBJS)