FOTA using OptiBoot copy_flash_pages
-
Hello everyone,
as a challenge, I want to try to implement FOTA using the OptiBoot copy_flash_pages to MySensors. The reason is that need a little more flash to implement LoRaWAN on my climate sensors that are not close enough to a MySensors gateway, so I'll do it with a ATmega644P or (for some reasons cheaper on LCSC) a ATmega1284P. As there is more of half the flash available when they run on MySensors, I see it as a challenge to implement FOTA without an additional I2C flash chip.
I'll use this thread as a blog to show and discuss my progress with you. If you are not interested, let me know, so I won't bother you further.
As a start, I ordered two PCBs from LCSC. A CPU PCB for a ATmega1284P or ATmega664P, and a PCB for the radio (and a Flash chip, but this is for some other project). I'll try to attach the schematics. I'll keep you updated as soon as they arrive.Regards!
Edit: PDF did not work, so here are some PNGs:
-
IT WORKS
I got a first working version, using an ATmega1284P running on MightyCore 2.2.2 (as soon as I began developement, they switched from Optiboot to Urboot in version 3.0.0, whicht does not include the copy_flash_pages function anymore, but I'm working on a work around there).
Only thing I could not solve is to do a CRC check of the image after download...
You can try it out here: https://github.com/eiten/MySensors/tree/FOTAInternalFlashTest
It's not beautiful yet with much Serial.prints in it, but maybe it helps you if you find errors.