Zephyr nrf52840 SD Card issue

Hi.

1. code path ncs\v2.6.0\zephyr\samples\subsys\fs

2. use 16G SD Card

3. Direct connected SD card to nrf52840_SK (VCC , GND , CS , CLK , MOSI , MISO)

4. The SD Cord use FAT and no any data

Question : Can't access SD card

below is pr.conf

CONFIG_DISK_ACCESS=y
CONFIG_LOG=y
CONFIG_FILE_SYSTEM=y
CONFIG_FAT_FILESYSTEM_ELM=y
CONFIG_PRINTK=y
CONFIG_MAIN_STACK_SIZE=2048


CONFIG_DISK_DRIVER_SDMMC=y
CONFIG_SPI=y

below is app.overlay (Don't use nrf52840dk_nrf52840.overlay)

/ {
	pinctrl: pin-controller 
	{
		compatible = "nordic,nrf-pinctrl";
		spi1_default: spi1_default {
			group1 {
				psels = <NRF_PSEL(SPIM_SCK, 0, 31)>,
					<NRF_PSEL(SPIM_MOSI, 0, 30)>,
					<NRF_PSEL(SPIM_MISO, 0, 8)>;
			};
		};
	
		spi1_sleep: spi1_sleep {
			group1 {
				psels = <NRF_PSEL(SPIM_SCK, 0, 31)>,
					<NRF_PSEL(SPIM_MOSI, 0, 30)>,
					<NRF_PSEL(SPIM_MISO, 0, 8)>;
				low-power-enable;
			};
		};
	};
};

&spi1 {
    status = "okay";
    cs-gpios = < &gpio0 21 GPIO_ACTIVE_HIGH >;
    sdhc0: sdhc@0 {
        compatible = "zephyr,mmc-spi-slot";
        reg = < 0x0 >;
        status = "okay";
        label = "SDHC0";
        spi-max-frequency = < 24000000 >;
    };
};

below is log

*** Booting Zephyr OS build v3.3.99-ncs1-1 ***
[00:00:00.438,751] <err> main: Storage init ERROR!
[00:00:00.438,812] <err> fs: fs mount error (-5)
Error mounting disk.
[00:00:00.438,842] <err> fs: fs not mounted (mp == 0x20000000)

  • I get the same question on 52840. I checked the overlay file.  But it can run on 52832.

    / {
    	pinctrl: pin-controller 
    	{
    		compatible = "nordic,nrf-pinctrl";
    		spi1_default: spi1_default {
    			group1 {
    				psels = <NRF_PSEL(SPIM_SCK, 0, 23)>,
    					<NRF_PSEL(SPIM_MOSI, 0, 20)>,
    					<NRF_PSEL(SPIM_MISO, 0, 21)>;
    			};
    		};
    	
    		spi1_sleep: spi1_sleep {
    			group1 {
    				psels = <NRF_PSEL(SPIM_SCK, 0, 23)>,
    					<NRF_PSEL(SPIM_MOSI, 0, 20)>,
    					<NRF_PSEL(SPIM_MISO, 0, 21)>;
    				low-power-enable;
    			};
    		};
    	};
    };
    
    &spi1 {
        status = "okay";
        cs-gpios = < &gpio0 19 GPIO_ACTIVE_HIGH>;
    	sdhc-spi-slot@0 {
    		compatible = "zephyr,sdhc-spi-slot";
    		reg = <0x0 >;
    		spi-max-frequency = <24000000>;
    		status = "okay";
    		
    		mmc {
    			compatible = "zephyr,sdmmc-disk";
    			status = "okay";
    			
    		};	
    	};
    };

    this code build with 52832, It can run. power gnd cs mosi clk miso the same.

    what can i do next?

  • this is my error message:

    *** Booting nRF Connect SDK v2.5.0 ***
    [00:00:01.025,970] <err> spi_nrfx_spi: Timeout waiting for transfer complete
    [00:00:01.026,000] <err> sdhc_spi: Card SCLK init sequence failed
    [00:00:01.026,031] <err> sd: Could not disable card power via SDHC
    [00:00:01.026,031] <err> main:  1 - Storage init ERROR!
    [00:00:01.227,264] <err> spi_nrfx_spi: Timeout waiting for transfer complete
    [00:00:01.227,294] <err> sdhc_spi: Card SCLK init sequence failed
    [00:00:01.227,294] <err> sd: Could not disable card power via SDHC
    [00:00:01.227,325] <err> fs: fs mount error (-5)
    Error mounting disk.
    [00:00:01.227,355] <err> fs: fs not mounted (mp == 0x20000000)
    

  • Make your own post with your issue - its VERY likely different from the problem that OP had.

Related