Hello Vladimir,
The latest pushes to the develop branches of Bpod_HiFi_Firmware and Bpod_Gen2 have a fix.
The firmware now has a formatter built in, and detects when pre-allocation of the data file has failed to complete, indicating a corrupted card. The BpodHiFi class checks for successful pre-allocation on startup, and formats the card automatically if necessary. After formatting and validation of pre-allocation, startup continues as usual.
As a precaution that may reduce the incidence of corrupted cards, the firmware now calls FsFile.sync() to ensure that the file allocation table is updated after each complete file transfer or preallocation op.
The detection and auto-format fix works, but I need to ensure that it didn't break anything. It will be included in the upcoming v1.9.0 release of Bpod_Gen2, including firmware binaries for easy update with LoadBpodFirmware().
If this works robustly with HiFi, I'll add the same fix to BpodWavePlayer in the subsequent release - and I can share a patch if you'd like to beta test it once it's ready.
Josh