I was reading an application note that discusses dealing with Electrical Fast Transients (EFT) and other issues that could cause malfunctions in embedded systems. The application note is at [1].
One of the suggestions is "filling unused program memory with a trap instruction sequence to stop the runaway code, and to allow a WDT time-out and reset" in case the CPU goes haywire and starts executing some garbage from unused flash memory. Can it be done automatically with the build system? (It might require a Kconfig option because doing this means you have to use 100% of the flash. Maybe developers will not want that, at least during development, to avoid the flash wear level.) References: [1] Microchip application note AN2587, "EMI, EMC, EFT, and ESD Circuit Design Consideration for 32-bit Microcontrollers" page 44: https://ww1.microchip.com/downloads/aemDocuments/documents/OTH/ApplicationNotes/ApplicationNotes/00002587A.pdf Cheers, Nathan