Ir ao conteúdo

Compilando para Teensy 3.0 no Windows utilizando Makefile

Boa tarde,

Se você não quer utilizar a Arduino IDE (Teensy IDE?) para programar e enviar seus códigos para o Teensy 3.0 você pode utilizar o Makefile.

A última versão da IDE por enquanto você consegue no Forum do PJRC . Como ele diz, existe um exemplo de Makefile na pasta: “arduino-1.0.3\hardware/teensy/cores/teensy3” porém para utiliza-lo você precisa fazer alguns passos como adicionar o “arduino-1.0.3\hardware\tools\arm-none-eabi\bin” ao seu PATH para que possa utilizar os executaveis desta pasta tranquilamente. Para isso abra o seu Prompt de Comando: Iniciar – Executar – CMD

E em seguida insira o seguinte comando:

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

[Se você não quer entender as modificações que eu realizei va para o final da publicação]

Para garantir que não estragaria o arquivo, fiz uma copia completa do diretório. Em seguida ao executar o

cs-make.exe

Recebia a seguinte mensagem de erro:

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

Verificando o Makefile decidi alterar as configurações das váriaveis para caminho completo já que eu fiz uma copia do teeensy/core.
TOOLSPATH = C:\CAMINHO_PARA_O_ARDUINO\arduino-1.0.3\hardware\tools
LIBRARYPATH = Deixei como estava
COMPILERPATH = C:\CAMINHO_PARA_O_ARDUINO\arduino-1.0.3\hardware\tools\arm-none-eabi\bin

O erro continuou o mesmo, continuando a entender o código percebi os “abspath” e pensei que poderia estar dando problema por eu estar usando caminhos absolutos então removi todos os “$(abspath” lembrando que o mesmo possui um parêntesis que fecha o comando. Então por exemplo:

$(abspath $(COMPILERPATH)) ficará $(COMPILERPATH)

Tentando compilar novamente com cs-make, iniciou a compilar mas no final aconteceu o seguinte erro:

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

Analisando o arquivo encontrei: “path=$(shell pwd)” e me pareceu que pwd não era um comando válido de shell em windows. Testei no console, e não era. Então alterei para “path=$(shell echo %cd%)”. Antes de compilar novamente decidi tentar limpar os arquivos que já foram gerados com cs-make clean

O erro encontrado foi:

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

E me pareceu que ele estava chamando rm -f no windows o que também não é um comando válido. Alterei o comando rf para:

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

Com isso consegui limpar os arquivos. E tentei compilar novamente e funcionou! Realizei uns testes alterando o main.cpp e estava sendo compilado e enviado ao meu Teensy 3.0 como deveria ser. De qualquer forma trabalhar com todos aqueles arquivos e os meus juntos seria um tanto quanto trabalhoso, então copiei todos os arquivos com exceção do Makefile e do main.cpp para teensy/ dentro do meu projeto. Assim eu conseguiria compilar com o Makefile sem ter todos os arquivos em uma confusão. Alterei os CPP e C files para:

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)

As configurações do linker para:

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

E para ficar consistente:

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

E encontrei o seguinte erro:

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

Alterei as CPPFLAGS para:

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

E também lembrei que o clean deveria ser alterado para:

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

E adicionei:

CURRENT_PATH=$(shell echo %cd%)

Logo após as configurações que não devem ser alteradas pelo usuário. Com isso consegui utilizar o Makefile no Windows 7 para compilar e fazer upload para o Teensy 3.0 e mantendo os arquivos separados.

Resumo:
Você deve editar as váriaveis TOOLSPATH , COMPILERPATH e LIBRARYPATH para o seu caminho COMPLETO.
Em seguida crie uma pasta para o seu projeto “Meu_Projeto”
Crie uma pasta dentro dela chamada “teensy” (Meu_Projeto/teensy/)
Copie “arduino-1.0.3\hardware/teensy/cores/teensy3/” para “Meu_Projeto/teensy/” (os sub-diretórios também, mas o Makefile não)
Adicione o Makefile que você encontra no final deste post em “Meu_Projeto”
Copie o arquivo “Meu_Projeto/teensy/main.cpp” para o “Meu_Projeto/main.cpp”
Programe apartir do main.cpp
Compile e faça Upload com cs-make

Makefile para Teensy no Windows

Espero que seja útil,
Matheus

Publicado emCcppTeensywindows

