Can't see SD card via usbd_msc

I am trying to see onboard SD card via usbd_msc and I can not achieve that. I am sure SD card is connected properly and working as I can mount it and write files to it form on-chip code. But if I try to configure MSC device to use SD card as a backed, my Linux system does not mount it. In fact, I think it does not get partition table. I have tired using RAM blockdevice and I could mount it no problem. Can anyone suggest where should I look, how do I debug this?

The card I am using is Kingston 32G card, I have tried splitting 1MB partition and formatting the whole card to FAT32 from nrf52840 code using f_mkfs to no avail, however it's size is detected correctly:

Jan  3 20:03:59 veikia kernel: [ 6313.067048] usb 1-4: new full-speed USB device number 50 using xhci_hcd
Jan  3 20:03:59 veikia kernel: [ 6313.218460] usb 1-4: New USB device found, idVendor=0000, idProduct=0000
Jan  3 20:03:59 veikia kernel: [ 6313.218469] usb 1-4: New USB device strings: Mfr=1, Product=1, SerialNumber=1
Jan  3 20:03:59 veikia kernel: [ 6313.218476] usb 1-4: Product: 000000000000
Jan  3 20:03:59 veikia kernel: [ 6313.218482] usb 1-4: Manufacturer: 000000000000
Jan  3 20:03:59 veikia kernel: [ 6313.218488] usb 1-4: SerialNumber: 000000000000
Jan  3 20:03:59 veikia kernel: [ 6313.224824] usb-storage 1-4:1.0: USB Mass Storage device detected
Jan  3 20:03:59 veikia kernel: [ 6313.225148] scsi host2: usb-storage 1-4:1.0
Jan  3 20:03:59 veikia mtp-probe: checking bus 1, device 50: "/sys/devices/pci0000:00/0000:00:14.0/usb1/1-4"
Jan  3 20:03:59 veikia mtp-probe: bus: 1, device: 50 was not an MTP device
Jan  3 20:04:00 veikia kernel: [ 6314.252097] scsi 2:0:0:0: Direct-Access     Zive     SDC              1.00 PQ: 0 ANSI: 6
Jan  3 20:04:00 veikia kernel: [ 6314.253129] sd 2:0:0:0: Attached scsi generic sg1 type 0
Jan  3 20:04:00 veikia kernel: [ 6314.253466] sd 2:0:0:0: [sdb] 60751872 512-byte logical blocks: (31.1 GB/29.0 GiB)
Jan  3 20:04:00 veikia kernel: [ 6314.331242] sd 2:0:0:0: [sdb] Write Protect is off
Jan  3 20:04:00 veikia kernel: [ 6314.331244] sd 2:0:0:0: [sdb] Mode Sense: 00 00 00 00
Jan  3 20:04:00 veikia kernel: [ 6314.411549] sd 2:0:0:0: [sdb] Asking for cache data failed
Jan  3 20:04:00 veikia kernel: [ 6314.411567] sd 2:0:0:0: [sdb] Assuming drive cache: write through

However, mounting process seems to stop here. I can not see SD card being accessed - no clock, no CS signal.

USB state machine in nrf82540 goes like this:

<info> app: USB CONNECTED
<info> app: Initializing disk 0 (RAM)...
<info> app: Mounting volume...
<info> app: USB power detected
<info> app: USB ready
<info> app: APP_USBD_EVT_STATE_CHANGED
<info> app: USB evt start
<info> app: USB suspend
<info> app: USB resume
<info> app: APP_USBD_EVT_STATE_CHANGED
<info> app: APP_USBD_EVT_STATE_CHANGED
<info> app: APP_USBD_EVT_STATE_CHANGED
<info> app: APP_USBD_EVT_STATE_CHANGED
<info> app: APP_USBD_EVT_STATE_CHANGED
<info> app: APP_USBD_EVT_STATE_CHANGED

However, when I disconnect the device from USB, Linux burps this:



Jan  3 20:18:37 veikia kernel: [ 7191.639773] usb 1-4: reset full-speed USB device number 51 using xhci_hcd


