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

Parents Reply
  • Hi, sorry for the delay in answering, but I was struggling with running examples you have provided. Both are using BLE, but in peripheral role, not central. Even though I tried to run the project from second link you provided. I downloaded SDK 16 and changed flash_placement.xml and .emProject file to match nrf52832 specification. I also encountered some weird memory errors, but it turned out that the array size was too large for this nrf. After all these changes project compiles and runs, but BLE is working (I can see NORDIC_UART advertising device in nRF Connect app), but SD card never mounts. After that I made changes to sdk_config.h, which I previously made in my project to get my sd card reader to work with DK board, i.e. change NRF_SPI_DRV_MISO_PULLUP_CFG from 1 (PULLDOWN) to 0 (NOPULL). I changed used SPI from 0 to 1, even though in my project both "worked" (i.e. worked as described in my first post).

    I have no more ideas what to do or what to check, but I'm attaching code from second link, modified by myself. Maybe you can check it, find the reason why it's not working on nRF52-DK.

    ble_app_uart_fatfs_send_sdk_16.0.0_changed_for_nrf52832dk.zip

Children
Related