I am trying to use AN4379 (USB device bootloader) for a project, but after transferring ~24576 bytes, there is a problem, and an error causes the bootloader to stop. This error will not occur with the AN4379 sample project, as the application file being transferred is not large enough to cause this issue to arise.
The problem is that the 'MSD_Event_Callback' (in the 'disk.c' file) function is reading the first part of the file a second time, causing an 'invalid file' error, and terminating the process. I have tested this problem extensively, and it is very clear that after transferring 24576 bytes, the data buffer passed to 'MSD_Event_Callback' contains the beginning of the file again ("S0030000FC" in my case).
I have no real idea as to what is causing this error, but it seems likely that the host is re-transmitting the file for some reason; perhaps the transfer was not correctly acknowledged in previous communications, or the device is requesting a re-transmission.
Any input or solution is very much appreciated, and thanks for reading this post.