I am not sure if I understand, butThe Optiboot 8 has a function to write to flash, which can be called from application (skech). I use this function in the ArduinoOTA library to write new version of the application received over network to upper part of the flash memory. Other function added to Optiboot by me the copies the application to address 0 and resets the board.So yes it is possible to write a function to flash and jump to it.https://github.com/jandrassy/ArduinoOTA/blob/master/src/utility/optiboot.hhttps://github.com/MCUdude/optiboot_flash/pull/5/commits/d671e2287b20f7fe26b31c9da1605a73876a36e0https://github.com/Optiboot/optiboot/pull/269/commits/b998bfef2dbd14cf1ec4a3ee10268e1e49a6dd60
My poor short-term, this is the MCUdude MightyCore; https://github.com/MCUdude/MightyCore
You run the hex in the upper part and it copies itself over the old hex down low?
look for addressing the upper 64K of a 1284P's flash and find reference to the RAMPZ register for use by ELPM/SPM.And then when I look in the Instruction Set Summary there is no ELPM. SPM yes, ELPM no.Okay, got the AVR IS Manual and straightened out... 1284P instructions are 16/32 bit, the IP is to 64K 16 bit words in flash. A 2-byte Z jump or call can reach anywhere in 128K.
just suppose you put executable bytes in PROGMEM, you can load the address and jump or call indirect and run them?
Is there some sort of PROGMEM can't do that?
the library in the running sketch writes the new version into upper half and then the bootloader copies it to address 0 to run it after reset
So you never jump to or call the code loaded in the upper end?