Do FAT and directory entries update at close stage?
Good question... I think the filesystem code may do some caching which may delay writing those details...
The problem is, you're experiencing the same issue on two different cameras which (I think) should rule out accidental memory corruption by PSM code.
I don't have any idea other than trying to find out what is causing the writing failure.
If you have an operational PTP connection, you could try to dump some RAM (perhaps the first 4..6 MB) to the PC. You should do it with cards that are the same size, have the same content (no images, only PSM related files), one card that is working with AC power, another that is not working with AC power.
Test scenario:
- dump RAM
- open() for writing
- dump RAM
- close()
- dump RAM
The RAM snapshots can then be analysed/compared.
It can of course be that filesystem related data is located elsewhere in RAM, and that won't make things easier...
Some other suggestions:
- try making a .fi2 version of your code and see whether you get the same issues
- try putting PSM into the AdditionAgentRAM area and see whether it behaves differently
// ARAM_HEAP_START = 0x60e000 // Found @ 0xff99dc24
// ARAM_HEAP_SIZE = 0x22000 // Found @ 0xff99dbe4