I'm using a PIC18F47K40. My reprogramming driver (from Windows) normally bypasses the boot loader, but in this instance I needed to be able to rewrite it without requiring a programmer. For this chip, the boot code writes 128 bytes of new ROM data into the PIC's internal write buffer and then the write procedure is initiated. Once the write process has completed, the PIC just continues on as normal and executes whatever code is at the current PC, whether it was changed by the write process or not. I don't know if this approach will work for all PICs though, but here the entire ROM space can be reprogrammed. My boot loader code is in a small block of its own ROM space that doesn't move with code modifications. Even so,, as I mentioned you have to be mindful of changes that will affect the execution of the boot loader programming loop. cheers Tony On Fri, Jan 12, 2018 at 8:02 AM, Brent Brown wrote: > Interesting. Bootloaders normally(?) ignore/reject any commands to write = within the address range they occupy. You could allow it to do so, but sure= ly problems occur as soon as you alter the instruction about to be executed= to something different. I can't see how you could get away with it unless = every important piece of code in the bootloader that pertains to bootloadin= g remains unchanged, and typically that would be all of it~! > I'm thinking mostly PIC16F here. Not sure if any PICs allow executing fro= m RAM... if so that would be a different story. > > > > > -------- Original message -------- > From: Anthony Nixon > Date: 1/12/18 9:30 AM (GMT+12:00) > To: "Microcontroller discussion list - Public." > Subject: [PIC] Boot Code Overwrite > > Hi all, > > I had a problem recently where a project is in use by some clients but > I had to rewrite the boot loader to make a new feature available. > > In the past I have had to write some temporary boot code to rewrite > the entire chip including the new boot code. > > It never occurred to me that a boot loader can rewrite over the top of > itself. To save myself a lot of code fuss, I tried this approach and > it works fine. > > The only caveat is that the new boot code must not modify (or very > carefully modify) any of the code target addresses that reside inside > the operating part of the boot code. > > Probably old news to some, but it saved me a lot of work. > > cheers > > Tony > -- > http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > -- > http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist --=20 http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .