Patch for possible use of AgentRAM.
Thanks for doing this, I think it seems like a good approach.
In the attached patch, I've added support for D10 and elph130. I also added some code to check that the generated bin fits if you enable OPT_CHDK_IN_ARAM. This correctly makes the build fail on elph130, which doesn't have enough aram for a full CHDK binary.
On D10, both OPT_CHDK_IN_ARAM and OPT_ARAM_MALLOC appear to work. I haven't exercised them heavily yet.
On elph130, OPT_ARAM_MALLOC crashes shortly after startup in a call to firmware free() from spytask. I haven't looked into this in detail yet.
Some other general comments:
core_get_free_memory used to return the largest free block. In the patched code it returns the sum of the largest free blocks, which isn't really equivalent. For a single value, it might make more sense to return the largest single free block.
lua get_meminfo needs to be updated. Adding "aram" as a heap type to explicitly get the aram heap makes sense. It's less clear what the default should do. The current behavior is to return the heap that CHDK is allocating from. If this returned only the aram value, it could make current scripts think they are running out of memory. It might make sense to make a "combined" value that builds a meminfo from all the pools that are being used. The free size and total size would be the combined values, the largest free block would be the largest among all the pools etc. I'm not sure what you'd do with the allocated peak, but it probably doesn't matter much.
Since we know the canon heap size (from get_meminfo, but it could also be obtained from the firmware dump), it would be possible to detect if the pointer passed to free() falls in any of the heaps. This might be useful for debugging at some point.