Hello World Teensy 3.0 without Teensyduino

Status
Not open for further replies.

kellydunn

Member
Hello World Teensy 3.0 without Arduino

Hello there!

I've seen a few forum posts on here on how to compile and upload sketches to Teensy 3.0 without using Arduino, but most of them never seem to be resolved or otherwise have become inactive. I've munged together some of the previous efforts into what seems to be like a stripped down "hello world" that could be written in plain C, but it does not run correctly once uploaded to my Teensy 3.0.

My attempts at a hello world program can be found here. It's very similar to blink_fast_Teensy3 from the blink_both package.

My program compiles without error when made with this Makefile, which I cobbled together from various posts on this forum on how to compile code using the arm-none-eabi toolchain.

Once compiled, I'm also able to load the resultant .hex onto my Teensy 3.0 using teensy_loader_cli version 2.1, found here.

However, once the program is uploaded, it does not exhibit the behavior I'd expect; the LED does not blink as intended.

Is there something I'm missing? Uploading pre-compiled example .hex files work, so I'm pretty sure the issue is either in my code or at the compilation step.

Any help would be greatly appreciated!
 
Last edited:
Confused... Arduino is a simple IDE and a large library. Teensy3 has some of the same libraries, redesigned for the Teensy3 target.
The code snippet you show seems to use Arduino libraries.
So is your goal to use the Arduino-like Teensy3 libraries but not the Arduino IDE?

The Eclipse IDE has been adapted so that Teensy3 code can be edited, modularized, etc, with that traditional project and module notion, rather than Auduino's all in one source simplificaition. Maybe that's what you meant?
Using Eclipse, one doesn't need to struggle with a makefile.
 
Confused... Arduino is a simple IDE and a large library. Teensy3 has some of the same libraries, redesigned for the Teensy3 target.
The code snippet you show seems to use Arduino libraries.
So is your goal to use the Arduino-like Teensy3 libraries but not the Arduino IDE?

The Eclipse IDE has been adapted so that Teensy3 code can be edited, modularized, etc, with that traditional project and module notion, rather than Auduino's all in one source simplificaition. Maybe that's what you meant?
Using Eclipse, one doesn't need to struggle with a makefile.

You're correct that I don't want to use the Arduino IDE. In fact, I don't want to use *any* IDE; I want to develop solely with a text editor and the teensy_loader_cli. I understand the value that Eclipse might bring to the table, but I would rather struggle with a Makefile at this point than configure a rather large application in order to do development. As mentioned earlier, I've been able to compile and load my program onto my teensy without the aid of an IDE, but the program is not working; the LED is not blinking as intended.

It's unclear to me if I'm missing some boilerplate code in my program to initialize the Teensy, or if my Makefile is missing something. I downloaded Teensyduino and used the Makefile in /hardware/teensy/cores/teensy3 as directed here. Assuming that others have successfully compiled a program using Teensy3 with this Makefile, I'm more concerned that the issue is in my code, but I can't seem to find anything online that could help me diagnose the issue.
 
Last edited:
Historically, 2 Linux distros have caused tremendous amounts of pain: Gentoo & Arch.

If you're using a toolchain or other software provided by Arch, I would look at that first. Well, actually, I'd just try it with Ubuntu. Then again, this problem may have nothing to do with Arch.... but over the last few years there have been so many problems on those 2 distros, plus a small number on Fedora.
 
Historically, 2 Linux distros have caused tremendous amounts of pain: Gentoo & Arch.

If you're using a toolchain or other software provided by Arch, I would look at that first. Well, actually, I'd just try it with Ubuntu. Then again, this problem may have nothing to do with Arch.... but over the last few years there have been so many problems on those 2 distros, plus a small number on Fedora.

At first glance, it doesn't look like I'm using any software obtained from pacman or aur repositories to build my teensy program; my arm-none-eabi toolchain seems to be a custom build from PJRC. Is there anything in specific that I should be looking for to diagnose this issue further?
 