4.154 Comentários

  1. RobertCok RobertCok

    Обращение в клинику необходимо, если самочувствие ухудшается, период запоя длится несколько дней, появляется слабость, тревога, бессонница, тошнота или признаки алкогольной абстиненции. Врач оценивает самочувствие, уточняет стаж употребления, возраст, хронические болезни и прошлый опыт лечения. Если человек пьет долго и самостоятельно выйти из запоя не может, вызов нарколога на дому помогает быстро начать лечение.
    Изучить вопрос глубже – вывод из запоя в стационаре геленджик

  2. Hey! I know this is somewhat off topic but I was wondering if you knew where I could locate a captcha plugin for my comment form? I’m using the same blog platform as yours and I’m having trouble finding one? Thanks a lot!

  3. ????? ???? ????? ??? ???? ??? ?? ??? ??? ???? ????? ?????? ?? ??? ??????. ???? ????? ?? ????? ?? ???????? ?? ???? ??? ??????? ??????? ???????? ????? ???????. ???? ???? ????? ????? ?? ?????? ????? ??? ??????.

    ??? ????? ??????? ?? ?? ???? ?? ??????? — ??????? 3000 ???? ??? ?? ?????. ?? ?????? ??????? ?? Pragmatic Play ? NetEnt ? Play’n GO. ??? ???? Gates of Olympus ? Sweet Bonanza? ???? ???? Book of Dead ??? ??? ??? ????????. ?????? ????????? ???? ?? Evolution? ???? ??? ????? ???? ????? ?? Crazy Time ?? ???? ??????? ??.

    ??????? ????? ??????? ???? ??? ??? ??????? ??????? ??? ثلاث ثمانيات ستارز ??? ?? ?????. ???? ??? ????? ??? ????? ?????? ??? 100% ????? ????? ??????? ?? ?????? ??? wagering ???? ?? ???? ??? ???? ???? ??????.

    ??????? ????? ???????? ?????? ???????? — Visa ? Mastercard ???????? ????? Skrill ? Neteller? ???? ??????? ???????? ??????? ???? ????. ??? ????? ????? ?????? ????? ???? ??????? ???????????.

    ??? ?????? ??? ?? ?????? ???????? ???? ???? ???? ??? ???? ??? ??????? ?? ???????. ??? ???? Curacao ????? ????? ???????. ?? ?????? ??? ????? ?? ????: ???? 888starz apk ?? ?????? ?????? ???? ?????? ?? ??? ??????.

  4. Ich zocke jetzt seit ein paar Monaten und muss ehrlich sagen, ich war anfangs skeptisch, ob so ein Laden mit Coins uberhaupt was taugt. Uber nen Kumpel drauf gekommen, der seit Ewigkeiten bitcoin online poker spielt, und naja – hangen geblieben bin ich trotzdem. Grade fur deutsche Spieler ist das ohnehin manchmal echt zah, was Ein- und Auszahlungen angeht, dazu spater.

    An Spielen gibts echt genug zu tun – ich schatze mal irgendwas um die 2000 Slots, alles in allem. Die ublichen Verdachtigen sind naturlich vertreten: Play’n GO mit dem ganzen Kram, Book of Dead, das lauft alles rund. Der Live-Bereich kommt von Evolution, richtige Croupiers und Shows wie Crazy Time, da hab ich abends schon zu oft. Aber gut, das Kernstuck ist fur mich halt der Pokertisch – Bitcoin Poker eben, darum gehts mir ja.

    Zum Bonus: angeboten wurden mir die ublichen 100% obendrauf plus rund 200 Free Spins, verteilt uber mehrere Tage. Der Umsatz ist 35-fach, ist fair genug fur die Branche, aber lest euch die AGB genau an. Ab und zu laufen kostenlose Turniere und mal was ohne Einzahlung, damit testet man ohne Risiko ein paar Hande. Die aktuellen Aktionen und Codes findet ihr am besten direkt bei poker sites bitcoin falls ihrs genau wissen wollt, lohnt sich.

    Nicht alles ist Gold – Withdrawals. Per Bitcoin gings bei mir meist unter ner Stunde, echt sauber. Aber als ich mal uber Skrill wollte, zog sich das und die Verifizierung zog sich. Visa, Mastercard, Skrill, Neteller gehen alle, aber ganz ehrlich der Witz an der Sache ist, dass keiner gro? mitliest. Mindesteinzahlung waren 20 Euro, Konto anlegen ging in funf Minuten.

    Am Handy lauft es uberraschend gut – ne eigene App gibts fur beide Systeme, und im Browser geht auch alles. Der Kundendienst ist rund um die Uhr erreichbar, die deutschsprachige Hilfe war ok, aber nicht perfekt, zur Not auf Englisch. Zur Lizenz passt es, darauf achte ich. Fur deutsche Spieler, die bitcoin poker spielen reinschnuppern wollen – fur mich passts gerade, mal sehen wie lange.

Deixe um comentário

O seu endereço de e-mail não será publicado. Campos obrigatórios são marcados com *