MIOS Bootstrap Loader

The MIOS bootstrap loader allows you to install applications, but also the operating system itself in the flash memory of a PIC over the MIDI interface without the use of a special programming device. It is possible to exchange application code on-the-fly, which makes the development of applications very efficient.

Installation of the Primary Bootstrap Loader

The MIDIbox project started around 1998. In these years it was quite common that PCs were equipped with a RS232 and SSP ("printer") port, so that PICs could be programmed with cheap DIY programmers such as MBHP_JDM or MBHP_BURNER.

Today (more than 10 years later), these interfaces have been completely replaced by USB. If you don't own an old PC, USB will be the only choice. Some DIY USB programmers exist, such as Brenner8, but fortunately Microchip noticed the need for a hobbyist solution as well, and published the PICkit2 (and later also the PICkit3), which are available for around 50 EUR.

Since Microchip published the schematics as open source, some clones exist which are even cheaper. And these clones are actually my proposed solution for people who want to program PICs for the MBHP platform, because they are sufficient for our purposes. Clones are only available for PICkit2. They will also work under Linux and MacOS with command line tools which are provided by Microchip at the PICkit2 page!

I tried a PICkit2 clone from Diamex, which is available in their shop, but also at Reichelt for 30 EUR. Similar clones can be found at ebay.

MBHP_CORE isn't designed for "In Circuit Serial Programming" (ICSB), therefore you have to build a special programming board which consists of a DIP socket and a 6-pin header, which connects to the PICkit2 (clone):

Programming the bootloader under Windows is easy: just use the PICkit GUI, import the bootloader_*.hex which matches with your PIC (can be found in the MIOS installation package), and press the "Write" button.

Under MacOS and Linux, you can use pk2cmd, which can be downloaded from the PICkit2 page as well. After the download, copy the bootloader_*.hex file into the same directory where pk2cmd resists - here a typical command log while programming the bootloader for a PIC18F4685 device under MacOS:

You don't want to buy a PIC programmer to save money?

You could buy preprogrammed PICs from SmashTV or Mike, or you can ask a friend or a member of the MIDIbox Forum who already owns a PIC programmer for burning the bootstrap loader into the chip

MIOS and Application Upload via MIDI

After the primary bootloader has been flashed, it's strongly recommended to use MIOS Studio to download MIOS and the applicatio via MIDI. Don't flash the appr. .hex files with your programmer, because this will overwrite previous installations of the primary bootloader (and MIOS if application .hex is flashed).

Boot options

The bootstrap loader has to know about two important parameters: the MIDI device ID, which should be unique number in a chain of multiple MIDIboxes, and the baudrate. It can be chosen between the common MIDI baudrate (31250) and the rate used by the MIDIbox-to-COM interface (38400).A third parameter allows to define the connected LCD type, so that MIOS is able to select the appropriate driver before printing a message on screen. Currently character displays (1x8, 1x16, 2x16, 2x20, 2x40, 4x16, 4x40) and KS0108-based graphical LCDs are supported, other GLCD types require a special driver which is embedded into the application.

The boot options are located in the PIC ID header. The SysEx device ID is located in bitfield ID[57-63], the UART mode in ID[55], the LCD type in ID[48..51], the MBHP_IIC_MIDI address for MIDI Out redirection in ID[40..47]. Here are some setup examples:

SmashTV wrote a nice online user interface to select the PIC ID values!

Unfortunately, "modern" PIC programmers (like for PICKIT2) don't allow to change the ID from the GUI anymore. :-(
Therefore the proposed solution (aside from .hex file hacking) is the usage of the change_id application, which allows to change these parameters via MIDI.

SysEx protocol specifics

If it should be for interest, the SysEx commands and error codes are described in this document.