David Dorran, one of my colleagues in the School of Electrical and Electronic Engineering here in the Dublin Institute of Technology, has created a wonderful bootloader for the PIC18F4620 microcontroller:
David Dorran’s PIC18F4620 Bootloader
A bootloader is basically a very small program which resides in the flash memory of a microcontroller alongside the main program which the developer has written to control the chip’s behaviour during normal operation. What normally happens is that the bootloader runs first whenever the chip is powered up. It then does one of two things – either
- The main program is simply executed as normal, or
- The bootloader begins downloading a new version of the main program from an external source (probably a PC) and overwriting the previous version in flash memory.
Different bootloaders use different criteria for choosing whether to enter normal operation or update the microcontroller’s software, but it’s usually something relatively simple like the state (high or low) of a specific pin at the moment the chip is powered up (which is exactly what Dave’s bootloader does).
What’s great about bootloaders is that they allow you to update the software on a microcontroller using a very simple and cheap hardware device such as a USB-to-serial converter, rather than using a dedicated programming device (such as the PICkit 2 for the PIC) which may be considerably more expensive.
In our school, we use a lot of PIC microcontrollers and they’re really great to work with. However, one downside of using them in teaching is that the USB programming interface is relatively expensive – around €30 for the PICkit 2. Dave’s bootloader will allow us (and others) to program each chip once with a PICkit 2 to put the bootloader on it, and then give it to a student with a €5 USB-to-serial converter, which they can use to program it from then on.
As well as the actual bootloader (that’s the tiny code that actually runs on the microcontroller each time it is powered up) Dave has provided a very clear circuit diagram and a build script for use with the XC8 compiler when you’re compiling your own code for the PIC.
I think this is really exciting news for teachers or anyone else using PIC microcontrollers on a tight budget – Well done Dave! Here’s that link again:
David Dorran’s PIC18F4620 Bootloader
