Isaac Marino Bavaresco wrote: > I=B4m using the PIC18 TCP/IP boot-loader from Microchip, and it indeed > is almost transparent to the application developer. > > The only change to the code one must do is to reduce the length of the > program FLASH segment in the linker-script, because the boot-loader > resides at the end of the flash memory. > > The boot-loader then takes the first two instructions of the > application, saves them in an area inside itself followed with a jump > to the third instruction and replaces the original instructions with > a jump to its own start. > > When calling the application, the boot-loader just jumps to the saved > original instructions. That seems silly for a production bootloader. You're not trying to teach students about how a bare PIC works, and you are in a environment where some restrictions on the app code should be fine. My TCP bootloader for the PIC 18 just specifies that execution of the app starts at 4. That leaves two instruction words before the first interrupt vector. That is enough for a GOTO instruction, which can jump to any location in memory without being dependent on current state (unlike a PIC 16 GOTO which depends on PCLATH). The bootloader owns locations 0-3 and a chunk at the end of memory. The bootloader only needs to ignore data sent to it outside the app range. This still makes it easy to test the app by itself. The app code has two NOP instructions at 0, followed by the GOTO. When the app is loaded directly with a programmer or the ICE, the PIC executes the two NOPs on startup instead of the bootloader. The same HEX file can either be programmed directly or passed to the upload program to send to the bootloader just like in the other case, but the bootloader itself is less complex. ******************************************************************** Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products (978) 742-9014. Gold level PIC consultants since 2000. -- = http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist