3.2.3.2.1 IRTCTRL[DONE] Bit

IRT code signals the end of IRT execution by setting the DONE bit in the IRTCTRL register. Once the DONE bit is set, the next instruction fetch from a non-IRT region causes the device to exit IRT mode and begin executing the main application code. After this transition, the IRT region becomes inaccessible to non-IRT code.

Exiting IRT Mode

//Indicate end of IRT execution
IRTCTRLbits.DONE = 1; 

//NEXT: Jump to non-IRT code to complete the process

An IRT region can execute code from a FIRMWARE type region if the DONE bit is not set yet. For boot systems that need to share a larger software library between the boot and mutable stages, leaving the DONE bit unset can allow the IRT code to run code in that FIRMWARE region and return to the boot code. Once the DONE bit is set, an attempt to return to the IRT code from the FIRMWARE region will cause an exception.

For systems that don’t need to share FIRMWARE code regions, setting the DONE bit as early in the boot sequence as possible can help prevent access to the IRT region in the event of an invalid jump to a non-FIRMWARE code section.

It is preferred that all non-IRT code regions have execution permissions disabled on Reset and set the DONE bit before execution permission is enabled on any non-IRT section.