How to make Teensyduino do something different on compile complete?

Status
Not open for further replies.

jwatte

Well-known member
I use Teensyduino on Windows to write Teensy code.
I actually use a Raspberry Pi and a Teensy on a robot, to which I'm connecting remotely.
I'm using plain ssh and vim for developing on the Pi.
I'd like to not have to walk over to the robot, re-plug the Teensy into the Windows machine, flash it, and plug it back, when I want to update the software.

There are two ways I can do this:

1) Use cross-compiler magic to generate ARM/Thumb code for the Teensy on the RPi, using a makefile project, and use vim to edit the Teensy code just like I do for the Pi.
2) Hook the Arduino IDE to somehow use ssh (pscp/plink) to put the compiled HEX file onto the RPi, and then tell the RPi to push the new binary to the Teensy.

If I wanted to try option 2), what would be the easiest way to do this?
 
As I recall this thread talked about loading from a Raspberry Pi: https://forum.pjrc.com/threads/3654-Teensy-loader-for-Raspberry-Pi. The last posting was from 2013.

Note, the load_linux_only.c file (http://www.pjrc.com/teensy/beta/load_linux_only.c) does not seem to have been updated since 2010, and only mentions the mk20dx128 (Teensy 3.0). Hopefully it is still compatible with the 3.1/3.2 (mk20dx256vlh7).

And there was this tar file mentioned: http://www.pjrc.com/teensy/teensy_raspberrypi.tar.gz.
 
Arduino 1.6.x allows customization of its build process with platform.txt. Teensyduino uses this now to run "teensy_post_compile" which is the utility that informs Teensy Loader of Arduino's freshly compiled code.

If you want to change how Arduino works, you could try editing that file. Unfortunately, the syntax is somewhat complex and not well documented, other than in Arduino's source code (which has become far more complex in the last year). But maybe with a little fiddling you could get it to run a program or script of your own design?

Other than this generic advise about where to look, I really can't guide or help your effort to customize Arduino.

On the Raspberry Pi side, at this time your best bet is probably the command line loader. It works great on Raspberry Pi.

Eventually the full official (not Debian's old, modified, poorly maintained) Arduino IDE will come to Raspberry Pi. But that many be many months out. It's in Arduino's hands at this point.
 
Paul, Thanks, that's approximately what I was looking for!

The code for the post-builder is:

Code:
recipe.hooks.postbuild.1.pattern="{compiler.path}/teensy_post_compile" "-file={build.project_name}" "-path={build.path}" "-tools={compiler.path}" "-board={build.board}"

This seems to indicate that I could add a postbuild.2.pattern rule that would call my batch file. Worth a shot!
 
Last edited:
Yeah, that works great! I add this rule:

Code:
recipe.hooks.postbuild.2.pattern="C:\code\mpq_2016\push.bat" "{build.path}\{build.project_name}.hex" "{build.project_name}.hex"

And use this script:
Code:
echo pushing %1
pscp "%1" "pi@10.0.0.49:%2"
plink pi@10.0.0.49 teensy_loader_cli --mcu=mk20dx256 -s "%2"

And Bob's my uncle!

This of course hard-codes a few bits of my particular project, so to get it all flexible is more work, which probably nobody would ever really need :)
 
Status
Not open for further replies.
Back
Top