Just tried compiling my program using the same toolchain on an 64-bit release of Ubuntu 12.04. It successfully compiled, and it appears to have uploaded to my Teensy without an issue.

My program however, still does not appear to be running as intended :(

Any other pointers / things to investigate?
 
Last edited:
Another update: As a sanity check, I decided to use the arduino IDE to compile and upload an example to my teensy. After successfully compiling and uploading the example programs, my teensy is behaving as expected. It appears that these operations are working on my Arch machine, so I'm less convinced it has to do with my host OS.

As an additional test, I tried compiling the arudino example with the Makefile supplied above, but it once again did not behave as intended on the teensy. I think something's up with the Makefile at this point.

I'm not too knowledgeable about the internal workings of the arduino IDE, but I'm interested to learn more about how it compiles code into .hex files that then get verified and uploaded to the teensy behind the scenes. Would anyone be able to give me some more info such that I could continue debugging my compilation step?
 
I just did a quick test with the latest Teensyduino 1.17-rc1. I simply ran "make" in the hardware/teensy/cores/teensy3 directory.

It compiled main.hex and uploaded to a Teensy3 automatically with Teensy Loader. That Teensy3 is blinking quite nicely! At least here on my Ubuntu 12.04 system, it seems to be working.

Here's the complete output.

Code:
paul@preston:~/teensy/arduino-1.0.5/hardware/teensy/cores/teensy3 > make
/home/paul/teensy/arduino-1.0.5/hardware/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 -D__MK20DX128__ -DARDUIO=104 -I.  -c -o analog.o analog.c
/home/paul/teensy/arduino-1.0.5/hardware/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 -D__MK20DX128__ -DARDUIO=104 -I.  -c -o eeprom.o eeprom.c
/home/paul/teensy/arduino-1.0.5/hardware/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 -D__MK20DX128__ -DARDUIO=104 -I.  -c -o keylayouts.o keylayouts.c
/home/paul/teensy/arduino-1.0.5/hardware/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 -D__MK20DX128__ -DARDUIO=104 -I.  -c -o math_helper.o math_helper.c
In file included from math_helper.h:33:0,
                 from math_helper.c:39:
arm_math.h: In function 'arm_pid_q15':
arm_math.h:5329:5: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
/home/paul/teensy/arduino-1.0.5/hardware/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 -D__MK20DX128__ -DARDUIO=104 -I.  -c -o mk20dx128.o mk20dx128.c
/home/paul/teensy/arduino-1.0.5/hardware/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 -D__MK20DX128__ -DARDUIO=104 -I.  -c -o nonstd.o nonstd.c
/home/paul/teensy/arduino-1.0.5/hardware/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 -D__MK20DX128__ -DARDUIO=104 -I.  -c -o pins_teensy.o pins_teensy.c
/home/paul/teensy/arduino-1.0.5/hardware/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 -D__MK20DX128__ -DARDUIO=104 -I.  -c -o serial1.o serial1.c
/home/paul/teensy/arduino-1.0.5/hardware/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 -D__MK20DX128__ -DARDUIO=104 -I.  -c -o serial2.o serial2.c
/home/paul/teensy/arduino-1.0.5/hardware/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 -D__MK20DX128__ -DARDUIO=104 -I.  -c -o serial3.o serial3.c
/home/paul/teensy/arduino-1.0.5/hardware/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 -D__MK20DX128__ -DARDUIO=104 -I.  -c -o touch.o touch.c
/home/paul/teensy/arduino-1.0.5/hardware/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 -D__MK20DX128__ -DARDUIO=104 -I.  -c -o usb_desc.o usb_desc.c
/home/paul/teensy/arduino-1.0.5/hardware/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 -D__MK20DX128__ -DARDUIO=104 -I.  -c -o usb_dev.o usb_dev.c
/home/paul/teensy/arduino-1.0.5/hardware/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 -D__MK20DX128__ -DARDUIO=104 -I.  -c -o usb_joystick.o usb_joystick.c
/home/paul/teensy/arduino-1.0.5/hardware/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 -D__MK20DX128__ -DARDUIO=104 -I.  -c -o usb_keyboard.o usb_keyboard.c
/home/paul/teensy/arduino-1.0.5/hardware/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 -D__MK20DX128__ -DARDUIO=104 -I.  -c -o usb_mem.o usb_mem.c
/home/paul/teensy/arduino-1.0.5/hardware/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 -D__MK20DX128__ -DARDUIO=104 -I.  -c -o usb_midi.o usb_midi.c
/home/paul/teensy/arduino-1.0.5/hardware/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 -D__MK20DX128__ -DARDUIO=104 -I.  -c -o usb_mouse.o usb_mouse.c
/home/paul/teensy/arduino-1.0.5/hardware/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 -D__MK20DX128__ -DARDUIO=104 -I.  -c -o usb_rawhid.o usb_rawhid.c
/home/paul/teensy/arduino-1.0.5/hardware/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 -D__MK20DX128__ -DARDUIO=104 -I.  -c -o usb_seremu.o usb_seremu.c
/home/paul/teensy/arduino-1.0.5/hardware/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 -D__MK20DX128__ -DARDUIO=104 -I.  -c -o usb_serial.o usb_serial.c
/home/paul/teensy/arduino-1.0.5/hardware/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 -D__MK20DX128__ -DARDUIO=104 -I.  -c -o yield.o yield.c
/home/paul/teensy/arduino-1.0.5/hardware/tools/arm-none-eabi/bin/arm-none-eabi-g++ -std=gnu++0x -felide-constructors -fno-exceptions -fno-rtti -Wall -g -Os -mcpu=cortex-m4 -mthumb -nostdlib -MMD -DF_CPU=48000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH -D__MK20DX128__ -DARDUIO=104 -I.  -c -o AudioStream.o AudioStream.cpp
/home/paul/teensy/arduino-1.0.5/hardware/tools/arm-none-eabi/bin/arm-none-eabi-g++ -std=gnu++0x -felide-constructors -fno-exceptions -fno-rtti -Wall -g -Os -mcpu=cortex-m4 -mthumb -nostdlib -MMD -DF_CPU=48000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH -D__MK20DX128__ -DARDUIO=104 -I.  -c -o avr_emulation.o avr_emulation.cpp
/home/paul/teensy/arduino-1.0.5/hardware/tools/arm-none-eabi/bin/arm-none-eabi-g++ -std=gnu++0x -felide-constructors -fno-exceptions -fno-rtti -Wall -g -Os -mcpu=cortex-m4 -mthumb -nostdlib -MMD -DF_CPU=48000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH -D__MK20DX128__ -DARDUIO=104 -I.  -c -o HardwareSerial1.o HardwareSerial1.cpp
/home/paul/teensy/arduino-1.0.5/hardware/tools/arm-none-eabi/bin/arm-none-eabi-g++ -std=gnu++0x -felide-constructors -fno-exceptions -fno-rtti -Wall -g -Os -mcpu=cortex-m4 -mthumb -nostdlib -MMD -DF_CPU=48000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH -D__MK20DX128__ -DARDUIO=104 -I.  -c -o HardwareSerial2.o HardwareSerial2.cpp
/home/paul/teensy/arduino-1.0.5/hardware/tools/arm-none-eabi/bin/arm-none-eabi-g++ -std=gnu++0x -felide-constructors -fno-exceptions -fno-rtti -Wall -g -Os -mcpu=cortex-m4 -mthumb -nostdlib -MMD -DF_CPU=48000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH -D__MK20DX128__ -DARDUIO=104 -I.  -c -o HardwareSerial3.o HardwareSerial3.cpp
/home/paul/teensy/arduino-1.0.5/hardware/tools/arm-none-eabi/bin/arm-none-eabi-g++ -std=gnu++0x -felide-constructors -fno-exceptions -fno-rtti -Wall -g -Os -mcpu=cortex-m4 -mthumb -nostdlib -MMD -DF_CPU=48000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH -D__MK20DX128__ -DARDUIO=104 -I.  -c -o IntervalTimer.o IntervalTimer.cpp
/home/paul/teensy/arduino-1.0.5/hardware/tools/arm-none-eabi/bin/arm-none-eabi-g++ -std=gnu++0x -felide-constructors -fno-exceptions -fno-rtti -Wall -g -Os -mcpu=cortex-m4 -mthumb -nostdlib -MMD -DF_CPU=48000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH -D__MK20DX128__ -DARDUIO=104 -I.  -c -o IPAddress.o IPAddress.cpp
/home/paul/teensy/arduino-1.0.5/hardware/tools/arm-none-eabi/bin/arm-none-eabi-g++ -std=gnu++0x -felide-constructors -fno-exceptions -fno-rtti -Wall -g -Os -mcpu=cortex-m4 -mthumb -nostdlib -MMD -DF_CPU=48000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH -D__MK20DX128__ -DARDUIO=104 -I.  -c -o main.o main.cpp
/home/paul/teensy/arduino-1.0.5/hardware/tools/arm-none-eabi/bin/arm-none-eabi-g++ -std=gnu++0x -felide-constructors -fno-exceptions -fno-rtti -Wall -g -Os -mcpu=cortex-m4 -mthumb -nostdlib -MMD -DF_CPU=48000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH -D__MK20DX128__ -DARDUIO=104 -I.  -c -o Print.o Print.cpp
/home/paul/teensy/arduino-1.0.5/hardware/tools/arm-none-eabi/bin/arm-none-eabi-g++ -std=gnu++0x -felide-constructors -fno-exceptions -fno-rtti -Wall -g -Os -mcpu=cortex-m4 -mthumb -nostdlib -MMD -DF_CPU=48000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH -D__MK20DX128__ -DARDUIO=104 -I.  -c -o Stream.o Stream.cpp
/home/paul/teensy/arduino-1.0.5/hardware/tools/arm-none-eabi/bin/arm-none-eabi-g++ -std=gnu++0x -felide-constructors -fno-exceptions -fno-rtti -Wall -g -Os -mcpu=cortex-m4 -mthumb -nostdlib -MMD -DF_CPU=48000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH -D__MK20DX128__ -DARDUIO=104 -I.  -c -o Tone.o Tone.cpp
/home/paul/teensy/arduino-1.0.5/hardware/tools/arm-none-eabi/bin/arm-none-eabi-g++ -std=gnu++0x -felide-constructors -fno-exceptions -fno-rtti -Wall -g -Os -mcpu=cortex-m4 -mthumb -nostdlib -MMD -DF_CPU=48000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH -D__MK20DX128__ -DARDUIO=104 -I.  -c -o usb_flightsim.o usb_flightsim.cpp
/home/paul/teensy/arduino-1.0.5/hardware/tools/arm-none-eabi/bin/arm-none-eabi-g++ -std=gnu++0x -felide-constructors -fno-exceptions -fno-rtti -Wall -g -Os -mcpu=cortex-m4 -mthumb -nostdlib -MMD -DF_CPU=48000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH -D__MK20DX128__ -DARDUIO=104 -I.  -c -o usb_inst.o usb_inst.cpp
/home/paul/teensy/arduino-1.0.5/hardware/tools/arm-none-eabi/bin/arm-none-eabi-g++ -std=gnu++0x -felide-constructors -fno-exceptions -fno-rtti -Wall -g -Os -mcpu=cortex-m4 -mthumb -nostdlib -MMD -DF_CPU=48000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH -D__MK20DX128__ -DARDUIO=104 -I.  -c -o WMath.o WMath.cpp
/home/paul/teensy/arduino-1.0.5/hardware/tools/arm-none-eabi/bin/arm-none-eabi-g++ -std=gnu++0x -felide-constructors -fno-exceptions -fno-rtti -Wall -g -Os -mcpu=cortex-m4 -mthumb -nostdlib -MMD -DF_CPU=48000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH -D__MK20DX128__ -DARDUIO=104 -I.  -c -o WString.o WString.cpp
/home/paul/teensy/arduino-1.0.5/hardware/tools/arm-none-eabi/bin/arm-none-eabi-gcc -Os -Wl,--gc-sections -mcpu=cortex-m4 -mthumb -Tmk20dx128.ld -o main.elf analog.o eeprom.o keylayouts.o math_helper.o mk20dx128.o nonstd.o pins_teensy.o serial1.o serial2.o serial3.o touch.o usb_desc.o usb_dev.o usb_joystick.o usb_keyboard.o usb_mem.o usb_midi.o usb_mouse.o usb_rawhid.o usb_seremu.o usb_serial.o yield.o AudioStream.o avr_emulation.o HardwareSerial1.o HardwareSerial2.o HardwareSerial3.o IntervalTimer.o IPAddress.o main.o Print.o Stream.o Tone.o usb_flightsim.o usb_inst.o WMath.o WString.o -lm
/home/paul/teensy/arduino-1.0.5/hardware/tools/arm-none-eabi/bin/arm-none-eabi-size main.elf
   text	   data	    bss	    dec	    hex	filename
  36860	   1584	   2012	  40456	   9e08	main.elf
/home/paul/teensy/arduino-1.0.5/hardware/tools/arm-none-eabi/bin/arm-none-eabi-objcopy -O ihex -R .eeprom main.elf main.hex
/home/paul/teensy/arduino-1.0.5/hardware/tools/teensy_post_compile -file=main -path=/home/paul/teensy/arduino-1.0.5/hardware/teensy/cores/teensy3 -tools=/home/paul/teensy/arduino-1.0.5/hardware/tools
/home/paul/teensy/arduino-1.0.5/hardware/tools/teensy_reboot
 
Could you maybe describe how I can archive the same on my mac. I currently use arduino to program, but would love to use another text editor. I know that I could use the arduino setting "external editor", but I don't like to run arduino as separate app.

I want to use Chocolat for Mac, which supports running of makefiles.

Let's imagine I used chocolat, wrote an arduino code and saved it as .ino. What would be my next step? What do I need to edit in the makefile or what do I need to do with it? Thanks!
 
I just did a quick test with the latest Teensyduino 1.17-rc1. I simply ran "make" in the hardware/teensy/cores/teensy3 directory.

It compiled main.hex and uploaded to a Teensy3 automatically with Teensy Loader. That Teensy3 is blinking quite nicely! At least here on my Ubuntu 12.04 system, it seems to be working.

I downloaded the latest teensyduino suite, and tried my hand at compiling the example listed therin, and after compiling and uploading on my Arch machine, it seems to be working nicely :)

