Skip to main content
Visitor II
April 3, 2021
Question

Writing .BMP to SD card using FATFS. Distorted image.

  • April 3, 2021
  • 2 replies
  • 1060 views

Hi!

I wrote a program to write a .bmp file to SD card using FATFS. I am using STM32CubeIDE and its generated code. I converted my .bmp file to a byte array online and then copied the array to my program.

If i write the whole data at once, everything is ok. The image appears on SD card and is not distorted.

res = f_write(&SDFile, bmp , 8864, (void *)&byteswritten);

0693W000008ydeRQAQ.bmpIf I write data in two parts, the image appears on SD, but its upper rows get shifted right a little.

res = f_write(&SDFile, header , 62, (void *)&byteswritten);
res = f_write(&SDFile, pixeldata , 8802, (void *)&byteswritten);

0693W000008ydeWQAQ.bmpWhat could be the problem? Thank you!

    This topic has been closed for replies.

    2 replies

    Visitor II
    April 20, 2021

    Hello Andrei,

    We have no known issue where a file, when written in chunks, a data corruption occurs. Could you please provide the bitmap file (in its binary and header form)?

    Letting us know which FATFs version, cube IDE version, device ID, cube firmware version, etc... would be helpful.

    BeST regards,

    Walid

    Visitor II
    February 23, 2022

    Hello Andrei,

    I think you can open two files with hex editor and compare the headers.