sjmelnikoff wrote:
If you erase flash location 0xFF0F (FSEC), this sets the security bits, which means that next time you reset the processor, you won't be able to write to flash at all without first doing a mass erase. You can't get around this using backdoor key access, as that is also disabled by erasing this location.
As mentioned above, the best place to put a bootloader is in the 0xC000 block. You have an interrupt vector table as part of it, with each vector jumping to a secondary table at a fixed location in the application.
Incidentally, it's not necssary to run the whole bootloader in RAM. The only part which needs to be executed out of RAM is the code which starts the write to flash, and waits for it to finish. You can do it in 10 bytes, like this:
WriteToFlash:
bset FSTAT, #CBEIF ; execute command by writing 1 to CBEIF
brclr FSTAT, #CCIF,*+0 ; loop while CCIF = 0
rts ; return
Steve.
sjmelnikoff wrote:
If you erase flash location 0xFF0F (FSEC), this sets the security bits, which means that next time you reset the processor, you won't be able to write to flash at all without first doing a mass erase. You can't get around this using backdoor key access, as that is also disabled by erasing this location.
As mentioned above, the best place to put a bootloader is in the 0xC000 block. You have an interrupt vector table as part of it, with each vector jumping to a secondary table at a fixed location in the application.
Incidentally, it's not necssary to run the whole bootloader in RAM. The only part which needs to be executed out of RAM is the code which starts the write to flash, and waits for it to finish. You can do it in 10 bytes, like this:
WriteToFlash:
bset FSTAT, #CBEIF ; execute command by writing 1 to CBEIF
brclr FSTAT, #CCIF,*+0 ; loop while CCIF = 0
rts ; return
Steve.
steve,
That would work except that when I reflash the boot, the erase and write loop must be in RAM. This being the case, for only one reflash version, I reprogram the app this way too, except that I can do it in multiple blocks since I can return from the erase and write loops.