Bonn, Germany
Offline
God Member
Karma: 0
Posts: 903
|
 |
« on: September 24, 2009, 05:28:34 am » |
What change would like to see? I would like to see command-line parameters for the ide to pass a .pde file for compilation and or compilation&upload, much like the two buttons, yet as simple as calling a compiler. This would, in my imagine, be something like:
Compiling only: arduino -c "file" [-mcu "328"]
Compile and Upload arduino -c "file" -u [-mcu "328"] [-p "com3"]
For the whole matter i would suggest the following paramters:
c "file" - Compile the file with the target settings of the IDE u - Upload to Port already set inside the IDE
Optional: -mcu - Override the Target device -p - Override the standard port
Any callbacks could stay the same as inside the IDE.
Why? This would enable people (like me) using external editors to simply build via commandline. Currently external editors are only supported with having the IDE opened, this woul remove that factor and would also make it easier for people writing their own IDEs to keep up with Arduino Syntax and Includes.
Would this cause any incompatibilities with previous versions? If so, how can these be mitigated? I cant think of any incompatibilities. -------------------------------------------------
Just mirrored from the google code's page.
|
|
|
|
|
Logged
|
Believe me, Mike, I calculated the odds of this succeeding against the odds I was doing something incredibly stupid[ch8230] and I went ahead anyway.
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 11
Arduino rocks
|
 |
