Accessing the device with libmtp may crash and reboot the device

I discovered that transferring files with libmtp (eg when using Linux/Amarok) can result in the device firmware crashing and rebooting at the end of the transfer or upon disconnect (eg pressing “disconnect device” in Amarok). The device comes back immediatly but the FAT file system on the device may had been rendered currupt - even so corrupt that the database refresh freezes. Additionally the device can then be stuck in an infinite loop (turning off and back on may not go into USB-PC connection mode, even thou the device is connected, but instead goes directly back into the database refresh which freezes). Escaping this loop is a bit tricky - I have to fiddle around with disconnecting/connecting the device, removing/inserting the SDHC card, several resets and reset-to-msc mode.

If/when I get back into USB-PC connection mode, I have to reformat the internal memory (and sometimes the SDHC card, too), because just fixing the FAT tables with chkdsk/fsck does damage the mp3 files (crosslinked clusters, truncated files). This is not good - the firmware should close the filesystem before rebooting - or even better: it should not crash during mtp access. It should also be able to identify damaged songs and skip these during the refresh, maybe showing some summary at the end like “skipped XY damaged files”. It should also be able to auto-repair damaged FAT tables. Some FAT errors may go unseen for a while and result in a completely unusable device some transfers later.