Files disappear from flash if created just before coldboot

We ran into a problem of FlashDisk files’ disappearance on Colibri T20 BSP 2.4b2.

If a file/folder is created on the FlashDisk 500-1000 ms before a coldboot, it won’t remain on the flash after boot is completed. If delay is 1500 ms, the files/folders do remain.

Earlier we encountered a similar problem on Colibri iMX6 BPS 1.6: Corrupted files after copying to Flashdisk - #13 by mirsky

On iMX6, the problem could be fixed by disabling TRIM command for eMMC:


On Colibri T20, adding this value to the registry didn’t help.

Is there a known fix for the problem?

Colibri T20 512MB V1.2A
Official Image 2.4b2 (CE7.0 TEGRA)

Tegra T20 doesn’t have an eMMC. It has a raw NAND. So all flash handling done by WinCE itself. And trim is not applicable here. The file system uses a cached write sequence. So when your application writes to flash it writes it to ram. A thread in the background writes the ram sectors to flash. Another thread is also responsible for garbage collection and sector wear levelling.

The 2.4 BSP has a FlushTimeout set to 500ms plus mentioned thread needs some time to do its job. It has a low priority and a high CPU load can delay it.

What is your use case? Can you reboot a system after 1.5 sec delay after write?

Alex, thank you for the explanation!

Certainly, we can add some delay. However if it’s possible, we would like not to depend on an unreliable timeout, but to call some flushing function before resetting.

I tried to call



HANDLE hStore = ::OpenStore(_T("DSK1:"));
::DeviceIoControl(hStore, IOCTL_DISK_FLUSH_CACHE, NULL, 0, NULL, 0, NULL, NULL);

None of them worked.

Is there an action I could perform to ensure that everything is already written?

WinCE has two level of cache - FS cash and Disk cache. The FSSCTL_FLUSH_BUFFERS works by flushing FS level caches and data will be moved to a Disk subsystem level. So you need to use IOCTL_DISK_FLUSH_CACHE after that.

Finalizing the issue, I’d like to share results of a test:

  • Without any flushing, the minimal time to wait is 1200 ms, otherwise files will disappear;
  • With both flushings, the minimal time to wait is 900-1000 ms.

So flushing doesn’t help much and sleeping must be added before resetting.