Jan  3 20:19:02 veikia kernel: [ 7216.463163] usb 1-4: USB disconnect, device number 51
Jan  3 20:19:02 veikia kernel: [ 7216.478990] sd 2:0:0:0: [sdb] tag#0 FAILED Result: hostbyte=DID_NO_CONNECT driverbyte=DRIVER_OK
Jan  3 20:19:02 veikia kernel: [ 7216.479007] sd 2:0:0:0: [sdb] tag#0 CDB: Read(10) 28 00 00 00 00 00 00 00 08 00
Jan  3 20:19:02 veikia kernel: [ 7216.479016] print_req_error: I/O error, dev sdb, sector 0
Jan  3 20:19:02 veikia kernel: [ 7216.479036] Buffer I/O error on dev sdb, logical block 0, async page read
Jan  3 20:19:02 veikia kernel: [ 7216.479153] ldm_validate_partition_table(): Disk read failed.
Jan  3 20:19:02 veikia kernel: [ 7216.479223] Dev sdb: unable to read RDB block 0
Jan  3 20:19:02 veikia kernel: [ 7216.479328]  sdb: unable to read partition table
Jan  3 20:19:02 veikia kernel: [ 7216.480022] sd 2:0:0:0: [sdb] Read Capacity(10) failed: Result: hostbyte=DID_NO_CONNECT driverbyte=DRIVER_OK
Jan  3 20:19:02 veikia kernel: [ 7216.480032] sd 2:0:0:0: [sdb] Sense not available.
Jan  3 20:19:02 veikia kernel: [ 7216.480051] sd 2:0:0:0: [sdb] 0 512-byte logical blocks: (0 B/0 B)
Jan  3 20:19:02 veikia kernel: [ 7216.480130] sd 2:0:0:0: [sdb] Attached SCSI removable disk
Jan  3 20:19:02 veikia systemd-udevd[11794]: inotify_add_watch(9, /dev/sdb, 10) failed: No such file or directory

If I don't configure, initialize and mount FAT in nrf52840 code, USB device initialization goes normally on Linux side, just disk contains "no media" - it seems scsi layer works fine.

My code is based on the usbd_msc example:

NRF_BLOCK_DEV_SDC_DEFINE(
        m_block_dev_sdc2,
        NRF_BLOCK_DEV_SDC_CONFIG(
                SDC_SECTOR_SIZE,
                APP_SDCARD_CONFIG(SDC_MOSI_PIN, SDC_MISO_PIN, SDC_SCK_PIN, SDC_CS_PIN)
         ),
         NFR_BLOCK_DEV_INFO_CONFIG("Zive", "SDC", "1.00")
);


diskio_blkdev_t drives2[] = {
        DISKIO_BLOCKDEV_CONFIG(NRF_BLOCKDEV_BASE_ADDR(m_block_dev_sdc2, block_dev), NULL)
};

#define BLOCKDEV_LIST() (                                   \
        NRF_BLOCKDEV_BASE_ADDR(m_block_dev_sdc2, block_dev)  \
)
//        NRF_BLOCKDEV_BASE_ADDR(m_block_dev_sdc2, block_dev)

#define ENDPOINT_LIST() APP_USBD_MSC_ENDPOINT_LIST(1, 1)

#define MSC_WORKBUFFER_SIZE (1024)

APP_USBD_MSC_GLOBAL_DEF(m_app_msc,
                        0,
                        msc_user_ev_handler,
                        ENDPOINT_LIST(),
                        BLOCKDEV_LIST(),
                        MSC_WORKBUFFER_SIZE);

void usb_device() {
    static const app_usbd_config_t usbd_config = {
            .ev_state_proc = usbd_user_ev_handler
        };

    nrfx_clock_init(clk_handler);

    fatfs_init();
    fatfs_mkfs();

    APP_ERROR_CHECK(app_usbd_init(&usbd_config));

    app_usbd_class_inst_t const * class_inst_msc = app_usbd_msc_class_inst_get(&m_app_msc);

    APP_ERROR_CHECK(app_usbd_class_append(class_inst_msc));

    APP_ERROR_CHECK(app_usbd_power_events_enable());

//    app_usbd_enable();
//    app_usbd_start();

    while (true) {
        while (app_usbd_event_queue_process()) {
            /* Nothing to do */
        }

        if(!is_usb_power_connected()) {
            NRF_LOG_INFO("USB power disconnected, resetting NOW!");
            delay(1);
            soft_reset();
        }
        nrf_pwr_mgmt_run();
    }
}

