MSD file refresh

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Oxanagig3
Level 2
Level 2
5 replies posted 5 questions asked 5 sign-ins

Hello,

I am following the PSoC6 USB MSD logger example.

GitHub - cypresssemiconductorco/mtb-example-psoc6-usb-msc-logger: This example demonstrates how to c...

I would like to do similar things in my project, everything works fine, except that the log file doesn't get refreshed when I open up the file(or the better way to say this is that the Windows/Mac OS doesn't re-read this file when I open it again even though the log file content has been changed by the PSoC6), in the example, it returns a fail status to force the OS reload the flash drive.

            /* Emulate ejection every 5 times */

            if ((button_count % 5) == 0)

            {

                usb_comm_refresh();

            }

I am wondering if there is a better way to notify the OS that the file content has been changed, and read it again when I open the file, not use the cache.

I know some of the products can do that without force ejecting the flash disk.

Thanks,

Xiang

0 Likes
1 Solution
Rakshith
Moderator
Moderator
Moderator
250 likes received 1000 replies posted 750 replies posted

Hello Xiang,

I received an update from the internal team.

The USB MSD acts as a block device for the local file system built on top of it. The overwhelming majority of block device file systems that are built imply the fact that while the file system is mounted, only the operating system can change the contents of the block device. Therefore, they do not provide mechanisms for how a block device can tell the operating system that one of its data blocks has been changed.

An exception (or workaround) is when the block device reports a media eject. In this case, the file system will be emergency unmounted and when the block device reports the readiness of the medium, then it might be remounted.

Thanks and Regards,

Rakshith M B

Thanks and Regards,
Rakshith M B

View solution in original post

2 Replies
Rakshith
Moderator
Moderator
Moderator
250 likes received 1000 replies posted 750 replies posted

Hello Xiang,

I found this discussion that could provide more information - https://stackoverflow.com/questions/6775951/usb-mass-storage-device-side-data-changes-not-visible-on...

This could be a limitation in the interaction between the OS and the USB Mass Storage Device.

I have also requested our internal team for confirmation and will provide a response on this thread once I get an update regarding the same.

Thanks and Regards,

Rakshith M B

Thanks and Regards,
Rakshith M B
0 Likes
Rakshith
Moderator
Moderator
Moderator
250 likes received 1000 replies posted 750 replies posted

Hello Xiang,

I received an update from the internal team.

The USB MSD acts as a block device for the local file system built on top of it. The overwhelming majority of block device file systems that are built imply the fact that while the file system is mounted, only the operating system can change the contents of the block device. Therefore, they do not provide mechanisms for how a block device can tell the operating system that one of its data blocks has been changed.

An exception (or workaround) is when the block device reports a media eject. In this case, the file system will be emergency unmounted and when the block device reports the readiness of the medium, then it might be remounted.

Thanks and Regards,

Rakshith M B

Thanks and Regards,
Rakshith M B