Go Down

Topic: Arduino bundle for TextMate (Read 5 times) previous topic - next topic

Oliver Keller

Aug 28, 2007, 01:44 am Last Edit: Aug 28, 2007, 02:02 am by ozel Reason: 1
When working on pure avr-gcc projects (off arduino goodness), I simply hit Comand-R (r like in run) and textmate starts executing the makefile which is living in the same folder.
David once also released a makfile for arduino! See http://www.arduino.cc/en/Hacking/CommandLine
EDIT: @xSmurf: oops! I just see you allready found the makfile... I missed your edit in the second post. I leave the link here as a reference.

But somewhere on the forum I think I've read, the arduino makefile is now somehow out of date ....
I haven't tested it since the 0007 release. I only know that within the current arduino IDE there's no  makefile beeing used besides java to compile everything.

a comandline preprocessing java for arduino code would be gorgeous. Could you still keep the actuall compiling step in a makefile? I think it's a nice standard.
As everything is still avr-gcc/libc compatible so far, it would be just convenient to stay compatible with a  standardised compiling scheme. Have you heard of www.cmake.org? It looks like they try to avoid plattform specific issues like you reported with make in first arduino releases.

A textmate bundle could just issue the java preprocessing comand with a dedicated preferences.txt and then start (c)make...


last edited: [timestamp=1188259247]


I tried using the makefile from 0009 and I modified the path and it built without any issue as far as I could see. As for upload, I modified the avrdude command a little and I get this

Code: [Select]

/Users/mlalonde/Applications/Development/Arduino/arduino-0009/tools/avr/bin/avrdude -C /Users/mlalonde/Applications/Development/Arduino/arduino-0009/tools/avr/etc/avrdude.conf -F -p atmega168 -P /dev/tty.usbserial* -c stk500 -b 19200 -U flash:w:ntsc.hex
avrdude: stk500_getsync(): not in sync: resp=0x30
avrdude: stk500_2_ReceiveMessage(): timeout

If the Makefiles become a reliable way of building outside the IDE, I'm not sure there is a real need for a command line tool.
"Pilots believe in a clean living... they never drink wisky from a dirty glass."

Oliver Keller

Ok, forgett what I said about cmake. It's just another beast as automake/autoconfig...

xSmurf, your' right. We actualy don't need a java comand line when a proper makefile exists.

Last night I decided not to sleep and came up with this:

  • An improved makefile, which features the same auto reset feature which the arduino IDE does on Diecimila boards. I found out, that avrdude supports to toggle the DTR line... :-)
  • The Makefile also allows to compile and work with standard .pde files directly. I does automatic preprocessing by simple shell commands. No additions to standard .pde files are needed... at least with led_blink works like a charm! ;-)
  •  I made a small addition to textmate's standard Makefile Bundle. You have now command-R for compiling and command-U for upload. Just as in the Arduino IDE.
  • I upgraded an old Arduino Extreme V2 (atmega8 board) to auto-reset itself from the serial port, just like Diecimila boards can. It's very easy but usefull and described in the makefile.

But there are also some things that need additional work and thoughts:
  • As I compile and "preprocess" (this word is really to much for what happens in the makefile :) the .pde into a .cpp file, errors that arouse from compiling do refer to that new file. So if you click on an error in the nice Textmate info window, you will be redirected to this file, instead of your .pde file, where you actually wan't to code.
  • The Textmate info windows show output of compiling and uploading only at the end of each process. It would be nice to see everything right when it happens...
  • I couldn't test to include additional .c files. Should it be enough to have .h header files included at the top in the .pde (just like in the Arduino IDE)? Or does the makefile need extra knowledge. Probably putting the extra .c files in $SRC?
  • things I missed so far...

Here's the makefile and the extended TextMate Bundle:

I hope some find this usefull. I enjoy using it! :-) Esp. with auto-reset, the programming is so amazing fast.

Regarding TextMate shortcut keys: Besides CMD-U and CMD-R remember CMD-W to close the compile and upload info windows. Also CMD-< and CMD-> is handy to cycle between all open TextMate windows.



Wow, very nice.

I had no idea that avrdude supported the reset automatically either (right now I'm doing it manually before calling avrdude).  That's awesome, I'll have to try to incorporate it into the next version.  

Do you mind if I include this, or a variant of it, in the next Arduino release?

Also, there is one more preprocessing step that the Arduino environment does, which is to automatically generate prototypes for your functions.  It's a small thing, but it might sketches slightly incompatible between the Makefile and environment.  

Oliver Keller

hi mellis,

of corse you can do with it what you want. It's anyway just a patchwork between different makfiles I found.
You mean, there could be a problem if people don't create a protoype of a self written function before calling their function? I'm shure there is some regular expression for this... how do you filter the protoypes in java? Do you compare against a list of core funcions?

BTW: I think there is an error in the original makefile in targets/arduino:
I think the line that starts with "$(TARGET).elf:" should also depend on $(TARGET).cpp (in my Makefile it is
$(TARGET).pde). Othwerise it didn't recompile on my system if I changed something in $(TAGET).cpp.

Re: avrdude reset. This was a funny discovery. I saw the reset definition for serial bitbangers and thought "hmmm, wait a minute..." ;). The reset line is held low during the whole upload process. Thats OK, when we use a capacitor for the connection just as in the Diecimila boards.
I tested is also with another - rather unusual - usb-serial converter from Silabs (CP2102). It works niceley! So this shouldn't depend on FDTI or other converters.


Go Up