HAHA! commit

This commit is contained in:
gauthiier 2015-08-20 16:52:24 +02:00
commit 76ad2eff2f
4 changed files with 357 additions and 0 deletions

7
README.md Normal file
View File

@ -0,0 +1,7 @@
Usage: t3make00 [options]
Options:
-h, --help show this help message and exit
-i, --install installs t3make00 (~/.bashrc)
-p PROJECT, --project=PROJECT
name of the project (defaults to value args[0])

179
t3make00 Executable file
View File

@ -0,0 +1,179 @@
#!/usr/bin/python2.7
# 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
import os, platform, sys, shutil
import urllib2
import zipfile, tarfile
from StringIO import StringIO
from optparse import OptionParser
teensy_src_url = "https://github.com/PaulStoffregen/cores/archive/master.zip"
arm_tool_chain_url_mac = "https://launchpad.net/gcc-arm-embedded/4.8/4.8-2013-q4-major/+download/gcc-arm-none-eabi-4_8-2013q4-20131218-mac.tar.bz2"
arm_tool_chain_url_linux = "https://launchpad.net/gcc-arm-embedded/4.8/4.8-2013-q4-major/+download/gcc-arm-none-eabi-4_8-2013q4-20131204-linux.tar.bz2"
basepath = os.path.dirname(os.path.realpath(__file__))
def run():
print "#0 staging"
if not os.path.exists("libs"):
os.mkdir("libs")
if not os.path.exists("src"):
os.mkdir("src")
# link to gcc and teensy tools
os.symlink(os.path.join(basepath, "tools"), "tools")
#ftech teensy3
print "#1 fetching teensy3"
teensy_cores_src = urllib2.urlopen(teensy_src_url)
teensy_zip_file = zipfile.ZipFile(StringIO(teensy_cores_src.read()))
for n in teensy_zip_file.namelist():
(dirname, filename) = os.path.split(n)
if "teensy3" in dirname:
dirname = "libs" + os.sep + dirname.replace("cores-master/", "")
if filename == '':
if not os.path.exists(dirname):
os.mkdir(dirname)
else:
fp = open(os.path.join(dirname, filename), 'wr');
fp.write(teensy_zip_file.read(n))
fp.close();
teensy_zip_file.close()
if not os.path.exists("src" + os.sep + "main.cpp"):
shutil.move("libs" + os.sep + "teensy3" + os.sep + "main.cpp", "src")
print "#2 fetching Makefile"
shutil.copy(os.path.join(basepath, "t3make00.makefile"), "Makefile")
print "done."
def sanity():
if not os.path.exists(os.path.join(basepath, "tools")):
sys.exit("No valid installation yet. Aborting. \nPlease run t3make00 --install once before creating projects.");
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":
arm_tool_chain_url = arm_tool_chain_url_linux
else:
print "Platform " + platform_name + "not supported. Aborting..."
sys.exit(0)
base_tools = os.path.join(basepath, "tools")
if not os.path.exists(base_tools):
os.mkdir(base_tools)
print "#1 fetching arm toolchain (may take minutes)"
arm_tool_chain_src = urllib2.urlopen(arm_tool_chain_url)
arm_tool_chain_src_io = StringIO(arm_tool_chain_src.read())
arm_tool_chain_tar = tarfile.open(fileobj=arm_tool_chain_src_io, mode="r:bz2")
arm_tool_chain_tar.extractall(path=base_tools)
arm_tool_chain_tar.close()
for f in os.listdir(base_tools):
if f.startswith("gcc"):
os.rename(os.path.join(base_tools, f), os.path.join(base_tools, "gcc"))
print "#2 fetching teensy-tools"
teensy_tools_tar = tarfile.open(os.path.join(basepath, "teensy-tools.tar.bz2"), mode="r:bz2")
teensy_tools_tar.extractall(path=base_tools)
teensy_tools_tar.close()
print "#3 updating PATH"
home = os.path.expanduser("~")
bashrc = os.path.join(home, ".bashrc")
if not os.path.exists(bashrc):
with open(bashrc, "a") as fp:
fp.write("PATH=$PATH:" + basepath + "\n")
fp.write("export PATH")
else:
print "Please add " + basepath + "to your ~/.bashrc PATH"
if __name__ == '__main__':
p = OptionParser();
p.add_option('-i', '--install', action="store_true", help="installs t3make00 (~/.bashrc)")
p.add_option('-p', '--project', action="store", help="name of the project (defaults to value args[0])")
options, args = p.parse_args()
if options.install:
install()
sys.exit(1)
if not options.project and len(args) == 0:
sys.exit("No project specified. Aborting.\nt3make00 --help for usage information.");
if len(args) > 1:
sys.exit("Too many arguments. Aborting.\nt3make00 --help for usage information.");
project_path = '.'
if options.project:
project_path = options.project
else:
project_path = args[0]
if not os.path.exists(project_path):
os.mkdir(project_path)
os.chdir(project_path)
sanity()
run()
sys.exit(1)

