Hey Orci I can give you some tips but I can't give you a working example.
1- You need to divide your program memory into 3 parts: Bootloader, Current Program Code, New Program Code.
2- The bootloader starts at address 0x0000, it is the first code that will be loaded, at the end of the bootloader you will have a jump routine with the starting address of the "Current Code". The bootloader is responsible of writing the New Code once it is received.
3- Send the "New Code" as hex data taken from the compiler output to the PIC with OTA.
4- Check that all the data is received, and if it is received check if it is the correct data. (Usually with CRC)
5- After the checking is completed, call the bootloader in order to write the data to the right addresses. (The addresses can be found in the hex code sent, check this
LINK for more details about the composition of the hex file for PIC MCU.
Notes:
1- Edit your compiler settings, to make sure the bootloader compiles at address 0x0000.
2- Edit your compiler settings, to make sure the Current Code compiles at the defined starting address.
3- Edit the address for the interrupts to make it Current Code Starting Address + Old Interrupt Address
4- Compile the bootloader get the hex file, compile the Current Code get the hex file. With a text editor, join the two files and program the PIC with the new code.
Hope it helps somehow