Is there a reason to limit OTA size on ATMEGA1284p to 64kB ?

Started by Uncle Buzz, February 23, 2020, 06:29:26 AM

Uncle Buzz

I saw in the bootloader source than sketch is limited to 31k on ATMEGA328p (32k - 1k for bootloader), and  64k for ATMEGA1284p. I wonder why ATMEGA1284p can't have a limit to 127k (128k - 1k for bootloader) ?
Is there a technical reason or is it an arbitrary choice to limit size ?

Felix

It kind of pushes the limits of practicality.
With the standard protocol it can take a long time to transfer that much data, and also 64K is a very LARGE sketch for an AVR.
So it was just a decision made at that time to limit it to 64k for the MEGA. Nobody has ever reported a need to flash more than that over OTA.
Do you have such a case?

In any case, it is an easy code change to allow more address bytes. In fact for M0 I did allow this in HandleWirelessHEXData() (image signature ends at byte 10 leaving 3 bytes for address):

#if defined (MOTEINO_M0)
  flash.writeByte(10,':');
  uint32_t bytesFlashed=11;
#else
  flash.writeByte(9,':');
  uint32_t bytesFlashed=10;
#endif


And the bootloader will look for those 3 bytes instead of just 2. 3 bytes allows 16MBytes, I think that is more than enough ;-)

Uncle Buzz

I don't' have a need for the moment, but I have a project where the sketch is growing because of adding some libraries... I switched on MEGA because 31k was not enough. And since I want to be able to upload a new sketch over the air, I would like to know if I'm limited to 64k or if it could be increased if needed.

I saw this limit which is not the flash size, so I was wondering if there's another reason than a long upload process to restrict the size before trying to increase it and discovering some problem you already be aware of...

Felix

No problems that I'm aware of other than the usual potential interference during a long OTA upload. I saw that but very rarely and it can happen with shorter uploads as well.