Zephyr fatfs example fails with SD card

Hi,

I'm trying to reproduce the fatfs example on a nrf52840 DK and Sandisk micro SD card that's plugged into a Sparkfun Transflash breakout board. I can't seem to mount the micro SD card in the sample example (I've confirmed that the micro SD card is formatted correctly). I've tried this on NCS v2.0.0 and v2.1.0

Here is the overlay I'm using:

```

&spi1 {
    status = "okay";

    cs-gpios = <&gpio1 17 GPIO_ACTIVE_HIGH>;

    sdhc0: sdhc@0 {
        compatible = "zephyr,mmc-spi-slot";
        reg = <0>;
        status = "okay";
        label = "SDHC0";
        spi-max-frequency = <1000000>;
    };
};
```
and here is the prj.conf:
````
CONFIG_DISK_DRIVER_SDMMC=y
CONFIG_SPI=y
CONFIG_DISK_ACCESS=y
CONFIG_LOG=y
CONFIG_FILE_SYSTEM=y
CONFIG_FAT_FILESYSTEM_ELM=y
CONFIG_PRINTK=y
CONFIG_MAIN_STACK_SIZE=2048
```
 

Can you advise?

Parents
  • Hi

    What error exactly are you getting on your application's end? It could be an electrical issue if the SD card doesn't support the same voltage levels as the nRF52 for example. There has been a known issue in the past that the voltage on VDD on the DK is too low for some SD cards. What other GPIOs than P0.17 are you using to connect your SD card?

    Best regards,

    Simon

  • Hi Simon,

    Thanks for getting back. This is the error I'm seeing from the SD SPI driver (it looks like getting zeroes back on the SPI bus with no activity):

    00> *** Booting Zephyr OS build v3.0.99-ncs1 ***
    00>
    00> MAB sdhc_spi_detect -- set card to idle state
    00>
    00> MAB sdhc_spi_detect -- enabled crc mode
    00>
    00> MAB sdhc_spi_detect -- card left idle state
    00>
    00> MAB sdhc_spi_detect -- successfully read OCR (ocr = 0)
    00>
    00> MAB sdhc_spi_detect -- successfully read CSD
    00>
    00> MAB sdhc_spi_rx_block -- token = 0
    00>
    00> MAB sdhc_spi_detect -- sdhc_spi_rx_block was unsuccessful (-5)
    00>
    00> MAB disk_spi_sdhc_access_init -- sdhc_spi_detect err = -5
    00>
    00> [00:00:00.377,410] <err> main: Storage init ERROR!
    00> Failed to mount SD card
    00>

    The connections are as follows:

    DI <--> P0.30

    SCK <--> P0.31

    DO <--> P0.08

    Please let me know what else to try to identify the issue.

    Best,

Reply
  • Hi Simon,

    Thanks for getting back. This is the error I'm seeing from the SD SPI driver (it looks like getting zeroes back on the SPI bus with no activity):

    00> *** Booting Zephyr OS build v3.0.99-ncs1 ***
    00>
    00> MAB sdhc_spi_detect -- set card to idle state
    00>
    00> MAB sdhc_spi_detect -- enabled crc mode
    00>
    00> MAB sdhc_spi_detect -- card left idle state
    00>
    00> MAB sdhc_spi_detect -- successfully read OCR (ocr = 0)
    00>
    00> MAB sdhc_spi_detect -- successfully read CSD
    00>
    00> MAB sdhc_spi_rx_block -- token = 0
    00>
    00> MAB sdhc_spi_detect -- sdhc_spi_rx_block was unsuccessful (-5)
    00>
    00> MAB disk_spi_sdhc_access_init -- sdhc_spi_detect err = -5
    00>
    00> [00:00:00.377,410] <err> main: Storage init ERROR!
    00> Failed to mount SD card
    00>

    The connections are as follows:

    DI <--> P0.30

    SCK <--> P0.31

    DO <--> P0.08

    Please let me know what else to try to identify the issue.

    Best,

Children
No Data
Related