Using SD card on nRF9161 DK

Hello, we've a nRF9161 DK board a we saw on the back side a footprint for mounting an SD card holder and we found the SD card holder component in the BOM.

Unfortunately there is no mention about the usage of the SD card in for the nRF9161 DK anywhere in the documentation.

Is there any problem on using the SD card on nRF9161 DK (trough SPI I guess) ?

What do we have to do to connect the SD card to the nRF9161 module (excluding the soldering of the card holder)?

Thanks in advance for the support,

Joel

Parents
  • I was talking about J8 on the bottom side of the board listed on the BOM as "microSD Card Connector"...

  • It shouldn't matter whether it is an nRF9161DK or nRF52840DK when it comes to SD card. 

    Or did I misunderstand you?

    Best regards,

    Edvin

  • Hello... I'm a little confused ... mass storage example is building with success when i set nrf52840dk/nrf52840 as board (which has its dt overlay under boards).

    west build -b nrf52840dk/nrf52840 -d build -- -DCONFIG_APP_MSC_STORAGE_SDCARD=y is ok

    If I set nrf9161dk/nrf9161 the build ends with errors ... 

    west build -b nrf9161dk/nrf9161 -d build -- -DCONFIG_APP_MSC_STORAGE_SDCARD=y fails

    C:/ncs/v3.0.2/zephyr/samples/subsys/usb/mass/src/main.c:36:2: error: #error No supported disk driver enabled
       36 | #error No supported disk driver enabled

    Joel

  • You need to copy the nrf52840-related overlay file and rename it for the board you are building for (nrf9161dk_nrf9161_cpuapp.overlay).

    Best regards,

    Edvin

  • Ok, of course this makes the sample building with success ... but nrf52840dk_nrf52840.overlay  maps storage_partition onto the mx25r64 serial SPI flash ... not to the SD card .

    Which changes are needed to set storage_partition being pointing to the SD card ?

    Joel

  • Hi Joel,

    Edvin is out of office on PTO so I'll be handling this case for this week (lets hope we can resolve it by Friday before I also leave for PTO..).

    If I understand you correct, what you're missing now is to port the solution so that it works on a 9161dk, right? 

    If so, then what we're missing should be the following.

    You're correct that this specific configuration maps to the SPI flash, which is due to the nRF52840DK not having a SD card reader on board so it requires the additional hardware mentioned in the build command here:

    But lets stick to making this sample work for the nRF9160DK before we look into the SD card implenation (divide and conquer the problem).

    It also mentions the additional config in the last build argument and since you're working with NCS, you still need to have a pm_static.yml for your partitioning as well as an overlay tailored to the board you're using, which brings us to the last problem.

    Edvin says that you can copy the nrf52840 related overlay and rename it for the board you're building for, which is correct, but you also have to make a modification to the external flash device that you're using. The nRF9161  uses the GD25WB256 flash, which you can see in an overlay file here: https://github.com/NordicDeveloperAcademy/ncs-inter/blob/main/l9/l9_e3_sol/spi/app_gd.overlay and/or in any cellular samples in nrf/samples where the external flash is enabled or the board files within zephyr/boards/nordic/ in the SDK.

    I.e change your overlay (which should be) for

    nrf52840dk_nrf52840.overlay:

    /*
     * Copyright (c) 2019 Peter Bigot Consulting, LLC
     *
     * SPDX-License-Identifier: Apache-2.0
     */
    
    /delete-node/ &storage_partition;
    
    &mx25r64 {
    	partitions {
    		compatible = "fixed-partitions";
    		#address-cells = <1>;
    		#size-cells = <1>;
    
    		storage_partition: partition@0 {
    			label = "storage";
    			reg = <0x00000000 0x00020000>;
    		};
    	};
    };
    
    / {
    	msc_disk0 {
    		compatible = "zephyr,flash-disk";
    		partition = <&storage_partition>;
    		disk-name = "NAND";
    		cache-size = <4096>;
    	};
    };

    to 

    nrf9160dk_nrf9160.overlay (or the target you're building for as listed: 

    and do something like (I've merged the app_gd.overlay and the 52840 overlay, there might be something wrong so check when building if it behaves as expected)

    /*
     * Copyright (c) 2019 Peter Bigot Consulting, LLC
     *
     * SPDX-License-Identifier: Apache-2.0
     */
    
    /delete-node/ &storage_partition;
    
    &gd25wb256 {
    	status = "okay";
    };
    
    / {
    	chosen {
    		nordic,pm-ext-flash = &gd25wb256;
    	};
    };
    
    
    &gd25wb256 {
    	partitions {
    		compatible = "fixed-partitions";
    		#address-cells = <1>;
    		#size-cells = <1>;
    
    		storage_partition: partition@0 {
    			label = "storage";
    			reg = <0x00000000 0x00020000>;
    		};
    	};
    };
    
    / {
    	msc_disk0 {
    		compatible = "zephyr,flash-disk";
    		partition = <&storage_partition>;
    		disk-name = "NAND";
    		cache-size = <4096>;
    	};
    };

    After we've succeeded with this, we should have a emulated SD card in SPI external flash for the 9161DK which is good, because now we now that the sample works and compiles for the nRF9160DK and we can exclude quite a bit of uncertainties.

    The next task is to port it to an SD card.

    To do this we need some more modifications (or additional hardware). "west build -b nrf52840dk/nrf52840 --shield waveshare_epaper_gdeh0154a07 samples/subsys/usb/mass -- -DCONFIG_APP_MSC_STORAGE_SDCARD=y" handles the extra hardware since it uses a shield that has an SD card reader, and it adds the extra configuration.

    In addition https://docs.nordicsemi.com/bundle/ncs-latest/page/zephyr/samples/subsys/usb/mass/README.html#sd_card_example takes us to modifications that you need to do yourself, i.e https://docs.nordicsemi.com/bundle/ncs-latest/page/zephyr/services/storage/disk/access.html#disk-access-api and to add a SPI (I assume that this is the peripheral you will be using) that can do SD card https://docs.nordicsemi.com/bundle/ncs-latest/page/zephyr/services/storage/disk/access.html#disk-access-api. An example can be seen in the latter link for how to set this up:

    &spi1 {
            status = "okay";
            cs-gpios = <&porta 27 GPIO_ACTIVE_LOW>;
    
            sdhc0: sdhc@0 {
                    compatible = "zephyr,sdhc-spi-slot";
                    reg = <0>;
                    status = "okay";
                    mmc {
                        compatible = "zephyr,sdmmc-disk";
                        disk-name = "SD";
                        status = "okay";
                    };
                    spi-max-frequency = <24000000>;
            };
    };

    Kind regards,
    Andreas

Reply
  • Hi Joel,

    Edvin is out of office on PTO so I'll be handling this case for this week (lets hope we can resolve it by Friday before I also leave for PTO..).

    If I understand you correct, what you're missing now is to port the solution so that it works on a 9161dk, right? 

    If so, then what we're missing should be the following.

    You're correct that this specific configuration maps to the SPI flash, which is due to the nRF52840DK not having a SD card reader on board so it requires the additional hardware mentioned in the build command here:

    But lets stick to making this sample work for the nRF9160DK before we look into the SD card implenation (divide and conquer the problem).

    It also mentions the additional config in the last build argument and since you're working with NCS, you still need to have a pm_static.yml for your partitioning as well as an overlay tailored to the board you're using, which brings us to the last problem.

    Edvin says that you can copy the nrf52840 related overlay and rename it for the board you're building for, which is correct, but you also have to make a modification to the external flash device that you're using. The nRF9161  uses the GD25WB256 flash, which you can see in an overlay file here: https://github.com/NordicDeveloperAcademy/ncs-inter/blob/main/l9/l9_e3_sol/spi/app_gd.overlay and/or in any cellular samples in nrf/samples where the external flash is enabled or the board files within zephyr/boards/nordic/ in the SDK.

    I.e change your overlay (which should be) for

    nrf52840dk_nrf52840.overlay:

    /*
     * Copyright (c) 2019 Peter Bigot Consulting, LLC
     *
     * SPDX-License-Identifier: Apache-2.0
     */
    
    /delete-node/ &storage_partition;
    
    &mx25r64 {
    	partitions {
    		compatible = "fixed-partitions";
    		#address-cells = <1>;
    		#size-cells = <1>;
    
    		storage_partition: partition@0 {
    			label = "storage";
    			reg = <0x00000000 0x00020000>;
    		};
    	};
    };
    
    / {
    	msc_disk0 {
    		compatible = "zephyr,flash-disk";
    		partition = <&storage_partition>;
    		disk-name = "NAND";
    		cache-size = <4096>;
    	};
    };

    to 

    nrf9160dk_nrf9160.overlay (or the target you're building for as listed: 

    and do something like (I've merged the app_gd.overlay and the 52840 overlay, there might be something wrong so check when building if it behaves as expected)

    /*
     * Copyright (c) 2019 Peter Bigot Consulting, LLC
     *
     * SPDX-License-Identifier: Apache-2.0
     */
    
    /delete-node/ &storage_partition;
    
    &gd25wb256 {
    	status = "okay";
    };
    
    / {
    	chosen {
    		nordic,pm-ext-flash = &gd25wb256;
    	};
    };
    
    
    &gd25wb256 {
    	partitions {
    		compatible = "fixed-partitions";
    		#address-cells = <1>;
    		#size-cells = <1>;
    
    		storage_partition: partition@0 {
    			label = "storage";
    			reg = <0x00000000 0x00020000>;
    		};
    	};
    };
    
    / {
    	msc_disk0 {
    		compatible = "zephyr,flash-disk";
    		partition = <&storage_partition>;
    		disk-name = "NAND";
    		cache-size = <4096>;
    	};
    };

    After we've succeeded with this, we should have a emulated SD card in SPI external flash for the 9161DK which is good, because now we now that the sample works and compiles for the nRF9160DK and we can exclude quite a bit of uncertainties.

    The next task is to port it to an SD card.

    To do this we need some more modifications (or additional hardware). "west build -b nrf52840dk/nrf52840 --shield waveshare_epaper_gdeh0154a07 samples/subsys/usb/mass -- -DCONFIG_APP_MSC_STORAGE_SDCARD=y" handles the extra hardware since it uses a shield that has an SD card reader, and it adds the extra configuration.

    In addition https://docs.nordicsemi.com/bundle/ncs-latest/page/zephyr/samples/subsys/usb/mass/README.html#sd_card_example takes us to modifications that you need to do yourself, i.e https://docs.nordicsemi.com/bundle/ncs-latest/page/zephyr/services/storage/disk/access.html#disk-access-api and to add a SPI (I assume that this is the peripheral you will be using) that can do SD card https://docs.nordicsemi.com/bundle/ncs-latest/page/zephyr/services/storage/disk/access.html#disk-access-api. An example can be seen in the latter link for how to set this up:

    &spi1 {
            status = "okay";
            cs-gpios = <&porta 27 GPIO_ACTIVE_LOW>;
    
            sdhc0: sdhc@0 {
                    compatible = "zephyr,sdhc-spi-slot";
                    reg = <0>;
                    status = "okay";
                    mmc {
                        compatible = "zephyr,sdmmc-disk";
                        disk-name = "SD";
                        status = "okay";
                    };
                    spi-max-frequency = <24000000>;
            };
    };

    Kind regards,
    Andreas

Children
No Data
Related