Changes between Initial Version and Version 1 of arduino/software/cmdline


Ignore:
Timestamp:
Mar 15, 2010, 5:06:57 PM (15 years ago)
Author:
Jürgen Berwein
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • arduino/software/cmdline

    v1 v1  
     1= Compiling an Arduino project on the command line  =
     2By default the Arduino package comes with a simple IDE to edit, compile and upload code to the controller. For small projects this editor gives you a reasonable amount of comfort and features. When editing larger source code the editor becomes annoying. You start to which that you can easily use your favorite editor and compile and upload the produced code the way you are used to it, over the command line.
     3
     4= Download and install the latest (working) Ardunio  =
     5Download and install the latest package either from your distribution repository or directly from the [http://arduino.cc/en/Main/Software Arduino] page. Remember where the installation path is.
     6
     7= Create a Project =
     8Create a project directory where you want to put your source code to.
     9
     10{{{
     11cd  /where/ever/your/project/path/is
     12mkdir PROJECT_NAME
     13}}}
     14The PROJECT_NAME has to be the same name as the main source code file which includes the setup and loop functions. Then you have to copy two files to that directory. First the Makefile which you can download here.
     15
     16A key point that was hard to figure out, was that the Arduino needs to be reset right before a program is uploaded. This is automatically done by the IDE, but not by the Makefile. If this is not in place, you’ll get error messages like:
     17
     18
     19{{{
     20stk500_recv(): programmer is not responding
     21}}}
     22or
     23
     24
     25{{{
     26avrdude: stk500_getsync(): not in sync: resp=0x16
     27avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x34
     28}}}
     29to fix this, create a python script like below and place it either somewhere your $PATH is pointing or simply right into your project directory and make it executable 
     30
     31{{{
     32chmod u+x pulsedtr.py
     33}}}
     34
     35{{{
     36import serial
     37import time
     38import sys
     39
     40if len(sys.argv) != 2:
     41    print "Please specify a port, e.g. %s /dev/ttyUSB0" % sys.argv[0]
     42    sys.exit(-1)
     43
     44ser = serial.Serial(sys.argv[1])
     45ser.setDTR(1)
     46time.sleep(0.5)
     47ser.setDTR(0)
     48ser.close()
     49}}}
     50Prepare your Makefile by changing the following line for your needs.
     51
     52{{{
     53INSTALL_DIR = /install/path/of/arduino
     54PORT = /dev/ttyUSB0
     55MCU = atmega8
     56F_CPU = 16000000
     57}}}
     58Now you can start editing your program file. Save it and compile it by type '''make '''and upload it to your board by '''make upload''' at the command line.
     59
     60Thats it!