Go Down

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

xSmurf

I don't want to attack the great work you guys do, but I simply prefer coding with TextMate rather than the Arduino IDE. Getting syntax highlighting was very easy with the help of the keywords.txt file. Right now I'm using AppleScripts from within TextMate to Run & Upload using the Arduino IDE. But this means the IDE has to be open and comes front most. Moreover, the actions take more time. I was wondering, is there any documentation about the build process? What would one do to achieve the same results the IDE does when you compile the code but from within a terminal? The IDE seems to be linking and building all the libraries on the fly. I take it if I were to manually link to the libraries a single avr-gcc command would build everything. Is this right? Apart from that, what else does it do? How does it create the .hex, .rom and .elf files? Uploading seems pretty straight forward though.

Thanks a lot ^.^

P.S. Let me know if you're interested in the bundle, I could put it up on svn or something!
"Pilots believe in a clean living... they never drink wisky from a dirty glass."

xSmurf

#1
Aug 24, 2007, 10:07 pm Last Edit: Aug 24, 2007, 10:57 pm by xSmurf Reason: 1
My bad, I missed the readily available Makefile.  :-[
EDIT:
Works nicely ^-^ however it only seems to work with 0007, or at least not with 0009 (haven't tested 0008). What would be needed to make it work with 0009?
"Pilots believe in a clean living... they never drink wisky from a dirty glass."

mellis

A TextMate bundle would be awesome.  Please post it when you think it's ready.  BTW, there's more information on the build process here: http://www.arduino.cc/en/Hacking/BuildProcess.  There have been a couple of requests for a command line version of the Arduino software (e.g. a Java .jar) that could do things like the preprocessing of sketch code and uploading of sketches.  Would that be useful for this?  (No promises, though.)

xSmurf

#3
Aug 24, 2007, 11:01 pm Last Edit: Aug 24, 2007, 11:03 pm by xSmurf Reason: 1
It would be very useful as the bundle wouldn't need to be updated (much at least) when a new version is released. It would also mean that you could edit from either TM or the IDE without needing to add all the prototypes and linking. Maybe the program could accept a config file for setting the type of uC and board or just as parameters?

EDIT

That would also mean the bundle could possibly be compatible with the E-TextEditor.
"Pilots believe in a clean living... they never drink wisky from a dirty glass."

brianbr

I would vote for a command line script that can be invoked from BBEdit ... on the Mac

cheers ... BBR

xSmurf

"Pilots believe in a clean living... they never drink wisky from a dirty glass."

Daniel

theres' something better than BBedit? Will it work in my cave? I only have a few batteries left in here. :)

D


xSmurf

"Pilots believe in a clean living... they never drink wisky from a dirty glass."

westfw

Is there a "generic" way of getting the Arduino development environment to build a sketch to binary form from the command line?  That would solve this "problem", right?

xSmurf

This is pretty much was David was proposing.
"Pilots believe in a clean living... they never drink wisky from a dirty glass."

Oliver Keller

#10
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.

@david
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...

Oli

last edited: [timestamp=1188259247]

xSmurf

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:
http://rapidshare.com/files/51829818/Arduino_Makfile_Textmate_Bundle.zip.html

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.

cheers,
Oli

mellis

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.

oli

Go Up