
Brief introduction to Bootloaders
---------------------------------

You firstly need to find the files "Boot_Loader.*" either for the 16F or
the 18F series.. The 16F ones are in the Examples directory under the
MikroElektronika directory thus...

C:\Program Files\MikroElektronika\mikroPascal PRO for PIC\Examples\p16\bootloader16

These files are the code for the small bootloader program itself that has to sit
on the target PIC micro and which does the actual program loading onto the PIC
via RS232. The small "Bootloader" program needs to first be burned into the PIC
using a programming board, such as easyPIC.

To burn the small bootloader program onto the PIC you use the "conventional"
method that means use their EasyPIC board and its USB programming system to burn
in the bootloader just as if it was a normal program being loaded onto the PIC.

Once the Bootloader is burned onto the PIC device it sits at the VERY bottom of
memory space and gets run every time you reboot or reset the PIC itself.
Typically PIC mikrobootloaders occupy only 100 to 300 bytes at the bottom of
memory and so do not take up much space at all.

Now.. The small bootloader program on the PIC is run EVERY time you power up or
reset the device.. It waits a few seconds to see if you are trying to
communicate with it via RS232 and load a new user program. IF it does not see
you trying to communicate with it within the first few seconds then it transfers
the PIC processor to the start of your USER program elsewhere in memory.. and
the user program runs as normal until the next power off/on or reset.

IF the bootloader does see you trying to communicate with it within the first
few seconds then it receives the new user program via RS232 and loads above the
small bootloader program ready for it to run as normal later on. The PC program
that handles the communication to/from the bootloader is the MIKROBOOTLOADER.

The reason RS232 is used is that it needs a minimum of just 3 wires.. TX / RX
and Earth 0V. WHY use RS232 you ask? Well.. We are designing hand held
devices and once our PIC are loaded into these then it is VERY difficult to
reprogram them later on in the field. However.. using the bootloader program and
a simple 3 wire connector we can reprogram the hand held devices thousands of
times VERY easily using a simple serial cable AND say a normal laptop. WE DO NOT
THEN NEED to have a specialised USB PIC burning programmer to reprogram the
devices.


FAQ
---------------------------------

- If the bootloader option is not required, presumably the space it would have
occupied then becomes available for user programs ? If already installed, how is
it removed ?

ANSWER/ The small amount of memory that the bootloader takes up can be used if
you no longer want the bootloader for RS232 programming. You simply use a
"Conventional" programmer (such as PICFlash) to load a user program as normal.
It overwrites the small booloader and the PIC then runs like normal. You then
need to use a programmer each time you want to program the PIC.


- Does the IDE require the presence of existing bootloader code to be
user-specified at compile time, or is any pre-existing bootloader code simply
over-written by subsequent Mikrobootloader downloads (as I suspect) ?

ANSWER/ There are loads of bootloader programs on the internet. Each bootloader
will only function with its PC based communications program... each one sends
special characters to/from the PC program during its USER program loading into
FLASH memory. Once you have burned in the small PIC bootloader onto the PIC
device then you will ALWAYS use its corresponding PC based control program to
use the bootloader from therein. If you try to use another then it will simply
NOT load the new USER program. You can OVERWRITE the small bootloader program
with another version anytime using a "conventional" USB programmer such as the
EasyPIC3 system.
