Great job. I did a very similar thing for the PIC18 series two years ago but my bootloader is written in C.
I also used XModem and TeraTerm. The difference is that I send a bin file via XModem.
I suggest you to disable interrupts when deleting or writing to memory.
Thanks.
I should update this, I have documented the source code now, and modified it to be a two pass operation. The first time, the loader checks all the checksums are valid (and if the transfer was not corrupted). It then says 'OK' and waits for a second pass that does the actual programming. That way, if the first pass fails for any reason, nothing is changed.
The intent of the code was it is part of a bigger program that has a serial interface. In the particular program this is part of, the user types <TAB>P and the program then does
BCF INTCON,GIE ; Disable interrupts
LGOTO bootstrapSo interrupts are disabled for the whole time the bootstrap is run. All transfers use polling for input, and it isn't necessary on output because it only sends one or two characters at a time.
It can be used as a separate program, to load another program later on. In that case the processor starts with interrupts disabled and they aren't enabled by the loader.
The one disadvantage is that to use the bootloader more than once, the user has to have some way of invoking it from any program they load. I haven't looked to see how Arduino code manages to fire the bootstrap every start then decide it doesn't need to run and switches to the program. For my purpose how it works is fine. I only want to send users a program that I have tested already, so each Version will be able to update itself to the next version.