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"...

  • Hello Joel,

    You can have a look at the USB Mass storage sample found in NCS\zephyr\samples\subsys\usb\mass.

    Please check out the sample description found here, as this shows how to enable support for SD cards:

    https://docs.nordicsemi.com/bundle/ncs-latest/page/zephyr/samples/subsys/usb/mass/README.html#usb-mass

    Best regards,

    Edvin

  • Hello... before using the SD card.(mount it and write/read to it) I've to format it ... isn't it ?

    The SD card gets now properly detected (disk_access_init):

    *** Booting nRF Connect SDK v3.0.2-89ba1294ac9b ***
    *** Using Zephyr OS v4.0.99-f791c49f492c ***
    [00:00:00.252,471] <dbg> sd: sd_init_io: Host controller support 3.3V max
    [00:00:00.252,471] <dbg> sd: sd_init_io: Resetting power to card
    [00:00:00.256,195] <dbg> sdhc_spi: sdhc_spi_send_cmd: cmd0 arg 0x0
    [00:00:00.256,988] <dbg> sdhc_spi: sdhc_spi_send_cmd: cmd8 arg 0x1aa
    [00:00:00.257,751] <dbg> sd: sd_send_interface_condition: Found SDHC with CMD8 support
    [00:00:00.257,781] <dbg> sdhc_spi: sdhc_spi_send_cmd: cmd59 arg 0x1
    [00:00:00.258,544] <dbg> sdhc_spi: sdhc_spi_send_cmd: cmd58 arg 0x0
    [00:00:00.259,429] <dbg> sdhc_spi: sdhc_spi_send_cmd: cmd55 arg 0x0
    [00:00:00.260,223] <dbg> sdhc_spi: sdhc_spi_send_cmd: cmd41 arg 0x40000000
    [00:00:00.271,087] <dbg> sdhc_spi: sdhc_spi_send_cmd: cmd55 arg 0x0
    [00:00:00.271,881] <dbg> sdhc_spi: sdhc_spi_send_cmd: cmd41 arg 0x40000000
    [00:00:00.272,644] <dbg> sd: sdmmc_send_ocr: SDMMC responded to ACMD41 after 1 attempts
    [00:00:00.272,674] <dbg> sdhc_spi: sdhc_spi_send_cmd: cmd58 arg 0x40000000
    [00:00:00.273,468] <dbg> sdhc_spi: sdhc_spi_send_cmd: cmd10 arg 0x0
    [00:00:00.274,902] <dbg> sd: card_read_cid: Card MID: 0x3, OID: DS
    [00:00:00.274,932] <dbg> sdhc_spi: sdhc_spi_send_cmd: cmd9 arg 0x0
    [00:00:00.276,397] <dbg> sd: sdmmc_read_csd: Card block count 7744512, block size 512
    [00:00:00.276,397] <inf> sd: Maximum SD clock is under 25MHz, using clock of 1000000Hz
    [00:00:00.276,428] <dbg> sdhc_spi: sdhc_spi_send_cmd: cmd55 arg 0x0
    [00:00:00.276,977] <dbg> sdhc_spi: sdhc_spi_send_cmd: cmd51 arg 0x0
    [00:00:00.277,740] <dbg> sd: sdmmc_read_scr: SD reports specification version 8
    [00:00:00.277,770] <inf> littlefs: LittleFS version 2.9, disk version 2.1

    but I get an error calling:

    #define MKFS_FS_TYPE FS_LITTLEFS
    #define MKFS_DEV_ID "SDCard"
    #define MKFS_FLAGS 0

     fs_mkfs(MKFS_FS_TYPE, (uintptr_t)MKFS_DEV_ID, NULL, MKFS_FLAGS);

    [00:00:00.277,770] <err> littlefs: Can't init littlefs backend, review configs and flags 0x00000000
    [00:00:00.277,770] <err> fs: mkfs error (-134)

    My .conf is:

    CONFIG_DISK_ACCESS=y
    CONFIG_DISK_DRIVERS=y
    CONFIG_DISK_DRIVER_SDMMC=y

    CONFIG_DEBUG=y
    CONFIG_LOG=y
    CONFIG_LOG_MODE_MINIMAL=n

    CONFIG_FILE_SYSTEM=y
    CONFIG_FILE_SYSTEM_LITTLEFS=y
    CONFIG_FILE_SYSTEM_MKFS=y

    CONFIG_FS_LITTLEFS_BLK_DEV=y
    CONFIG_FS_LITTLEFS_FMP_DEV=n

    Is there something missing ? how shall i call fs_mkfs in order to format the SD card ?

    The USB mass storage code sample do not helps me a lot in the understanding on how to make the connection between  LittleFS and the file system to the sd card driver ... 

    Is there anything missing the dts overlay (like partitions ... )?  Sorry it may be a stupid question but I'm really new to Zephyr and the understanding is not immediate to me (if I understood it corectly mass storage sample supports only FAT as fs for  SD card and not LittleFS on SD card).

    Thx, Joel

  • Can you try to format it using the mass storage sample? If you insert it and connect the DK with the nRF's USB port, does it show up at all in the listed drives attached to your computer? If not, do you have one of these USB->SD-card adapters that you can try to use?

    Best regards,

    Edvin

  • Hello... I formatted no the SD card with a FAT filesystem (to get at leas a starting point) ... I will switch to LittleFS later once things are working... 

    I'm using SDK v3.0.2 on visual studio code ith the v3.0.2 tool-chain. Looking at the README.rst description to build the usb mass storage it should be enough:

    - create a new application using copy from sample (usb mass storage) sample 

    - add a build configuration with Board target set to nrf9161dc/nrf9161

    - at this point (to build for SD card with SPI interface ) the README requires to invoke the build with the option -DCONFIG_APP_MSC_STORAGE_SDCARD=y (which I suppose is defining the symbol CONFIG_APP_MSC_STORAGE_SDCARD and sets it to the value y). Since I'm calling the build directly from VSCode... how should I set CONFIG_APP_MSC_STORAGE_SDCARD to y ? directly in prj.conf ? using Kconfig GUI ? ... 

    If I just build the application without any modification I get a compilation error stating:

    C:/ncs/MyApp/mass_2/src/main.c:36:2: error: #error No supported disk driver enabled
       36 | #error No supported disk driver enabled

    Same thing if I add CONFIG_APP_MSC_STORAGE_SDCARD=y directly to prj.conf.

    What do I need to set to successfully build this sample for SD card on SPI interface with FAT filesystem on nrf9161DK ?

  • Just to understand if there is something wrong with the sample or my SDK (v3.0.2 ) installation I generated a new mass storage project for nrf52840dk/nrf52840 (which is listed in the README file as a compatible board).

    The sample doesn't build ... 

    C:/ncs/v3.0.2/nrf/include/flash_map_pm.h:47:22: error: 'PM_storage_partition_ID' undeclared (first use in this function)
       47 | #define PM_ID(label) PM_##label##_ID

    ...

    How shall I proceed to get this sample be configured and build correctly ?

    Joel

Reply
  • Just to understand if there is something wrong with the sample or my SDK (v3.0.2 ) installation I generated a new mass storage project for nrf52840dk/nrf52840 (which is listed in the README file as a compatible board).

    The sample doesn't build ... 

    C:/ncs/v3.0.2/nrf/include/flash_map_pm.h:47:22: error: 'PM_storage_partition_ID' undeclared (first use in this function)
       47 | #define PM_ID(label) PM_##label##_ID

    ...

    How shall I proceed to get this sample be configured and build correctly ?

    Joel

Children
No Data
Related