171
t3make00.makefile Executable file
View File

@ -0,0 +1,171 @@
# t3make00 Makefile
# adapted from apmorton's teensy-template https://github.com/apmorton/teensy-template
# gauthiier - d@gauthiier.info
# The name of your project (used to name the compiled .hex file)
TARGET = $(notdir $(CURDIR))
# The teensy version to use, 30, 31, or LC
TEENSY = 31
# Set to 24000000, 48000000, or 96000000 to set CPU core speed
TEENSY_CORE_SPEED = 48000000
# Some libraries will require this to be defined
# If you define this, you will break the default main.cpp
#ARDUINO = 10600
# configurable options
OPTIONS = -DUSB_SERIAL -DLAYOUT_US_ENGLISH
# directory to build in
BUILDDIR = $(abspath $(CURDIR)/build)
#************************************************************************
# Location of Teensyduino utilities, Toolchain, and Arduino Libraries.
# To use this makefile without Arduino, copy the resources from these
# locations and edit the pathnames. The rest of Arduino is not needed.
#************************************************************************
# generale tools path
TOOLSPATH = $(CURDIR)/tools
# path location for Teensy Loader, teensy_post_compile and teensy_reboot
ifeq ($(OS),Windows_NT)
$(error What is Win Dose?)
else
UNAME_M := $(shell uname -m)
ifneq ($(UNAME_M),x86_64)
$(error only support for x86_64... sorry)
endif
UNAME_S := $(shell uname -s)
TEENSY_TOOLSPATH = $(TOOLSPATH)/teensy-tools/$(UNAME_S)-$(UNAME_M)
endif
# path location for Teensy 3 core
COREPATH = libs/teensy3
# path location for Arduino libraries
LIBRARYPATH = libs
# path location for the arm-none-eabi compiler
COMPILERPATH = $(TOOLSPATH)/gcc/bin
#************************************************************************
# Settings below this point usually do not need to be edited
#************************************************************************
# CPPFLAGS = compiler options for C and C++
CPPFLAGS = -Wall -g -Os -mthumb -ffunction-sections -fdata-sections -nostdlib -MMD $(OPTIONS) -DTEENSYDUINO=124 -DF_CPU=$(TEENSY_CORE_SPEED) -Isrc -I$(COREPATH)
# 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 -mthumb
# additional libraries to link
LIBS = -lm
# compiler options specific to teensy version
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
endif
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
LC_FILES := $(wildcard $(LIBRARYPATH)/*/*.c)
LCPP_FILES := $(wildcard $(LIBRARYPATH)/*/*.cpp)
C_FILES := $(wildcard src/*.c)
CPP_FILES := $(wildcard src/*.cpp)
INO_FILES := $(wildcard src/*.ino)
#subfolder -- one level
C_FILES += $(wildcard src/*/*.c)
CPP_FILES += $(wildcard src/*/*.cpp)
# 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) $(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

Binary file not shown.