Please help!

  • I might have been misleading telling that SD card is not being accessed. It is being accessed on several occasions, but not being accessed when the enumeration stalls.

    I have added some logging to app_sdcard.c to see what commands are being issued to SD card:

    <info> app: USB CONNECTED
    <info> app: Initializing disk 0 (RAM)...
    <info> app: CMD: 64
    <info> app: CMD: 64
    <info> app: CMD: 72
    <info> app: CMD: 233
    <info> app: CMD: 233
    <info> app: CMD: 233
    <info> app: CMD: 233
    <info> app: CMD: 233
    <info> app: CMD: 233
    <info> app: CMD: 233
    <info> app: CMD: 122
    <info> app: CMD: 73
    <info> app: Mounting volume...
    <info> app: CMD: 81
    <info> app: CMD: 81
    <info> app: CMD: 81
    <info> app: USB go go go
    <info> app: APP_USBD_EVT_STATE_CHANGED
    <info> app: USB evt start
    <info> app: USB suspend
    <info> app: USB resume
    <info> app: APP_USBD_EVT_STATE_CHANGED
    <info> app: APP_USBD_EVT_STATE_CHANGED
    <info> app: APP_USBD_EVT_STATE_CHANGED
    <info> app: CMD: 82
    <info> app: CMD: 76

    It seems SD card commands "Read multiple blocks" and "STOP_TRANSMISSION" are being issued while enumerating. Everything stalls after that.

  • In addition I have logged the incoming SCSI commands:

    <info> app: USB CONNECTED
    <info> app: Initializing disk 0 (RAM)...
    <info> app: CMD: 64
    <info> app: CMD: 64
    <info> app: CMD: 72
    <info> app: CMD: 233
    <info> app: CMD: 233
    <info> app: CMD: 233
    <info> app: CMD: 233
    <info> app: CMD: 233
    <info> app: CMD: 233
    <info> app: CMD: 233
    <info> app: CMD: 122
    <info> app: CMD: 73
    <info> app: Mounting volume...
    <info> app: Read 1 blocks from 0
    <info> app: CMD: 81
    <info> app: Read 1 blocks from 2048
    <info> app: CMD: 81
    <info> app: Read 1 blocks from 2049
    <info> app: CMD: 81
    <info> app: USB go go go
    <info> app: APP_USBD_EVT_STATE_CHANGED
    <info> app: USB evt start
    <info> app: USB suspend
    <info> app: USB resume
    <info> app: APP_USBD_EVT_STATE_CHANGED
    <info> app: APP_USBD_EVT_STATE_CHANGED
    <info> app: APP_USBD_EVT_STATE_CHANGED
    <info> usbd_msc: SCSI_CMD_INQUIRY
    <info> usbd_msc: SCSI_CMD_TESTUNITREADY
    <info> usbd_msc: SCSI_CMD_READCAPACITY10
    <info> usbd_msc: SCSI_CMD_MODESENSE6
    <info> usbd_msc: SCSI_CMD_REQUESTSENSE
    <info> usbd_msc: SCSI_CMD_REQUESTSENSE
    <info> usbd_msc: SCSI_CMD_MODESENSE6
    <info> usbd_msc: SCSI_CMD_REQUESTSENSE
    <info> usbd_msc: SCSI_CMD_MODESENSE6
    <info> usbd_msc: SCSI_CMD_REQUESTSENSE
    <info> usbd_msc: SCSI_CMD_MODESENSE6
    <info> usbd_msc: SCSI_CMD_REQUESTSENSE
    <info> usbd_msc: SCSI_CMD_MODESENSE6
    <info> usbd_msc: SCSI_CMD_REQUESTSENSE
    <info> usbd_msc: SCSI_CMD_MODESENSE6
    <info> usbd_msc: SCSI_CMD_REQUESTSENSE
    <info> usbd_msc: SCSI_CMD_MODESENSE6
    <info> usbd_msc: SCSI_CMD_REQUESTSENSE
    <info> usbd_msc: SCSI_CMD_MODESENSE6
    <info> usbd_msc: SCSI_CMD_REQUESTSENSE
    <info> usbd_msc: SCSI_CMD_MODESENSE6
    <info> usbd_msc: SCSI_CMD_REQUESTSENSE
    <info> usbd_msc: SCSI_CMD_MODESENSE6
    <info> usbd_msc: SCSI_CMD_REQUESTSENSE
    <info> usbd_msc: SCSI_CMD_MODESENSE6
    <info> usbd_msc: SCSI_CMD_REQUESTSENSE
    <info> usbd_msc: SCSI_CMD_MODESENSE6
    <info> usbd_msc: SCSI_CMD_REQUESTSENSE
    <info> usbd_msc: SCSI_CMD_TESTUNITREADY
    <info> usbd_msc: SCSI_CMD_PREVENTMEDIAREMOVAL
    <info> usbd_msc: SCSI_CMD_TESTUNITREADY
    <info> usbd_msc: SCSI_CMD_READCAPACITY10
    <info> usbd_msc: SCSI_CMD_MODESENSE6
    <info> usbd_msc: SCSI_CMD_REQUESTSENSE
    <info> usbd_msc: SCSI_CMD_MODESENSE6
    <info> usbd_msc: SCSI_CMD_REQUESTSENSE
    <info> usbd_msc: SCSI_CMD_MODESENSE6
    <info> usbd_msc: SCSI_CMD_REQUESTSENSE
    <info> usbd_msc: SCSI_CMD_MODESENSE6
    <info> usbd_msc: SCSI_CMD_REQUESTSENSE
    <info> usbd_msc: SCSI_CMD_MODESENSE6
    <info> usbd_msc: SCSI_CMD_REQUESTSENSE
    <info> usbd_msc: SCSI_CMD_MODESENSE6
    <info> usbd_msc: SCSI_CMD_REQUESTSENSE
    <info> usbd_msc: SCSI_CMD_MODESENSE6
    <info> usbd_msc: SCSI_CMD_REQUESTSENSE
    <info> usbd_msc: SCSI_CMD_MODESENSE6
    <info> usbd_msc: SCSI_CMD_REQUESTSENSE
    <info> usbd_msc: SCSI_CMD_MODESENSE6
    <info> usbd_msc: SCSI_CMD_REQUESTSENSE
    <info> usbd_msc: SCSI_CMD_MODESENSE6
    <info> usbd_msc: SCSI_CMD_REQUESTSENSE
    <info> usbd_msc: SCSI_CMD_MODESENSE6
    <info> usbd_msc: SCSI_CMD_REQUESTSENSE
    <info> usbd_msc: SCSI_CMD_MODESENSE6
    <info> usbd_msc: SCSI_CMD_REQUESTSENSE
    <info> usbd_msc: SCSI_CMD_READ10
    <info> app: Read 2 blocks from 0
    <info> app: CMD: 82
    <info> app: CMD: 76

  • In contrast, when the RAM disk is setup instead of SD card, SCSI commands go like this:

    <info> app: USB CONNECTED
    <info> app: Initializing disk 0 (RAM)...
    <info> app: Mounting volume...
    <info> app: Read req from block 12 size 0(x0) to 20004230
    <error> app: Mount failed. Filesystem not found. Please format device.
    <info> app:
    Creating filesystem...
    <info> app: IOCTL GET_SECTOR_COUNT
    <info> app: 537132948
    <info> app: Read req from block 12 size 0(x0) to 2804D
    <info> app: Read req from block 12 size 0(x0) to 2804D
    <info> app: Read req from block 12 size 0(x0) to 2804D
    <info> app: Read req from block 12 size 0(x0) to 2804D
    <info> app: Read req from block 12 size 0(x0) to 2804D
    <info> app: Read req from block 12 size 0(x0) to 2804D
    <info> app: Read req from block 12 size 0(x0) to 2804D
    <info> app: Read req from block 12 size 0(x0) to 2804D
    <info> app: Read req from block 12 size 0(x0) to 2804D
    <info> app: Read req from block 12 size 0(x0) to 2804D
    <info> app: Read req from block 12 size 0(x0) to 2804D
    <info> app: Read req from block 12 size 0(x0) to 2804D
    <info> app: Read req from block 12 size 0(x0) to 2804D
    <info> app: Read req from block 12 size 0(x0) to 2804D
    <info> app: Read req from block 12 size 0(x0) to 2804D
    <info> app: Read req from block 12 size 0(x0) to 2804D
    <info> app: Read req from block 12 size 0(x0) to 2804D
    <info> app: Read req from block 12 size 0(x0) to 2804D
    <info> app: Read req from block 12 size 0(x0) to 2804D
    <info> app: Read req from block 12 size 0(x0) to 2804D
    <info> app: Read req from block 12 size 0(x0) to 2804D
    <info> app: Read req from block 12 size 0(x0) to 2804D
    <info> app: Read req from block 12 size 0(x0) to 2804D
    <info> app: Read req from block 12 size 0(x0) to 2804D
    <info> app: Read req from block 12 size 0(x0) to 2804D
    <info> app: Read req from block 12 size 0(x0) to 2804D
    <info> app: Read req from block 12 size 0(x0) to 2804D
    <info> app: Read req from block 12 size 0(x0) to 2804D
    <info> app: Read req from block 12 size 0(x0) to 2804D
    <info> app: Read req from block 12 size 0(x0) to 2804D
    <info> app: Read req from block 12 size 0(x0) to 2804D
    <info> app: Read req from block 12 size 0(x0) to 2804D
    <info> app: Read req from block 12 size 0(x0) to 2804D
    <info> app: Read req from block 12 size 0(x0) to 2804D
    <info> app: IOCTL SYNC
    <info> app: Mounting volume...
    <info> app: Read req from block 12 size 0(x0) to 20004230
    <info> app: Read req from block 12 size 0(x0) to 20004230
    <info> app: Done
    <info> app: USB go go go
    <info> app: APP_USBD_EVT_STATE_CHANGED
    <info> app: USB evt start
    <info> app: USB suspend
    <info> app: USB resume
    <info> app: APP_USBD_EVT_STATE_CHANGED
    <info> app: APP_USBD_EVT_STATE_CHANGED
    <info> app: APP_USBD_EVT_STATE_CHANGED
    <info> usbd_msc: SCSI_CMD_INQUIRY
    <info> usbd_msc: SCSI_CMD_TESTUNITREADY
    <info> usbd_msc: SCSI_CMD_READCAPACITY10
    <info> usbd_msc: SCSI_CMD_MODESENSE6
    <info> usbd_msc: SCSI_CMD_REQUESTSENSE
    <info> usbd_msc: SCSI_CMD_REQUESTSENSE
    <info> usbd_msc: SCSI_CMD_MODESENSE6
    <info> usbd_msc: SCSI_CMD_REQUESTSENSE
    <info> usbd_msc: SCSI_CMD_MODESENSE6
    <info> usbd_msc: SCSI_CMD_REQUESTSENSE
    <info> usbd_msc: SCSI_CMD_MODESENSE6
    <info> usbd_msc: SCSI_CMD_REQUESTSENSE
    <info> usbd_msc: SCSI_CMD_MODESENSE6
    <info> usbd_msc: SCSI_CMD_REQUESTSENSE
    <info> usbd_msc: SCSI_CMD_MODESENSE6
    <info> usbd_msc: SCSI_CMD_REQUESTSENSE
    <info> usbd_msc: SCSI_CMD_MODESENSE6
    <info> usbd_msc: SCSI_CMD_REQUESTSENSE
    <info> usbd_msc: SCSI_CMD_MODESENSE6
    <info> usbd_msc: SCSI_CMD_REQUESTSENSE
    <info> usbd_msc: SCSI_CMD_MODESENSE6
    <info> usbd_msc: SCSI_CMD_REQUESTSENSE
    <info> usbd_msc: SCSI_CMD_MODESENSE6
    <info> usbd_msc: SCSI_CMD_REQUESTSENSE
    <info> usbd_msc: SCSI_CMD_MODESENSE6
    <info> usbd_msc: SCSI_CMD_REQUESTSENSE
    <info> usbd_msc: SCSI_CMD_MODESENSE6
    <info> usbd_msc: SCSI_CMD_REQUESTSENSE
    <info> usbd_msc: SCSI_CMD_TESTUNITREADY
    <info> usbd_msc: SCSI_CMD_PREVENTMEDIAREMOVAL
    <info> usbd_msc: SCSI_CMD_TESTUNITREADY
    <info> usbd_msc: SCSI_CMD_READCAPACITY10
    <info> usbd_msc: SCSI_CMD_MODESENSE6
    <info> usbd_msc: SCSI_CMD_REQUESTSENSE
    <info> usbd_msc: SCSI_CMD_MODESENSE6
    <info> usbd_msc: SCSI_CMD_REQUESTSENSE
    <info> usbd_msc: SCSI_CMD_MODESENSE6
    <info> usbd_msc: SCSI_CMD_REQUESTSENSE
    <info> usbd_msc: SCSI_CMD_MODESENSE6
    <info> usbd_msc: SCSI_CMD_REQUESTSENSE
    <info> usbd_msc: SCSI_CMD_MODESENSE6
    <info> usbd_msc: SCSI_CMD_REQUESTSENSE
    <info> usbd_msc: SCSI_CMD_MODESENSE6
    <info> usbd_msc: SCSI_CMD_REQUESTSENSE
    <info> usbd_msc: SCSI_CMD_MODESENSE6
    <info> usbd_msc: SCSI_CMD_REQUESTSENSE
    <info> usbd_msc: SCSI_CMD_MODESENSE6
    <info> usbd_msc: SCSI_CMD_REQUESTSENSE
    <info> usbd_msc: SCSI_CMD_MODESENSE6
    <info> usbd_msc: SCSI_CMD_REQUESTSENSE
    <info> usbd_msc: SCSI_CMD_MODESENSE6
    <info> usbd_msc: SCSI_CMD_REQUESTSENSE
    <info> usbd_msc: SCSI_CMD_MODESENSE6
    <info> usbd_msc: SCSI_CMD_REQUESTSENSE
    <info> usbd_msc: SCSI_CMD_MODESENSE6
    <info> usbd_msc: SCSI_CMD_REQUESTSENSE
    <info> usbd_msc: SCSI_CMD_READ10
    <info> app: Read req from block 12 size 0(x0) to 2003FE80
    <info> app: Read req from block 12 size 0(x0) to 0
    <info> usbd_msc: SCSI_CMD_READ10
    <info> app: Read req from block 12 size 0(x1) to 1
    <info> app: Read req from block 12 size 0(x0) to 0
    <info> usbd_msc: SCSI_CMD_PREVENTMEDIAREMOVAL
    <info> usbd_msc: SCSI_CMD_TESTUNITREADY
    <info> usbd_msc: SCSI_CMD_TESTUNITREADY
    <info> usbd_msc: SCSI_CMD_READCAPACITY10
    <info> usbd_msc: SCSI_CMD_PREVENTMEDIAREMOVAL
    <info> usbd_msc: SCSI_CMD_MODESENSE6
    <info> usbd_msc: SCSI_CMD_REQUESTSENSE
    <info> usbd_msc: SCSI_CMD_MODESENSE6
    <info> usbd_msc: SCSI_CMD_REQUESTSENSE
    <info> usbd_msc: SCSI_CMD_MODESENSE6
    <info> usbd_msc: SCSI_CMD_REQUESTSENSE
    <info> usbd_msc: SCSI_CMD_MODESENSE6
    <info> usbd_msc: SCSI_CMD_REQUESTSENSE
    <info> usbd_msc: SCSI_CMD_MODESENSE6
    <info> usbd_msc: SCSI_CMD_REQUESTSENSE
    <info> usbd_msc: SCSI_CMD_MODESENSE6
    <info> usbd_msc: SCSI_CMD_REQUESTSENSE
    <info> usbd_msc: SCSI_CMD_TESTUNITREADY
    <info> usbd_msc: SCSI_CMD_MODESENSE6
    <info> usbd_msc: SCSI_CMD_REQUESTSENSE
    <info> usbd_msc: SCSI_CMD_MODESENSE6
    <info> usbd_msc: SCSI_CMD_REQUESTSENSE
    <info> usbd_msc: SCSI_CMD_MODESENSE6
    <info> usbd_msc: SCSI_CMD_REQUESTSENSE
    <info> usbd_msc: SCSI_CMD_MODESENSE6
    <info> usbd_msc: SCSI_CMD_REQUESTSENSE
    <info> usbd_msc: SCSI_CMD_MODESENSE6
    <info> usbd_msc: SCSI_CMD_REQUESTSENSE
    <info> usbd_msc: SCSI_CMD_MODESENSE6
    <info> usbd_msc: SCSI_CMD_REQUESTSENSE
    <info> usbd_msc: SCSI_CMD_READ10
    <info> app: Read req from block 12 size 0(x1) to 1
    <info> app: Read req from block 12 size 0(x0) to 0
    <info> app: Read req from block 12 size 0(x1) to 1
    <info> app: Read req from block 12 size 0(x1) to 1
    <info> usbd_msc: SCSI_CMD_TESTUNITREADY
    <info> usbd_msc: SCSI_CMD_PREVENTMEDIAREMOVAL
    <info> usbd_msc: SCSI_CMD_TESTUNITREADY
    <info> usbd_msc: SCSI_CMD_TESTUNITREADY
    <info> usbd_msc: SCSI_CMD_PREVENTMEDIAREMOVAL
    <info> usbd_msc: SCSI_CMD_PREVENTMEDIAREMOVAL
    <info> usbd_msc: SCSI_CMD_TESTUNITREADY
    <info> usbd_msc: SCSI_CMD_PREVENTMEDIAREMOVAL
    <info> usbd_msc: SCSI_CMD_TESTUNITREADY
    <info> usbd_msc: SCSI_CMD_TESTUNITREADY
    <info> usbd_msc: SCSI_CMD_READ10
    <info> app: Read req from block 12 size 0(x1) to 1
    <info> app: Read req from block 12 size 0(x185764) to 61000000
    <info> app: Read req from block 12 size 0(x1) to 1
    <info> app: Read req from block 12 size 0(x1) to 1
    <info> usbd_msc: SCSI_CMD_TESTUNITREADY
    <info> usbd_msc: SCSI_CMD_READ10
    <info> app: Read req from block 12 size 0(x1) to 1
    <info> app: Read req from block 12 size 0(x185764) to 61000000
    <info> app: Read req from block 12 size 0(x1) to 1
    <info> app: Read req from block 12 size 0(x1) to 1
    <info> usbd_msc: SCSI_CMD_READ10
    <info> app: Read req from block 12 size 0(x1) to 1
    <info> app: Read req from block 12 size 0(x185764) to 61000000
    <info> app: Read req from block 12 size 0(x1) to 1
    <info> app: Read req from block 12 size 0(x1) to 1
    <info> usbd_msc: SCSI_CMD_TESTUNITREADY
    <info> usbd_msc: SCSI_CMD_READ10
    <info> app: Read req from block 12 size 0(x1) to 1
    <info> app: Read req from block 12 size 0(x185764) to 61000000
    <info> app: Read req from block 12 size 0(x1) to 1
    <info> app: Read req from block 12 size 0(x1) to 1
    <info> usbd_msc: SCSI_CMD_TESTUNITREADY
    <info> usbd_msc: SCSI_CMD_PREVENTMEDIAREMOVAL
    <info> usbd_msc: SCSI_CMD_TESTUNITREADY
    <info> usbd_msc: SCSI_CMD_TESTUNITREADY
    <info> usbd_msc: SCSI_CMD_PREVENTMEDIAREMOVAL
    <info> usbd_msc: SCSI_CMD_READ10
    <info> app: Read req from block 12 size 0(x1) to 1
    <info> usbd_msc: SCSI_CMD_READ10
    <info> app: Read req from block 12 size 0(x1) to 1
    <info> usbd_msc: SCSI_CMD_READ10
    <info> app: Read req from block 12 size 0(x1) to 1
    <info> usbd_msc: SCSI_CMD_READ10
    <info> app: Read req from block 12 size 0(x1) to 1
    <info> usbd_msc: SCSI_CMD_READ10
    <info> app: Read req from block 12 size 0(x1) to 1
    <info> usbd_msc: SCSI_CMD_READ10
    <info> app: Read req from block 12 size 0(x1) to 1
    <info> usbd_msc: SCSI_CMD_READ10
    <info> app: Read req from block 12 size 0(x1) to 1
    <info> usbd_msc: SCSI_CMD_READ10
    <info> app: Read req from block 12 size 0(x1) to 1
    <info> usbd_msc: SCSI_CMD_READ10
    <info> app: Read req from block 12 size 0(x1) to 1
    <info> usbd_msc: SCSI_CMD_READ10
    <info> app: Read req from block 12 size 0(x1) to 1
    <info> usbd_msc: SCSI_CMD_READ10
    <info> app: Read req from block 12 size 0(x1) to 1
    <info> usbd_msc: SCSI_CMD_READ10
    <info> app: Read req from block 12 size 0(x1) to 1
    <info> usbd_msc: SCSI_CMD_READ10
    <info> app: Read req from block 12 size 0(x1) to 1
    <info> usbd_msc: SCSI_CMD_READ10
    <info> app: Read req from block 12 size 0(x1) to 1
    <info> usbd_msc: SCSI_CMD_READ10
    <info> app: Read req from block 12 size 0(x1) to 1
    <info> usbd_msc: SCSI_CMD_READ10
    <info> app: Read req from block 12 size 0(x1) to 1
    <info> usbd_msc: SCSI_CMD_READ10
    <info> app: Read req from block 12 size 0(x1) to 1
    <info> usbd_msc: SCSI_CMD_READ10
    <info> app: Read req from block 12 size 0(x1) to 1
    <info> usbd_msc: SCSI_CMD_READ10
    <info> app: Read req from block 12 size 0(x1) to 1
    <info> usbd_msc: SCSI_CMD_READ10
    <info> app: Read req from block 12 size 0(x1) to 1
    <info> usbd_msc: SCSI_CMD_READ10
    <info> app: Read req from block 12 size 0(x1) to 1
    <info> usbd_msc: SCSI_CMD_READ10
    <info> app: Read req from block 12 size 0(x1) to 1
    <info> usbd_msc: SCSI_CMD_READ10
    <info> app: Read req from block 12 size 0(x1) to 1
    <info> usbd_msc: SCSI_CMD_READ10
    <info> app: Read req from block 12 size 0(x1) to 1
    <info> usbd_msc: SCSI_CMD_READ10
    <info> app: Read req from block 12 size 0(x1) to 1
    <info> usbd_msc: SCSI_CMD_READ10
    <info> app: Read req from block 12 size 0(x1) to 1
    <info> usbd_msc: SCSI_CMD_READ10
    <info> app: Read req from block 12 size 0(x1) to 1
    <info> usbd_msc: SCSI_CMD_READ10
    <info> app: Read req from block 12 size 0(x1) to 1
    <info> usbd_msc: SCSI_CMD_READ10
    <info> app: Read req from block 12 size 0(x1) to 1
    <info> usbd_msc: SCSI_CMD_READ10
    <info> app: Read req from block 12 size 0(x1) to 1
    <info> usbd_msc: SCSI_CMD_READ10
    <info> app: Read req from block 12 size 0(x1) to 1
    <info> usbd_msc: SCSI_CMD_READ10
    <info> app: Read req from block 12 size 0(x1) to 1
    <info> usbd_msc: SCSI_CMD_READ10
    <info> app: Read req from block 12 size 0(x1) to 1
    <info> usbd_msc: SCSI_CMD_WRITE10
    <info> app: Read req from block 12 size 0(x1) to 1
    <info> usbd_msc: SCSI_CMD_READ10
    <info> app: Read req from block 12 size 0(x1) to 1
    <info> usbd_msc: SCSI_CMD_TESTUNITREADY
    <info> usbd_msc: SCSI_CMD_TESTUNITREADY

    ...

  • I have added more logging to app_usbd_msc.c in case of SD card it gives the following:

    <info> usbd_msc: SCSI_CMD_READ10
    <info> usbd_msc: cmd_read_start
    <info> app: Read 2 blocks from 0
    <info> app: CMD: 82
    <info> usbd_msc:info> usbd_msc: read_blockmem: id: 0, left: 4096, datalen: 4096, ret: 0
    <info> app: CMD: 76
    <error> app: ERROR 17 [NRF_ERROR_BUSY] at /home/miceuz/nrf/nRF5_SDK/components/libraries/log/src/nrf_log_backend_uart.c:83

    Ignoring the logging error, it seems SD card transfer finish does not trigger USB transfer.

    I really need help on this one as we have chosen nrf52840 based on this example - I have assumed I will be able to use this functionality judging from the fact that an example is available.

  • Hi, sorry for not replying on this. I will try to set up the example now and see what happens here. Just a question, are you trying to access the SD card from both the nRF chip and the USB at the same time? Also, just to check: Do you power the SD card properly with a stable source? VDD on the DK has too low voltage for many SD cards.