How to read a large file (About 240MB) from SD card

Hello all, I hope you are doing well. 

I Have a project on NRF52840 in which I have multiple sensors connected to the NRF52 and the sensor data are storing in the SD card in the form of a CSV file of size 240 MB. I want to read this large file from the SD card and then send it to the mobile app using ble_periperhial. I have used This example and modified it, but the problem is that I can only read 220000 bytes from the SD card in the buffer at once and when I am trying to increase 

   #define FILE_SIZE_MAX (Maximum size in bytes of the file to be read from SDCARDgreater than 220000, while the following;

                                            static uint8_t file_buffer[FILE_SIZE_MAX]; 

                                           ff_result = f_read(&file, file_buffer, FILE_SIZE_MAX, (UINT *) &bytes_read);

 Then it gives the following error:

                                      .bss is too large to fit in RAM1 memory segment
                                     .heap is too large to fit in RAM1 memory segment
                                      section .heap overlaps absolute placed section .stack
                                      section .stack VMA [000000002003e000,000000002003ffff] overlaps section .bss VMA [0000000020002c64,0000000020224b08]   

                                               

I don't know about this error and how to solve it. Simply I want to read the whole file (234MB) from the SD card at once and then send it in chunks to the mobile app, Is this possible or do I have to read in chunks from the SD card too? 

Any help regarding this will be highly appreciated.

  • Hi Sami

    If it reports the DATA_SIZE error when you try to set a scan filter on the name it could be that the name stored in m_target_periph_name is too long for the advertise packet. Could you let me know what the name is?

    I made a relay example based on ble_app_uart and ble_app_uart_c a while back which you can find here, but I don't think there are any official or unofficial examples combining the hrs_rscs_relay and ble_app_uart examples, no. 

    Best regards
    Torbjørn

  • Hi Torbjørn, thanks for the help. 

    I have merged ble-nus to the hrs_rscs_relay(both central & peripheral), everything works fine, and I can see my device in the UART portion of the nRF Toolbox app(after adding ble-nus) and the nRF52 DK can connect to the nRF Toolbox or connect app. But the problem is that when I connect the Heart rate sensor to the nRF52 DK(both central & peripheral) then the nRF Toolbox or nRF Connect app is no longer able to connect to the nRF52 DK. 

    In simple words when I am trying to connect nRF Toolbox or nRF Connect app to the nRF52 DK(both central & peripheral) before I connect the Heart Rate Sensor then the Apps are connecting very easily, but when I connect the Heart Rate Sensor first to the nRF52DK  then the Apps are no longer able to connect to the DK.

    The heart rate sensor can connect at any time whether the DK is connected to App or not, but the App is not able to connect to the DK when there is a heart rate sensor already connected. Can you please help me with what I am doing wrong?  

    I am facing this problem after adding ble-nus functionality in the hrs_rscs_relay project. Before adding the ble-nus, the device was advertising(and scanning of course)  but with another UUID which was not compatible with the UART functionality of the nRF Toolbox app, and the device name was only visible in the nRF Connect app and the nRF connect app was easily connectable to the DK irrespective of the heart rate sensor. But after adding the nus functionality and changing the advertising UUID of DK, the device is now visible in the nRF Toolbox app as well, but now I am facing a connectivity problem after connecting the heart rate sensor. 

    Best Regards,

    Sami

  • ## UPDATE

    Seems like I have found the reason for this behavior. When I Change the following setting in the config.h file then this problem is not occurring. 

    change    NRF_SDH_BLE_GATT_MAX_MTU_SIZE           from 247 to 243

                    NRF_SDH_BLE_GAP_EVENT_LENGTH            from 400 to 6

                    NRF_SDH_BLE_GAP_DATA_LENGTH               from 251 to 27 

    and          BLE_GATT_ATT_MTU_DEFAULT     from 247 to   23

    After doing these changes in the Sdk_config.h file, I no longer face the connecting issue to both the Heart Rate sensor and Mobile App. 

    Now the problem is that I want to use a larger MTU (247), an Event length of 400, and a Data Lenght of 251 to increase the throughput. But When I am trying with these settings for high throughput then I am facing the connectivity issue as described in the previous reply. I am totally confused about what to do, your help will be highly appreciated. 

    Best Regards,

    Sami

  • Hi Sami

    It's interesting that the phones can't connect at all. Do you still see the advertising come through, but it fails to connect to it, or you don't see the advertisement either?

    Do you know what the connection interval of the heart rate sensor is?
    Possibly it is sufficient to increase the connection interval, rather than making drastic changes to the event and data lengths. 

    Also, I don't understand why reducing the MTU size, data length and default MTU would make such a big impact. It is mainly the event length that decides how long each event could last, which might impact how much time is available for other connections, advertising etc. 

    What happens if you only change the event length and not the other parameters? 

    An event length of 400 is quite a lot. Have you tried with more moderate values like 20-50 to see if you can get both links working without having to sacrifice too much bandwidth? 

    Best regards
    Torbjørn

  • Hello Torbjørn, thanks for the help.

    The problem has been solved by doing the following changes to sdk_config.h:

    Change    NRF_SDH_BLE_CENTRAL_LINK_COUNT   from 2 to 1

    And          NRF_SDH_BLE_TOTAL_LINK_COUNT         from 3 to 2

    That is; I have reduced the Central_link_Count by 1 and it worked like a magic. But still, I don't know how it worked and what is CENTRAL_LINK_COUNT, to be honestGrinning. Can you please explain it a little? and will it affect my development or not? 

    Once Again thank you so much for your precious time & suggestions,

    Best Regards,

    Sami

Related