GCBOOT - a PIC18F2525 bootloader written in Great Cow Basic

The GCBOOT bootloader occupies the top 4Kbytes of a PIC18F2525 microcontroller chip (from B000 to BFFF) and permits user hex programs to be uploaded via a 9600 baud serial connection without requiring special software beyond a certain amount of delay after sending each line. Most terminal emulator programs (Hyperterminal etc) have a setup option for line delay, under Linux a simple script can be used. Although set up for the '18F2525 chip, it should work with other PIC18F chips with minor changes.

In the stock setup the PC serial lines are connected to the PIC using current-limiting resistors with a weak pullup on the RX line, so if the serial cable is not connected then the application runs. If using an inverting interface such as a MAX232 or other type of serial interface, or to use another pin to indicate when to run the application, then the source needs to be modified and recompiled. By default the B0 pin is configured as an output for a status indicator LED that lights when the bootloader is active and blinks while uploading code, modify and recompile to use another pin or disable this function. GCBOOT requires that the first 4 bytes of the user program contain a long goto to the startup code (usually the case), it stores the application goto within itself and replaces it with a goto B000 instruction so that the bootloader runs first, then the bootloader runs the application if the "app run" pin (default RX) is a certain polarity (default high) or the execute command is given. GCBOOT only responds to program code locations, configuration bits and eeprom locations are silently ignored and it won't allow overwriting locations occupied by the bootloader. Flash is not erased first so it's possible to load code segments without removing code that is already present. The bootloader menu has options for examining flash and ram locations and for clearing flash and ram for debugging.

Source code for gcboot
Text docs for gcboot
gcboot package including a hex file

The source code is written in Great Cow Basic. The internal assembler of older versions of GCB didn't support programs more than 32Kbytes so had problems compiling the source code unless gpasm was used to assemble the intermediate code, to my knowledge this has been fixed now. Also flash memory space is tight so compiler differences may cause compile failure. If there are problems recompiling, the modified version of the compiler I used is in the gcb.tar.gz file.

GCBOOT last modified November 13, 2010. This page last modified July 15, 2012.