Ardpicprog
 All Files Pages
Host program for controlling the PIC programmer

Ardpicprog is a program that runs on the host machine and controls the process of reading to and writing from a PIC or EEPROM device. It connects via a serial port to the sketch running on the Arduino that implements the PIC or EEPROM programming logic.

The command-line syntax of Ardpicprog is designed to be backwards-compatible with picprog to make it easy to replace invocations of picprog in existing Makefile's and build scripts.

The host program does not implement any specific logic for programming PIC and EEPROM devices. It merely communicates with a sketch running on the Arduino via a serial port and asks it to perform READ, WRITE, ERASE, and other commands. The sketch itself takes care of the low-level details of talking to the device. To support a new device type, the sketch will need to be replaced with an alternative that is familiar with the low-level programming details of the new device. The circuit for the PIC programmer shield may also need to be modified.

Note: the Serial Monitor in the Arduino IDE should be closed while Ardpicprog is in use. Otherwise the monitor may steal some of the serial data that was intended for Ardpicprog and the reading or burning process will fail.

Usage

ardpicprog --quiet -q --warranty --copying --help -h
--device DEVTYPE -d DEVTYPE --pic-serial-port PORT -p PORT
--input-hexfile INPUT -i INPUT --output-hexfile OUTPUT -o OUTPUT
--ihx8m --ihx16 --ihx32 --cc-hexfile CCFILE -c CCFILE --skip-ones
--erase --burn --force-calibration --list-devices --speed SPEED

Common options

–quiet
Suppress the copyright header.
–device DEVTYPE, -d DEVTYPE
Specifies the type of device that is in the programmer; e.g. pic16f84, pic16f628a, etc. If this option is not present or it is set to auto, then Ardpicprog will attempt to autodetect the device in the programmer. Older PIC devices that do not have an identifier word will need the –device option to be specified manually. The –list-devices option can be used to list all supported device types. See also, Supported PIC and EEPROM devices.
–pic-serial-port PORT, -p PORT
Specifies the serial port tty device to use to communicate with the programmer. The default is /dev/ttyACM0 under POSIX systems and COM1 under Windows.
–speed SPEED
Specifies the speed of the serial connection to the programmer. The default is 9600. Other allowable values are 19200, 38400, 57600, 115200, and 230400. Note: the setup() function of the sketch running in the Arduino will need to be modified to use the same speed. This option is specific to Ardpicprog; it does not exist in picprog.

Reading from a PIC or EEPROM device

ardpicprog --output-hexfile OUTPUT --skip-ones
–output-hexfile OUTPUT, -o OUTPUT
Reads the entire contents of the device and writes them in Intel HEX format to OUTPUT.
–skip-ones
Ignores any word from the device that is all-ones; i.e. not set to a specific value.
–ihx8m, –ihx16, –ihx32
Selects the type of HEX file to write to OUTPUT. The default is –ihx16 for low and mid-range PIC devices and –ihx32 for high-range PIC devices.

Burning a PIC or EEPROM device

ardpicprog --erase --burn --input-hexfile INPUT
–erase
Erases the device before burning program, data, and configuration words onto it.
–burn
Burn program, data, and configuration words onto the PIC or EEPROM device. The words will be read back after burning to verify that they have been written correctly.
–input-hexfile INPUT, -i INPUT
Specifies the HEX file whose contents should be written to the device. The input must be in Intel HEX format, be it IHX8M, IHX16, or IHX32. The contents of the HEX file must be suitable for the type of device in the programmer.
–cc-hexfile CCFILE, -c CCFILE
After reading the contents of the input INPUT, write the contents back out to CCFILE. This is intended for debugging purposes to verify that the INPUT was read correctly.
–force-calibration
Forces the calibration words (e.g. OSCCAL) in the PIC device, if any, to be erased and overwritten with the values from the INPUT. If this option is not specified then the programmer will preserve the original calibration words. If –force-calibration is not specified, then calibration words that appear in INPUT will be ignored.
–output-hexfile OUTPUT, -o OUTPUT
After burning, read back the contents of the device and write them to OUTPUT.

Other options

–list-devices
Lists all of the PIC or EEPROM devices that are supported by the programmer sketch running on the Arduino. If your device type does not appear in this list, then you will need a new version of the sketch. This option is specific to Ardpicprog; it does not exist in picprog.
–help
Prints usage information for Ardpicprog.
–copying
Prints the GNU General Public License, Version 3.
–warranty
Prints the warranty disclaimer.

Ignored options

The following options are provided for backwards-compatibility with picprog, but are ignored by Ardpicprog:

–jdm
–k8048
–nordtsc
–rdtsc
–reboot
–slow

Environment

PIC_DEVICE
PIC or EEPROM device to read or burn. Defaults to autodetection of the device type. The –device option overrides this environment variable.
PIC_PORT
Specifies the serial port tty device to use to communicate with the programmer. The default is /dev/ttyACM0 under POSIX systems and COM1 under Windows. The –pic-serial-port option overrides this environment variable.

Exit values

0
The reading or burning process completed with no error.
64
There was a problem with the command-line syntax.
65
INPUT is not in Intel HEX format.
66
Could not open INPUT or CCFILE.
74
An error occurred while talking to the programmer, the burning process failed for some reason (e.g. read-back of contents did not match), or there was a problem when writing to OUTPUT.
76
The device is unknown to the programmer.