Subversion Repositories svn.mios


Rev 1134 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
163 tk 1
HEADER 3 MIOS Bootstrap Loader
<H1>MIOS Bootstrap Loader</H1>
1134 tk 5
<P CLASS=INFO>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.<P>
163 tk 6
1134 tk 7
<H2>Installation of the Primary Bootstrap Loader</H2>
163 tk 8
1136 tk 9
<P CLASS=DESC>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 <A HREF="mbhp_jdm_expired.html">MBHP_JDM</A> or <A HREF="mbhp_burner.html">MBHP_BURNER</A>.</P>
163 tk 10
1136 tk 11
<P CLASS=DESC>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 <A HREF="" TARGET="_blank">Brenner8</A>, but fortunately <A HREF="" TARGET="_blank">Microchip</A> noticed the need for a hobbyist solution as well, and published the <A HREF="" TARGET="_blank">PICkit2</A> (and later also the <A HREF="" TARGET="_blank">PICkit3</A>), which are available for around 50 EUR.</P>
163 tk 12
1136 tk 13
<P CLASS=DESC>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 <A HREF="" TARGET="_blank">PICkit2</A> page!</P>
163 tk 14
1134 tk 15
<P CLASS=DESC>I tried a PICkit2 clone from <A HREF="" TARGET="_blank">Diamex</A>, which is available in their shop, but also at <A HREF="" TARGET="_blank">Reichelt</A> for 30 EUR. Similar clones can be found at <A HREF="" TARGET="_blank">ebay</A>.</P>
163 tk 16
1134 tk 17
<P CLASS=DESC><A HREF="mbhp_core.html">MBHP_CORE</A> 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):<BR>
<center><img src="mbhp/pickit_dip40_adapter_board.jpg" width="575"></center></P>
163 tk 19
1134 tk 20
<P CLASS=DESC><A HREF="mbhp/pickit_dip40_adapter_board.pdf">Here the schematic</A></P>
163 tk 21
1134 tk 22
<P CLASS=DESC>Programming the bootloader under Windows is easy: just use the <A HREF="" TARGET="_blank">PICkit GUI</A>, import the bootloader_*.hex which matches with your PIC (can be found in the <A HREF="mios_download.html">MIOS installation package</A>), and press the "Write" button.<BR>
<center><img src="mbhp/pickit_programming_windows.png" width=543 height=659></center></P>
163 tk 24
1134 tk 25
<P CLASS=DESC>Under MacOS and Linux, you can use <B>pk2cmd</B>, which can be downloaded from the <A HREF="" TARGET="_blank">PICkit2 page</A> 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:
<TT><PRE style="margin-left:50px; font-size:8pt">
<I>macmini2:PK2CMDv1-20MacOSX TK$</I> <B>cd ~/Downloads/PK2CMDv1-20MacOSX</B>
<I>macmini2:PK2CMDv1-20MacOSX TK$</I> <B>cp ~/Downloads/mios_v1_9g/pic18f4685/burner/bootloader_v1_2b_pic18f4685.hex .</B>
<I>macmini2:PK2CMDv1-20MacOSX TK$</I> <B>./pk2cmd -P</B>
Auto-Detect: Found part PIC18F4685.
Operation Succeeded
<I>macmini2:PK2CMDv1-20MacOSX TK$</I> <B>./pk2cmd -P -F bootloader_v1_2b_pic18f4685.hex -J0 -M</B>
Auto-Detect: Found part PIC18F4685.
PICkit 2 Program Report
12-10-2013, 9:14:03
Device Type: PIC18F4685
Program Succeeded.
Operation Succeeded
163 tk 40
1134 tk 42
<H2>You don't want to buy a PIC programmer to save money?</H2>
163 tk 43
1134 tk 44
<P CLASS=DESC>You could buy preprogrammed PICs from <A HREF="" TARGET="_blank">SmashTV</A> or <A HREF="" TARGET="_blank">Mike</A>, or you can ask a friend or a member of the <A HREF="" TARGET="_blank">MIDIbox Forum</A> who already owns a PIC programmer for burning the bootstrap loader into the chip</P>
163 tk 45
1136 tk 46
<H2>MIOS and Application Upload via MIDI</H2>
163 tk 47
1134 tk 48
<P CLASS=INFO>After the primary bootloader has been flashed, it's strongly recommended to use <A HREF="mios_studio.html">MIOS Studio</A> 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).</P>
163 tk 49
1134 tk 50
<P CLASS=INFO>See also the <A HREF="mios_bootstrap_newbies.html">Newbies page</A>, and in case of troubles, the <A HREF="howto_debug_midi.html">MIOS Studio Troubleshooting Page</A>.</P>
163 tk 51
1134 tk 53
<H2>Boot options</H2>
163 tk 54
1134 tk 55
<P CLASS=DESC>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 <A HREF="midibox_to_com.html">MIDIbox-to-COM</A> interface (38400).<BR>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.</P>
<P CLASS=DESC>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:
  <LI><B>ID = 0000000000000000</B>: common MIDI interface, character LCD, Device ID 0x00
  <LI><B>ID = 0000000000000001</B>: common MIDI interface, character LCD, Device ID 0x01 (e.g. for a <A HREF="midibox_sid.html">MBSID Slave #1"</A>)
  <LI><B>ID = 0000000000000002</B>: common MIDI interface, character LCD, Device ID 0x01 (e.g. for a <A HREF="midibox_sid.html">MBSID Slave #2"</A>)
  <LI><B>ID = 0000000000000003</B>: common MIDI interface, character LCD, Device ID 0x01 (e.g. for a <A HREF="midibox_sid.html">MBSID Slave #3"</A>)
  <LI><B>ID = 0000000000000142</B>: MIDIbox-to-COM interface, character LCD
  <LI><B>ID = 0000000000001000</B>: common MIDI interface, graphical LCD (KS0108)
  <LI><B>ID = 0000000000007000</B>: common MIDI interface, custom LCD driver (see also <A HREF="" TARGET="_blank">these examples</A>)
  <LI><B>ID = 0000000000120000</B>: common MIDI interface, redirect MIDI Out stream to MBHP_IIC_MIDI with address 0x12
<P CLASS=DESC>SmashTV wrote a nice online user interface to select the <A HREF="" TARGET="_blank">PIC ID values</A>!</P>
<P CLASS=DESC>Unfortunately, "modern" PIC programmers (like for PICKIT2) don't allow to change the ID from the GUI anymore. :-(<BR>
Therefore the proposed solution (aside from .hex file hacking) is the usage of the <A HREF="mios_download.html">change_id</A> application, which allows to change these parameters via MIDI.</A>
163 tk 74
<H2>SysEx protocol specifics</H2>
1117 tk 76
<P CLASS=INFO>If it should be for interest, the SysEx commands and error codes are described in <A HREF="">this document</A>.
163 tk 77
   <LI>upload of MIOS (12k): 9 seconds</LI>
   <LI>upload of a typical application (4k): 3 seconds</LI>
1134 tk 85
<P CLASS=DESC><A HREF="mios_download.html">The bootloader image file is part of the MIOS release package.</A></P>
163 tk 86