STM32 Host USB Memory FatFs reads corrupt data

I am on a project with an STM32F407 on a custom board and I am having trouble with reading from a USB memory device.

The code framework is generated with CubeMX and setup to use FatFs and USB in host mode to access a USB memory stick.

While it mostly seem to be working, that is the USB enumerates, FatFs mounts and I can display directories and read and write small files (like an ini config file), I have trouble reading larger files like WAV files that are used for audio play back through a DAC.

When I open the WAV file, I read the header OK but as soon as I need to read more ( I read chunks of 2K bytes), the data I read is corrupt. Right after the f_read, I check the data buffer and there is corruption in the data. The buffer data is recognizable as I used a custom WAV file with a known simple waveform.

I noted that even though the data is corrupt, it is fairly consistent from cycle to cycle i.e. every time I read the file it is the same corruption.

What could be the cause of this? I already spend days on this on something which is quite an obscure problem that may be lurking on the low level libraries or the CubeMX configuration that I may not understand or have missed (documentation is not very clear :-( )

When I do files system and IO sub-system validation I write very long streams of pseudo-random data that are easy to check, and hard for the system to accidentally get right with any common failure modes.

Suggest you validate the FatFs via USB writer thoroughly, and document the failure(s) to ST. If it validates Ok, then review more carefully what you are doing with the data and the file system.

The consistent failure is a bit odd, does it fall on a 64-byte boundary?