Hacking.BuildProcess History

Hide minor edits - Show changes to markup

June 01, 2010, at 09:09 PM by Equipo Traduccion -
Changed lines 4-7 from:

Bastantes cosas suceden antes de que tu código de Arduino se meta en tu placa Arduino. Primero, el entorno de Arduino lleva a cabo algunas pequeñas transformaciones para asegurarse que el código es formalmente correcto para C o C++(dos lenguajes de programación conocidos). Después pasa la compilador (avr-gcc), que trasforma el código legible por el ser humano a instrucciones legibles para la máquina (llamados ficheros objeto). Entonces este codigo se combina (se "linkea" contra) las librerías estándar de Arduino que implementan las funciones básicas como digitalWrite() o Serial.print(). El resultado es un único archivo hexadecimal Intel, que contiene los bytes necesarios para ser guardados en la memoria de programas del chip de la placa Arduino. Este archivo entonces se graba en la placa: transmitiéndolo vía USB o puerto serie, a través del bootloader que lleva incorporado el chip o con hardware de programación externo.

to:

Bastantes cosas suceden antes de que tu código de Arduino se meta en tu placa Arduino. Primero, el entorno de Arduino lleva a cabo algunas pequeñas transformaciones para asegurarse que el código es formalmente correcto para C o C++(dos lenguajes de programación conocidos). Después pasa al compilador (avr-gcc), que trasforma el código legible por el ser humano a instrucciones legibles para la máquina (llamados ficheros objeto). Entonces este codigo se combina (se "linkea" contra) las librerías estándar de Arduino que implementan las funciones básicas como digitalWrite() o Serial.print(). El resultado es un único archivo hexadecimal Intel, que contiene los bytes necesarios para ser guardados en la memoria de programas del chip de la placa Arduino. Este archivo entonces se graba en la placa: transmitiéndolo vía USB o puerto serie, a través del bootloader que lleva incorporado el chip o con hardware de programación externo.

Changed lines 13-69 from:

Transformations to the main sketch file

The Arduino environment performs a few transformations to your main sketch file (the concatenation of all the tabs in the sketch without extensions) before passing it to the avr-gcc compiler.

First, #include "WProgram.h" is added to the top of your sketch. This header file (found in <ARDUINO>/hardware/cores/<CORE>/) includes all the defintions needed for the standard Arduino core.

