haha! commit
This commit is contained in:
parent
b1fffad5d6
commit
e0a8878941
19
main.cpp
Normal file
19
main.cpp
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#include <Arduino.h>
|
||||||
|
|
||||||
|
extern "C" int main(void)
|
||||||
|
{
|
||||||
|
setup();
|
||||||
|
while (1) {
|
||||||
|
loop();
|
||||||
|
yield();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void setup(void) {
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop(void) {
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
274
t4make00
Executable file
274
t4make00
Executable file
@ -0,0 +1,274 @@
|
|||||||
|
#!/usr/local/bin/python3
|
||||||
|
|
||||||
|
import sys, os, platform, glob, logging, argparse
|
||||||
|
import urllib.request
|
||||||
|
import io, zipfile, tarfile, shutil
|
||||||
|
|
||||||
|
|
||||||
|
# 777$7II7III??+,.......:+~=7$$Z$?$OOZOZ77?$$I+??I$ZOD8DD8DD888O$7$77$Z$$$ZZZZZOOO
|
||||||
|
# $$$777$$77II??~.,..,.=?777$ZZ==$OZZ$I?=+?Z+==~=7Z7Z$OO8888DDDD8ZOZ$$$7Z$ZOZ$ZZOO
|
||||||
|
# $$$7ZZ$Z$$77II=~:.,.:??+IZZZ+?O$ZI+?+:~+7I~~,:~?Z$88O88D88DDDDD8OZOZ$$$ZZZZZOOZZ
|
||||||
|
# $$$$ZZ$$$$777I??:::,:7ZZ8OZ$$$7?=::,:~??~:,.....7$8$IZDDD8DDDNDDOZZO$$ZZZZZOZOOO
|
||||||
|
# $$$77$7$7III$II+==+$$$OOO8OZ?=:......~. ........,?ZOI$88DOD8DDN8D888$7$ZZ$$Z$$ZO
|
||||||
|
# $$7$$$77I77$ZZ$7,:Z$OZOOOOOI. ...,~:.....:~~+:===$Z$7OOD8DDD88O8D888O$7$Z$$$$OZ
|
||||||
|
# $$77$$77I$$ZOZI,.7Z88O88O8?. .,:~~::,,.,,,+?$ZZZZZ8OZZ$8$8NDDDD88ODO8ZZ$$$OZZZOO
|
||||||
|
# Z$Z$$$77$Z$$O$~.~?$ZOOOOOZ, ,?7$7II+:..,~+$III777I77I$O8OD8DD8D8DO8D88$77$$$ZZZZ
|
||||||
|
# OOOOZc$ZOZOZZ?..+??IZO8NO$I?===+=~~~,...,~II???+~:+~:+ZO8D88DOODDDDD8D88OZ77$ZZZ
|
||||||
|
# ZOZOOZZZZZOZ$II.~?I$ZZO8ZO~. ..~?+~~.. .,?$I$ZO888O?~$Z88D888O8888DONDD88Z7777$
|
||||||
|
# OZZ8O8OZZOZZZZ7I7I$ZZ7$OZ7:.=7ZDO7?~.. ,::+O7$O8O78O7IOD88N8D8DD88DD8OOOO7$$7Z
|
||||||
|
# OOOZ88888OOOOZZI~?I$Z$OZI+?77,?$I?:.. .,:,,~,,~+++~+I$ZZ8DDD8DNDD8DDOOOZ7?$$7$
|
||||||
|
# OOOZO88OO8OZ7=:,.?7IZZOZI,~=~. ... . ..,,.. ...=:..~I$Z8DDDD8D8DDOD88a7II777$
|
||||||
|
# $OOOOOOO8O+.,.:++:++$ZOO7 .,. .,,,.... ..:~.:$Z8DD8DDD88DDD8O$?????I7
|
||||||
|
# OO8O8O8OZ$.,:?=..::?IZZ8Z .. ..,.,=,.. ..:I??7O8DD88D888D8OOI?II77II
|
||||||
|
# OOOO8OZZ7=,~7?~,,,~~?$7OZ,. .,:~=:,.,:, ..:=+:~788DDD88Z888OZ$+I?III$7
|
||||||
|
# ZOZZO$$$ZZZZ$I:~:~,,7=77$~:.. .:$$==IOO7=,.,....,:,:=+$D8DD8888D887II?7777$$
|
||||||
|
# ZOOZZZ$$ZZZZ7+::=:::::II~.:.. ..=+?+IIII:...,,..,,,:==$DDD88888DD8$ZZ$$ZOOOO
|
||||||
|
# 7ZO$n7I$$$Z$7I~,,:,,.,=?:,,.. . ,:::~~I?:,......,,:,:=ZO888D88D8DO88O8888888
|
||||||
|
# 77777$77$$7I?~,.. .,,,=+~.. ~+=:~+:+II+=~:,:..,,::~?ZODO888D88DD8DDDD8D88N
|
||||||
|
# ?77???I?II?~:,.....=.:?+~. ., .:?7I:::~::=+~~...,:~=?$OOOZ888OO8OO8888D8D8D
|
||||||
|
# 7II??I+++~:,.. .,==$7+,. .IZ7~~~~,~:++=:..::~++7ZZODDD8D888a8OOD88D88
|
||||||
|
# I???+~:,,,... .=:=~I$$+, .$7?+++++=+==+~,,:==+?78DDDDDDDO88OZOO88O888
|
||||||
|
# ??+::,,... ... .78Z7IZO=...... ,77:..:::.,~?+~::=++~?$8DDDN8D8O88O88OOOOO88
|
||||||
|
# ~=~:,,,.,.... .:OO$Z$7... ?$~ .......,:=~,:++==?$88D88D8ZOZOOZOOOO8DOO
|
||||||
|
# :~=+:,,.. . ..,?$$+.. =...::,... ,~::~?===+OD88888OZOOOZO$ZOOZZZ8
|
||||||
|
# ,~++++==.. ....~ZZO~. .:~=~,,...:=~~$7?+?$DD8D8OOZZOZOZOOOO8O8O8
|
||||||
|
# .:=+==++,. ...,.:+8DZ...I$7:.....,~=:,....+~?I7=?=$O8DDOOZ88OOO8OOOOOZZO88
|
||||||
|
# ,:~===?d, .:,:?OD8O...ZOO$$?I,...=~:,,,,~===?+?+77Z8OZ$Z$OOZZOOO8OOOOO8O8
|
||||||
|
# ,:~=~~=+.. ..=Z8888$.+OZ8OOZ8O7,.::=:~~=~:+????I$$?7$$ZZZOOOOOOOOO8O8OOOOO
|
||||||
|
# ,,:~~~+=.. ~ZO87I7Z,:7OOZOO?OD$~,:~:+?+==+?+=+77$?IOOZZZOOOOO8OOOOOOOOO888
|
||||||
|
# ..,,~=+~.. . =$OO:..+?.IZOOZOZ$OZ?=~=~=++=+:?III7$7I=7DD8ZZOO8OO88OO8ZOZ$ZOOO
|
||||||
|
# ..... .... . ,~?7OZ7..:~I+ZZOO$OOOZZ$+7++?+??I777$$Z7I?~Z8D8OO$Z888O8888ZOZOZOO8
|
||||||
|
# ,.....,~~==:=?$ZOZ7 .,~7IZZOZZZZOOOZO$I$Z$$Z$Z$ZZ7$I+==~DDDN8DDO$O88D8DDZO8OZ888
|
||||||
|
# =+=:~::=~~:+$ZZZ$+...I77$OZ$$IIZ$?$Z7=======~=++??==,::=D8D88D8D8ZOODOOOZZ8ZOaOO
|
||||||
|
|
||||||
|
teensy_src_url = "https://github.com/PaulStoffregen/cores/archive/master.zip"
|
||||||
|
arm_tool_chain_url_mac = "https://developer.arm.com/-/media/Files/downloads/gnu-rm/9-2020q2/gcc-arm-none-eabi-9-2020-q2-update-mac.tar.bz2"
|
||||||
|
|
||||||
|
basepath = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
installpath = os.path.join(os.path.expanduser("~"), "t4make00")
|
||||||
|
|
||||||
|
def install():
|
||||||
|
|
||||||
|
print("#0 staging")
|
||||||
|
|
||||||
|
platform_name = platform.system()
|
||||||
|
if platform_name == "Darwin":
|
||||||
|
arm_tool_chain_url = arm_tool_chain_url_mac
|
||||||
|
elif platform_name == "Linux":
|
||||||
|
print("Platform " + platform_name + "not supported. Aborting...")
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
print("Platform " + platform_name + "not supported. Aborting...")
|
||||||
|
return False
|
||||||
|
|
||||||
|
tools = os.path.join(installpath, "tools")
|
||||||
|
libs = os.path.join(installpath, "libs")
|
||||||
|
|
||||||
|
if not os.path.exists(installpath):
|
||||||
|
os.mkdir(installpath)
|
||||||
|
os.mkdir(tools)
|
||||||
|
os.mkdir(libs)
|
||||||
|
|
||||||
|
|
||||||
|
############# tools/gcc-arm-none-eabi
|
||||||
|
print("#1 fetching arm toolchain (may take minutes)")
|
||||||
|
|
||||||
|
if not os.path.exists(os.path.join(tools, "gcc-arm-none-eabi")):
|
||||||
|
|
||||||
|
arm_tool_chain_src = urllib.request.urlopen(arm_tool_chain_url)
|
||||||
|
arm_tool_chain_tar = tarfile.open(fileobj=io.BytesIO(arm_tool_chain_src.read()) , mode="r:bz2")
|
||||||
|
arm_tool_chain_tar.extractall(path=tools)
|
||||||
|
arm_tool_chain_tar.close()
|
||||||
|
|
||||||
|
for f in os.listdir(tools):
|
||||||
|
if f.startswith("gcc"):
|
||||||
|
os.rename(os.path.join(tools, f), os.path.join(tools, "gcc-arm-none-eabi"))
|
||||||
|
|
||||||
|
else:
|
||||||
|
print(" tools/gcc-arm-none-eabi already exists. Skipping.")
|
||||||
|
|
||||||
|
|
||||||
|
############# tools/teensy-tools
|
||||||
|
print("#2 fetching teensy-tools")
|
||||||
|
|
||||||
|
if not os.path.exists(os.path.join(tools, "teensy-tools")):
|
||||||
|
|
||||||
|
teensy_tools_tar = tarfile.open(os.path.join(basepath, "teensy-tools.tar.bz2"), mode="r:bz2")
|
||||||
|
teensy_tools_tar.extractall(path=tools)
|
||||||
|
teensy_tools_tar.close()
|
||||||
|
|
||||||
|
### copy libarm_x_math into gcc-arm-none-eabi for cortex math libs
|
||||||
|
arm_lib = os.path.join(tools, 'gcc-arm-none-eabi', 'arm-none-eabi', 'lib')
|
||||||
|
libarm = os.path.join(tools, 'teensy-tools','libarm_x_math')
|
||||||
|
for f in glob.glob(os.path.join(libarm, '*.a')):
|
||||||
|
shutil.copy(f, arm_lib)
|
||||||
|
shutil.rmtree(libarm, ignore_errors=True)
|
||||||
|
|
||||||
|
else:
|
||||||
|
print(" tools/teensy-tools already exists. Skipping.")
|
||||||
|
|
||||||
|
############# tools/teensy-src
|
||||||
|
print("#3 fetching teensy core librairies")
|
||||||
|
|
||||||
|
if not os.path.exists(os.path.join(libs, "teensy4")):
|
||||||
|
|
||||||
|
teensy_cores_src = urllib.request.urlopen(teensy_src_url)
|
||||||
|
teensy_zip_file = zipfile.ZipFile(io.BytesIO(teensy_cores_src.read()))
|
||||||
|
|
||||||
|
for n in teensy_zip_file.namelist():
|
||||||
|
(dirname, filename) = os.path.split(n)
|
||||||
|
if "teensy4" in dirname or "teensy3" in dirname:
|
||||||
|
dirname = os.path.join(libs, dirname.replace("cores-master/", ""))
|
||||||
|
if filename == '':
|
||||||
|
if not os.path.exists(dirname):
|
||||||
|
os.mkdir(dirname)
|
||||||
|
else:
|
||||||
|
with open(os.path.join(dirname, filename), "wb") as fp:
|
||||||
|
fp.write(teensy_zip_file.read(n))
|
||||||
|
|
||||||
|
|
||||||
|
teensy_zip_file.close()
|
||||||
|
|
||||||
|
# delete main.cpp
|
||||||
|
main4 = os.path.join(libs, 'teensy4', 'main.cpp')
|
||||||
|
main3 = os.path.join(libs, 'teensy3', 'main.cpp')
|
||||||
|
|
||||||
|
if os.path.isfile(main4):
|
||||||
|
os.remove(main4)
|
||||||
|
|
||||||
|
if os.path.isfile(main3):
|
||||||
|
os.remove(main3)
|
||||||
|
|
||||||
|
|
||||||
|
############# copy files
|
||||||
|
print("#4 copying files")
|
||||||
|
|
||||||
|
for f in ['t4make00', 't4make00.makefile', 'main.cpp']:
|
||||||
|
t4s = os.path.join(installpath, f)
|
||||||
|
if os.path.isfile(t4s):
|
||||||
|
if yes_no(f + " is already installed. Overwrite? [y/n] "):
|
||||||
|
os.remove(t4s)
|
||||||
|
else:
|
||||||
|
continue
|
||||||
|
shutil.copy(os.path.join(basepath, f), installpath)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
############# ~/.bash_profile
|
||||||
|
### -- shoudl be .bashrc but damn macOS nonsense....
|
||||||
|
|
||||||
|
print("#5 updating ~/.bash_profile")
|
||||||
|
|
||||||
|
home = os.path.expanduser("~")
|
||||||
|
bash_profile = os.path.join(home, ".bash_profile")
|
||||||
|
|
||||||
|
|
||||||
|
if os.path.exists(bash_profile):
|
||||||
|
# with open(bash_profile, "a") as fp:
|
||||||
|
with open(bash_profile, "r+") as fp:
|
||||||
|
c = fp.read()
|
||||||
|
if 'T4MAKE00PATH' in c:
|
||||||
|
print("T4MAKE00PATH already exists in .bash_profile. Skipping.")
|
||||||
|
else:
|
||||||
|
fp.write("\n# t4make00\n")
|
||||||
|
fp.write("export T4MAKE00PATH=$HOME/t4make00\n")
|
||||||
|
fp.write("export PATH=$T4MAKE00PATH:$PATH")
|
||||||
|
else:
|
||||||
|
print("Please add " + installpath + "to your ~/.bash_profile PATH")
|
||||||
|
|
||||||
|
print("done.")
|
||||||
|
return True
|
||||||
|
|
||||||
|
def uninstall():
|
||||||
|
|
||||||
|
print("#0 removing everything")
|
||||||
|
|
||||||
|
shutil.rmtree(installpath)
|
||||||
|
|
||||||
|
# print "#1 updating ~/.bashrc"
|
||||||
|
|
||||||
|
# -- this needs work ---
|
||||||
|
|
||||||
|
# home = os.path.expanduser("~")
|
||||||
|
# bashrc = os.path.join(home, ".bashrc")
|
||||||
|
|
||||||
|
# if os.path.exists(bashrc):
|
||||||
|
# import fileinput
|
||||||
|
# delete_line = "PATH=$PATH:" + basepath + "\n"
|
||||||
|
# deleted = False
|
||||||
|
# for l in fileinput.input(bashrc, inplace=1):
|
||||||
|
# if l != delete_line: print l
|
||||||
|
# else: deleted = True
|
||||||
|
# if not deleted:
|
||||||
|
# print "Could not update ~/.bashrc porperly.\nPlease make sure to erase " + basepath + " from your ~/.bashrc PATH"
|
||||||
|
|
||||||
|
print("done.")
|
||||||
|
return True
|
||||||
|
|
||||||
|
def yes_no(msg):
|
||||||
|
r = input(msg).lower()
|
||||||
|
return r == 'y' or r == 'yes'
|
||||||
|
|
||||||
|
def new(projectname):
|
||||||
|
|
||||||
|
os.mkdir(projectname)
|
||||||
|
os.mkdir(os.path.join(projectname, 'libs'))
|
||||||
|
|
||||||
|
## teensy version
|
||||||
|
tv = input("Teensy version? [41, 40, 30, 31, or LC] ")
|
||||||
|
if tv not in [ '41', '40', '30', '31', 'LC']:
|
||||||
|
print("Version " + tv + " not supported. Aborting.")
|
||||||
|
return False
|
||||||
|
|
||||||
|
## teensy core + teensyduino
|
||||||
|
if tv in ['41', '40']:
|
||||||
|
tc = 'teensy4'
|
||||||
|
td = '149' # check this...
|
||||||
|
elif tv in ['30', '31', 'LC']:
|
||||||
|
tc = 'teensy3'
|
||||||
|
td = '124' # check this...
|
||||||
|
|
||||||
|
# read template makefile
|
||||||
|
d = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
with open(os.path.join(d, 't4make00.makefile'), 'r') as fp:
|
||||||
|
makefile = fp.read()
|
||||||
|
|
||||||
|
# patch
|
||||||
|
makefile = makefile.replace('<teensy-version>', tv).replace('<teensy-core>', tc).replace('<teensyduino-version>', td)
|
||||||
|
|
||||||
|
# create new makefile
|
||||||
|
with open(os.path.join(projectname, 'Makefile'), 'w') as fp:
|
||||||
|
fp.write(makefile)
|
||||||
|
|
||||||
|
# main.cpp
|
||||||
|
shutil.copyfile(os.path.join(d, 'main.cpp'), os.path.join(projectname, projectname + '.cpp'))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
|
||||||
|
p = argparse.ArgumentParser(description='t4make00 -- makes makefiles for teensy 4')
|
||||||
|
p.add_argument('-i', '--install', help="installs t4make00 (~/.bashrc)", action='store_true')
|
||||||
|
p.add_argument('-u', '--uninstall', help="uninstalls t4make00 (~/.bashrc)", action='store_true')
|
||||||
|
p.add_argument('-n', '--new', help="create new project", type=str)
|
||||||
|
|
||||||
|
args = p.parse_args()
|
||||||
|
|
||||||
|
if args.install:
|
||||||
|
if install():
|
||||||
|
sys.exit(1)
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
elif args.uninstall:
|
||||||
|
if uninstall():
|
||||||
|
sys.exit(1)
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
elif args.new:
|
||||||
|
if new(args.new):
|
||||||
|
sys.exit(1)
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
231
t4make00.makefile
Normal file
231
t4make00.makefile
Normal file
@ -0,0 +1,231 @@
|
|||||||
|
# t4make00 Makefile
|
||||||
|
# adapted from apmorton's teensy-template https://github.com/apmorton/teensy-template
|
||||||
|
# and based on Makefile examples as part of teensy's cores https://github.com/PaulStoffregen/cores
|
||||||
|
# gauthiier - d@gauthiier.info
|
||||||
|
|
||||||
|
# name of your project (used to name the compiled .hex file)
|
||||||
|
TARGET = $(notdir $(CURDIR))
|
||||||
|
|
||||||
|
# directory to build in
|
||||||
|
BUILDDIR = $(abspath $(CURDIR)/build)
|
||||||
|
|
||||||
|
# (local) libraries
|
||||||
|
LIBRARYPATH = $(abspath $(CURDIR)/libs)
|
||||||
|
|
||||||
|
|
||||||
|
#*****************************************************
|
||||||
|
# Location of utilites, toolchains, etc...
|
||||||
|
# note: $T4MAKE00PATH must be part of your PATH
|
||||||
|
#*****************************************************
|
||||||
|
|
||||||
|
# generale tools path
|
||||||
|
TOOLSPATH = $(T4MAKE00PATH)/tools
|
||||||
|
|
||||||
|
# general libs path
|
||||||
|
LIBSPATH = $(T4MAKE00PATH)/libs
|
||||||
|
|
||||||
|
# path location for the arm-none-eabi compiler
|
||||||
|
COMPILERPATH = $(TOOLSPATH)/gcc-arm-none-eabi/bin
|
||||||
|
|
||||||
|
# path location for teensy-tools
|
||||||
|
ifeq ($(OS), Windows_NT)
|
||||||
|
$(error NT not supported)
|
||||||
|
else
|
||||||
|
UNAME_M := $(shell uname -m)
|
||||||
|
ifneq ($(UNAME_M),x86_64)
|
||||||
|
$(error only support for x86_64... sorry)
|
||||||
|
endif
|
||||||
|
|
||||||
|
UNAME_S := $(shell uname -s)
|
||||||
|
#note: (ver.00) only packs t4make00 with Darwin-x86_64...
|
||||||
|
ifneq ($(UNAME_S),Darwin)
|
||||||
|
$(error only support for Darwin-x86_64... sorry)
|
||||||
|
endif
|
||||||
|
|
||||||
|
TEENSY_TOOLSPATH = $(TOOLSPATH)/teensy-tools/$(UNAME_S)-$(UNAME_M)
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
#*****************************************************
|
||||||
|
# Teensy specificities: version, cores, etc.
|
||||||
|
#*****************************************************
|
||||||
|
|
||||||
|
# teensy version to use, 41, 40, 30, 31, or LC
|
||||||
|
TEENSY = <teensy-version>
|
||||||
|
|
||||||
|
# teensy core to use, teensy3, teensy4
|
||||||
|
TEENSYCORE = <teensy-core>
|
||||||
|
|
||||||
|
# teensyduino version to use
|
||||||
|
TEENSYDUINO = <teensyduino-version>
|
||||||
|
|
||||||
|
# path location for teensy core to use, teensy3, teensy4
|
||||||
|
COREPATH = $(LIBSPATH)/$(TEENSYCORE)
|
||||||
|
|
||||||
|
|
||||||
|
#*****************************************************
|
||||||
|
# Compiler, linker options
|
||||||
|
#*****************************************************
|
||||||
|
|
||||||
|
# compiler options specific to teensy core
|
||||||
|
ifeq ($(TEENSYCORE), teensy3)
|
||||||
|
|
||||||
|
# Set to 24000000, 48000000, or 96000000 to set CPU core speed
|
||||||
|
TEENSY_CORE_SPEED = 48000000
|
||||||
|
|
||||||
|
# configurable options
|
||||||
|
OPTIONS = -DF_CPU=$(TEENSY_CORE_SPEED) -DUSB_SERIAL -DLAYOUT_US_ENGLISH -DUSING_MAKEFILE
|
||||||
|
|
||||||
|
# cpu options
|
||||||
|
CPUOPTIONS = -mthumb
|
||||||
|
|
||||||
|
# CPPFLAGS = compiler options for C and C++
|
||||||
|
CPPFLAGS = -Wall -g -Os $(CPUOPTIONS) -ffunction-sections -fdata-sections -MMD $(OPTIONS) -I$(COREPATH) -I$(LIBRARYPATH) -I. -DTEENSYDUINO=$(TEENSYDUINO)
|
||||||
|
|
||||||
|
# compiler options for C++ only
|
||||||
|
CXXFLAGS = -std=gnu++0x -felide-constructors -fno-exceptions -fno-rtti
|
||||||
|
|
||||||
|
# compiler options for C only
|
||||||
|
CFLAGS =
|
||||||
|
|
||||||
|
# linker options
|
||||||
|
LDFLAGS = -Os -Wl,--gc-sections $(CPUOPTIONS)
|
||||||
|
|
||||||
|
# additional libraries to link
|
||||||
|
LIBS = -lm
|
||||||
|
|
||||||
|
else ifeq ($(TEENSYCORE), teensy4)
|
||||||
|
|
||||||
|
# Set to 600000000 to set CPU core speed (can we clock it higher?)
|
||||||
|
TEENSY_CORE_SPEED = 600000000
|
||||||
|
|
||||||
|
# configurable options
|
||||||
|
OPTIONS = -DF_CPU=$(TEENSY_CORE_SPEED) -DUSB_SERIAL -DLAYOUT_US_ENGLISH -DUSING_MAKEFILE
|
||||||
|
|
||||||
|
# cpu options with single & double precision FPU
|
||||||
|
CPUOPTIONS = -mthumb -mfloat-abi=hard -mfpu=fpv5-d16
|
||||||
|
|
||||||
|
# CPPFLAGS = compiler options for C and C++
|
||||||
|
CPPFLAGS = -Wall -g -O2 $(CPUOPTIONS) -ffunction-sections -fdata-sections -MMD $(OPTIONS) -I$(COREPATH) -I$(LIBRARYPATH) -I. -DTEENSYDUINO=$(TEENSYDUINO)
|
||||||
|
|
||||||
|
# compiler options for C++ only
|
||||||
|
CXXFLAGS = -std=gnu++14 -felide-constructors -fno-exceptions -fno-rtti -fpermissive -Wno-error=narrowing
|
||||||
|
|
||||||
|
# compiler options for C only
|
||||||
|
CFLAGS =
|
||||||
|
|
||||||
|
# linker options
|
||||||
|
LDFLAGS = -Os -Wl,--gc-sections $(CPUOPTIONS)
|
||||||
|
|
||||||
|
# additional libraries to link
|
||||||
|
LIBS = -lm -larm_cortexM7lfsp_math -lstdc++
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
$(error Invalid setting for TEENSYCORE)
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
|
# compiler options specific to teensy version
|
||||||
|
ifeq ($(TEENSY), 40)
|
||||||
|
CPPFLAGS += -D__IMXRT1062__ -mcpu=cortex-m7 -DARDUINO_TEENSY40
|
||||||
|
LDSCRIPT = $(COREPATH)/imxrt1062.ld
|
||||||
|
LDFLAGS += -mcpu=cortex-m7 -T$(LDSCRIPT)
|
||||||
|
else ifeq ($(TEENSY), 41)
|
||||||
|
CPPFLAGS += -D__IMXRT1062__ -mcpu=cortex-m7 -DARDUINO_TEENSY41
|
||||||
|
LDSCRIPT = $(COREPATH)/imxrt1062_t41.ld
|
||||||
|
LDFLAGS += -mcpu=cortex-m7 -T$(LDSCRIPT)
|
||||||
|
else ifeq ($(TEENSY), 30)
|
||||||
|
CPPFLAGS += -D__MK20DX128__ -mcpu=cortex-m4
|
||||||
|
LDSCRIPT = $(COREPATH)/mk20dx128.ld
|
||||||
|
LDFLAGS += -mcpu=cortex-m4 -T$(LDSCRIPT)
|
||||||
|
else ifeq ($(TEENSY), 31)
|
||||||
|
CPPFLAGS += -D__MK20DX256__ -mcpu=cortex-m4
|
||||||
|
LDSCRIPT = $(COREPATH)/mk20dx256.ld
|
||||||
|
LDFLAGS += -mcpu=cortex-m4 -T$(LDSCRIPT)
|
||||||
|
else ifeq ($(TEENSY), LC)
|
||||||
|
CPPFLAGS += -D__MKL26Z64__ -mcpu=cortex-m0plus
|
||||||
|
LDSCRIPT = $(COREPATH)/mkl26z64.ld
|
||||||
|
LDFLAGS += -mcpu=cortex-m0plus -T$(LDSCRIPT)
|
||||||
|
LIBS += -larm_cortexM0l_math
|
||||||
|
else
|
||||||
|
$(error Invalid setting for TEENSY)
|
||||||
|
endif
|
||||||
|
|
||||||
|
# set arduino define if given
|
||||||
|
ifdef ARDUINO
|
||||||
|
CPPFLAGS += -DARDUINO=$(ARDUINO)
|
||||||
|
else
|
||||||
|
CPPFLAGS += -DUSING_MAKEFILE
|
||||||
|
endif
|
||||||
|
|
||||||
|
# names for the compiler programs
|
||||||
|
CC = $(abspath $(COMPILERPATH))/arm-none-eabi-gcc
|
||||||
|
CXX = $(abspath $(COMPILERPATH))/arm-none-eabi-g++
|
||||||
|
OBJCOPY = $(abspath $(COMPILERPATH))/arm-none-eabi-objcopy
|
||||||
|
SIZE = $(abspath $(COMPILERPATH))/arm-none-eabi-size
|
||||||
|
|
||||||
|
# automatically create lists of the sources and objects
|
||||||
|
# library sources
|
||||||
|
LC_FILES := $(shell find $(LIBRARYPATH) \( -name examples -o -name extras -o -path name \) -prune -false -o -name "*.c")
|
||||||
|
LCPP_FILES := $(shell find $(LIBRARYPATH) \( -name examples -o -name extras -o -path name \) -prune -false -o -name "*.cpp")
|
||||||
|
# core sources
|
||||||
|
CC_FILES := $(wildcard $(COREPATH)/*.c)
|
||||||
|
CCPP_FILES := $(wildcard $(COREPATH)/*.cpp)
|
||||||
|
# project sources
|
||||||
|
C_FILES := $(wildcard *.c)
|
||||||
|
CPP_FILES := $(wildcard *.cpp)
|
||||||
|
INO_FILES := $(wildcard *.ino)
|
||||||
|
|
||||||
|
|
||||||
|
# include paths for libraries
|
||||||
|
L_INC := $(foreach lib,$(filter %/, $(wildcard $(LIBRARYPATH)/*/)), -I$(lib))
|
||||||
|
|
||||||
|
SOURCES := $(C_FILES:.c=.o) $(CPP_FILES:.cpp=.o) $(INO_FILES:.ino=.o) $(CC_FILES:.c=.o) $(CCPP_FILES:.cpp=.o) $(LC_FILES:.c=.o) $(LCPP_FILES:.cpp=.o)
|
||||||
|
OBJS := $(foreach src,$(SOURCES), $(BUILDDIR)/$(src))
|
||||||
|
|
||||||
|
all: hex
|
||||||
|
|
||||||
|
build: $(TARGET).elf
|
||||||
|
|
||||||
|
hex: $(TARGET).hex
|
||||||
|
|
||||||
|
post_compile: $(TARGET).hex
|
||||||
|
@$(abspath $(TEENSY_TOOLSPATH))/teensy_post_compile -file="$(basename $<)" -path=$(CURDIR) -tools="$(abspath $(TEENSY_TOOLSPATH))"
|
||||||
|
|
||||||
|
reboot:
|
||||||
|
@-$(abspath $(TEENSY_TOOLSPATH))/teensy_reboot
|
||||||
|
|
||||||
|
upload: post_compile reboot
|
||||||
|
|
||||||
|
$(BUILDDIR)/%.o: %.c
|
||||||
|
@echo "[CC]\t$<"
|
||||||
|
@mkdir -p "$(dir $@)"
|
||||||
|
@$(CC) $(CPPFLAGS) $(CFLAGS) $(L_INC) -o "$@" -c "$<"
|
||||||
|
|
||||||
|
$(BUILDDIR)/%.o: %.cpp
|
||||||
|
@echo "[CXX]\t$<"
|
||||||
|
@mkdir -p "$(dir $@)"
|
||||||
|
@$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(L_INC) -o "$@" -c "$<"
|
||||||
|
|
||||||
|
$(BUILDDIR)/%.o: %.ino
|
||||||
|
@echo "[CXX]\t$<"
|
||||||
|
@mkdir -p "$(dir $@)"
|
||||||
|
@$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(L_INC) -o "$@" -x c++ -include Arduino.h -c "$<"
|
||||||
|
|
||||||
|
$(TARGET).elf: $(OBJS) $(LDSCRIPT)
|
||||||
|
@echo "[LD]\t$@"
|
||||||
|
@$(CC) $(LDFLAGS) -o "$@" $(OBJS) $(LIBS)
|
||||||
|
|
||||||
|
%.hex: %.elf
|
||||||
|
@echo "[HEX]\t$@"
|
||||||
|
@$(SIZE) "$<"
|
||||||
|
@$(OBJCOPY) -O ihex -R .eeprom "$<" "$@"
|
||||||
|
|
||||||
|
# compiler generated dependency info
|
||||||
|
-include $(OBJS:.o=.d)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
@echo Cleaning...
|
||||||
|
@rm -rf "$(BUILDDIR)"
|
||||||
|
@rm -f "$(TARGET).elf" "$(TARGET).hex"
|
||||||
BIN
teensy-tools.tar.bz2
Normal file
BIN
teensy-tools.tar.bz2
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user