Page 1 of 1

STM32F746G-DISCO microSD Card Issues

Posted: Fri Sep 13, 2019 7:04 pm
by jtrug
Hi,

Board: STM32F746G-DISCO
Version: Chibios 17.6,18.2.2,19.1.3
Compiler: GCC 7.0 (Windows ChibiStudio)

I am trying to write to the microSD on my F7 discovery board with FatFS. Whenever using 18.2 or 19.2 I get consistent but periodic garbage on the output. See attached hellobad.txt for an example. I rolled back to the 17.6 and the same code produced no problem at all. See hello3good.txt for example of it.

In each case I take the demo included with Chibios and change the configuration to enable sd card and serial and then nothing else. The code I am using for my test is included below.

Code: Select all

    sdStart(&SD1, NULL);

    static BaseSequentialStream* chp = (BaseSequentialStream*)&SD1;

    if (!blkIsInserted(&SDCD1)) {
      chprintf(chp, "Card not inserted, aborting.\r\n");
    }
    else{
      chprintf(chp, "Card is inserted.\r\n");
    }

    chprintf(chp, "Connecting... ");

    if (sdcConnect(&SDCD1)) {
      chprintf(chp, "failed\r\n");
    }

    FATFS fs;           /* Filesystem object */
    FIL fil;            /* File object */
    FRESULT res;        /* API result code */
    UINT bw;            /* Bytes written */

    f_mount(&fs, "", 0);
    res = f_open(&fil, "hello4.txt", FA_CREATE_ALWAYS | FA_WRITE);
    for (int i = 0; i < 200; ++i) {
      f_write(&fil, "Hello, World!\r\n", 15, &bw);
    }

    f_close(&fil);
    chprintf(chp, "done writing");


Anyone have any idea what could be different or the problem?

Thanks,

Re: STM32F746G-DISCO microSD Card Issues

Posted: Fri Sep 13, 2019 8:54 pm
by Giovanni
Hi,

Have you checked for possible stack overflows?

Giovanni

Re: STM32F746G-DISCO microSD Card Issues

Posted: Mon Sep 16, 2019 2:23 pm
by jtrug
Thanks that solved my issue. Going into the makefile and increasing the stack size of the main thread fixed all my write issues.

Appreciate the quick help!