STM32F746G-DISCO microSD Card Issues Topic is solved

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
jtrug
Posts: 2
Joined: Fri Sep 13, 2019 6:24 pm

STM32F746G-DISCO microSD Card Issues

Post 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,
Attachments
hello.zip
Results of SD Card Testing Good and Bad
(348 Bytes) Downloaded 336 times
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: STM32F746G-DISCO microSD Card Issues

Post by Giovanni »

Hi,

Have you checked for possible stack overflows?

Giovanni
jtrug
Posts: 2
Joined: Fri Sep 13, 2019 6:24 pm

Re: STM32F746G-DISCO microSD Card Issues

Post 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!
Post Reply