Robot Projects index
This is the homepage for my bootloader for the PIC 16F876 chip. The bootloader
consist of two parts parts: The bootloader as an assembler file (bootloader.asm),
and a c transfer program for Linux / Unix (boottransfer.c).
To build the bootloader.hex you'll need GPUTILS from
To transfer bootloader.hex to the PIC chip, you'll need
a PIC programmer, for example picprog:
To use the bootloader, you'll need a serial connection to
the PIC: The Tx and Rx pins on the PIC must be connected
(through a level shifter IC) to the Rx and Tx pins on
one of the PC's serial ports. GND must be connected too.
Download the bootloader-1.0.tgz
To build bootloader.hex and build and install boottransfer:
To transfer bootloader.hex using picprog:
To test the bootloader:
This will transfer the test program test.hex to the PIC using the boottransfer
program. This program will flash a led connected to PORTA pin 4.
Currently the PIC must be clocked at 14745600hz, but it can easily be changed,
just calculate a new value for SPBRG using the formula:
SPBRG = Fosc/(16*Baudrate)-1
where Fosc is the oscilator clock rate, ie. 20000000 for a 20Mhz clock, and
Baudrate is 57600. Insert this in the function "serial_init".
If you want to transfer programs compiled with the CCS compiler
you'll need a
#ORG 0x0100, 0x01FF
statement in front of the main() function, so the bootloader knows where
the program starts.
Currently only the bootloader have only been tested with the PIC16f876 chip,
but should work on others as well (you'll have to change BOOTLOADER_START in
bootloader.h to 0x0E00 on chips with only 4K program memory).
The bootloader will NOT work unmodified on 16FxxxA chips.
The functions flash_program_write and flash_data_write must be rewritten
according to the new way of writing to flash memory on these chips.
Fuses in the transfered user program hex-file are ignored
4. Copyright notice
Copyright (C) 2003 Rasmus Friis Kjeldsen
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Library General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
I can be contacted on email at: rasmus (AT) reblag (DOT) dk
The latest version of the bootloader can be found at: