BLE Data Length Extension w/ RTT Logging

Hello, 

I am using the nRF5340 development kit alongside the nRF Connect mobile application for Android to establish a BLE connection and update the link layer packet size to the maximum of 251 bytes. This works as expected when my config is the following:

#
# Copyright (c) 2018 Nordic Semiconductor
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

# Logger module
CONFIG_LOG=y

# Button and LED library
CONFIG_DK_LIBRARY=y

# Floating Point Unit
CONFIG_FPU=y

# Bluetooth LE
CONFIG_BT=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_DEVICE_NAME="LiteBEST"
CONFIG_BT_LBS=y
CONFIG_BT_LBS_POLL_BUTTON=y
CONFIG_BT_GATT_CLIENT=y

# STEP 5 - Configure your preferred connection parameters
CONFIG_BT_PERIPHERAL_PREF_MIN_INT=800
CONFIG_BT_PERIPHERAL_PREF_MAX_INT=800
CONFIG_BT_PERIPHERAL_PREF_LATENCY=0
CONFIG_BT_PERIPHERAL_PREF_TIMEOUT=400
CONFIG_BT_GAP_AUTO_UPDATE_CONN_PARAMS=y

# STEP 8.2 - Enable PHY updates.
CONFIG_BT_USER_PHY_UPDATE=y

# STEP 12 - Update Data Length and MTU
CONFIG_BT_USER_DATA_LEN_UPDATE=y
CONFIG_BT_CTLR_DATA_LENGTH_MAX=251
CONFIG_BT_BUF_ACL_RX_SIZE=251
CONFIG_BT_BUF_ACL_TX_SIZE=251
CONFIG_BT_L2CAP_TX_MTU=247

# Increase stack size for the main thread and System Workqueue
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
CONFIG_MAIN_STACK_SIZE=2048
CONFIG_BT_RX_STACK_SIZE=2048

I have used Lesson 3 Exercise 2 from Nordic Academy code and the prj configs, which can be found at this GitHub linkto create the above prj.conf and attached (please_work.zip) code base. Here is the expected output from that prj.conf and code: 

expected output showing increased data length on BLE link layer

When I add the following lines to my config (the prj_candi.conf file), I get the unexpected output of the default BLE link layer packet size = 27 bytes. 

# enable RTT logging
CONFIG_PRINTK=y
CONFIG_USE_SEGGER_RTT=y
CONFIG_RTT_CONSOLE=y
CONFIG_LOG_BACKEND_RTT=y 

Following is the unexpected output:

unexpected BLE link layer packet length

I'll reiterate: the only change is the config file and, obviously, how I'm observing the incoming data, VCOM port vs JTAG. 

This is the same issue I was experiencing as described in my previous ticket's later replies, which I thought I had a workaround for, but I do not. Please help me understand why this is happening and how I can solve this. If you'd like BLE sniffer logs to further prove this, you can refer to the linked ticket, or I can provide more upon request, but I think you'll be able to recreate the problem using the attached zip. Please create a build using the default "prj.conf" file, this should work as expected on an nRF5340 dev kit when examining the output over VCOM1, and then a second build using the "prj_candi.conf" file and examine using RTT.

This is the minimum code/project I could come up with to recreate the issue I'm having in my main codebase. Thank you so much for your time and effort. 

Respectfully,

Brady Adcock

---

Tools Used: 

Toolchain and SDK are both v2.4.1
Windows 11, Version 10.0.22621 Build 22621
nRF5340-DK, PCA10095
nRF Connect for VS Code v2023.9.336
Pixel 7 Pro, android version 13, build #TQ3A.230901.001.C2
Entire Project zip w/ build: 

Parents
  • Hi Brady,

    I am not able to reproduce this. When I take your project and add the Kconfigs you described for RTT, the data length update procedure still happens. Are you sure this is the only change you did? Can you share the code with these changes, as well as a sniffer trace that shows how this works on your end? Also, if you are able to provide more detailed steps in case I need to do something specific in order to reproduce it, that could be usefull.

    Einar

  • Hey Einar!

    I hate to hear that you were not able to reproduce this behavior, so I decided to take a quick video walking you through the exact steps I took and the buttons clicked, as well as showing the live BLE sniffer trace in real time. 

    Attached are the BLE sniffer logs taken during the recording, and I'll also show the screenshots from those moments below:

    1) default prj.conf build (timestamp 5:57)

    # Logger module
    CONFIG_LOG=y
    
    # Button and LED library
    CONFIG_DK_LIBRARY=y
    
    # Floating Point Unit
    CONFIG_FPU=y
    
    # Bluetooth LE
    CONFIG_BT=y
    CONFIG_BT_PERIPHERAL=y
    CONFIG_BT_DEVICE_NAME="LiteBEST"
    CONFIG_BT_LBS=y
    CONFIG_BT_LBS_POLL_BUTTON=y
    CONFIG_BT_GATT_CLIENT=y
    
    # STEP 5 - Configure your preferred connection parameters
    CONFIG_BT_PERIPHERAL_PREF_MIN_INT=800
    CONFIG_BT_PERIPHERAL_PREF_MAX_INT=800
    CONFIG_BT_PERIPHERAL_PREF_LATENCY=0
    CONFIG_BT_PERIPHERAL_PREF_TIMEOUT=400
    CONFIG_BT_GAP_AUTO_UPDATE_CONN_PARAMS=y
    
    # STEP 8.2 - Enable PHY updates.
    CONFIG_BT_USER_PHY_UPDATE=y
    
    # STEP 12 - Update Data Length and MTU
    CONFIG_BT_USER_DATA_LEN_UPDATE=y
    CONFIG_BT_CTLR_DATA_LENGTH_MAX=251
    CONFIG_BT_BUF_ACL_RX_SIZE=251
    CONFIG_BT_BUF_ACL_TX_SIZE=251
    CONFIG_BT_L2CAP_TX_MTU=247
    
    # Increase stack size for the main thread and System Workqueue
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
    CONFIG_MAIN_STACK_SIZE=2048
    CONFIG_BT_RX_STACK_SIZE=2048

    BLE sniffer trace for the above moment (no_rtt_config_video_recording.pcapng)

    2) RTT config prj_candi.conf build (timestamp 15:20)

    # Logger module
    CONFIG_LOG=y
    
    # Button and LED library
    CONFIG_DK_LIBRARY=y
    
    # Floating Point Unit
    CONFIG_FPU=y
    
    # Bluetooth LE
    CONFIG_BT=y
    CONFIG_BT_PERIPHERAL=y
    CONFIG_BT_DEVICE_NAME="LiteBEST"
    CONFIG_BT_LBS=y
    CONFIG_BT_LBS_POLL_BUTTON=y
    CONFIG_BT_GATT_CLIENT=y
    
    # STEP 5 - Configure your preferred connection parameters
    CONFIG_BT_PERIPHERAL_PREF_MIN_INT=800
    CONFIG_BT_PERIPHERAL_PREF_MAX_INT=800
    CONFIG_BT_PERIPHERAL_PREF_LATENCY=0
    CONFIG_BT_PERIPHERAL_PREF_TIMEOUT=400
    CONFIG_BT_GAP_AUTO_UPDATE_CONN_PARAMS=y
    
    # STEP 8.2 - Enable PHY updates.
    CONFIG_BT_USER_PHY_UPDATE=y
    
    # STEP 12 - Update Data Length and MTU
    CONFIG_BT_USER_DATA_LEN_UPDATE=y
    CONFIG_BT_CTLR_DATA_LENGTH_MAX=251
    CONFIG_BT_BUF_ACL_RX_SIZE=251
    CONFIG_BT_BUF_ACL_TX_SIZE=251
    CONFIG_BT_L2CAP_TX_MTU=247
    
    # Increase stack size for the main thread and System Workqueue
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
    CONFIG_MAIN_STACK_SIZE=2048
    CONFIG_BT_RX_STACK_SIZE=2048
    
    # enable RTT logging
    CONFIG_PRINTK=y
    CONFIG_USE_SEGGER_RTT=y
    CONFIG_RTT_CONSOLE=y
    CONFIG_LOG_BACKEND_RTT=y 

    BLE sniffer trace for the above moment (rtt_config_video_recording_ll_req_visible.pcapng)

    Again, I can not thank you enough for taking the time to help me out! I really appreciate it, Einar. I don't think I need to re-attach the repository as it is the same in the video and attached earlier and the tools are the same. Thank you!!!!!!!!

    Regards,

    Brady Adcock

  • Hi Brady,

    Thank you for the video. I see that your description is correct. I originally just modified the prj.conf from the solution in the dev accademy execsize, but did not see the issue that way. I also did not see it when I took your project and just added the part for enabling RTT logging for prj.conf. However, if I use you prj_candi.conf, I see the issue. In other words, if I use an identical prj.conf which produce the exact same .config as with your prj_candi.conf, I do not see the issue. But with prj_candi.conf I do.

    In short, I reproduce the same as you now. And the beaviour is not expected at all, but I need a bit more time to digg into this and try to understand what is going on. I will come back to you when I know more.

    Br,

    Einar

Reply
  • Hi Brady,

    Thank you for the video. I see that your description is correct. I originally just modified the prj.conf from the solution in the dev accademy execsize, but did not see the issue that way. I also did not see it when I took your project and just added the part for enabling RTT logging for prj.conf. However, if I use you prj_candi.conf, I see the issue. In other words, if I use an identical prj.conf which produce the exact same .config as with your prj_candi.conf, I do not see the issue. But with prj_candi.conf I do.

    In short, I reproduce the same as you now. And the beaviour is not expected at all, but I need a bit more time to digg into this and try to understand what is going on. I will come back to you when I know more.

    Br,

    Einar

Children
  • Hi Brady,

    Looking futher, I noticed that the .config file of the hci_rpmsg is different when using prj_candi.conf and using an identical prj.conf. This means that among other things, the parameter CONFIG_BT_CTLR_DATA_LENGTH_MAX=251 is missing, and then the default of 27 is used.

    The reason for this is that when you specify a configuration file in VS Code, that is added to the west build command as -DCONF_FILE=<conf_file>. And this will replace existing config files. And for child images, the same suffix will have to be used. So if you copy the existing child_image/hci_rpmsg.conf to child_image/hci_rpmsg_candi.conf, it will work (as that matches your conf file name prj_candi.conf). Alternatively, if you build from the command line, you could use -DEXTRA_CONF_FILE=<conf_file>. This is not supported by the VS Code plugin at the moment, but I have asked the team to look into if this should be supported (and perhaps the default).

    Einar

Related