Question about Teensy3.1 with Makefile (no Arduino IDE)

Status
Not open for further replies.

_joachim

Member
Hello from Germany, this is my first post in this forum :)

I'm using a Teensy 3.1 but I don't like the Arduino IDE. I like to use Eclipse with a Makefile or a similar tool. In my case now I'm taking the Makefile which was installed after installing Arduino with Teensyduino in the path c:\xxx\arduino-1.8.0\hardware\teensy\avr\cores\teensy3\

I start with a simple "blinky" and it is working. Now I'm adding the SPI I/F and the build process is working. Up to now I don't test the SPI I/F.
But I also like to debug via SWD I/F. Therefore I change the compiler/linker optimization in the Makefile to -O0 (instead of(-Os).
After building I got the linker error: xxxx/avr/libraries/SPI/SPI.cpp:264: undefined reference to `SPCR'
When I'm changing back to -Os, everything is fine. But for debugging is -Os very bad. And I'm not a C++ expert (only the very basics) and didn't see the problem.

So I kindly like to ask for an idea, how to solve this.
Thank you very much.

Best regards
Joachim
 
That's a bug. There is only an extern declaration for SPCR, but no actual definition.

Try adding "-fdata-sections -ffunction-sections" to your compiler flags.
 
Thank you for the fix. At the moment I'm not at my desktop PC so I can't test it.
But why linking is working with option -Os ? This is strange for me. Is the compiler/linker deleting code due the optimization and SPI is not really working? I wrote I don't test SPI up to now.
 
The class doesn't have non-static data members and everything is inline. The instance I defined isn't really used, so it can be optimized away.
 
Thank you again for the patch and even for the fast response. Today I'm testing the patch in it is working (only compiling). If the SPI I/F ir really working I don't know up to now ;-) That's my next step.

Edit: Now the SPI is tested and working :D
 
Last edited:
Status
Not open for further replies.
Back
Top