sprintf() definition location within Teensyduino.

Status
Not open for further replies.

garvamel

Member
Hello!

I'm working with a Teensy 3.2 on PlatformIO, and I just noticed the framework it has for teensy doesn't support sprintf() with floats. I'd like to add it from the teensyduino framework, but I don't have a clue to where it is located.

Thanks in advance!
 
sprintf is part of libc (which comes with the toolchain). The standard ARM toolchain uses newlib as libc with floating point support for sprintf disabled by default. To enable float support, you need to append "-u _printf_float" to your link flags.

I have no idea how PlatformIO works. With a standard Arduino/Teensyduino, you can edit "arduino/hardware/teensy/avr/boards.txt" and change the link options, e.g. change:
teensy31.build.flags.libs=-larm_cortexM4l_math -lm
to:
teensy31.build.flags.libs=-larm_cortexM4l_math -lm -u _printf_float
 
sprintf is part of libc (which comes with the toolchain). The standard ARM toolchain uses newlib as libc with floating point support for sprintf disabled by default. To enable float support, you need to append "-u _printf_float" to your link flags.

I have no idea how PlatformIO works. With a standard Arduino/Teensyduino, you can edit "arduino/hardware/teensy/avr/boards.txt" and change the link options, e.g. change:
teensy31.build.flags.libs=-larm_cortexM4l_math -lm
to:
teensy31.build.flags.libs=-larm_cortexM4l_math -lm -u _printf_float

Brilliant! I will try this out tomorrow! It's super easy to modify compilation/link flags in platformIO.

So far platformIO is quite nice in terms of project management and ease of use, but works mainly on Atom text editor (kinda slow and buggy sometimes) and I'm a Sublime guy. I'd recommend trying it out though.
 
Brilliant! I will try this out tomorrow! It's super easy to modify compilation/link flags in platformIO.

So far platformIO is quite nice in terms of project management and ease of use, but works mainly on Atom text editor (kinda slow and buggy sometimes) and I'm a Sublime guy. I'd recommend trying it out though.

I'm using CLion for editing my PlatformIO projects. I feel right at home, because my day job involves using IntelliJ IDEA (Java, Scala, Python).

The syntax highlighting is pretty good.. it's even sensitive to defined headers, and will fold code blocks that won't be included because of #ifdef and friends. Screen Shot 2016-09-01 at 10.32.10 PM.png
 
I'm using CLion for editing my PlatformIO projects. I feel right at home, because my day job involves using IntelliJ IDEA (Java, Scala, Python).

The syntax highlighting is pretty good.. it's even sensitive to defined headers, and will fold code blocks that won't be included because of #ifdef and friends.View attachment 7988

Looks nice, but the pay wall is a big no no, I already have a Sublime Text license.
 
sprintf is part of libc (which comes with the toolchain). The standard ARM toolchain uses newlib as libc with floating point support for sprintf disabled by default. To enable float support, you need to append "-u _printf_float" to your link flags.

I have no idea how PlatformIO works. With a standard Arduino/Teensyduino, you can edit "arduino/hardware/teensy/avr/boards.txt" and change the link options, e.g. change:
teensy31.build.flags.libs=-larm_cortexM4l_math -lm
to:
teensy31.build.flags.libs=-larm_cortexM4l_math -lm -u _printf_float

I love you. Worked perfectly and crisis averted. I wasted way too many hours on this yesterday -.-
 
So far platformIO is quite nice in terms of project management and ease of use, but works mainly on Atom text editor (kinda slow and buggy sometimes) and I'm a Sublime guy. I'd recommend trying it out though.
I dislike PlatformIO. Atom doesn't fully honor my font preferences (some fonts look like crap, I have Cleartype disabled), it crashes, it sometimes hangs with 100% CPU usage. PlatformIO doesn't ask for an install location, it dumps all its binaries into my home directory (no thank you). There doesn't seem to be an easy way to have multiple Arduino / Teensyduino versions or compiler versions, ...

I'm using CMake projects (Ninja build backend) with QtCreator. All the syntax highlighting, #define recognition/highlighting (the CMake build configuration is checked), auto-completion, ... is there. I can do a full rebuild (including Teensy core) in 1.3 seconds (PlatformIO takes 2.6s). A build of just the sketch and generating the .hex file takes 300 milliseconds (PlatformIO takes 1s).
 
I dislike PlatformIO. Atom doesn't fully honor my font preferences (some fonts look like crap, I have Cleartype disabled), it crashes, it sometimes hangs with 100% CPU usage. PlatformIO doesn't ask for an install location, it dumps all its binaries into my home directory (no thank you). There doesn't seem to be an easy way to have multiple Arduino / Teensyduino versions or compiler versions, ...

I'm using CMake projects (Ninja build backend) with QtCreator. All the syntax highlighting, #define recognition/highlighting (the CMake build configuration is checked), auto-completion, ... is there. I can do a full rebuild (including Teensy core) in 1.3 seconds (PlatformIO takes 2.6s). A build of just the sketch and generating the .hex file takes 300 milliseconds (PlatformIO takes 1s).

That is sadly all true, haha. But it is an improvement over my shitty project management skills.

I will definitely try your setup as well. Any recommendations or tips? I'm on OSX.
 
Status
Not open for further replies.
Back
Top