pkcmd_lx_usage - Anobium/PICKitPlus GitHub Wiki
Introduction
These are usage instructions. We assume a PICkit programmer and you are using the programmer as the power source.
In the examples below substitute %chipname% with the name of your target chip, and substitute %Filename% with the path and filename of your hex file.
To program all memory regions (except userids) and leave 5v on from the PICkit programmer:
-w -p%ChipModel% -f%FileName% -mpec -zv -a5
To program all memory regions at 3.3v and leave the power on afterward:
-w -p%ChipModel% -f%FileName% -mpec -zv -a3.3
To program all memory regions using an external power source:
-p%ChipModel% -f%FileName% -mpec
To program config and program memories whilst retaining eeprom contents, using external power:
-p%ChipModel% -f%FileName% -mpc
Commands
Command | Parameter | Explanation | Usage |
---|---|---|---|
-2 |
No parameter |
-2 Selects a PICKit 2 programmer only. The application can be forced to use a PICKit 2 programmer. This is useful when you have more than one programmer attached. |
Usage: |
-3 |
No parameter |
-3 Selects a PICKit 3 programmer only. The application can be forced to use a PICKit 3 programmer and ignore any PICKit 2 devices. This is useful when you have more than one programmer attached. |
Usage: |
--devicelist |
--devicelist List all supported devices. This is an exclusive command. Other command line parameters will be ignored. |
Usage: You may wish to pipe or redirect the output to a file. For example: --devicelist | more Will show the information in pages using the |
|
--devicelist-csv |
--devicelist-csv List all supported devices in CSV format. This is an exclusive command. Other command line parameters will be ignored. |
Usage: You may wish to pipe or redirect the output to a file. |
|
--family |
family number |
--family Use automatic selection for the attached microcontroller within the family of microcontrollers. This is mutually exclusive to |
Usage: The software will search through the family 22 microcontrollers.
|
--firmware |
No parameter |
--firmware Flash firmware for a PICKIT 3 programmer. This an exclusive command. Other command line parameters will be ignored. PICKit 3 device programmmer hex files are assumed to be in the same folder as the program. When using this switch you may get an error on the first attempt. This a know condition. Simply try the switch and/or unplug and retry. |
Usage: |
-a |
Requires a parameter |
-a Adjust the standard operating voltage. Can be used with programmers that support changing the operating voltage, such as official PICKit 2 and 3 tools. Not all clone PICKIT programmers support changing the operating voltages. Examples: -a5 -a3.3 -a2.8 If instructed to leave power on after programming (-zv), the voltage after programming will reflect this parameter. The -a parameter requires -w to operate. If -w is not specified then -a will not set the operating voltage. See also: -k to remove programmer power. |
Usage: Fixed Voltage Case |
-b |
Requires a filename as parameter |
-b The filename of the PKPlusDeviceFile.dat file. This an optional switch. The PKPlusDeviceFile.dat file is assumed to be in the same folder as the AppImage, unless otherwise specified. If present, --devicefile and --devicefile-csv will take this switch into account. |
Usage: |
-c |
No parameter |
-c Blank Check. Set the errorlevel to 0 if blank and nonzero (usually 16) otherwise.
|
Usage: |
-d |
-d Requires a parameter |
-d Delay on exit of the application. This switch will delay the exit of the application. This allows you time to review the output from the application (for example if you are running it from a script or IDE which will close the output window immediately afterward). You can specify a time delay or wait for a key press. For a time delay, use -dN, where N is an integer value. To wait for a keypress, use -dK. Some IDEs do not play well with -dK, because they don’t allow the user to interact with the spawned process using the keyboard. Using -dK with IDEs that do not support user input during programming may cause the IDE to lock up, waiting for a key press that can never arrive. Your mileage may vary. |
Usage: |
-e --erase |
No parameter required |
-e Erase device All memory regions and eeprom (if present) are reset to their default values as specified in the datasheet for that chip. This is a positional argument. Positional arguments are processed in the order they are given. If -e is placed AFTER -m, the device will first be programmed and then subsequently erased. The purpose of positional arguments is to permit multiple operations (erase, read, write) to be performed in a single invocation. |
|
-g |
Requires a parameter or parameter(s) string |
-g get (read, export) memory contents from device. Full options are: -gpecs memory regions are: p = Program memory e = EEPROM c = Configuration memory s = UserIDs 1) At least one memory region MUST be specified. If no memory region is specified as a parameter then the operation will fail. 2) If memory regions are specified then the specified regions are exported to the file specified with -f. For example, -gc will export the config memory region. 3) The export will be to the terminal (STDOUT) if -f is not specified. 4) -f is positional and must be specified BEFORE the -g or -m operation to which it refers. |
Usage: |
-h |
No parameter |
-h Show the basic Help. This switch shows a basic list of the supported arguments and their purposes. |
Usage: `-h ` Shows the list of the command line arguments. |
-i |
Requires -p<partname> |
-i Display device ID and revision. Shows the Device ID and Revision in hexadecimal. |
Usage: |
-j |
No parameter |
-j Detect and summarise the attached PICKit programmers. Unit IDs of all connected PICKit programmers will be displayed. |
Usage: |
-k --killpower |
No parameter |
-k Remove power previously left on using -zv. -k is mutually exclusive to -w See also: -a. |
Usage: |
-m |
Requires a parameter or parameter(s) string |
-m Program device. Full options are: -mpecs memory regions are: p = Program memory e = EEPROM c = Configuration memory s = UserIDs The order in which these flags are specified is not important. 1) Memory regions MUST be specified. If no memory region is specified then the operation will fail. 2) Some chips have constraints on what memory types can be written by themselves. For example, some don’t support writing the config without also writing or erasing the program memory. For such chips, invalid programming attempts will fail with an error message. 3) If a memory region is specified then the memory region IS FIRST ERASED, then programmed. In other words, -e is implied for the memory region(s) specified. 4) All specified memory regions are automatically verified after programming. There is currently no way to disable this. To specify an output filename, use -f. This is a positional argument, and must appear BEFORE -m. If omitted, the data will be printed to the terminal instead. |
Usage: |
-n |
Requires a PICKit programmer name string as a parameter |
-n Program the device with the specified name. Use the PICkit programmer with the given Unit ID string (its so-called "serial"). Useful when multiple PICkit programmers units are connected. Not particularly useful when multiple programmers have the same ID. (Yes, this is a thing.) |
Usage: |
-p |
Requires a chip model name |
-p Program the device with the specified name. This argument is mandatory for all chip-related operations (i.e. read, write, erase). The switch specifies the target chip ("part") to be programmed. The device string needs to match the device being programmed, or the operation will fail. The device string is used to extract key information from the device database. An incorrect device string will not work and an error message will be issued. Specifying an incorrect part name may cause damage to your part. For example, specifying a PIC18F6520 when you have connected the low-voltage PIC18LF6520 will (unless -a is specified) apply 5 volts to the part, potentially damaging it. You may optionally omit the "PIC" prefix from your part name. For example, -p12F675 and -pPIC12F675 are both valid arguments. The part name is not case-sensitive. |
Usage:
Example 2. Program a 12F675. |
-r |
Requires a parameter |
Implemented as -rnnnn where nnnn is the size of the flash memory block to be protected, and where nnn can be any value within the constaints of NVRAM erase row size. Suggest multiples of 0x20. Currently the largest block HEF/SAF on any PIC is 0x100 (words) but This could possibly change in the future. So valid values would be 0x20, 0x60, 0x80 up to 0x100 |
Usage: Example 1: Example 2: |
-q |
Set the output to minimal (quiet) |
Usage: |
|
-s |
Requires a hexadecimal parameter |
-s sets the UserID value for microcontrollers that support UserID bytes/words. Supports hexadecimal values only. Supports usage of leading 0x and characters 0xhhhh to the specific length stated in the datasheet. There are two components to the command. The hexadecimal value and the command switch. 1) Hexadecimal value: -s is a positional value. Therefore, it has no effect until a write operation is performed. You must put -s hexadecimal value prior to the -m switch. 2) You must add the s parameter to the -m command. Example -mpecs |
Usage: |
-u |
Requires a hexadecimal parameter |
-u sets the OSCCAL value on devices with OSCCAL support. Supports hexadecimal values only. Supports usage of leading 0x and four characters 0xhhhh, or, a four character string hhhh. The hexadecimal value must start with 0x34; the next 6 bits determine the OSCCAL; and the lower two bits must be zero. Essentially, the 6 bits adjust the frequency up or down to achieve 4 MHz. -u is a positional command. Therefore, it has no effect until a write operation is performed. It must be specified before -m. Changing the OSCCAL value impacts the operating frequency of the device. YOU MUST ENSURE THE VALUE COMPLIES WITH THE SPECIFICATION AS STATED IN THE DATASHEET. Typical values are similar to 0x343C. NOTE: The PICKit+2 GUI can regenerate the OSCCAL value for you automatically. |
Usage:
Example 2. Set to hexadecimal value 0x3438 |
-w --applypower |
No parameter |
-w Power device from programmer, if safe to do so. Power will be applied during programming operations. If a specific voltage has not been specified with -a, the default voltage for the selected part will be used. Before applying power, the software will check if power is already present. If power is found to be present, the software will not attempt to supply more power. See also: -a, -k
NOTE: These command line switches operate differently from the original Microchip command line utility.
|
Usage: -w Power the device for programming.
|
-z --on-exit |
Requires one or more flags |
-z Keep power and/or MCLR asserted upon exit. -z Must be used with at least one of the flags V or M. The order of these flags is not important, and they are not case-sensitive. Specifies state on exit where v=power and m=mclr. See also: -a |
Usage: |
--nolog |
No flag required |
Prevent log file creation/updating. |
Usage: |
Application Errorlevels
Errorlevel | Exit meaning |
---|---|
0 | Success |
1 | "Incorrect Argument" |
2 | "Power Problem" |
3 | "Part Not Found" |
4 | "No Tool Found" |
5 | "Firmware Problem" |
6 | "Communication Problem" |
7 | "File Not Found" |
8 | "This Feature is Broken" |
9 | "This Feature is Not Implemented" |
10 | "Not Valid" |
11 | "Verification Failed" |
12 | "System Error" |
13 | "Bad Hex File" |
14 | "This Operation is Not Supported" |
15 | "This product is unlicensed" |
16 | "Blank Check Failed" |
17 | "An internal error has occurred" |
18 | "Requested operation is not possible" |
19 | "Product license could not be validated" |
20 | "A fatal error has occurred" |
Dump file
In the event of a crash, a dumpfile will be created at ~/.pkcmd.dump
,
and a message displayed to indicate the dumpfile has been created.
This can be used to diagnose issues and you may be requested to send the
dumpfile to the development team to assist in the root cause analysis of
the issue.
General Guidelines
When using this executable a parameter is either a standalone flag or a key/value pair.
For -m
and -g
there is no default. You must specify memory region.
-w
defaults to the standard operating voltage for the device, unless
-a
is also used to specify a voltage.
When a PICKit 3 device programmmer is first plugged in to USB the MCLR is asserted (pin is held low). A PICKit 2 device programmmer does not do this.
If you need to set or reset the BANDGAP on your device. Please use the PICKitPlus Windows Application for the PICKit 2 or PICKit 3. This can reset the BANDGAP with a click. Simply read the device, then select the 'BandGap:' in the upper part of the application interface - this will change the BandGap value. Select the desired BandGap by reselecting 'BandGap' and then Write or Erase the device.
And… quotes can be used around the argument; and it can optionally be separated from the switch by a space. This is a universal rule.