Conversation
|
Some discussion here: https://forum.arduino.cc/index.php?topic=586707 Another user has pointed out that this version only works on chips with <=64k of flash. |
|
@gmattinson boards.txt board variant? |
|
@JAndrassy right, sorry, I forgot about that part. Partially because I didn't know what to do with it since boards.txt only needs to change if you define BIGBOOT to enable these changes. And I only changed it for the ATmega328p since that is the only board I have to test with. Here are the changes I made: optiboot32.menu.cpu.atmega328p.upload.maximum_size=31744 Original values were 32256 and 0xDE. This adjusts the fuses for the new boot loader size (1024 bytes instead of 512 bytes). |
Created optiboot_copy which is equivalent to memcpy() for program memory. This allowed me to make self-updating firmware.
To work, your sketch must consume less than half of the available program memory. This allows you to temporarily write your entire sketch to the free flash memory and then use optiboot_copy to copy the sketch from the temporary location to the correct address.
When the copy is done, obviously the return address in the call stack is incorrect. Hence the last line of optiboot_copy calls to a user-specified address instead of returning. In my case, that address is 0 which reboots the device.