PIC bootloaders

Microcontroller Topics
Post Reply
NTSH1996
Sergeant
Sergeant
Posts: 19
Joined: Sat Jan 02, 2010 12:57 am

PIC bootloaders

Post by NTSH1996 » Sat Jan 02, 2010 7:17 am

hey guys, anyone know what is a bootloader ?
User avatar
Neo
Site Admin
Site Admin
Posts: 2642
Joined: Wed Jul 15, 2009 2:07 am
Location: Colombo

Re: PIC bootloaders

Post by Neo » Sat Jan 02, 2010 1:16 pm

A standard firmware comes in two major parts.
  1. Bootloader
  2. Main application
The difference can be easily distinguished if we understand the basics and the requirement of the bootloader.
  1. When you switch on your board (Microcontroller or DSP) the system will transfer control to a particular point in memory referred as first address location or entry point (This is defined in the manual). This is usually a pointer in FLASH. In some advanced systems like DSPs, this point can be changed to External FLASH, External EEPROM, etc... using DIP switches. We need to write the bootloader program to this location. If the bootloader is too large to fit, we simply write a small code to jump to another location with enough memory.
  2. Boot-loader can be used to initialise basic units of the device like UART, I2C, etc..., Verify components, Check power supply, wait for new firmware upgrade, etc...
  3. Finally the boot-loader should jump to main application.
    You can see an example code here.
Note that boot-loader is always written to the first address location in memory where it gets the control immediately after the unit is switched on.

EXAMPLE:
Now you might be wondering about the requirement of a bootloader. Bottloader is a very useful part of the firmware. You might have seen some professional devices that can be re-flashed using USB or RS232. For example, ADSL routers can be upgraded to latest version that can be downloaded through Internet. In this case, it is essential to have a bootloader in the system. It works as below.
  1. PC sends start firmware update (Say 0xFF00FF00) bytes and keep on sending a firmware re-flash code (Say 0x88006600) to notify the PC is waiting to send the new firmware.
  2. When UNIT receive 0xFF00FF00, it resets itself so the bootloader starts again and UART/USB is initialised.
  3. Bootloader waits for few seconds until it identify the firmware re-flash code (0x88006600). Once it receives the code, it will send a command to request a line of new firmware followed by the memory address and write it to a the given location in memory. This process will repeat until it receives the last line.
  4. Once firmware re-flash is done, bootloader resets the UNIT and you are ready with the new firmware.
If a bootloader wasn't there, you would have to provide a Microcntroller/DSP Programmer and required software to your client along with the device :mrgreen:

Now you can imagine a system where you program your microcontroller through RS232 port without using the Programmer. (You only have to use Programmer ones to write the bootloader)

Hope this helps.
Post Reply

Return to “Microcontrollers”