Here's my
non-working attempt at a patch to make the CHDK code behave correctly for >2GB files.
Tested on sx710
camtests all pass, so sub 2 GB stuff seems fine.
Used a 2260826276 zip file to test.
Attempting to upload after running camtests resulted in IO Error on the chdkptp side. The camera appears to be running normally, but it is not possible to reconnect, even with reset_device.
I tried this twice. In one instance, powering off the camera seemed normal, but I was unable to power it on without pulling the battery. In another, the camera became unresponsive while still on.
Trying to upload on a fresh boot without running camtests first, I got an immediate "general error"
Copying the file to the SD card with a card reader trying to download in chdkptp, I get
read_data failed 0x2ff
ERROR: I/O error
The file from the failed download is 2145386496 bytes. This is 2^31 - 2 MB. chdkptp uses a 2MB buffer for file transfers, so it seems likely that the read request which hit 2^31 failed.
While it's quite possible there are bugs in my code, my suspicion is the Canon code uses signed values. I haven't tried standard ptp getobject or sendobject with a >2gb file yet.
If we want to support this, it would probably make more sense to add operations to do partial uploads and downloads: Read X bytes from offset, append X bytes or write X bytes at offset.
I'm not sure this is worth doing. The case of downloading > 2gb files seems useful, but fairly rare.
There are additional issues in CHDK lua, since the stat size is negative for > 2gb files. chdkptp side code can work around this, but it would be on a case by case basis.
It may become more of an issue in the future,
@srsa_4c suggested DryOS 59 extended the stat structure to support 64 bit sizes. >4 GB files would require a lot of changes, though probably not too common for CHDK until exFAT boot or multi-partition is supported.