« Reply #1 on: October 16, 2009, 11:19:08 am » |
I fully agree that command-line development should be as easy as the IDE, but with the choice of editor and without the need for a graphical environment in which to run the IDE. I've made a relatively gigantic wrapper script for the Arduino Makefile to help accomplish this - it would have been simpler to just create a new script + Makefile from scratch, but the advantage of wrapping the original Makefile is that I don't need to maintain the script much when Arduino is updated. The script itself is intended only for Linux (although other *nix environments should work, too, but command-line setup hasn't been made as easy for e.g. Mac OS X), and it's currently available here: http://arkku.com/misc/arduino_make.shThe way it works is you define some environmental variables (hopefully just once) to set the location of your Arduino installation, the device node to access the device (preferably something like /dev/arduino created via udev rules) and then a new program can be made and uploaded like so: mkdir MyProgram cd MyProgram edit MyProgram.pde ardmake ardmake upload (Where ardmake is what I renamed the script to in my local installation, the full name would be awkward to type every time.) It strives to autodetect libraries from the #include-directives in a manner similar to Arduino, and does so recursively (i.e. libraries can use other libraries), and supports custom library paths. Settings for the microcontroller are all read from Arduino's boards.txt (an environmental variable is used to set the board name, e.g. "diecimila" or "sanguino" or whatever). I've also put in some support for easy flashing with AVRISP and AVRDragon, including fuses and bootloaders. Of course, all of this is just tested on my system (Ubuntu Linux 9.04, avr-gcc and avrdude installed from Ubuntu packages)
I'm releasing the script in the hope that someone else will find it useful. But I haven't touched the Arduino IDE in six months now; everything I've needed to do has been done on the command-line via the script.
|
|
|
|
« Last Edit: October 16, 2009, 11:25:59 am by Arkku »
|
Logged
|
|
|
|
|
0
Offline
Sr. Member
Karma: 0
Posts: 388
|
 |
« Reply #2 on: October 19, 2009, 08:27:41 pm » |
Arkku, that is a very professional job you did there. Compliments on your work.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 11
Arduino rocks
|
 |
« Reply #3 on: October 31, 2009, 09:59:07 pm » |
Thanks, and also thanks for pointing out the typo in the instructions, I've uploaded a corrected version to the same place. =)
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 4
Arduino rocks
|
 |
« Reply #4 on: November 25, 2009, 01:08:27 am » |
Couple things. First off this script looks very promising for cli development. One issue is that there is no "reboot" so you either have to press the button manually or, you get: avrdude: ser_recv(): programmer is not responding avrdude: stk500_recv(): programmer is not responding anywho, I have gotten a .hex successfully uploaded, yet it isn't working on the arduino? http://pastie.org/714116There is a paste of my program, and upload log. Any help would be much appreciated.
|
|
|
|
« Last Edit: November 25, 2009, 01:08:44 am by fsk141 »
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 4
Arduino rocks
|
 |
« Reply #5 on: November 25, 2009, 02:21:14 am » |
I fixed the upload error by dropping arduino 0017 into my home dir '/home/fsk141/arduino' I forgot that it needs write permission  . Anywho, the only thing not working is the reset, and that should be fairly straightforward.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 4
Arduino rocks
|
 |
« Reply #6 on: November 25, 2009, 04:08:16 am » |
perl -MDevice::SerialPort -e 'Device::SerialPort->new("/dev/ttyUSB0")->pulse_dtr_on(1000)'; This is the only command that I can get to refresh the DTR  Anywho, I've been trying to implement this in the script, but keep getting errors  ... 918 do_autoreset: 919 \t@echo Sending reset to prepare for upload... 920 #\tstty -F $(PORT) hupcl || true 921 \tperl -MDevice::SerialPort -e 'Device::SerialPort->new("/dev/ttyUSB0")->pulse_dtr_on(1000)'; 922 \t@echo
Error... /home/fsk141/.scripts/ardmake: line 921: syntax error near unexpected token `(' /home/fsk141/.scripts/ardmake: line 921: `\tperl -MDevice::SerialPort -e 'Device::SerialPort->new("/dev/ttyUSB0")->pulse_dtr_on(1000)';'
|
|
|
|
« Last Edit: November 25, 2009, 04:10:47 am by fsk141 »
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 11
Arduino rocks
|
 |
« Reply #7 on: November 25, 2009, 02:44:48 pm » |
Hi, The stty-command works for me, and I'm hesitant to add a Perl-dependency to the script itself. However, if the Perl-command works for you, try the following (at the place where you inserted it): \tperl -MDevice::SerialPort -e "Device::SerialPort->new(\"$(PORT)\")->pulse_dtr_on(1000);"
(Untested, I don't have the required Perl library installed.)
|
|
|
|
« Last Edit: November 25, 2009, 02:51:08 pm by Arkku »
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 11
Arduino rocks
|
 |
« Reply #8 on: November 25, 2009, 05:31:24 pm » |
As for the complied code not running, I'm not sure what might be wrong. I never had any problems uploading code that compiles properly, and I just tried your LED.pde successfully.
Have you set the ARDUINO_BOARD environmental variable to match the board you are using? It defaults to "diecimila" (as it happens to be what I have), but newer boards should use "atmega328" or "mega". (Check out hardware/boards.txt in your Arduino dir for boards types.)
I assume the same program works for you from the Arduino IDE?
Let me know if there's something that needs fixing in the script; just because it's always worked for me doesn't mean it works for anyone else. The defaults are also rather selfishly tuned for my installation; but all the crucial stuff can be overridden with environmental variables.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 11
Arduino rocks
|
 |
« Reply #9 on: November 28, 2009, 11:29:46 pm » |
Update: We seem to have solved the reset issue discussed above. I've also fixed a few other bugs and rewritten most of the configuration to be somewhat more user-friendly (although the target audience of this script is still the experienced command-line user, as others will be using the IDE). The new version is now available. I should probably make a web-page to document it better, but the helps are also rewritten so it might be easier to get into.
|
|
|
|
|
Logged
|
|
|
|
|
Forum Administrator
Cambridge, MA
Offline
Faraday Member
Karma: 7
Posts: 3532
|
 |
« Reply #10 on: November 29, 2009, 07:58:47 pm » |
You should also try the latest version of avrdude (in SVN: https://savannah.nongnu.org/svn/?group=avrdude). It should perform the auto-reset automatically using the "arduino" programmer type. It would be great to know if that removes the need to set HUPCL on the serial port.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 11
Arduino rocks
|
 |
« Reply #11 on: December 05, 2009, 10:12:56 pm » |
Hi mellis,
The latest avrdude also does do the trick, so I changed the script to try to detect when the avrdude being used supports the "arduino" programmer type and switch to using it with the "upload" and "download" targets. (The old behaviour with the stty + sleep reset, which seemed to fix the reset issues described above without resorting to Perl, is accessible by using "upload_autoreset" and "download_autoreset" instead.)
Users of the script, please let me know if these changes broke something, e.g. if the avrdude reset turns out to be less reliable than the stty + sleep reset. The new version of the script is at the old location.
|
|
|
|
« Last Edit: December 05, 2009, 10:14:13 pm by Arkku »
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 11
Arduino rocks
|
 |
« Reply #12 on: December 08, 2009, 04:30:43 pm » |
Added an experimental "serial monitor" to the script; I think this completes the feature set of the command-line environment to include everything (and more) that's in the current graphical IDE (sans editor capabilities, of course, but vim takes care of that; after all, free choice of editor is probably the primary reason why people like me use the command-line environment).
Of course, on the downside the script is rather Linux-specific and in many places something of a huge kludge. =)
|
|
|
|
|
Logged
|
|
|
|
|
Belgium
Offline
Newbie
Karma: 0
Posts: 3
|
 |
« Reply #13 on: December 29, 2009, 04:36:42 pm » |
Awesome! Thank you so much for sharing this! Compile and upload are working perfectly for me on Ubuntu 9.10. Serial isn't though (not really a big issue personally, I'm fine using screen for now.) It's giving me the following error: Starting serial monitor on port /dev/ttyUSB0 at 115200 bps. Your input will be sent to the serial port. Press Ctrl-C to stop.
ardmake: 769: cannot create /dev/ttyUSB0: Invalid argument The same happens when I run it as root. When using the following it works fine: stty -F /dev/ttyUSB0 cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts && screen /dev/ttyUSB0 115200 And again thanks for sharing, this was really what I needed at the moment!
|
|
|
|
|
Logged
|
|
|
|
|
|