I even used my Makefile in the same directory, and it produces similar results.

The issue now however, is that if I try to compile my code outside of this directory (read: in some other workspace), it will result in a non-blinking teensy. Would you happen to know how I could alter the compile step such that I can develop, build, and upload in a separate working directory?
 
Last edited:
Could you maybe describe how I can archive the same on my mac.

Pretty much exactly the same way as using Linux.

But first, you'll need to install the Xcode command line tools, because Mac OS-X doesn't come with "make". You might be able to get this free from Apple's app store, or you might need to create a free developer account (they'll show you lots of offers for a $99 account, which is only needed for things like signing apps). There are lots of pages like this one with info about Xcode command line tools.

Then just open a Terminal (from Applications > Utilities). You need to use the "cd" command to change to the directory where the "hardware/teensy/cores/teensy3" files are located. On my mac, I put a copy of Arduino 1.0.5 in my home directory and installed Teensyduino 1.17-rc1. Arduino is a directory named "Arduino.app", and the hardware folder is in "Contents/Resources/Java". Then just type "make".

Here's a screenshot showing the 2 to commands. Just use "cd" to change to the directory, then "make" to build the code.

screen1.png
(click for full size)

It's really that easy. Just 2 commands. The hardest part is getting Xcode without paying Apple $99.

