The PIC24 Bully bootloader is a serial bootloader for the PIC24H/F/FK and the dsPIC33 families. This bootloader was developed from C and assembly code originally distributed by Microchip (see the AN1094 application note. I have tested the bootloader on the p24FJ64GA002, p24HJGP202, and p24HJ32GP202 targets. The bootloader window application is a .NET application and the supplied executable found in the code archive has been tested with WinXp, Vista, and Vista64. The supplied executable has been reported to be incompatible with WinXP64; but recompiling from the source may work (untested, the source files are supplied in the archive).After unpacking, you will have the following directories:
Installation of the
Windows bootloader application
Copy the bin/winbootldr.exe and bin/devices.txt to a target directory and try executing winbootldr.exe. If it does not run then try installing the latest .NET runtime from Microsoft as this is a .NET application.
.NET Requirements You need at least .NET 2.0.XXX or above runtime framework installed. You can download this by searching for “.NET framework” at www.microsoft.com/downloads . If you do not have at the .NET runtime installed, then you may get this error message:![]() Using the bootloader This assumes you have a PIC24H/F target programmed with the bootloader firmware, and connected to your PC via a serial port. If you have the RTS# line the USB-to-Serial cable connected to MCLR#, then the RTS# checkbox pulls MCLR# low when checked, and MCLR# when unchecked. In the bootloader application:
If the bootloader does
not work
The
Bootloader Firmware and Persistent DataThe bootloader's firmware stack pointer is initialized around 0x0E50 the last time I checked. This means that if your application has persistent data above that point, it may (will) get stepped on. The bootloader's static data buffer that takes up the space before this is persistent, so any of the application's persistent data in this space will be safe. If the bootloader loads a program, then it sets the POR bit to simulate a power-on reset for the new program; this way if your program checks the POR bit to initialize persistent data you will get correct behavior.The Bootloader and Configuration BitsConfiguration bits on PIC24H/PIC24F devices determine things like initial clock source selection, watchdog timer timeout, etc. The file 24h_24f_target/pic24_configbits.c file sets the configuration bits for the bootloader firmware, currently the bootloader uses the internal FRC +PLL as the initial clock source (16MHz FCY for PIC24F, 40 MHz FCY for PIC24H). Feel free to modify these config bits to whatever you need.For PIC24H devices, configuration bits are located in a special area of flash memory. For PIC24F devices, a packed version of the configuration bits are located near the end of the last page of flash memory, and at device reset time, these are unpacked into the configuration registers. Configuration bits can also be specified in the application hex file that is downloaded by the bootloader. Before version 0.19, the bootloader and associated firmware had the following behavior in terms of configuration bits programming if the configuration bits were present in the hex file.
Beginning with Version 0.19, there is now a checkbox that allows control of configuration bit programming if they exist in the application hex file. This checkbox setting is only used if the Version 2.0 or better of the firmware is loaded (the bootloader now checks the firmware version during programming, and if it lower the Version 2.0, then the old behavior for configuration bit programming is used). WithVersion 0.19 and later, if the configuration bit programming is enabled and configuration bits are present in the application hex file, then the configuration bits are programmed for both PIC24H and PIC24F devices. If configuration bit programming is disabled, then configuration bits are not programmed for either PIC24H or PIC24F devices. For PIC24F devices, this has the nasty side effect of not programming the last page of flash memory (the last 512 instructions of program memory), so make sure that you do not have any program code there. The reason to disable configuration bit programming is that the bootloader may become inoperable if the application has incorrect configuration bit settings (i.e. specify an external crystal as a clock source and there is no crystal present). I would recommend for PIC24H devices to set the bootloader configuration bits the way you want them in the bootloader firmware by editing 24h_24f_target/pic24_configbits.c , and then disable configuration bit programming when downloading applications. This way, you cannot kill the bootloader via incorrect configuration bits in the application. CommentsSend comments to Bob Reese (reese@ece.msstate.edu).Version 0.25, Feb 3 2009 Now includes the data transfer protocol. Version 0.20, Nov 23 2008 Fixed a problem in the configuration bit programming - configuration bits were still being programmed even if the check box for disabling this was checked. A side effect was that configuration bits could be corrupted in this case. Also, verification was fixed - it was indicating a match even if the program contents did not match. Version 0.19, October 9 2008 Added support for enabling/disabling configuration bit programming, see the section titled “The Bootloader and Configuration bits”. The changes affected both the GUI and the firmware. Also, the COM port, baud rate, and other settings are now saved on exit in the local applications folder, and restored when restarted. Version 0.18, October 7 2008 Fixed a problem with the configuration bits sometimes getting corrupted by the verification process. Version 0.17, September 3 2008 GUI changes: Added verification of program memory after programming, and a check box for enabling logging (the log file is named bullyBootloaderLog.txt is in the same directory as the bootloader executable). Version 0.16, Aug 19 2008 Firmware now sets the POR bit if a program is loaded, this way a new program thinks that a POR has occurred and the C runtime initializes persistent variables. Also, added a the RTS#(MCLR#) check box and the "RTS# and Prgrm" button to the bootloader. Version 0.15, Jul 13 2008 Added firmware support for Explorer16/100pin board (see 24h_24f_target/Explorer16_100p_bootloader.mcp). Fixed problem with bootloader GUI not detecting location clash between user application and bootloader firmware - bootloader GUI will not load application code if a clash exists). Version 0.14, Jun 5 2008 If no serial ports exits, handle gracefully. Version 0.13, May 27 2008 Added a 'small RAM' flag to devices.txt to flag devices with less < 2K RAM, such as the PIC24HJ12GP202. They cannot hold an entire program memory page in SRAM at time, so programming is done a half-page at a time. This also affected the firmware in the 24H_F_target directory. Version 0.12, May 26 2008 Added some fixes by He Wen Guang, with the main being to change the configuration space size for 24H devices to include the User ID words. This affected the firmware in the 24H_F_target directory as well. Version 0.11, May 23 2008 Added revision name to processor ID that is printed out, and restored process ID to the 'devices.txt' file. Processor that connect is now checked for both correct device ID and process ID (upper byte of revision number). Initial Release: Version 0.10, May 19 2008 |

