2014-10-14 02:48:07 +02:00
########################################################################
#
2014-10-16 01:29:26 +02:00
# Support for Teensy 3.x boards
2014-10-14 02:48:07 +02:00
#
2014-10-16 01:29:26 +02:00
# https://www.pjrc.com/teensy/
2014-10-14 02:48:07 +02:00
#
2014-10-22 22:27:59 +02:00
# You must install teensyduino for this Makefile to work:
#
# http://www.pjrc.com/teensy/teensyduino.html
2014-10-16 01:29:26 +02:00
#
# Copyright (C) 2014 Jeremy Shaw <jeremy@n-heptane.com> based on
# work that is copyright 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 Arduino 0011 Makefile by M J Oldfield
#
# Original Arduino adaptation by mellis, eighthave, oli.keller
#
# Refer to HISTORY.md file for complete history of changes
#
########################################################################
2014-10-14 02:48:07 +02:00
2014-10-22 22:27:59 +02:00
i f n d e f A R D M K _ D I R
ARDMK_DIR := $( realpath $( dir $( realpath $( lastword $( MAKEFILE_LIST) ) ) ) )
e n d i f
# include Common.mk now we know where it is
i n c l u d e $( ARDMK_DIR ) / C o m m o n . m k
2015-09-15 01:00:30 +02:00
ARDMK_VENDOR = teensy
2016-11-04 19:21:02 +01:00
ARDUINO_CORE_PATH = $( ARDUINO_DIR) /hardware/teensy/avr/cores/teensy3
BOARDS_TXT = $( ARDUINO_DIR) /hardware/$( ARDMK_VENDOR) /avr/boards.txt
2014-10-14 02:48:07 +02:00
2023-12-11 23:31:51 +01:00
# get hex path from the build directory. if path is cygwin based (cygdrive/path/example/), just discard cygwin root when calling Windows-native applications
2023-12-12 00:12:54 +01:00
i f e q ( $( shell uname | grep -c "CYGWIN ") , 1 )
HEX_PATH = $( shell cygpath -w $( abspath $( OBJDIR) ) )
HEX_PATH := $( subst \, /, $( HEX_PATH) )
e l s e
# Default for non-Cygwin environments
HEX_PATH = $( abspath $( OBJDIR) )
e n d i f
2014-10-14 02:48:07 +02:00
2017-02-04 16:15:13 +01:00
i f n d e f F _ C P U
ifndef BOARD_SUB
2018-09-13 23:44:12 +02:00
SPEEDS := $( call PARSE_BOARD," $( BOARD_TAG) ,menu.speed.*.build.fcpu " ) # Obtain sequence of supported frequencies.
2017-02-04 16:15:13 +01:00
SPEEDS := $( shell printf "%d\n" $( SPEEDS) | sort -g) # Sort it, just in case. Printf to re-append newlines so that sort works.
F_CPU := $( lastword $( SPEEDS) ) # List is sorted in ascending order. Take the fastest speed.
#$(info "speeds is " $(SPEEDS)) # Good for debugging
else
2018-09-13 23:44:12 +02:00
F_CPU := $( call PARSE_BOARD,$( BOARD_TAG) ,menu.speed.$( BOARD_SUB) .build.fcpu)
2017-02-04 16:15:13 +01:00
endif
e n d i f
2016-11-05 20:10:15 +01:00
# if boards.txt gets modified, look there, else hard code it
2018-09-13 23:44:12 +02:00
ARCHITECTURE = $( call PARSE_BOARD,$( BOARD_TAG) ,build.architecture)
2016-11-05 20:19:15 +01:00
i f e q ( $( strip $ ( ARCHITECTURE ) ) , )
2016-11-05 20:10:15 +01:00
ARCHITECTURE = arm
e n d i f
2014-10-14 02:48:07 +02:00
AVR_TOOLS_DIR = $( call dir_if_exists,$( ARDUINO_DIR) /hardware/tools/$( ARCHITECTURE) )
2016-11-04 19:28:18 +01:00
# define plaform lib dir ignoring teensy's oversight on putting it all in avr
i f n d e f A R D U I N O _ P L A T F O R M _ L I B _ P A T H
ARDUINO_PLATFORM_LIB_PATH = $( ARDUINO_DIR) /hardware/$( ARDMK_VENDOR) /avr/libraries
$( call show_config_variable,ARDUINO_PLATFORM_LIB_PATH,[ COMPUTED] ,( from ARDUINO_DIR) )
e n d i f
2014-10-14 02:48:07 +02:00
########################################################################
# command names
2018-09-14 16:14:14 +02:00
TOOL_PREFIX = arm-none-eabi
2014-10-14 02:48:07 +02:00
# processor stuff
i f n d e f M C U
2018-09-13 23:44:12 +02:00
MCU := $( call PARSE_BOARD,$( BOARD_TAG) ,build.mcu)
2014-10-14 02:48:07 +02:00
e n d i f
2014-10-22 22:27:59 +02:00
i f n d e f M C U _ F L A G _ N A M E
MCU_FLAG_NAME = mcpu
e n d i f
2014-10-14 02:48:07 +02:00
########################################################################
# FLAGS
2015-01-23 11:10:53 +01:00
i f n d e f U S B _ T Y P E
USB_TYPE = USB_SERIAL
e n d i f
CPPFLAGS += -DLAYOUT_US_ENGLISH -D$( USB_TYPE)
2014-10-14 02:48:07 +02:00
2018-09-13 23:44:12 +02:00
CPPFLAGS += $( call PARSE_BOARD,$( BOARD_TAG) ,build.option)
2014-10-14 02:48:07 +02:00
2018-09-13 23:44:12 +02:00
CXXFLAGS += $( call PARSE_BOARD,$( BOARD_TAG) ,build.cppoption)
i f e q ( "$(call PARSE_BOARD,$(BOARD_TAG),build.gnu0x)" , "true" )
2014-10-14 02:48:07 +02:00
CXXFLAGS_STD += -std= gnu++0x
e n d i f
2018-09-13 23:44:12 +02:00
i f e q ( "$(call PARSE_BOARD,$(BOARD_TAG),build.elide_constructors)" , "true" )
2014-10-14 02:48:07 +02:00
CXXFLAGS += -felide-constructors
e n d i f
2018-09-13 23:44:12 +02:00
CXXFLAGS += $( call PARSE_BOARD,$( BOARD_TAG) ,build.flags.common)
CXXFLAGS += $( call PARSE_BOARD,$( BOARD_TAG) ,build.flags.cpu)
CXXFLAGS += $( call PARSE_BOARD,$( BOARD_TAG) ,build.flags.defs)
CXXFLAGS += $( call PARSE_BOARD,$( BOARD_TAG) ,build.flags.cpp)
2014-10-14 02:48:07 +02:00
2018-09-13 23:44:12 +02:00
CFLAGS += $( call PARSE_BOARD,$( BOARD_TAG) ,build.flags.common)
CFLAGS += $( call PARSE_BOARD,$( BOARD_TAG) ,build.flags.cpu)
CFLAGS += $( call PARSE_BOARD,$( BOARD_TAG) ,build.flags.defs)
2016-11-04 19:21:02 +01:00
2018-09-13 23:44:12 +02:00
ASFLAGS += $( call PARSE_BOARD,$( BOARD_TAG) ,build.flags.common)
ASFLAGS += $( call PARSE_BOARD,$( BOARD_TAG) ,build.flags.cpu)
ASFLAGS += $( call PARSE_BOARD,$( BOARD_TAG) ,build.flags.defs)
ASFLAGS += $( call PARSE_BOARD,$( BOARD_TAG) ,build.flags.S)
2016-11-04 19:21:02 +01:00
2018-09-13 23:44:12 +02:00
LDFLAGS += $( call PARSE_BOARD,$( BOARD_TAG) ,build.flags.cpu)
2016-11-04 19:21:02 +01:00
2018-09-13 23:44:12 +02:00
AMCU := $( call PARSE_BOARD,$( BOARD_TAG) ,build.mcu)
2016-11-04 19:21:02 +01:00
LDFLAGS += -Wl,--gc-sections,--relax
2019-07-02 19:02:57 +02:00
LINKER_SCRIPTS ?= -T${ ARDUINO_CORE_PATH } /${ AMCU } .ld
2018-09-13 23:44:12 +02:00
OTHER_LIBS = $( call PARSE_BOARD,$( BOARD_TAG) ,build.flags.libs)
2014-10-14 02:48:07 +02:00
2018-09-13 23:44:12 +02:00
CPUFLAGS = $( call PARSE_BOARD,$( BOARD_TAG) ,build.flags.cpu)
2016-11-04 19:37:10 +01:00
# usually defined as per teensy31.build.mcu=mk20dx256 but that isn't valid switch
MCU := $( shell echo ${ CPUFLAGS } | sed -n -e 's/.*-mcpu=\([a-zA-Z0-9_-]*\).*/\1/p' )
2014-10-16 01:29:26 +02:00
########################################################################
# some fairly odd settings so that 'make upload' works
#
# may require additional patches for Windows support
do_upload : override get_monitor_port =""
AVRDUDE = @true
2023-12-12 00:14:52 +01:00
RESET_CMD = nohup $( ARDUINO_DIR) /hardware/tools/teensy_post_compile -board= $( BOARD_TAG) -tools= $( abspath $( ARDUINO_DIR) /hardware/tools) -path= $( HEX_PATH) -file= $( TARGET) > /dev/null ; $( ARDUINO_DIR) /hardware/tools/teensy_reboot
2014-10-14 02:48:07 +02:00
2014-10-16 01:29:26 +02:00
########################################################################
# automatially include Arduino.mk for the user
2014-10-14 02:48:07 +02:00
i n c l u d e $( ARDMK_DIR ) / A r d u i n o . m k
2016-11-04 19:21:02 +01:00