SchmalzHaus logoEBB Bootloader

Introduction

The EiBotBoard is designed to be used with a USB bootloader. This bootloader is a slightly modified version of Microchip's wonderful USB HID bootloader. The EiBotBoard firmware is built in such a way as to be compatible with this HID bootloader, and in fact will NOT run without it.

The EBB bootloader is a separate application in the PIC's Flash program memory. It runs every time the EBB is reset  (or when the user executes the BL command - see the command reference page) and will either jump straight into the normal EBB firmware application, or retain control and execute 'bootloader mode'. When the bootloader is running and the EBB is in bootloader mode, you can send it commands over USB to erase the rest of Flash (that area that holds the main firmware) and then burn a new firmware application into Flash.

This bootloader action is very nice because it allows you to update your EBB to use any code you want - a new version of the EiBotFirmware for example, or your own code. You do not need a hardware programmer, or anything other than a simple (free) piece of software on your computer and a USB cable.

Bootloader Technical Details

The HID bootloader on EBB lives from 0x0000 to 0x0FFF in Flash. As the PIC's reset vector is at 0x0000, and its interrupt vectors are at 0x0018 and 0x0028, the bootloader occupies all three of those locations. That means it can 'intercept' or take control when an interrupt fires or a reset happens. Right now it only intercepts the reset vector, and just passes both interrupt vectors on to 0x1018 and 0x1028 respectively. The rest of Flash (from 0x1000 on) is reserved for the main firmware application, and can be erased and re-programmed by the bootloader. (This includes the config bits at the very end of Flash, by the way.)

When a reset occurs, execution starts from 0x0000. The bootloader begins executing, and checks for two things. It checks to see if the memory at 0x1000 is empty (in other words erased, or 0xFFFF) and if so it will not jump to the main firmware at 0x1000 but instead will remain in bootloader mode. It also checks to see if the PRG button is held down. If so, it waits until the PRG button is released, and then goes into bootloader mode, running the bootloader application. If neither of these things is true, it will jump to 0x1000 which is where the main firmware application should have its reset vector.

As of the 7/3/2010 version of the EBB bootloader, the Flash block that the bootloader occupies (0x0000 to 0x1000) is protected via the config bits and is not able to be erased. This means it should be impossible to create a situation where your EBB fails to boot into the bootloader by giving it a bad hex file or some other mishap. This will be true as long as you do not re-program the config bits. If you allow the bootloader to re-program the config bits (and  you have to do special things in order to enable this functionality) then you can prevent the EBB from booting and running the bootloader.

PC Applications for Bootloading

There are currently two PC applications you can use for bootloading. The first one is the 'official' tool from Microchip. It is a really nice .Net app written by Microchip and runs under Windows only. You can download version 2.6a from here. Or you can go to http://www.microchip.com/MAL and download the latest Microchip Application Library and the bootloader application should be installed to somewhere like C:\Microchip Solutions\USB Device - Bootloaders\HID - Bootloader\HIDBootLoader.exe. This tool is very easy to use, and will auto-detect your EBB if it is in bootload mode, and allows you to select a HEX file for downloading (programming) to the EBB.

The second tool is a command line tool called mphidflash. The official download location for this tool is http://code.google.com/p/mphidflash/. However, in order to make this tool work with the EBB under Windows, Mac OS and Linux, we had to modify it. Therefore, you need version 1.4 or above of mphidflash in order to use it with EBB. Until version 1.4 is available from the official site, you can download it here.

Instructions for Microchip's HID Bootloader.exe (Windows only)


If you want to change the firmware on your EiBotBoard, you can use the bootloader to program a new HEX file onto your board. The steps are as follows:
Download and run the HIDBootloader.exe application
Put your EBB into bootload mode by pressing and holding the PRG button while you press and release the RESET button. Then release the PRG button.
The red and green LEDs on the EBB should be blinking back and forth
The HIDBootloader.exe application should say [FILL IN]
Click Load Hex File and then navigate to the new HEX file you want to program.
Click Program/Verify
When the programming is complete, click Reset, and the board will reset and run the new firmware.

Instructions for mphidflash (Windows, Mac OS and Linux)


See this page.

Important Files


Questions? E-mail me at my e-mail address

Creative Commons License
EggBotBoard by Brian Schmalz is licensed under a Creative Commons Attribution 3.0 United States License.
Based on a work at www.schmalzhaus.com/EBB.
Permissions beyond the scope of this license may be available at www.schmalzhaus.com/EBB.