Next, the environment searches for function definitions within your main sketch file and creates declarations (prototypes) for them. These are inserted after any comments or pre-processor statements (#includes or #defines), but before any other statements (including type declarations). This means that if you want to use a custom type as a function argument, you should declare it within a separate header file. Also, this generation isn't perfect: it won't create prototypes for functions that have default argument values, or which are declared within a namespace or class.

Finally, the contents of the current target's main.cxx file are appended to the bottom of your sketch.

Targets

The Arduino environment supports multiple target boards with different chips (currently, only AVRs), CPU speeds, or bootloaders. These are defined in a board preferences file. Relevant variables include:

<BOARD>.name: the name to display in the Boards menu

<BOARD>.build.mcu: the microcontroller on the board (normally "atmega8" or "atmega168").

<BOARD>.f_cpu: the clock speed at which the microcontroller operates (normally "16000000L", or, for an ATmega168 running on its internal clock, "8000000L").

<BOARD>.core: which sub-directory of the hardware/cores/ directory to link sketches against (normally "arduino").

Also useful is this setting in the main preferences.txt file:

build.verbose: whether or not to print debugging messages while building a sketch (e.g. "false"). If true, will print the complete command line of each external command executed as part of the build process.

Note: that in Arduino 0004 and later, build.extension is unused - the main sketch file is always treated as a .cpp file.

Build process

Sketches are compiled by avr-gcc.

The include path includes the sketch's directory, the target directory (<ARDUINO>/hardware/core/<CORE>/) and the avr include directory (<ARDUINO>/hardware/tools/avr/avr/include/), as well as any library directories (in <ARDUINO>/hardware/libraries/) which contain a header file which is included by the main sketch file.

When you verify a sketch, it is built in a temporary directory in the system temp directory (e.g. /tmp on the Mac). When you upload it, it is built in the applet/ subdirectory of the sketch's directory (which you can access with the "Show Sketch Folder" item in the "Sketch" menu).

The .c and .cpp files of the target are compiled and output with .o extensions to this directory, as is the main sketch file and any other .c or .cpp files in the sketch and any .c or .cpp files in any libraries which are #included in the sketch.

These .o files are then linked together into a static library and the main sketch file is linked against this library. Only the parts of the library needed for your sketch are included in the final .hex file, reducing the size of most sketches.

The .hex file is the final output of the compilation which is then uploaded to the board. During a "Verify" the .hex file is written to /tmp (on Mac and Linux) or \Documents and Settings\<USER>\Local Settings\Temp (on Windows). During upload, it's written to the applet sub-directory of the sketch directory (which you can open with the "Show Sketch Folder" item in the Sketch menu).

Upload process

Sketches are uploaded by avrdude.

The upload process is also controlled by variables in the boards and main preferences files. Those in the boards file include:

<BOARD>.upload.protocol: the protocol that avrdude should use to talk to the board (typically "stk500").

<BOARD>.upload.speed: the speed (baud rate) avrdude should use when uploading sketches (typically "19200").

<BOARD>.upload.maximum_size: the maximum size for a sketch on the board (dependent on the chip and the size of the bootloader).

And in the main preferences file:

upload.verbose: whether or not to dump debugging messages while upload a sketch to a board (defaults to "false").

to:

Cambios en el archivo principal del sketch

El entorno de arduino lleva a cabo unos cambios en archivo principal del sketch (la uniono de todas las pestañas en el sketch que no tienen extensión) antes de pasarlo al copilador avr-gcc.

Primero, añade #include "WProgram.h" al inicio del sketch. Esta cabecera (ubicada en <ARDUINO>/hardware/cores/<CORE>/) incluye todas las definiciones necesarias del núcleo Arduino estándar.

A continuación, el entorno busca las definiciones de las funciones dentro del sketch y crea las declaraciones (prototipos) para las mismas. Estas son insertada después de cualquier comentario inicial, o llamadas al preprocesador (#includes y #defines) pero antes de cualquier otra instrucción (incluyendo las declaraciones de variables). Esto significa que si quieres usar un tipo de variable definida por ti como argumento en una función, la deberás declarar en un archivo de cabecera aparte. Además, este paso no es perfecto, no creara prototipos para funciones que tengan argumentos con valores por defecto, o que estén dentro de un espacio de nombres o clase.

Por ultimo, los contenidos del archivo main.cxx de la plataforma objetivo, se copian al final de tu sketch.

Plataformas objetivo

El entorno de Arduino soporta multiples plataformas objetivo con diferentes chips, (actualmente solo AVRs), velocidad de CPU, o bootloaders. Estas están definidas en una tabla dentro del [[Hacking/Preferences | archivo de preferencias]. Dentro de la variables mas importantes incluye:

<BOARD>.name: El nombre a enseñar en el menú de Placas

<BOARD>.build.mcu: El microcontrolador de la placa(normalmente "atmega168" o "atmega328p").

<BOARD>.f_cpu: La velocidad del reloj a la que el microprocesador funciona, (normalmente "16000000L", o si es un ATmega168 usando su reloj interno "8000000L")

<BOARD>.core: en que subdirectorio se encuentra el directorio hardware/cores/ contra los que vincular los sketches (normalmente "Arduino").

Igualmente útiles pueden ser estos parámetros en el archivo de preferencias generales preferences.txt:

build.verbose: enseñar o no los mensajes de depuración cuando se compila un sketch (ej. false). Si lo definimos a "true·, enseñara los comandos completos que se vayan ejecutando como parte del proceso de compilación.

Nota: a partir de Arduino 004 y posteriores, el parámetro build.extension esta en desuso - el archivo principal del sketch siempre es tratado como un archivo .cpp .

Proceso de compilación

Los Sketches son compilados por avr-gcc.

La ruta de "includes", incluye el directorio del sketch, el directorio de la plataforma objetivo (<ARDUINO>/hardware/core/<CORE>/) y el directorio de "includes" de avr (<ARDUINO>/hardware/tools/avr/avr/include/), al igual que cualquier directorio de librerías en (in <ARDUINO>/hardware/libraries/) cuya cabecera haya sido incluido en el sketch.

Cuando se verifica un sketch ("Run"), se compila en un directorio temporal dentro del directorio temporal del sistema (ej. /tmp en MacOSX). Cuando se graba en la placa, este se compila en el subdirectorio applet/ dentro del directorio del sketch. (al cual puedes acceder con "Ver directorio del sketch" en el menú "Sketch" del entorno)

Los archivos .c y .cpp de la plataforma objetivo son compilados y generan archivos .o en su directorio, al igual que el archivo del sketch y cualquier otro archivo .c o .cpp en cualquiera de las librerías que hayamos incluido en el sketch.

Estos archivos .o entonces son enlazados ("linked") entre ellos en una librería estática y el sketch es enlazado a esta librería. Solo las partes utilizadas de esta librería son incluidas en el archivo binario .hex resultante reduciendo así su tamaño.

El archivo .hex es el resultado final de la compilación y sera cargado en la placa.

Proceso de carga

Los Sketches son cargados por avrdude.

El proceso de carga esta también controlado por variables en los archivos de preferencias principal y de la placa. En los archivos de preferencia de la placa ("board") se incluye:

<BOARD>.upload.protocol: El protocolo que debe usar avrdude para hablar con la placa (normalmente "stk500").

<BOARD>.upload.speed: la velocidad (baudios por segundo) que avrdude debe usar para cargar el sketch (normalmente "57600").

<BOARD>.upload.maximum_size: El tamaño máximo de un sketch en la placa. (depende del chip y el tamaño del bootloader).

Y en el archivo principal de preferencias ("main"):

upload.verbose: si se debe o no mostrar los mensajes de depuración al cargar un sketch en la placa (por defecto "false").

June 01, 2010, at 01:51 AM by Equipo Traduccion -
Changed lines 1-10 from:

Arduino Build Process

Overview

A number of things have to happen for your Arduino code to get onto the Arduino board. First, the Arduino environment performs some small transformations to make sure that the code is correct C or C++ (two common programming languages). It then gets passed to a compiler (avr-gcc), which turns the human readable code into machine readable instructions (or object files). Then, your code gets combined with (linked against), the standard Arduino libraries that provide basic functions like digitalWrite() or Serial.print(). The result is a single Intel hex file, which contains the specific bytes that need to be written to the program memory of the chip on the Arduino board. This file is then uploaded to the board: transmitted over the USB or serial connection via the bootloader already on the chip or with external programming hardware.

Multi-file sketches

A sketch can contain multiple files (tabs). To manage them, click on the right-facing arrow just above the scroll bar near the top of the environment. Tabs have one of four extensions: no extension, .c, .cpp, or .h (if you provide any other extension, the period will be converted to an underscore). When your sketch is compiled, all tabs with no extension are concatenated together to form the "main sketch file". Tabs with .c or .cpp extensions are compiled separately. To use tabs with a .h extension, you need to #include it (using "double quotes" not <angle brackets>).

to:

Proceso de compilación de Arduino

Introducción

Bastantes cosas suceden antes de que tu código de Arduino se meta en tu placa Arduino. Primero, el entorno de Arduino lleva a cabo algunas pequeñas transformaciones para asegurarse que el código es formalmente correcto para C o C++(dos lenguajes de programación conocidos). Después pasa la compilador (avr-gcc), que trasforma el código legible por el ser humano a instrucciones legibles para la máquina (llamados ficheros objeto). Entonces este codigo se combina (se "linkea" contra) las librerías estándar de Arduino que implementan las funciones básicas como digitalWrite() o Serial.print(). El resultado es un único archivo hexadecimal Intel, que contiene los bytes necesarios para ser guardados en la memoria de programas del chip de la placa Arduino. Este archivo entonces se graba en la placa: transmitiéndolo vía USB o puerto serie, a través del bootloader que lleva incorporado el chip o con hardware de programación externo.

Sketches Multi-archivo

Un sketch puede contener múltiples archivos (pestañas). Para manejarlas, haz clic en la flecha de la derecha justo encima del las barras de desplazamiento cerca de la parte superior del entorno. Las pestañas tienen una de las siguientes extensiones, .c, .cpp o .h, si se proporciona otro tipo de extensión esta sera convertida a un añadido al nombre sustituyendo el punto por guión bajo), Cuando un sketch es compilado, todas las pestañas sin extensión serán concatenadas juntas para formas el archivo principal del scketch. Las pestañas con .c o .cpp se compilaran por separado. Para usar pestañas con extensión .h necesitas incluirlo (#include usando "comillas dobles" en vez de <mayor/menor que>).

March 30, 2008, at 06:30 PM by David A. Mellis - updating for the changes in arduino 0011.
Changed lines 15-18 from:

First, any #include statements in the main sketch file are moved to the top of the code. Then #include "WProgram.h" is added to the above them. This header file (found in <ARDUINO>/hardware/cores/<CORE>/) includes all the header files needed for the standard Arduino core.

Next, the environment searches for function definitions within your main sketch file and prepends declarations (prototypes) for them to the top of your sketch. Note that these prototypes will appear before any type declarations or #include statements in your code, meaning that they cannot contain references to custom types.

to:

First, #include "WProgram.h" is added to the top of your sketch. This header file (found in <ARDUINO>/hardware/cores/<CORE>/) includes all the defintions needed for the standard Arduino core.

Next, the environment searches for function definitions within your main sketch file and creates declarations (prototypes) for them. These are inserted after any comments or pre-processor statements (#includes or #defines), but before any other statements (including type declarations). This means that if you want to use a custom type as a function argument, you should declare it within a separate header file. Also, this generation isn't perfect: it won't create prototypes for functions that have default argument values, or which are declared within a namespace or class.

December 21, 2007, at 04:46 PM by David A. Mellis -
Changed lines 23-24 from:

The Arduino environment supports multiple target boards with different chips (currently, only AVRs), CPU speeds, or bootloaders. These are defined in a board preferences file. Relevant variables include:

to:

The Arduino environment supports multiple target boards with different chips (currently, only AVRs), CPU speeds, or bootloaders. These are defined in a board preferences file. Relevant variables include:

December 21, 2007, at 04:45 PM by David A. Mellis -
Changed lines 15-18 from:

First, #include "WProgram.h" is added to the top of the sketch. This header file (found in <ARDUINO>/hardware/cores/<CORE>/) includes all the header files needed for the standard Arduino core.

Next, the environment searches for function definitions within your main sketch file and prepends declarations (prototypes) for them to your sketch.

to:

First, any #include statements in the main sketch file are moved to the top of the code. Then #include "WProgram.h" is added to the above them. This header file (found in <ARDUINO>/hardware/cores/<CORE>/) includes all the header files needed for the standard Arduino core.

Next, the environment searches for function definitions within your main sketch file and prepends declarations (prototypes) for them to the top of your sketch. Note that these prototypes will appear before any type declarations or #include statements in your code, meaning that they cannot contain references to custom types.

October 22, 2007, at 07:00 PM by David A. Mellis - updating for arduino 0010
Changed lines 15-16 from:

First, #include "WProgram.h" is added to the top of the sketch. This header file (found in <ARDUINO>/lib/targets/<TARGET>/) includes all the header files needed for the standard Arduino core.

to:

First, #include "WProgram.h" is added to the top of the sketch. This header file (found in <ARDUINO>/hardware/cores/<CORE>/) includes all the header files needed for the standard Arduino core.

Changed lines 19-20 from:

Finally, as of Arduino 0008, the contents of the current target's main.cxx file are appended to the bottom of your sketch.

to:

Finally, the contents of the current target's main.cxx file are appended to the bottom of your sketch.

Changed lines 23-24 from:

The Arduino environment supports multiple target boards with different chips (currently, only AVRs) or CPU speeds. To configure it for a target, you need to edit the main Arduino preferences file. Relevant variables include:

to:

The Arduino environment supports multiple target boards with different chips (currently, only AVRs), CPU speeds, or bootloaders. These are defined in a board preferences file. Relevant variables include:

<BOARD>.name: the name to display in the Boards menu

<BOARD>.build.mcu: the microcontroller on the board (normally "atmega8" or "atmega168").

<BOARD>.f_cpu: the clock speed at which the microcontroller operates (normally "16000000L", or, for an ATmega168 running on its internal clock, "8000000L").

<BOARD>.core: which sub-directory of the hardware/cores/ directory to link sketches against (normally "arduino").

Also useful is this setting in the main preferences.txt file:

Deleted lines 36-41:

build.target: a sub-directory of <ARDUINO>/lib/targets/ (e.g. "arduino") - sketches will be linked against all .c/.cpp/.o files in this directory.

build.mcu: the microcontroller (e.g. "atmega8").

build.f_cpu: the clock speed (e.g. "16000000L"). Used to define the F_CPU constant when compiling.

Changed lines 43-44 from:

The include path includes the sketch's directory, the target directory (<ARDUINO>/lib/targets/<TARGET>/) and the avr include directory (<ARDUINO>/tools/avr/avr/include/), as well as any library directories (in <ARDUINO>/lib/targets/libraries/) which contain a header file which is included by the main sketch file.

to:

The include path includes the sketch's directory, the target directory (<ARDUINO>/hardware/core/<CORE>/) and the avr include directory (<ARDUINO>/hardware/tools/avr/avr/include/), as well as any library directories (in <ARDUINO>/hardware/libraries/) which contain a header file which is included by the main sketch file.

Changed lines 49-50 from:

As of Arduino 0008, these .o files are then linked together into a static library and the main sketch file is linked against this library. Only the parts of the library needed for your sketch are included in the final .hex file, reducing the size of most sketches.

to:

These .o files are then linked together into a static library and the main sketch file is linked against this library. Only the parts of the library needed for your sketch are included in the final .hex file, reducing the size of most sketches.

Changed lines 55-56 from:

Sketches are uploaded by uisp. The upload process is also controlled by variables in the preferences file. These include:

to:

Sketches are uploaded by avrdude.

The upload process is also controlled by variables in the boards and main preferences files. Those in the boards file include:

<BOARD>.upload.protocol: the protocol that avrdude should use to talk to the board (typically "stk500").

<BOARD>.upload.speed: the speed (baud rate) avrdude should use when uploading sketches (typically "19200").

<BOARD>.upload.maximum_size: the maximum size for a sketch on the board (dependent on the chip and the size of the bootloader).

And in the main preferences file:

Deleted lines 67-84:

upload.programmer: the protocol used for upload. the bootloader on the Arduino board uses "stk500", but some external programmers may use others.

upload.erase: whether or not to erase the board before uploading. Needs to be "false" when uploading normally with the bootloader, but can be set to "true" when using an external ISP.

upload.verify: whether or not to verify the success of the upload. Needs to be "false" when uploading normally with the bootloader, but can be set to "true" when using an external ISP.

upload.maximum_size: the maximum size of the compiled sketch in bytes; anything bigger will result in an error when you attempt to upload. On the Arduino board, this is 7168 as the ATmega8 has 8 Kb of program space, with 1 Kb taken by the bootloader. If using another chip or an external programmer (and thus, no bootloader), you'll want to adjust this accordingly.

serial.download_rate: the baud rate at which programs are upload. Should be "19200" on current Arduino boards; some older boards use "9600". Should be "115200" for an external AVR-ISP.

The actual command line call to uisp might end up looking something like this:

tools/avr/bin/uisp -dpart=atmega8 -dprog=stk500 -dserial=/dev/cu.usbserial-A1000fKl -dspeed=19200 --upload if=/Users/dmellis/Documents/Arduino/led_blink/applet/led_blink.hex

Compiling straight .c or .cpp files

You'll need to create a blank target. Make a directory called "blank" in <ARDUINO>/lib/targets/. Create a blank file called "WProgram.h". You may need to put the .c or .cpp file in an auxilary tab of your sketch (leaving the primary tab blank). You won't be able to use any of the Arduino functions unless you copy the corresponding files from <ARDUINO>/lib/targets/arduino.

August 07, 2007, at 08:39 PM by David A. Mellis -
Changed lines 47-48 from:

The .hex file is the final output of the compilation which is then uploaded to the board. During a "Verify" the .hex file is written to /tmp (on Mac and Linux) or ... (on Windows). During upload, it's written to the applet sub-directory of the sketch directory (which you can open with the "Show Sketch Folder" item in the Sketch menu).

to:

The .hex file is the final output of the compilation which is then uploaded to the board. During a "Verify" the .hex file is written to /tmp (on Mac and Linux) or \Documents and Settings\<USER>\Local Settings\Temp (on Windows). During upload, it's written to the applet sub-directory of the sketch directory (which you can open with the "Show Sketch Folder" item in the Sketch menu).

August 07, 2007, at 08:33 PM by David A. Mellis -
Changed lines 47-48 from:

The .hex file is the final output of the compilation which is then uploaded to the board.

to:

The .hex file is the final output of the compilation which is then uploaded to the board. During a "Verify" the .hex file is written to /tmp (on Mac and Linux) or ... (on Windows). During upload, it's written to the applet sub-directory of the sketch directory (which you can open with the "Show Sketch Folder" item in the Sketch menu).

June 12, 2007, at 06:34 AM by David A. Mellis - updating for changes to arduino 0008
Added lines 19-20:

Finally, as of Arduino 0008, the contents of the current target's main.cxx file are appended to the bottom of your sketch.

Added lines 45-46:

As of Arduino 0008, these .o files are then linked together into a static library and the main sketch file is linked against this library. Only the parts of the library needed for your sketch are included in the final .hex file, reducing the size of most sketches.

January 27, 2007, at 02:55 PM by David A. Mellis -
Deleted lines 2-3:

Warning: this may all change in future releases of Arduino.

December 21, 2006, at 06:47 PM by David A. Mellis -
Added lines 25-26:

build.verbose: whether or not to print debugging messages while building a sketch (e.g. "false"). If true, will print the complete command line of each external command executed as part of the build process.

Added lines 51-52:

upload.verbose: whether or not to dump debugging messages while upload a sketch to a board (defaults to "false").

November 05, 2006, at 04:57 PM by David A. Mellis -
Changed lines 1-2 from:

Arduino build process

to:

Arduino Build Process

Changed lines 5-6 from:

Overview

to:

Overview

Changed lines 9-10 from:

Multi-file sketches

to:

Multi-file sketches

November 05, 2006, at 04:56 PM by David A. Mellis -
Added lines 1-65:

Arduino build process

Warning: this may all change in future releases of Arduino.

Overview

A number of things have to happen for your Arduino code to get onto the Arduino board. First, the Arduino environment performs some small transformations to make sure that the code is correct C or C++ (two common programming languages). It then gets passed to a compiler (avr-gcc), which turns the human readable code into machine readable instructions (or object files). Then, your code gets combined with (linked against), the standard Arduino libraries that provide basic functions like digitalWrite() or Serial.print(). The result is a single Intel hex file, which contains the specific bytes that need to be written to the program memory of the chip on the Arduino board. This file is then uploaded to the board: transmitted over the USB or serial connection via the bootloader already on the chip or with external programming hardware.

Multi-file sketches

A sketch can contain multiple files (tabs). To manage them, click on the right-facing arrow just above the scroll bar near the top of the environment. Tabs have one of four extensions: no extension, .c, .cpp, or .h (if you provide any other extension, the period will be converted to an underscore). When your sketch is compiled, all tabs with no extension are concatenated together to form the "main sketch file". Tabs with .c or .cpp extensions are compiled separately. To use tabs with a .h extension, you need to #include it (using "double quotes" not <angle brackets>).

Transformations to the main sketch file

The Arduino environment performs a few transformations to your main sketch file (the concatenation of all the tabs in the sketch without extensions) before passing it to the avr-gcc compiler.

First, #include "WProgram.h" is added to the top of the sketch. This header file (found in <ARDUINO>/lib/targets/<TARGET>/) includes all the header files needed for the standard Arduino core.

Next, the environment searches for function definitions within your main sketch file and prepends declarations (prototypes) for them to your sketch.

Targets

The Arduino environment supports multiple target boards with different chips (currently, only AVRs) or CPU speeds. To configure it for a target, you need to edit the main Arduino preferences file. Relevant variables include:

build.target: a sub-directory of <ARDUINO>/lib/targets/ (e.g. "arduino") - sketches will be linked against all .c/.cpp/.o files in this directory.

build.mcu: the microcontroller (e.g. "atmega8").

build.f_cpu: the clock speed (e.g. "16000000L"). Used to define the F_CPU constant when compiling.

Note: that in Arduino 0004 and later, build.extension is unused - the main sketch file is always treated as a .cpp file.

Build process

Sketches are compiled by avr-gcc.

The include path includes the sketch's directory, the target directory (<ARDUINO>/lib/targets/<TARGET>/) and the avr include directory (<ARDUINO>/tools/avr/avr/include/), as well as any library directories (in <ARDUINO>/lib/targets/libraries/) which contain a header file which is included by the main sketch file.

When you verify a sketch, it is built in a temporary directory in the system temp directory (e.g. /tmp on the Mac). When you upload it, it is built in the applet/ subdirectory of the sketch's directory (which you can access with the "Show Sketch Folder" item in the "Sketch" menu).

The .c and .cpp files of the target are compiled and output with .o extensions to this directory, as is the main sketch file and any other .c or .cpp files in the sketch and any .c or .cpp files in any libraries which are #included in the sketch.

The .hex file is the final output of the compilation which is then uploaded to the board.

Upload process

Sketches are uploaded by uisp. The upload process is also controlled by variables in the preferences file. These include:

upload.programmer: the protocol used for upload. the bootloader on the Arduino board uses "stk500", but some external programmers may use others.

upload.erase: whether or not to erase the board before uploading. Needs to be "false" when uploading normally with the bootloader, but can be set to "true" when using an external ISP.

upload.verify: whether or not to verify the success of the upload. Needs to be "false" when uploading normally with the bootloader, but can be set to "true" when using an external ISP.

upload.maximum_size: the maximum size of the compiled sketch in bytes; anything bigger will result in an error when you attempt to upload. On the Arduino board, this is 7168 as the ATmega8 has 8 Kb of program space, with 1 Kb taken by the bootloader. If using another chip or an external programmer (and thus, no bootloader), you'll want to adjust this accordingly.

serial.download_rate: the baud rate at which programs are upload. Should be "19200" on current Arduino boards; some older boards use "9600". Should be "115200" for an external AVR-ISP.

The actual command line call to uisp might end up looking something like this:

tools/avr/bin/uisp -dpart=atmega8 -dprog=stk500 -dserial=/dev/cu.usbserial-A1000fKl -dspeed=19200 --upload if=/Users/dmellis/Documents/Arduino/led_blink/applet/led_blink.hex

Compiling straight .c or .cpp files

You'll need to create a blank target. Make a directory called "blank" in <ARDUINO>/lib/targets/. Create a blank file called "WProgram.h". You may need to put the .c or .cpp file in an auxilary tab of your sketch (leaving the primary tab blank). You won't be able to use any of the Arduino functions unless you copy the corresponding files from <ARDUINO>/lib/targets/arduino.

Share