Skip to content

Compile to Teensy 3.0 on Windows using Makefile

Good Night,

If you don’t want to use Arduino IDE (Or Teensy IDE? 😉 to programming and uploading your code to Teensy 3.0 you can use Makefiles.

The last IDE version can be found on PJRC Forum . As he said in the Beta 10 version, there is an Makefile example on “arduino-1.0.3\hardware/teensy/cores/teensy3” but to use it you need to add the arm binaries to your system path. To do this, open your command prompt. Start – execute – cmd.

And then type:

PATH = %PATH%;C:\CAMINHO_PARA_O_ARDUINO\arduino-1.0.3\hardware\tools\arm-none-eabi\bin

[If you don’t want to know the modifications that I did, just jump to the end where you can find a resume]

To guarantee that I will not screw everything, I did a copy of “arduino-1.0.3\hardware/teensy/cores/teensy3” and did my modifications on it. I executed:

cs-make.exe

Receveid this error message:

C:\CAMINHO_PARA_O_ARDUINO\arduino-1.0.3\Projects\Example_not_working>cs-make.exe
C:/Users/X-warrior/Desktop/tools/arm-none-eabi/bin/arm-none-eabi-gcc -Wall -g -Os -mcpu=cortex-m4 -mthumb -nostdlib -MMD -DF_CPU=48000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH -I. -c -o analog.o analog.c
process_begin: CreateProcess(NULL, C:/Users/X-warrior/Desktop/tools/arm-none-eabi/bin/arm-none-eabi-gcc -Wall -g -Os -mcpu=cortex-m4 -mthumb -nostdlib -MMD -DF_CPU=48000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH -I. -c -o analog.o analog.c, …) failed.
make (e=2): The system cannot find the file specified.
cs-make.exe: *** [analog.o] Error 2

Checking the Makefile I decided to change some configs and used FULL PATH for it.
TOOLSPATH = C:\CAMINHO_PARA_O_ARDUINO\arduino-1.0.3\hardware\tools
COMPILERPATH = C:\CAMINHO_PARA_O_ARDUINO\arduino-1.0.3\hardware\tools\arm-none-eabi\bin

The error received was the same, so checking the code again I saw the “abspath” and thought that maybe the problem was this, since I changed my folder location. So I removed all “$(abspath” remember that it has a parenthesis that closes the command. So for example:

$(abspath $(COMPILERPATH)) will be $(COMPILERPATH)

Trying to get it working again with cs-make, it started compiling it, but on the end I received this error:

C:\Users\X-warrior\Desktop\arduino-1.0.3\hardware\tools\arm-none-eabi\bin/arm-none-eabi-objcopy -O ihex -R .eeprom main.elf main.hex
C:\Users\X-warrior\Desktop\arduino-1.0.3\hardware\tools/teensy_post_compile -file=main -path= -tools=C:\Users\X-warrior\Desktop\arduino-1.0.3\hardware\tools
Opening Teensy Loader…
Teensy Loader could not find the file main
cs-make.exe: *** [main.hex] Error 1

Triple checking the Makefile I found “path=$(shell pwd)” and I didn’t remember this pwm command on windows so I tried to execute it and it didn’t work. So I changed it to “path=$(shell echo %cd%)”. Before I start compiling again I decide to clean directory using cs-make clean

I received the following errors:

C:\Users\X-warrior\Desktop\arduino-1.0.3\Projects\Example_not_working>cs-make.exe clean
rm -f *.o *.d main.elf main.hex
process_begin: CreateProcess(NULL, rm -f *.o *.d main.elf main.hex, …) failed.
make (e=2): The system cannot find the file specified.
cs-make.exe: *** [clean] Error 2

And then I noticed that it was calling rm -f which isn’t a windows command too. I changed the rm command to:

del *.o
del *.d
del $(TARGET).elf
del $(TARGET).hex

With this I managed to clean the files and tried to compile again, and… IT WORKS! I did a few tests using main.cpp that was being compiled and uploaded to my Teensy 3. Anyways to work with all that files wasn’t attractive so I decided to go a little further and do some cleaning. So inside my “Project” folder I copied all files excluding Makefile and main.cpp to my new folder inside my project “teensy/”. This way I can compile it without all that files on my working folder. I needed to do a few more changes on Makefile as follow:

C_FILES := $(wildcard *.c) \
$(wildcard $(addprefix teensy/, *.c)) \
$(wildcard $(addprefix teensy/util, *.c)) \
$(wildcard $(addprefix teensy/avr, *.c))
CPP_FILES := $(wildcard *.cpp) \
$(wildcard $(addprefix teensy/, *.cpp)) \
$(wildcard $(addprefix teensy/util, *.cpp)) \
$(wildcard $(addprefix teensy/avr, *.cpp))
OBJS := $(C_FILES:.c=.o) $(CPP_FILES:.cpp=.o)

Linker configuration to:

LDFLAGS = -Os -Wl,–gc-sections -mcpu=cortex-m4 -mthumb -Tteensy/mk20dx128.ld

And to keep it consistent:

$(TARGET).elf: $(OBJS) teensy/mk20dx128.ld
$(CC) $(LDFLAGS) -o $@ $(OBJS)

And then I found this error:

teensy/keylayouts.c:1: fatal error: avr/pgmspace.h: No such file or directory
compilation terminated.
cs-make: *** [teensy/keylayouts.o] Error 1

So I updated the CPPFLAGS to:

CPPFLAGS = -Wall -g -Os -mcpu=cortex-m4 -mthumb -nostdlib -MMD $(OPTIONS) -I. -Iteensy/

And also remembered that the clean should be updated too.

clean:
del *.o
del *.d
del $(TARGET).elf
del $(TARGET).hex
del $(CURRENT_PATH)\teensy\*.o
del $(CURRENT_PATH)\teensy\*.d

And add this on the begin of “Configurations that shouldn’t be updated”

CURRENT_PATH=$(shell echo %cd%)

With all this I managed to get the Makefile working on Windows compiling and uploading for Teensy 3.0

Summary:
You must update TOOLSPATH , COMPILERPATH and use your FULL PATH
Then create a folder “My_Project”
Create another folder inside your project called “teensy” (My_Project/teensy/)
Copy “arduino-1.0.3\hardware/teensy/cores/teensy3/” to “My_Project/teensy/” (subdir too, but not the Makefile)
Add the Makefile that you can download on the end of this post inside “My_Project”
Copy “Meu_Projeto/teensy/main.cpp” too “Meu_Projeto/main.cpp”
Programm inside main.cpp
Compile and upload with cs-make.exe

Makefile to Teensy on Windows

Matheus

Published inCcppTeensywindows

5,405 Comments

  1. Been using Betbolt UK for a few months now and tbh it’s grown on me. Game library is quite wide — reckon there’s upwards of 3,500 games in total. Play’n GO and NetEnt dominate the lobby, and Big Time Gaming in there too. Sweet Bonanza and Book of Dead are still the popular picks, they run smoothly on the site. The one thing that bugged me — game filtering isn’t the most intuitive, takes a bit of patience to find specific titles.

    Live dealer games are powered by Evolution Gaming which basically means quality’s solid. Crazy Time, Lightning Roulette, Monopoly Live — the main game shows are all there. Real croupiers, proper studios, and no streaming issues I’ve noticed. Usually I drift between the live games and the slot lobby based on what I fancy.

    The welcome offer at Betbolt UK was a 100% match up to ?100 plus 50 bonus spins for one of their Pragmatic slots. Wagering sits at 30x which is about standard for UK sites. Have a look at bet bolts before you register as offers shift around all the time. The min deposit for the welcome offer is ?20, standard stuff.

    Betbolt UK’s sportsbook is decent enough — Premier League coverage are well covered and the odds hold up to the main UK bookies. In-play works well generally, though I’ve noticed the odds can lag a bit on busy matchdays. Minor stuff really but worth noting.

    Betbolt UK cashouts have been solid for me. Using a Visa debit and funds arrived in under 24 hours. Visa, Mastercard, Skrill and Neteller are all supported, plus crypto if that’s your thing. The site holds an MGA licence which gives it some credibility at least. Live chat is 24/7 and response was fast the time I queried something.

  2. Нержавеющая стальная лента — один из ключевых видов металлопроката в промышленности. Её изготавливают из нержавеющих марок стали, таких как 12Х18Н10Т, 08Х18Н10, AISI 304 и их аналогов.

    Ключевые параметры нержавеющей ленты: высокая устойчивость к коррозии, хорошие прочностные показатели, пластичность и длительная работоспособность. Толщина полосы может быть от 0,05 до 2,0 мм, а ширина — от 5 до 400 мм под конкретные задачи.

    Применяется нержавеющая лента в пищевом производстве, в химической отрасли, в строительной сфере, в автомобилестроении и в медицине. Помимо этого её активно задействуют для изготовления пружин, бандажных хомутов, прокладок и уплотнений и облицовочных деталей.

    Подбирая стальную нержавеющую ленту следует принимать во внимание химический состав, состояние поставки (нагартованная или отожжённая), допуски по толщине и чистоту поверхности (зеркальная или полированная).

    Подробнее о продукции и условиях поставки рекомендуем на странице заказать нержавеющую ленту — тут размещён актуальный сортамент ленты из нержавеющей стали с описанием и формой заказа.

  3. OLaneCitty OLaneCitty

    Thank you for sharing this detailed and highly useful post. The way you organized the main points makes it very easy to follow along, and I truly appreciate the balanced tone you maintained throughout the entire piece from start to finish today.

    australian online pokies

  4. Il game show Crazy Time è sicuramente il giochi live più seguiti tra i giocatori italiani. Sviluppato dallo studio Evolution, il gioco è in onda dal 2020 mescolando una grande ruota colorata con quattro round bonus: Pachinko, Cash Hunt, Coin Flip e il bonus Crazy Time.

    Le regole sono accessibili: il conduttore fa girare la ruota, chi gioca scommette su uno dei quattro numeri e sui round bonus. A ogni spin il Top Slot può moltiplicare i premi fino a 50 volte. L’RTP teorico oscilla fra 94% e 96% in base al segmento.

    Dall’Italia è possibile giocare solo su piattaforme autorizzate ADM, e dal 2024 esiste un tavolo italiano dedicato. I limiti di puntata sono compresi tra 0,10 e 1.000 euro al tavolo italiano.

    Per approfondire sul funzionamento del gioco in Italia, si può consultare giocare a crazy time dove trovate statistiche aggiornate, guide su probabilità e frequenze e informazioni sul gioco responsabile.

Leave a Reply

Your email address will not be published. Required fields are marked *