nRF5340 BLE: How to create the rpmsg_nrf53_sram in partitions.yml during porting the sample 'peripheral_uart'

Hi Support Team,

I try to use BLE in 'Split Controller and Host' mode on nRF5340 DK. I ported the sample 'peripheral_uart' for appCore and 'hci_rpmsg' for netCore, and the bidirectional communication between the appCore's terminal and 'nRF Connect for Mobile' APP is successful.

But, strangely, the partitions.yml in my project and the one in the sample are different in the SRAM section.
my partitions.yml:

sram_primary:
  address: 0x20000000
  end_address: 0x20080000
  region: sram_primary
  size: 0x80000

The sample's: 

rpmsg_nrf53_sram:
  address: 0x20070000
  end_address: 0x20080000
  placement:
    before:
    - end
  region: sram_primary
  size: 0x10000
  
  sram_primary:
  address: 0x20000000
  end_address: 0x20070000
  region: sram_primary
  size: 0x70000

My questions:
1. In my understanding, the rpmsg_nrf53_sram is for RPMsg transport and is a must for BLE in 'Split Controller and Host' mode. Why there is no rpmsg_nrf53_sram in my partitions.yml, but the communication is still ok?
2. How can I create the rpmsg_nrf53_sram in my partition and let it be shared by the appCore and the netCore?
Thank you very much.

Best regards,
Yanpeng Wu

Parents
  • Hello Yanpeng,

    Could you provide a bit more information about how your project setup differs from the peripheral_uart sample? Do you still use the same hci_rpmsg child image in your build? The 'rpmsg_nrf53_sram' section should be added automatically by the build script here: https://github.com/nrfconnect/sdk-nrf/blob/d5a11bd8bd803fff7615f9b0c5227a60c761da27/subsys/partition_manager/CMakeLists.txt#L87 

    Best regards,

    Vidar

  • Hello Vidar,

    Thank you for your reply. I'm not using the original hci_rpmsg child image. In my application, I'm using a sysbuild and there is another small task on netCore, so I ported the code of hci_rpmsg to my application code on the netCore.

    In the sample peripheral_uart, I did not find how it define the hci_rpmsg as its default child image. I guessed it should be the configuration 'config NRF_DEFAULT_BLUETOOTH  default y' in the Kconfig.sysbuild, is it correct?

    After I ported the code to my application, the first build had some errors with the flash partition, then I added the cmake argument '-Dhci_rpmsg_OVERLAY_CONFIG="C:/ncs/v2.5.2/nrf/subsys/partition_manager/partition_manager_enabled.conf"', just as the sample did. After this, the BLE communication is ok, but when I compare the partitions.yml files in the sample and my project, I found the difference of rpmsg_nrf53_sram.

    Best regards,
    Yanpeng Wu

  • Hi Vidar,

    I changed the overlay to

    chosen {
    /* /delete-property/ zephyr,ipc_shm;*/
    nordic,nus-uart = &uart0;
    };

    but the build result and the send data behavior are the same. Could you help try the project on your nRF5340 DK and see the result?

    Best regards,
    Yanpeng Wu

  • Hi Yanpeng, 

    By "build result being the same," do you mean that CONFIG_RPMSG_NRF53_SRAM_SIZE is still set to 0x0 in your .config output?

    Best regards,

    Vidar

  • Hi Vidar,

    Sorry for the mistake. When I did a Pristine Build, the rpmsg_nrf53_sram was created properly in partitions.yml.
    But when I flash the image to DK, still can see 'ble_host: Failed to send data over BLE connection', sending data from appCore terminal failed. (the data flow from mobile app to appCore terminal is ok)

    It failed in bt_gatt_notify_cb():

    in bt_gatt_notify_cb:
    
    data.err = -ENOTCONN;
    data.type = BT_GATT_CCC_NOTIFY;
    data.nfy_params = params;
    
    LOG_WRN("[in bt_gatt_notify_cb - 7.1], data.err=%d", data.err); //data.err=-128
    bt_gatt_foreach_attr_type(data.handle, 0xffff, BT_UUID_GATT_CCC, NULL,
    1, notify_cb, &data); //failed in notify_cb when Notify all peers configured
    LOG_WRN("[in bt_gatt_notify_cb - 7.2], data.err=%d", data.err); //data.err=-128
    
    return data.err;

    Best regards,
    Yanpeng Wu

  • Hi Yanpeng,

    No worries. But I'm not seeing any errors when sending data here. Please try the attached hex file I built and see if you get the same result. This is built with the original hci_rpmsg sample.

    3527.merged_domains.hex

    Best regards,

    Vidar

  • Hi Vidar,

    Thank you so much for your professional support:). I found the send-data error is caused by the unproper operation sequences.


    1. I flashed the HEX you provided to my DK and tried to send/receive data and connect/disconnect. It can work well except in one situation: when the 'TX Characterristic Descriptors - Notifications and indications disabled' in the mobile APP, the 'ble_host: Failed to send data over BLE connection' will be reported.

    I'm not sure if this is a small bug, if the central(the mobile APP) connected with the peripheral (my nRF5340 DK) but disabled the 'Notifications and indications', that just means the central does not subscribe to the notification, the GAP server should send data as usual and should not report a failure, is it right?

    I also found when disconnect and reconnct from the mobile app, the default state of 'Notifications and indications' is enabled, but it is actually disabled. The send data error will occur in this situation too. That's the reason why sometimes only after disconnect/reconnct the error will appear.

    2. In addition, in my application, I created threads on both appCore and netCore, and the priority=7,

    K_THREAD_DEFINE(thread_check_id, LED_THREAD_STACKSIZE, blink_led, NULL, NULL, NULL,
    K_PRIO_COOP(7), 0, 100);

    and the ble_write_thread' priority also is 7
    K_THREAD_DEFINE(ble_write_thread_id, STACKSIZE, ble_write_thread, NULL, NULL,
    NULL, PRIORITY, 0, 0);

    I'm not sure if it will affect the BLE data sent. I changed my thread's priority to 9 now.

    After that, the BLE data bidirectional data exchange works well now.
    Maybe I can say I get the robust BLE connection now:). Next I will construct my BLE services and Characteristics for my application data. Could you help suggest a sample for this? In the sample 'peripheral_uart', I had not found the code for defining the Services and Characteristics. Thank you very much.

    Best regards,
    Yanpeng Wu

