cancel
Showing results for 
Search instead for 
Did you mean: 

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

Andrei1
Associate II

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!

2 REPLIES 2

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

KBaya.1
Associate

Hello Andrei,

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