UBW Firmware B (Bootloader) Documentation
Back to main UBW page

General - What is a bootloader? Why would I need something to load my boot anyway?
A bootloader is a small piece of code that typically lives on a microcontroller. It allows you to write your application (firmware) into the microcontroller. It communicates with a host PC over some type of communications channel - serial, CAN, Ethernet, or in the case of the UBW, USB. So why is this a neat thing to have?

Because it allows you to write your own applications (typically in C, using MPLAB and the C18 compiler, but not necessarily) and program that application into the micocontroller without needing additional programming hardware. Without a bootloader, you would need to purchase some type of hardware programmer that would erase and then program your microcontroller with your application. But the bootloader does this for you, and allows you to program the micro with no additional hardware.

OK, so the bootloader isn't really in the same league as the other UBW firmware versions. The bootloader sits in the PIC's flash from 0x0000 to 0x0800 and all of the other firmware versions take up 0x0800 through the end of Flash. This means that both applications reside in flash at the same time. You use the Bootloader to program new firmware versions into Flash with just a USB connection and a special application on the PC side.

How It Works
The Bootloader is just Microchip's USB bootloader code, but I had to change it very slightly so it would use the correct I/O bits for the LEDs and Program switch (and config settings) on the UBW board rather than the ones that come on Microchip's USB dev board. I also had to move some things around in memory so it would fit in the boot block when compiled by the student version of C18.

So how does it work? Well, if you plug in your UBW, or press the reset switch, the Bootloader gets control of the processor. It checks to see if the Program (PRG) switch is pressed. If so, it runs its own USB code that enumerates the UBW as a "PIC18F4550 Family Device" under "Other Devices" in the Device Manager, which communicates with the PC via Microchip's custom driver. You then run the bootloader application from the PC, and you can erase your UBW (only the part that doesn't contain the bootloader firmware), read it, write it, etc. The really great thing is that you can quickly and easily put new firmware on your UBW without having any extra hardware.

To Download New Firmware
The first thin you need to do is acquire the new HEX file you want to program into your UBW. You can find several on this website (for FW C, D etc.). You can also make your own by using a compiler or assembler. Then you need to download the install files for the "Microchip Custom Driver" from this link. The intaller will put some files onto your computer which are used when you connect your UBW in Bootloader mode for the first time. With the UBW board pluged into the USB port, press and hold the PRG (program) switch while you press and release the RST (reset) switch on your UWB. You can then release the PRG switch. If this is the first time you've run a UBW in bootloader mode on your PC, Windows will ask you to install a new device. Point it to the place where the 'mchpusb.inf' file is located (by default the installer puts it at C:\MCHPFSUSB\Pc\MCHPUSB Driver\Release). Click through the dialog boxes to install the INF file. (The exact squence of this depends upon your version of Windows.) Next run the PC Bootloader Application, which is called 'PDFSUSB.exe' and is located at C:\MCHPFSUSB\Pc\Pdfsusb by default. Once running, select the PICDEM FS USB 0 (boot) slection from the "Select PICDEM FS USB Board" pulldown, which will connect the bootloader PC app with the UBW bootloader code. Then just click "Load HEX File" and navigate to where the new firmware HEX file is that you want to download. Then click "Program Device". When it's done, it will tell you in the little log window on the bottom. After that you just press the RST switch on the UBW and your new firmware will start running. This all sounds complicated, but once you do it a couple times it becomes real quick. And many of the steps above only need to be done the first time.

To recap, here are the steps to download new code to the UBW (if you've previouslys connected it to your PC in Bootloader mode)
  1. Build your new code and generate a .hex file. (Or just download a new HEX file from this website - a new firmware version for example.)
  2. Run PDFSUSB.exe
  3. Hold down PRG while resetting the board (pressing and releasing the RST button)
  4. Pull down "PICDEM FS USB 0 (boot) from within PDFSUSB.exe
  5. Click "Load HEX File" and load in your new hex file into PDFSUSB.exe
  6. Click "Program Device" and wait until programming is done (just a couple of seconds)
  7. Reset your UBW to run the new firmware

Notes
Questions? E-mail me at my e-mail address
Back to main UBW page