Reply
  • Hi Vidar,

    Thank you so much for your professional support:). I found the send-data error is caused by the unproper operation sequences.


    1. I flashed the HEX you provided to my DK and tried to send/receive data and connect/disconnect. It can work well except in one situation: when the 'TX Characterristic Descriptors - Notifications and indications disabled' in the mobile APP, the 'ble_host: Failed to send data over BLE connection' will be reported.

    I'm not sure if this is a small bug, if the central(the mobile APP) connected with the peripheral (my nRF5340 DK) but disabled the 'Notifications and indications', that just means the central does not subscribe to the notification, the GAP server should send data as usual and should not report a failure, is it right?

    I also found when disconnect and reconnct from the mobile app, the default state of 'Notifications and indications' is enabled, but it is actually disabled. The send data error will occur in this situation too. That's the reason why sometimes only after disconnect/reconnct the error will appear.

    2. In addition, in my application, I created threads on both appCore and netCore, and the priority=7,

    K_THREAD_DEFINE(thread_check_id, LED_THREAD_STACKSIZE, blink_led, NULL, NULL, NULL,
    K_PRIO_COOP(7), 0, 100);

    and the ble_write_thread' priority also is 7
    K_THREAD_DEFINE(ble_write_thread_id, STACKSIZE, ble_write_thread, NULL, NULL,
    NULL, PRIORITY, 0, 0);

    I'm not sure if it will affect the BLE data sent. I changed my thread's priority to 9 now.

    After that, the BLE data bidirectional data exchange works well now.
    Maybe I can say I get the robust BLE connection now:). Next I will construct my BLE services and Characteristics for my application data. Could you help suggest a sample for this? In the sample 'peripheral_uart', I had not found the code for defining the Services and Characteristics. Thank you very much.

    Best regards,
    Yanpeng Wu

Children
  • Hi Yanpeng,

    Glad to hear that you were able to make it work. The client must be subscibed to the characteristic in order for the server to be able to send notifications, and this subscription is not retained across connections unless your devices are bonded. 

    Yanpengwu said:
    I also found when disconnect and reconnct from the mobile app, the default state of 'Notifications and indications' is enabled, but it is actually disabled.

    Is this with the nRF Connect app on Android or iOS? 

    Yanpengwu said:
    Next I will construct my BLE services and Characteristics for my application data. Could you help suggest a sample for this? In the sample 'peripheral_uart', I had not found the code for defining the Services and Characteristics. Thank you very much.

    You can use the NUS implementation as a reference for creating your own custom service: https://github.com/nrfconnect/sdk-nrf/blob/main/subsys/bluetooth/services/nus.c 

    Best regards,

    Vidar

  • Hi Vidar,

    I used the nRF Connect app on Android.
    Thank you for the suggestion and I will take the NUS as a reference for my custom service.
    Thank you again for the long and professional guidance and support. I close this ticket.

    Best regards,
    Yanpeng Wu

Related