P89 Serial Programmer Code
Program NXP P89V51RD2 from your favorite Unix system
Status: Beta
Brought to you by:
xwindows
p89pgm p89pgm is a simple Philips (NXP) P89V51RD2 microcontroller serial programmer for GNU/Linux and Unix-like platform. This program was originally written when I was assigned a college semester project that uses P89V51RD2 chip, but flashing tool for the chip (Flash Magic <http://www.flashmagictool.com/>) is non-free and didn't work on my GNU/Linux configuration, even with WINE <http://www.winehq.org/>. So I decided to roll my own. Currently p89pgm was written to be simple and have fewest library dependency as possible, and it just tasked for writing program, not reading or setting any fuse bits. Project website: http://p89pgm.sourceforge.net/ Contents -------- 1. Principle of Operation 2. Installation 2.1 System Requirement 2.2 Compiling 2.3 Installing 2.4 Uninstalling 3. Running 4. Author 1. PRINCIPLE OF OPERATION ========================= To program P89V51RD2, this programmer will put it into In-System Programming (ISP) mode first, by sending character 'U' repeatly to P89V51RD2's serial input while it's booting up (using 8-N-1 serial configuration). Once succeeds, the microcontroller will start repeating 'U's back. Then p89pgm will stop sending 'U' and send HEX file line-by-line to the microcontroller. If the microcontroller echo the line back with '.' appended, means operation of that line was succeeded. But if 'X' was appended instead, means operation of that line was failed. If all HEX lines were processed without error, p89pgm will terminate with return code 0. 2. INSTALLATION =============== p89pgm package comprises mainly the programmer (p89pgm) but also includes a little Intel HEX to binary converter (hex2bin) and binary to Intel HEX converter (bin2hex). Normally you should need only p89pgm. 2.1 System Requirement ---------------------- p89pgm should run on GNU/Linux or any Unix-like platform (including Cygwin). hex2bin and bin2hex should run on any platform that have C compiler. For source version of p89pgm, hex2bin or bin2hex; to use it you'd need: - C Compiler (that could compile at least ANSI C89) - Make These program have been tested using GNU C Compiler (GCC) 4.3.2, GNU Make 3.81 and running on Debian GNU/Linux 5.0 i386. For Cygwin port, tested and released using GNU C Compiler (GCC) 4.8.2, GNU Make 4.0 with cygwin1.dll 1.7.28 and running on Microsoft Windows XP SP3. Note: if you've just checked out p89pgm from git repository, you also need to run this command in source directory before proceeding to the next step: $ ./autogen.sh 2.2 Compiling ------------- To compile p89pgm, run this command in source directory $ make This will produce an executable named 'p89pgm' in the source directory. On the other hand, to compile hex2bin or bin2hex, run this command in source directory: (replace PROGNAME with 'hex2bin' or 'bin2hex') $ make PROGNAME This will produce an executable named 'hex2bin' (or 'bin2hex') in the source directory. If you wanted all of them, just use 'make all' instead. 2.3 Installing -------------- If you wanted to install p89pgm system-wide, use this command (as root): # make install This will install p89pgm binary to /usr/local/bin. If you want just hex2bin or bin2hex installed, use this command (as root): # make install-PROGNAME Replace 'PROGNAME' with 'hex2bin' or 'bin2hex'. If you wanted all program, use 'make install-all' instead. Alternatively, in case you need to install it just for yourself (like ~/bin), prepend PREFIX=... in front of 'install' and it will place binaries in 'bin' subfolder of your prefix. Also you didn't need to be root to install it. This example will install all three programs to your home folder (~/bin): $ make PREFIX=~ install-all (You can replace 'install-all' with 'install-hex2bin' or 'install-bin2hex' for installing only specific program, or just 'install' for installing only p89pgm) 2.4 Uninstalling ---------------- To uninstall, you just need to do the same step as installation, but change 'install' word to 'uninstall'. 3. RUNNING ========== After you finished installation, you could run this command to see available command line switches: $ p89pgm --help Note: Since p89pgm 0.3.0, you can let p89pgm configure your machine's serial port parameters automatically by using '--baud' option. See P89PGM.txt, HEX2BIN.txt and BIN2HEX.txt for detailed usage of each program. If you installed this on Unix-like system, you can view these documentation via system's manual page viewer (e.g. using 'man p89pgm'). 4. AUTHOR ========= p89pgm is written by Nutchanon Wetchasit, relased as Free Software under GNU GPL. For legal information, see LICENSE.txt