Bootloader-less Pro - Advanced AVR 3.0 Core - Part 2 - SPM erase self destruction code
A tiny bit of code can be written in the end of program memory space to self erase itself relatively easily for whatever reason. This demonstrates how to use spm from application section with simple inline asm and simple c. z-register shifted right 6 is the page address for 32 words page size mcu. 2^7=128 bytes per page; 6:0=7 bits.
ps. dummy who wrote avr-boot header uses a byte-address to point to a page, which works, but very dumb.
PPS. there are tons of dummies trying to use inline asm to show off their smartness. If you are a dummy, code written by you are trash regardless if you are using c or asm. Here the SPM function is mainly written in c. It's clean and clear and more portable and it compiles just as good.
PPPS. Self-written to self in the application seems to fail when the code is initialized from the application section even when the spm code is within the bootloader section using c, but if one failed, then a new route will be explored. A hard code method should technically be fail free.