Hi, I like to use "assertions" in my programs to help find problems and help make code that is more reliable. But the standard definitions of assertions for the Teensy 3.0 software doesn't work. Even a simple example made by modifying the standard Blink.ino example shows the problem that pops up while linking. Here's the modified code:
I added the include of assert.h and an assertion check in setup(). This isn't how I'm really using assertions in my code, it's just an example to show the problem. And the problem is that when I build the program the link stage comes up with a bunch of undefined references:
I figure the problem is that the definition of the functions to handle assert errors hasn't been "fixed" for use on the embedded Teensy platform but is instead trying to call functions that would normally be used on a platform with an operating system. I guess I was wondering if anybody had written their own code to handle assertion errors on this platform? I thought I would ask before trying to "roll my own" solution.
Note, you can build this code for a standard AVR Arduino target (eg an Arduino Micro).
I'm not expecting this to be something that goes high on the list of things that are broken with Teensy and need to be fixed. But I did want to at least add it to the list.
Code:
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
*/
#include "assert.h"
// Pin 13 has an LED connected on most Arduino boards.
// Pin 11 has the LED on Teensy 2.0
// Pin 6 has the LED on Teensy++ 2.0
// Pin 13 has the LED on Teensy 3.0
// give it a name:
int led = 13;
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
assert(led <15);
pinMode(led, OUTPUT);
}
I added the include of assert.h and an assertion check in setup(). This isn't how I'm really using assertions in my code, it's just an example to show the problem. And the problem is that when I build the program the link stage comes up with a bunch of undefined references:
C:\arduino\arduino-1.0.5\hardware\tools\arm-none-eabi\bin\arm-none-eabi-gcc -Os -Wl,--gc-sections -mcpu=cortex-m4 -mthumb -TC:\arduino\arduino-1.0.5\hardware\teensy\cores\teensy3\mk20dx128.ld -o C:\froeber\Projects\Kuji_lighter\SmartLighter\Arduino\Build\Blink.cpp.elf C:\froeber\Projects\Kuji_lighter\SmartLighter\Arduino\Build\Blink.cpp.o C:\froeber\Projects\Kuji_lighter\SmartLighter\Arduino\Build\analog.c.o C:\froeber\Projects\Kuji_lighter\SmartLighter\Arduino\Build\eeprom.c.o C:\froeber\Projects\Kuji_lighter\SmartLighter\Arduino\Build\keylayouts.c.o C:\froeber\Projects\Kuji_lighter\SmartLighter\Arduino\Build\mk20dx128.c.o C:\froeber\Projects\Kuji_lighter\SmartLighter\Arduino\Build\nonstd.c.o C:\froeber\Projects\Kuji_lighter\SmartLighter\Arduino\Build\pins_teensy.c.o C:\froeber\Projects\Kuji_lighter\SmartLighter\Arduino\Build\serial1.c.o C:\froeber\Projects\Kuji_lighter\SmartLighter\Arduino\Build\serial2.c.o C:\froeber\Projects\Kuji_lighter\SmartLighter\Arduino\Build\serial3.c.o C:\froeber\Projects\Kuji_lighter\SmartLighter\Arduino\Build\touch.c.o C:\froeber\Projects\Kuji_lighter\SmartLighter\Arduino\Build\usb_desc.c.o C:\froeber\Projects\Kuji_lighter\SmartLighter\Arduino\Build\usb_dev.c.o C:\froeber\Projects\Kuji_lighter\SmartLighter\Arduino\Build\usb_joystick.c.o C:\froeber\Projects\Kuji_lighter\SmartLighter\Arduino\Build\usb_keyboard.c.o C:\froeber\Projects\Kuji_lighter\SmartLighter\Arduino\Build\usb_mem.c.o C:\froeber\Projects\Kuji_lighter\SmartLighter\Arduino\Build\usb_midi.c.o C:\froeber\Projects\Kuji_lighter\SmartLighter\Arduino\Build\usb_mouse.c.o C:\froeber\Projects\Kuji_lighter\SmartLighter\Arduino\Build\usb_rawhid.c.o C:\froeber\Projects\Kuji_lighter\SmartLighter\Arduino\Build\usb_seremu.c.o C:\froeber\Projects\Kuji_lighter\SmartLighter\Arduino\Build\usb_serial.c.o C:\froeber\Projects\Kuji_lighter\SmartLighter\Arduino\Build\yield.c.o C:\froeber\Projects\Kuji_lighter\SmartLighter\Arduino\Build\HardwareSerial1.cpp.o C:\froeber\Projects\Kuji_lighter\SmartLighter\Arduino\Build\HardwareSerial2.cpp.o C:\froeber\Projects\Kuji_lighter\SmartLighter\Arduino\Build\HardwareSerial3.cpp.o C:\froeber\Projects\Kuji_lighter\SmartLighter\Arduino\Build\IntervalTimer.cpp.o C:\froeber\Projects\Kuji_lighter\SmartLighter\Arduino\Build\IPAddress.cpp.o C:\froeber\Projects\Kuji_lighter\SmartLighter\Arduino\Build\main.cpp.o C:\froeber\Projects\Kuji_lighter\SmartLighter\Arduino\Build\Print.cpp.o C:\froeber\Projects\Kuji_lighter\SmartLighter\Arduino\Build\Stream.cpp.o C:\froeber\Projects\Kuji_lighter\SmartLighter\Arduino\Build\Tone.cpp.o C:\froeber\Projects\Kuji_lighter\SmartLighter\Arduino\Build\usb_flightsim.cpp.o C:\froeber\Projects\Kuji_lighter\SmartLighter\Arduino\Build\usb_inst.cpp.o C:\froeber\Projects\Kuji_lighter\SmartLighter\Arduino\Build\WMath.cpp.o C:\froeber\Projects\Kuji_lighter\SmartLighter\Arduino\Build\WString.cpp.o -LC:\froeber\Projects\Kuji_lighter\SmartLighter\Arduino\Build -lm
c:/arduino/arduino-1.0.5/hardware/tools/arm-none-eabi/bin/../lib/gcc/arm-none-eabi/4.7.2/../../../../arm-none-eabi/lib/thumb2\libc.a(lib_a-signalr.o): In function `_kill_r':
signalr.c.text+0x14): undefined reference to `_kill'
c:/arduino/arduino-1.0.5/hardware/tools/arm-none-eabi/bin/../lib/gcc/arm-none-eabi/4.7.2/../../../../arm-none-eabi/lib/thumb2\libc.a(lib_a-signalr.o): In function `_getpid_r':
signalr.c.text+0x28): undefined reference to `_getpid'
c:/arduino/arduino-1.0.5/hardware/tools/arm-none-eabi/bin/../lib/gcc/arm-none-eabi/4.7.2/../../../../arm-none-eabi/lib/thumb2\libc.a(lib_a-fstatr.o): In function `_fstat_r':
fstatr.c.text+0x14): undefined reference to `_fstat'
c:/arduino/arduino-1.0.5/hardware/tools/arm-none-eabi/bin/../lib/gcc/arm-none-eabi/4.7.2/../../../../arm-none-eabi/lib/thumb2\libc.a(lib_a-isattyr.o): In function `_isatty_r':
isattyr.c.text+0x12): undefined reference to `_isatty'
collect2.exe: error: ld returned 1 exit status
I figure the problem is that the definition of the functions to handle assert errors hasn't been "fixed" for use on the embedded Teensy platform but is instead trying to call functions that would normally be used on a platform with an operating system. I guess I was wondering if anybody had written their own code to handle assertion errors on this platform? I thought I would ask before trying to "roll my own" solution.
Note, you can build this code for a standard AVR Arduino target (eg an Arduino Micro).
I'm not expecting this to be something that goes high on the list of things that are broken with Teensy and need to be fixed. But I did want to at least add it to the list.