You might want to explore what is possible with the EEMEM keyword (some discussion here ➜ EEMEM - #8 by rlogiacco, I did not look much deeper in the forum but I'm sure there are other discussions)
If I remember correctly it requires using an ISP, generating the .eep file and possibly modifying plattform.txt to upload automate this in the IDE