I put my bootloaders at the bottom of the memory and have GOTOs at the start of the moveable code which jump to the start of the main code, and the interrupt service vectors. I have one byte at the top of the address space which is set to 0x0FF when programmed, the bootloaders checks this, if it's set to 0x0FF it will execute the main code, if not, it starts the bootloader. When reprogramming the reflash utility clears this byte first so if there are any problems it will reboot into the bootloader. One thing you do have to make sure of is that you put GOTOs to all the interrupts you are likely to use, as you can't add any more later. Another aproach would be to put the bootloader at the top of the code and just jump straight to it from the reset vector, write your bootloader so that this address cannot be modified, as well as making sure your bootloader can't be modified. Then you have complete freedom with interrupt routines, I would think is a better approach in terms of flexibility. Martin -----Original Message----- From: pic microcontroller discussion list [mailto:PICLIST@MITVMA.MIT.EDU]On Behalf Of Harold Hallikainen Sent: 06 December 2002 18:30 To: PICLIST@MITVMA.MIT.EDU Subject: [PIC]: boot loader I am STARTING to look at boot loaders for an 18f6720 project that currently is all written in C. From what I've read, everyone seems to be putting boot loaders at the very "top" end of the memory map (high ROM addresses). It SEEMS that since the boot code always runs at startup, we could put it at low memory addresses and put the changing code above it, protecting the low memory addresses. I see a problem when the interrupt service routines move, but perhaps the ISR vectors could point to a fixed location in the changeable code that either has the ISR or a goto to the actual ISR, which is free to move. Putting the loader at low memory addresses and never overwriting these would keep a corrupted download from ever messing up the reset vector. The boot code would always execute on reset, then goto a fixed ROM location where the application code would ALWAYS start. There would similarly be a fixed ROM location where the ISR would ALWAYS be located (or, in either case, a goto to the actual code would be loc ated at this fixed location). It then SEEMS I should be able to use a #pragma sectiontype to tell the linker where to put the boot loader. I'm guessing this would best be written in assembly so I would not have to go through C initialization before running the boot loader. Instead, I'd goto the normal C entry point (where stacks are set up, initialized variables are initialized, etc.) after my bootloader timeout. So... where (if anywhere) am I going wrong? Is this a reasonable approach? Or, should I put the bootloader up in high memory? THANKS! Harold FCC Rules Online at http://www.hallikainen.com/FccRules/ ________________________________________________________________ Sign Up for Juno Platinum Internet Access Today Only $9.95 per month! Visit www.juno.com -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body