PIC operating as Host?
If PIC providing power then ensure Good capacitor on VBUS/5V
Try 150uF 6V ceramic (Not higher voltage as different capacitance if not near operating voltage)
Heap and Capacitance were the two thinks that affected my swapping out USB Memory Sticks. I have a cfg file and a log file, and I can eject and reinsert without re-init.
Are you waiting appropriately for connected SYS_FS_EVENT_MOUNT from your callback before trying to open files? If try too soon FS may not be fully ready.
I use Callback to detect removal and insert, though it is best to do a manual disconnect/close before removal to ensure that files have finished writing: SYS_FS_FileClose().
If the USB stick may be randomly removed it may be worth doing a FileSync periodically/appropriately to ensure no unwritten data pending to avoid incomplete file end.
Callback setup before BusEnable:
SYS_FS_EventHandlerSet(vCallback_FilesystemEvent, (uintptr_t)NULL);// Set the event handler and enable the bus (No Context needed)
USB_HOST_BusEnable(D_USB_FirstBus);//Note vUSB_EnableH() called above in case default USBHSInit doesn't point to vUSB_EnableH()
void vCallback_FilesystemEvent(SYS_FS_EVENT eEvent, void *pEventDataUnused, uintptr_t pContextUnused)
sFiles.bFsConnected = true;
sFiles.bFsConnected = false;
sFiles.sLogU.bReady = false;//File not ready for Read
sFiles.sCfgM.bReady = false;//File not ready for Read
sFiles.eFsCallbackUnknown = eEvent;