SD-Card file corruption on iMX7D WEC7 1.3

Files that are larger than 32 kB get corrupted when written / read from SD-Card.

Steps to reproduce on WEC 7:

  • Copy attached test.bmp file to a USB drive
  • Open the test.bmp directly from the USB drive - the image shows fine
  • Copy the file onto a SD-Card
  • Open the file from the SD-Card → the image doesn’t open, or shows torn

Test Environment:

  • Colibri Development Board
  • iMX7D 512 GB
  • WEC 7 (latest stable image 1.3 from Toradex)

For our project this is a very serious issue. In the release roadmap issue WC-912 looks like the issue we are facing here, but it looks like it has only been resolved for WEC 2013.

We have tried slower clock frequencies as shown in the knowledge base, but it had no effect.

What can we do get SD-Card working?

TEST.BMP (1.1 MB)

I followed your steps but wasn’t able to reproduce your issue neither on 1.2 nor on 1.3 version of WEC7 BSP. Have you tried another SD card?

Hello Alex, thank you for looking into this right away! We double checked with different cards (Kingston, Sandisk - different sizes and ages) and different boards (Iris, Colibri Dev, and our own) - the corruption is the same.

But maybe I wasn’t precise enough in my instructions. You need to copy the file onto the SD-Card using Windows CE and the file needs to be larger than 32 kB. For me it happens every time and for every kind of file. It’s just in image files that you can visually spot the corruption right away - other files it’s harder to compare.

Could you try this instead:

  • On the PC, copy a large image file onto a FAT32 formatted SD-Card (like my attached test.bmp)
  • On WEC7 in the file explorer, use clipboard copy and paste to create a copy of the original file on the SD-Card
  • Open the original file using the WEC7 image viewer → it shows fine
  • Open the copy using the WEC7 image viewer → it either doesn’t show or shows corrupted
  • Take the SD-Card back to the PC and open the copied image → the corruption is the same

I’m attaching an example of the uncorrupted image and of a corrupted one.

For us the issue is not really copying, but when we create files in our application and write them directly to the SD-Card - as soon as they are large enough, they get corrupted. They don’t corrupt when written to internal Flash or USB-Drive.

Thank you so much for helping out here.

TEST - Copy.BMP (1.1 MB)
TEST.BMP (1.1 MB)

Yes I’ve copied file from USB stick to SD card using Win CE

  • Double click on “My device”
  • Go to “USB HD”
  • Right click on “test.bmp”
  • Select “Copy”
  • Go to to “SD Card”
  • Right click and select “Paste”
  • Then double click on test.bmp
  • Result : Image as expected
    Then I’ve compared both test.bmp files and they are identical

Alex, thank you for being so fast in answering, that’s fantastic.

There must be a difference somewhere, even though I have no clue right now :frowning:
On T20’s it works perfectly, but on iMX7 we have the issue. I’ll keep on digging.

Which board did you use?
We have used Iris and Colibri Dev Board.

Сolibri iMX7D v1.1B
Colibri Evaluation Board v3.1A
Samsung PRO 32GB SD card

Hi Alex,

I have found a difference:

  • SD Card works fine on WEC7 1.3B2.
  • Corruption issues show on WEC7 1.3 (2021-11-25)

When I install colibri-imx7_winceimage_1.3b2-20190731.zip (bootloader and OS image). SD-Card is working fine.

When I install 104651-imx7-wince-image.zip, which is the official stable version, SD-Card writes have corruption issues.

We reproduced the mistake on:

  • Boards: Aster, Iris and Colibri Dev Board V3.1a
  • CoM: Multiple iMX7 1.1D 512 GB
  • SD-Cards: Kingston SDHC 4GB, Sandsik Ultra 16 GB, and others

I’m really very sure, that this is neither a boards issue, nor a card issue but in the OS image.

I’m hesitant to go back from using the official 1.3 image to 1.3b2 as we intend to use SPI in the near future, and 1.3 lists fixes for SPI.

Thanks for your help here!

Yes I can confirm reported issue with 1.3 image. We will investigate it and post an update ASAP.

1 Like

As a workaround you can disable DMA

[HKEY_LOCAL_MACHINE\Drivers\BuiltIn\ESDHC]
“DisableDMA” = dword:1

Alex,

Yes, this does solve the issue. I haven’t checked the impact on performance, yet.
Thanks for the workaround and for looking into the issue right away!

Greetings from Bavaria,
Daniel

It doesn’t affect read/write speed too much. Short transactions will be even faster. However big data transfer will definitely load CPU which can affect CPU hungry apps.

Thanks, very good to know!
Are you planning to release a new OS image that will have DMA reenabled for SD-Card?

Yes, this issue will be fixed in the next release.

1 Like

Hello @alex.tx - is there a newer WEC7 release we can test that has the DMA issue fixed? We’ll be saving larger files now to the SD-Card and would benefit from DMA.

And on a sidenote on DMA: We plan to interface to Espressif ESP32 C3 WiFi module via SPI. In the documentation of the SPI Lib it says that DMA isn’t supported on iMX7. Do you have a version that does support SPI via DMA?

Thank you!

We are planning to release a new version next month. However, according to information from our developers, it is highly unlikely that the issue with DMA support for ESDHC will be resolved. Therefore, DMA will be disabled by default in the SD card driver.

Unfortunately, we do not have an SPI library for the iMX7 that supports DMA

Thank you for checking and replying.