Here's the result:

screen2.png

That's it. The last command runs Teensy Loader, which programs the code onto your Teensy 3.0. As you can see from the screenshots, I just verified it works with Arduino 1.0.5 with Teensyduino 1.17-rc1 installed. I tested on a Macbook Pro with OS-X 10.7.

It's also probably possible to make this work with other programs that use make. But I can't help with those programs. Before you try something more complex, I would highly recommend you test it exactly as I have done in these screenshots, just run "make" from a Terminal in the correct directory, so you can verify it really does work.
 
Last edited:
Another update: I got my program compiling and running on my teensy3 as expected! The issue was that my Makefile was not grabbing any of the supplementary objects in the arduino-1.0.5/hardware/teensy/cores/teensy3 directory. I've updated my Makefile to reflect the changes for anyone who is curious.

However, this assumes that all of the supplementary objects in that directory have been compiled already and that the compiled main.o has been removed (you'll get an error about multiple definitions of main, otherwise).

Would it be valuable to distribute these supplementary objects as a static library? I imagine that it might be useful for people who might want to develop outside of an IDE.
 
You could potentially have a Makefile rule that builds the static library, using ar/ranlib for the target toolchain. Under Linux with Gnu Make, you could use the Make shell rules to build the list of objects in the supplementary object directory without having to list them all, using something like sed -e to skip main.o. I'm don't know if Windows/Mac make environments can do that.

Note, if you have multiple libraries, or you don't use ranlib, you might need to bracket all of the libraries with --start-group and --end-group directives.

Quoting from the friendly documentation:
`-( ARCHIVES -)'
`--start-group ARCHIVES --end-group'
The ARCHIVES should be a list of archive files. They may be
either explicit file names, or `-l' options.

The specified archives are searched repeatedly until no new
undefined references are created. Normally, an archive is
searched only once in the order that it is specified on the
command line. If a symbol in that archive is needed to resolve an
undefined symbol referred to by an object in an archive that
appears later on the command line, the linker would not be able to
resolve that reference. By grouping the archives, they all be
searched repeatedly until all possible references are resolved.

Using this option has a significant performance cost. It is best
to use it only when there are unavoidable circular references
between two or more archives.
 
Glad you got it working with your makefile.

The only makefile I actually test and support is the example makefile in hardware/teensy/cores/teensy3.

Would it be valuable to distribute these supplementary objects as a static library? I imagine that it might be useful for people who might want to develop outside of an IDE.

How would this handle the many different combinations of things like F_CPU, USB_SERIAL and other USB types, keyboard layouts and other configurable parameters?
 
How would this handle the many different combinations of things like F_CPU, USB_SERIAL and other USB types, keyboard layouts and other configurable parameters?

To be honest, I'm not entirely sure what the requirement would be for the "different combinations". Would the goal be to provide a certain subset of the supplementary objects such that it doesn't take up as much space as compiling against the entire suite?

Maybe in that case there could be an additional configure step where a user could specify which types of supplementary libraries they would like to compile against, which could then alter the Makefile accordingly?

It's fair if you only support the Makefile in the /hardware/teensy/cores/teensy3/ folder, I'm just brainstorming for those who might also want a similar workflow as I :)
 
Hi,
I am new to Teensy (bought 3.1) and tested the blink test successfully.
I am interested in the bare metal kind of build without Arduino, but would like to have the feature on loading the f/w via the USB.
So, apart from the "teensy_loader_cli" on the PC side do I need to use any library (teensy loader) in my f/w ? or will the MINI54TAN - F/w take care of receiving the f/w and loading it into the Freescale controller ?
Regards,
Vignesh
 
Status
Not open for further replies.
Back
Top