Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

FATFS disrupts work of BLE central on nRF52-DK

Hello!

I am using nRF52-DK to deploy my programs. I try to use writing to SD card in ble_app_uart_central example. Both fatfs and ble_app_uart (central) examples work separately. After adding fatfs initialization and mounting of SD card the program behaves unexpectedly.

If SD card mounts, there is a problem with BLE connection to peripheral, i.e. device discovery works, the device matches filters, nrf_ble_scan_connect_with_target is being called, but the last debug message I can see is "Connection status: 0". It seems like event NRF_BLE_SCAN_EVT_CONNECTED is either not triggered or is not handled properly. 

If SD card does not mount, connection is estabilished and everything concerning BLE connection works as expected.

The problem with BLE starts after calling f_mount function, because as for now I do not read or write anything to the device and without calling f_mount everything works well (I mean BLE).

Here is my fatfs_init code, which I call in the main function:

static void fatfs_init()
{
    FRESULT ff_result;
    DSTATUS disk_state = STA_NOINIT;

    // Initialize FATFS disk I/O interface by providing the block device.
    static diskio_blkdev_t drives[] =
    {
            DISKIO_BLOCKDEV_CONFIG(NRF_BLOCKDEV_BASE_ADDR(m_block_dev_sdc, block_dev), NULL)
    };

    diskio_blockdev_register(drives, ARRAY_SIZE(drives));

    NRF_LOG_INFO("Initializing disk 0 (SDC)...");
    for (uint32_t retries = 3; retries && disk_state; --retries)
    {
        disk_state = disk_initialize(0);
    }
    if (disk_state)
    {
        NRF_LOG_INFO("Disk initialization failed.");
        return;
    }

    uint32_t blocks_per_mb = (1024uL * 1024uL) / m_block_dev_sdc.block_dev.p_ops->geometry(&m_block_dev_sdc.block_dev)->blk_size;
    uint32_t capacity = m_block_dev_sdc.block_dev.p_ops->geometry(&m_block_dev_sdc.block_dev)->blk_count / blocks_per_mb;
    NRF_LOG_INFO("Capacity: %d MB", capacity);

    NRF_LOG_INFO("Mounting volume...");
    ff_result = f_mount(&fatfs, "", 1);
    if (ff_result)
    {
        NRF_LOG_INFO("Mount failed.");
        return;
    }
	NRF_LOG_INFO("Mounted.");
}

nRF5 SDK version: 17.0.2

Soft Device version (S132): 7.2.0

Related