|
Page 3 of 4 The bootloader application on the PC side needs to be able to perform 2 main tasks: read and write HEX files, and perform bootloading tasks by communicating with the PIC. Since you need to have something to send or recieve when attempting to implement the bootloader, I chose to start by first tackling the HEX file side. Dealing with HEX files Hex files are a reasonably easy format to deal with, but it still took some time for me to put together the necessary code. If you're very good with C#, you could probably do it a whole lot faster. Rather than explain all about the hex file format, please visit http://www.keil.com/support/docs/1584.htm for information. As you can see, the 2-byte address given on each line is only the lower 16 bits of the full address being referenced on the PIC. The higher bits are accessed using the "extended linear address" command, so often the first line of a hex file will be: Which sets the upper 2 bytes of the full 32-bit address to 0x0000. Note that the 2 bytes set with this command apply to all subsequent regular data transmissions, until they are changed again. Since the PIC program memory is 0x000000 to 0x007FFF, this command is issued one time, and applies to all the data that goes in program memory. Some compilers/assemblers do not include that, I guess zero is assumed for the initial value. It will be issued again when the ID locations (starting at 0x200000) and configuration bits (starting at 0x300000) need to be accessed, if the hex file contains that information. Following that, the rest of the hex file typically looks something like: :0800000083011F308A00042F68 :103E080083010A168A152F2F83120313C8000C1E6C :103E18000B2F48089900080083120313C801C90131
etc...
:103E580003180034142F0A308316031399002430F2 :103E68009800903083129800640010273B3A031999 :02400E00763FFB :00000001FF |
Where that last line (of transaction type 0x01) is the end of file marker. I have implemented the HexInterpreter class to deal with reading and writing HEX files. This class is covered in the Bootloader Interface DLL code documentation, or you can dig into the code if you want to know more. The OLD version of the example project is available here. I don't know why you'd want it (it's kind of a mess) but it's here until I finish phasing it out. DOWNLOAD OLD EXAMPLE PROJECT
{mos_sb_discuss:8}
|