L2CAP CoC connection only one credit per connection interval

Using nrf connect SDK 2.5.0

The nrf device is an L2CAP CoC server. I am using an RPi 4 to test with. The application is for transferring data through UART to another chip on the board to perform OTA updates. The connection sets up and I can transfer data successfully from the RPi to the nrf, but I only get 1 credit per connection interval, so throughput is limited. I have a connection interval of 7.5ms, an MTU of 245, so 245/7.5e-3 = 32KBps, which is roughly what my setup achieves, however I should be able to get 3 credits per interval (PHY 1M), so 98KBps. I want to fix this as some clients may have a larger min connection interval, so this issue would be exacerbated in that case.

I have tried increasing CONFIG_BT_BUF_ACL_RX_COUNT

a snippet of the prj:

CONFIG_BT_L2CAP_TX_BUF_COUNT=2
CONFIG_BT_BUF_ACL_TX_COUNT=2
CONFIG_BT_BUF_ACL_RX_COUNT=20
CONFIG_BT_NUS_UART_BUFFER_SIZE=244
CONFIG_BT_L2CAP_TX_MTU=247
CONFIG_BT_BUF_ACL_RX_SIZE=251
CONFIG_BT_BUF_ACL_TX_SIZE=251
CONFIG_BT_CTLR_DATA_LENGTH_MAX=251
I have tried configuring the SD so that it has plenty of buffer
int configure_softdevice_buffers(void)
{
    sdc_cfg_t cfg;
    cfg.buffer_cfg.rx_packet_count = CONFIG_BT_BUF_ACL_RX_COUNT;
    cfg.buffer_cfg.tx_packet_count = CONFIG_BT_BUF_ACL_TX_COUNT; 
    cfg.buffer_cfg.rx_packet_size  = CONFIG_BT_CTLR_DATA_LENGTH_MAX;
    cfg.buffer_cfg.tx_packet_size  = CONFIG_BT_CTLR_DATA_LENGTH_MAX;
    return sdc_cfg_set(SDC_DEFAULT_RESOURCE_CFG_TAG, SDC_CFG_TYPE_BUFFER_CFG, &cfg);
}

static int my_bt_low_level_init(void)
{
    int ret = configure_softdevice_buffers();
    if (ret) {
        printk("SDC Config failed: %d\n", ret);
    } else {
        printk("SDC Config success\n");
    }
    return 0;
}

// Use PRE_KERNEL_1 to ensure this runs before the BT stack starts
SYS_INIT(my_bt_low_level_init, PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE);

My server code is as basic as possible, except I have tried manually allocating a large enough net buf pool (size 20) using the alloc_buff callback. I tried without doing this initially with the same result. My recv callback does not do anything with the data currently, I just want to test the L2CAP connection speed first before adding UART.

#include <zephyr/kernel.h>
#include <zephyr/bluetooth/bluetooth.h>
#include <zephyr/bluetooth/conn.h>
#include <zephyr/bluetooth/l2cap.h>

#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(l2cap_channel);

#include "l2cap_channel.h"

/* Must match client */
#define L2CAP_PSM 0x0081
#define L2CAP_MTU 245
#define RX_BUFF_NUM 20
#define RX_BUFF_LENGTH 251
#define RX_BUFF_USER_DATA_SIZE 8

static struct bt_l2cap_le_chan l2cap_chan;

NET_BUF_POOL_FIXED_DEFINE(net_buff_pool_rx, RX_BUFF_NUM, RX_BUFF_LENGTH, RX_BUFF_USER_DATA_SIZE, NULL);

static uint32_t bytes_received = 0;


// L2CAP CALLBACKS
// --------------------------------------------------------

static void l2cap_connected(struct bt_l2cap_chan *chan)
{
    LOG_INF("L2CAP CoC connected");
}

static void l2cap_disconnected(struct bt_l2cap_chan *chan)
{
    LOG_INF("L2CAP CoC disconnected");
}

static int l2cap_recv(struct bt_l2cap_chan *chan, struct net_buf *buf)
{
    bytes_received += buf->len;

    return 0;
}

static struct net_buf *l2cap_chan_alloc_buf(struct bt_l2cap_chan *chan)
{
    struct net_buf *buf = net_buf_alloc(&net_buff_pool_rx, K_NO_WAIT);
    if (buf) {
        LOG_INF("Allocated buf for credit");
    } else {
        LOG_ERR("Failed to allocate buf for credit");
    }
    return buf;
}


// CHANNEL OPS
// --------------------------------------------------------

static struct bt_l2cap_chan_ops l2cap_ops = {
    .connected = l2cap_connected,
    .disconnected = l2cap_disconnected,
    .recv = l2cap_recv,
    .alloc_buf  = l2cap_chan_alloc_buf,
};

// ACCEPT CALLBACK
// --------------------------------------------------------

static int l2cap_accept(struct bt_conn *conn, struct bt_l2cap_chan **chan)
{
    LOG_INF("L2CAP CoC accept");
    struct bt_l2cap_le_chan *le_chan = &l2cap_chan; // Ensure this is the LE struct

    // Force reset the RX state before assigning
    memset(&le_chan->rx, 0, sizeof(le_chan->rx));

    le_chan->chan.ops = &l2cap_ops;
    le_chan->rx.mtu = L2CAP_MTU;
    le_chan->rx.mps = L2CAP_MTU;
    le_chan->rx.init_credits = RX_BUFF_NUM / 2; 

    *chan = &le_chan->chan;
    return 0;
}

// L2CAP SERVER
// --------------------------------------------------------

static struct bt_l2cap_server l2cap_server = {
    .psm = L2CAP_PSM,
    .sec_level = BT_SECURITY_L1,  // no auth no encryption
    .accept = l2cap_accept,
};

// PUBLIC METHODS
// --------------------------------------------------------
int l2cap_channel_init()
{
    return bt_l2cap_server_register(&l2cap_server);
}

Here is my btmon output from the RPi. it shows that I am only receiving 1 credit per connection interval even though the packet size that I am sending (30) is way less than the MTU. Note that this is not the same log as for the 32KBps connection, this is me testing with a lower MTU to prove out that there should be enough buffer on the controller to handle multiple credits. 

< HCI Command: LE Set Scan Parameters (0x08|0x000b) plen 7                                                                                                                                                                                                                           #1 4.846002
        Type: Passive (0x00)
        Interval: 60.000 msec (0x0060)
        Window: 60.000 msec (0x0060)
        Own address type: Public (0x00)
        Filter policy: Ignore not in white list (0x01)
> HCI Event: Command Complete (0x0e) plen 4                                                                                                                                                                                                                                          #2 4.846421
      LE Set Scan Parameters (0x08|0x000b) ncmd 1
        Status: Success (0x00)
< HCI Command: LE Set Scan Enable (0x08|0x000c) plen 2                                                                                                                                                                                                                               #3 4.846526
        Scanning: Enabled (0x01)
        Filter duplicates: Enabled (0x01)
> HCI Event: Command Complete (0x0e) plen 4                                                                                                                                                                                                                                          #4 4.846851
      LE Set Scan Enable (0x08|0x000c) ncmd 1
        Status: Success (0x00)
> HCI Event: LE Meta Event (0x3e) plen 35                                                                                                                                                                                                                                            #5 5.142090
      LE Advertising Report (0x02)
        Num reports: 1
        Event type: Connectable undirected - ADV_IND (0x00)
        Address type: Random (0x01)
        Address: D7:85:74:5F:87:45 (Static)
        Data length: 23
        Flags: 0x06
          LE General Discoverable Mode
          BR/EDR Not Supported
        Name (complete): SX00000
        Company: Ericsson Technology Licensing (0)
          Data: 000000000000
        RSSI: -35 dBm (0xdd)
< HCI Command: LE Set Scan Enable (0x08|0x000c) plen 2                                                                                                                                                                                                                               #6 5.142149
        Scanning: Disabled (0x00)
        Filter duplicates: Disabled (0x00)
> HCI Event: Command Complete (0x0e) plen 4                                                                                                                                                                                                                                          #7 5.144100
      LE Set Scan Enable (0x08|0x000c) ncmd 1
        Status: Success (0x00)
< HCI Command: LE Create Connection (0x08|0x000d) plen 25                                                                                                                                                                                                                            #8 5.144154
        Scan interval: 60.000 msec (0x0060)
        Scan window: 60.000 msec (0x0060)
        Filter policy: White list is not used (0x00)
        Peer address type: Random (0x01)
        Peer address: D7:85:74:5F:87:45 (Static)
        Own address type: Public (0x00)
        Min connection interval: 7.50 msec (0x0006)
        Max connection interval: 7.50 msec (0x0006)
        Connection latency: 0 (0x0000)
        Supervision timeout: 4000 msec (0x0190)
        Min connection length: 0.000 msec (0x0000)
        Max connection length: 0.000 msec (0x0000)
> HCI Event: Command Status (0x0f) plen 4                                                                                                                                                                                                                                            #9 5.144672
      LE Create Connection (0x08|0x000d) ncmd 1
        Status: Success (0x00)
> HCI Event: LE Meta Event (0x3e) plen 19                                                                                                                                                                                                                                           #10 5.349786
      LE Connection Complete (0x01)
        Status: Success (0x00)
        Handle: 64
        Role: Master (0x00)
        Peer address type: Random (0x01)
        Peer address: D7:85:74:5F:87:45 (Static)
        Connection interval: 7.50 msec (0x0006)
        Connection latency: 0 (0x0000)
        Supervision timeout: 4000 msec (0x0190)
        Master clock accuracy: 0x00
@ MGMT Event: Device Connected (0x000b) plen 36                                                                                                                                                                                                                                {0x0001} 5.349817
        LE Address: D7:85:74:5F:87:45 (Static)
        Flags: 0x00000008
          Unknown device flag (0x00000008)
        Data length: 23
        Flags: 0x06
          LE General Discoverable Mode
          BR/EDR Not Supported
        Name (complete): SX00000
        Company: Ericsson Technology Licensing (0)
          Data: 000000000000
< HCI Command: LE Read Remote Used Features (0x08|0x0016) plen 2                                                                                                                                                                                                                    #11 5.349912
        Handle: 64
> HCI Event: Command Status (0x0f) plen 4                                                                                                                                                                                                                                           #12 5.350757
      LE Read Remote Used Features (0x08|0x0016) ncmd 1
        Status: Success (0x00)
> ACL Data RX: Handle 64 flags 0x02 dlen 7                                                                                                                                                                                                                                          #13 5.366017
      ATT: Exchange MTU Request (0x02) len 2
        Client RX MTU: 247
> HCI Event: LE Meta Event (0x3e) plen 12                                                                                                                                                                                                                                           #14 5.366685
      LE Read Remote Used Features (0x04)
        Status: Success (0x00)
        Handle: 64
        Features: 0x2d 0x00 0x00 0x00 0x00 0x00 0x00 0x00
          LE Encryption
          Extended Reject Indication
          Slave-initiated Features Exchange
          LE Data Packet Length Extension
< ACL Data TX: Handle 64 flags 0x00 dlen 18                                                                                                                                                                                                                                         #15 5.366734
      LE L2CAP: LE Connection Request (0x14) ident 1 len 10
        PSM: 129 (0x0081)
        Source CID: 64
        MTU: 672
        MPS: 247
        Credits: 3
< ACL Data TX: Handle 64 flags 0x00 dlen 7                                                                                                                                                                                                                                          #16 5.367263
      ATT: Exchange MTU Response (0x03) len 2
        Server RX MTU: 517
< ACL Data TX: Handle 64 flags 0x00 dlen 7                                                                                                                                                                                                                                          #17 5.367276
      ATT: Exchange MTU Request (0x02) len 2
        Client RX MTU: 517
> HCI Event: LE Meta Event (0x3e) plen 11                                                                                                                                                                                                                                           #18 5.388874
      LE Data Length Change (0x07)
        Handle: 64
        Max TX octets: 251
        Max TX time: 2120
        Max RX octets: 251
        Max RX time: 2120
> ACL Data RX: Handle 64 flags 0x02 dlen 18                                                                                                                                                                                                                                         #19 5.396227
      LE L2CAP: LE Connection Response (0x15) ident 1 len 10
        Destination CID: 64
        MTU: 30
        MPS: 32
        Credits: 1
        Result: Connection successful (0x0000)
> HCI Event: Number of Completed Packets (0x13) plen 5                                                                                                                                                                                                                              #20 5.396619
        Num handles: 1
        Handle: 64
        Count: 2
> ACL Data RX: Handle 64 flags 0x02 dlen 7                                                                                                                                                                                                                                          #21 5.411145
      ATT: Exchange MTU Response (0x03) len 2
        Server RX MTU: 247
< ACL Data TX: Handle 64 flags 0x00 dlen 7                                                                                                                                                                                                                                          #22 5.411479
      ATT: Read Request (0x0a) len 2
        Handle: 0x0004
> HCI Event: Number of Completed Packets (0x13) plen 5                                                                                                                                                                                                                              #23 5.418762
        Num handles: 1
        Handle: 64
        Count: 2
> ACL Data RX: Handle 64 flags 0x02 dlen 12                                                                                                                                                                                                                                         #24 5.426104
      ATT: Read Response (0x0b) len 7
        Value: 53583030303030
< ACL Data TX: Handle 64 flags 0x00 dlen 7                                                                                                                                                                                                                                          #25 5.426409
      ATT: Read Request (0x0a) len 2
        Handle: 0x0006
> ACL Data RX: Handle 64 flags 0x02 dlen 7                                                                                                                                                                                                                                          #26 5.441071
      ATT: Read Response (0x0b) len 2
        Value: 0000
< ACL Data TX: Handle 64 flags 0x00 dlen 11                                                                                                                                                                                                                                         #27 5.441421
      ATT: Read By Type Request (0x08) len 6
        Handle range: 0x0001-0xffff
        Attribute type: Unknown (0x2b3a)
> HCI Event: Number of Completed Packets (0x13) plen 5                                                                                                                                                                                                                              #28 5.448773
        Num handles: 1
        Handle: 64
        Count: 2
> ACL Data RX: Handle 64 flags 0x02 dlen 9                                                                                                                                                                                                                                          #29 5.456084
      ATT: Error Response (0x01) len 4
        Read By Type Request (0x08)
        Handle: 0x0001
        Error: Attribute Not Found (0x0a)
< ACL Data TX: Handle 64 flags 0x00 dlen 11                                                                                                                                                                                                                                         #30 5.456288
      ATT: Read By Group Type Request (0x10) len 6
        Handle range: 0x0001-0xffff
        Attribute group type: Primary Service (0x2800)
> ACL Data RX: Handle 64 flags 0x02 dlen 18                                                                                                                                                                                                                                         #31 5.471163
      ATT: Read By Group Type Response (0x11) len 13
        Attribute data length: 6
        Attribute group list: 2 entries
        Handle range: 0x0001-0x0001
        UUID: Generic Attribute Profile (0x1801)
        Handle range: 0x0002-0x0006
        UUID: Generic Access Profile (0x1800)
< ACL Data TX: Handle 64 flags 0x00 dlen 11                                                                                                                                                                                                                                         #32 5.471362
      ATT: Read By Group Type Request (0x10) len 6
        Handle range: 0x0007-0xffff
        Attribute group type: Primary Service (0x2800)
> HCI Event: Number of Completed Packets (0x13) plen 5                                                                                                                                                                                                                              #33 5.478772
        Num handles: 1
        Handle: 64
        Count: 2
> ACL Data RX: Handle 64 flags 0x02 dlen 26                                                                                                                                                                                                                                         #34 5.486695
      ATT: Read By Group Type Response (0x11) len 21
        Attribute data length: 20
        Attribute group list: 1 entry
        Handle range: 0x0007-0x000c
        UUID: Nordic UART Service (6e400001-b5a3-f393-e0a9-e50e24dcca9e)
< ACL Data TX: Handle 64 flags 0x00 dlen 11                                                                                                                                                                                                                                         #35 5.486873
      ATT: Read By Group Type Request (0x10) len 6
        Handle range: 0x000d-0xffff
        Attribute group type: Primary Service (0x2800)
> ACL Data RX: Handle 64 flags 0x02 dlen 9                                                                                                                                                                                                                                          #36 5.501100
      ATT: Error Response (0x01) len 4
        Read By Group Type Request (0x10)
        Handle: 0x000d
        Error: Attribute Not Found (0x0a)
> HCI Event: Number of Completed Packets (0x13) plen 5                                                                                                                                                                                                                              #37 5.639217
        Num handles: 1
        Handle: 64
        Count: 1
< ACL Data TX: Handle 64 flags 0x00 dlen 31                                                                                                                                                                                                                                        #38 15.397047
      Channel: 64 len 27 sdu 25 [PSM 129 mode LE Flow Control (0x80)] {chan 0}
        19 00 00 00 02 20 2d 37 01 24 41 35 01 24 43 35  ..... -7.$A5.$C5
        01 24 45 35 01 24 47 35 01 24 49                 .$E5.$G5.$I     
< ACL Data TX: Handle 64 flags 0x00 dlen 31                                                                                                                                                                                                                                        #39 15.397074
      Channel: 64 len 27 sdu 25 [PSM 129 mode LE Flow Control (0x80)] {chan 0}
        19 00 35 01 24 00 00 00 00 00 00 00 00 00 00 00  ..5.$...........
        00 00 00 00 00 01 f3 01 24 4b 35                 ........$K5     
< ACL Data TX: Handle 64 flags 0x00 dlen 31                                                                                                                                                                                                                                        #40 15.397077
      Channel: 64 len 27 sdu 25 [PSM 129 mode LE Flow Control (0x80)] {chan 0}
        19 00 01 24 00 00 00 00 a1 f3 01 24 5f d0 01 24  ...$.......$_..$
        7d 37 01 24 7d 37 01 24 7d 37 01                 }7.$}7.$}7.     
< ACL Data TX: Handle 64 flags 0x00 dlen 31                                                                                                                                                                                                                                        #41 15.397090
      Channel: 64 len 27 sdu 25 [PSM 129 mode LE Flow Control (0x80)] {chan 0}
        19 00 24 7d 37 01 24 7d 37 01 24 7d 37 01 24 7d  ..$}7.$}7.$}7.$}
        37 01 24 7d 37 01 24 7d 37 01 24                 7.$}7.$}7.$     
< ACL Data TX: Handle 64 flags 0x00 dlen 31                                                                                                                                                                                                                                        #42 15.397099
      Channel: 64 len 27 sdu 25 [PSM 129 mode LE Flow Control (0x80)] {chan 0}
        19 00 7d 37 01 24 7d 37 01 24 4d 35 01 24 5d 35  ..}7.$}7.$M5.$]5
        01 24 7d 37 01 24 7d 37 01 24 7d                 .$}7.$}7.$}     
< ACL Data TX: Handle 64 flags 0x00 dlen 31                                                                                                                                                                                                                                        #43 15.397107
      Channel: 64 len 27 sdu 25 [PSM 129 mode LE Flow Control (0x80)] {chan 0}
        19 00 37 01 24 7d 37 01 24 7d 37 01 24 7d 37 01  ..7.$}7.$}7.$}7.
        24 7d 37 01 24 7d 37 01 24 7d 37                 $}7.$}7.$}7     
< ACL Data TX: Handle 64 flags 0x00 dlen 31                                                                                                                                                                                                                                        #44 15.397116
      Channel: 64 len 27 sdu 25 [PSM 129 mode LE Flow Control (0x80)] {chan 0}
        19 00 01 24 7d 37 01 24 7d 37 01 24 7d 37 01 24  ...$}7.$}7.$}7.$
        6d 35 01 24 7d 37 01 24 7d 37 01                 m5.$}7.$}7.     
> HCI Event: Number of Completed Packets (0x13) plen 5                                                                                                                                                                                                                             #45 15.402052
        Num handles: 1
        Handle: 64
        Count: 2
< ACL Data TX: Handle 64 flags 0x00 dlen 31                                                                                                                                                                                                                                        #46 15.402094
      Channel: 64 len 27 sdu 25 [PSM 129 mode LE Flow Control (0x80)] {chan 0}
        19 00 24 7d 37 01 24 7d 37 01 24 7d 37 01 24 7d  ..$}7.$}7.$}7.$}
        37 01 24 7d 37 01 24 7d 37 01 24                 7.$}7.$}7.$     
< ACL Data TX: Handle 64 flags 0x00 dlen 31                                                                                                                                                                                                                                        #47 15.402102
      Channel: 64 len 27 sdu 25 [PSM 129 mode LE Flow Control (0x80)] {chan 0}
        19 00 7d 37 01 24 7d 37 01 24 7d 37 01 24 7d 37  ..}7.$}7.$}7.$}7
        01 24 7d 37 01 24 7d 37 01 24 7d                 .$}7.$}7.$}     
> ACL Data RX: Handle 64 flags 0x02 dlen 12                                                                                                                                                                                                                                        #48 15.402763
      LE L2CAP: LE Flow Control Credit (0x16) ident 1 len 4
        Source CID: 64
        Credits: 1
> ACL Data RX: Handle 64 flags 0x02 dlen 12                                                                                                                                                                                                                                        #49 15.403728
      LE L2CAP: LE Flow Control Credit (0x16) ident 2 len 4
        Source CID: 64
        Credits: 1
> HCI Event: Number of Completed Packets (0x13) plen 5                                                                                                                                                                                                                             #50 15.403878
        Num handles: 1
        Handle: 64
        Count: 2
< ACL Data TX: Handle 64 flags 0x00 dlen 31                                                                                                                                                                                                                                        #51 15.403898
      Channel: 64 len 27 sdu 25 [PSM 129 mode LE Flow Control (0x80)] {chan 0}
        19 00 37 01 24 7d 37 01 24 00 00 00 00 7d 37 01  ..7.$}7.$....}7.
        24 7d 37 01 24 7d 37 01 24 7d 37                 $}7.$}7.$}7     
< ACL Data TX: Handle 64 flags 0x00 dlen 12                                                                                                                                                                                                                                        #52 15.403905
      LE L2CAP: Disconnection Request (0x06) ident 2 len 4
        Destination CID: 64
        Source CID: 64
> ACL Data RX: Handle 64 flags 0x02 dlen 12                                                                                                                                                                                                                                        #53 15.408912
      LE L2CAP: LE Flow Control Credit (0x16) ident 3 len 4
        Source CID: 64
        Credits: 1
> ACL Data RX: Handle 64 flags 0x02 dlen 12                                                                                                                                                                                                                                        #54 15.409706
      LE L2CAP: LE Flow Control Credit (0x16) ident 4 len 4
        Source CID: 64
        Credits: 1
> HCI Event: Number of Completed Packets (0x13) plen 5                                                                                                                                                                                                                             #55 15.410967
        Num handles: 1
        Handle: 64
        Count: 2
> ACL Data RX: Handle 64 flags 0x02 dlen 12                                                                                                                                                                                                                                        #56 15.410981
      LE L2CAP: LE Flow Control Credit (0x16) ident 5 len 4
        Source CID: 64
        Credits: 1
> ACL Data RX: Handle 64 flags 0x02 dlen 12                                                                                                                                                                                                                                        #57 15.411851
      LE L2CAP: LE Flow Control Credit (0x16) ident 6 len 4
        Source CID: 64
        Credits: 1
> HCI Event: Number of Completed Packets (0x13) plen 5                                                                                                                                                                                                                             #58 15.411988
        Num handles: 1
        Handle: 64
        Count: 2
> ACL Data RX: Handle 64 flags 0x02 dlen 12                                                                                                                                                                                                                                        #59 15.416413
      LE L2CAP: LE Flow Control Credit (0x16) ident 7 len 4
        Source CID: 64
        Credits: 1
> ACL Data RX: Handle 64 flags 0x02 dlen 12                                                                                                                                                                                                                                        #60 15.417195
      LE L2CAP: LE Flow Control Credit (0x16) ident 8 len 4
        Source CID: 64
        Credits: 1
> HCI Event: Number of Completed Packets (0x13) plen 5                                                                                                                                                                                                                             #61 15.417416
        Num handles: 1
        Handle: 64
        Count: 2
> ACL Data RX: Handle 64 flags 0x02 dlen 12                                                                                                                                                                                                                                        #62 15.418040
      LE L2CAP: LE Flow Control Credit (0x16) ident 9 len 4
        Source CID: 64
        Credits: 1
> ACL Data RX: Handle 64 flags 0x02 dlen 12                                                                                                                                                                                                                                        #63 15.423739
      LE L2CAP: Disconnection Response (0x07) ident 2 len 4
        Destination CID: 64
        Source CID: 64
> HCI Event: Number of Completed Packets (0x13) plen 5                                                                                                                                                                                                                             #64 15.639354
        Num handles: 1
        Handle: 64
        Count: 1

  • Hi

    Can you confirm that the RPi also is susceptible to accept higher credit counts than 1 on your test setup? I don't see anything obvious that would refuse the multiple credits on your end here. Are you able to get a sniffer trace of what's going on over the air so we can get a better look at what is happening during the data transfers?

    The obvious thing to check for you already seem to have done on the nRF side at least.

    Best regards,

    Simon

  • Hi Simon,

    Thank you for responding. Here is a Wireshark log. Note that there is a 5 second break between connecting and sending data. I added this so that sending data did not collide with the  MTU / interval update. but does mean that the log is a little polluted. My first time using Wireshark, so let me know if the config is OK / more info needed. 

    To be honest I am not really sure what I am looking at, but looks like the RPi (central) sends credit based connection request with initial 3 credits but gets back a credit based connection response from the nrf (peripheral) with only 1 credit. 

    wireshark_log_2026-01-16.pcapng

  • Hi

    Indeed, it seems like it's the peripheral (nRF52) that is setting the initial credits back to 1 here. Unfortunately there isn't much in the sniffer trace pointing to what exactly it is that  How are you handling the flow control frame on the peripheral side exactly? I will ask around internally what this could be due to, as I haven't found anything useful in the documentation yet on my end either.

    Best regards,

    Simon

  • Hi Simon,

    Honestly I am not sure how the flow control frame is handled, I have just been dealing with the higher level API calls. I simply register an L2Cap server as mentioned above, and have the call backs do as little as possible 

    In-case there is something that I am configuring incorrectly, here is my PRJ file. I am building this on an existing project, where I already have the Nordic Uart service running and working, (rx and tx GATT characteristic), and use the async UART API to handle Uart.

    #enable modules
    CONFIG_BOOTLOADER_MCUBOOT=y 
    CONFIG_NANOPB=y
    CONFIG_CRC=y
    
    # Enable the UART driver
    CONFIG_UART_ASYNC_API=y
    CONFIG_SERIAL=y
    
    CONFIG_RING_BUFFER=y
    
    # added config for issue https://github.com/zephyrproject-rtos/zephyr/issues/47925
    CONFIG_UART_0_ASYNC=y
    CONFIG_UART_0_NRF_HW_ASYNC=y
    CONFIG_UART_0_NRF_HW_ASYNC_TIMER=2
    CONFIG_BT_NUS_UART_RX_WAIT_TIME=1000
    
    CONFIG_HEAP_MEM_POOL_SIZE=0
    
    # Enable DK LED and Buttons library
    CONFIG_DK_LIBRARY=n
    
    # Drivers and peripherals
    CONFIG_I2C=n
    CONFIG_WATCHDOG=n
    #CONFIG_PINMUX=n
    CONFIG_SPI=n
    CONFIG_GPIO=y
    
    # Power management
    CONFIG_PM=y
    CONFIG_PM_DEVICE=y
    CONFIG_PM_DEVICE_RUNTIME=y
    CONFIG_REBOOT=y
    #CONFIG_POWEROFF=y
    
    # Interrupts
    CONFIG_DYNAMIC_INTERRUPTS=n
    CONFIG_IRQ_OFFLOAD=n
    
    # Memory protection
    CONFIG_THREAD_STACK_INFO=n
    CONFIG_THREAD_CUSTOM_DATA=n
    CONFIG_FPU=n
    
    # Boot
    CONFIG_BOOT_BANNER=n
    CONFIG_BOOT_DELAY=0
    
    # Build
    CONFIG_SIZE_OPTIMIZATIONS=y
    CONFIG_DEBUG=n
    
    # ARM
    CONFIG_ARM_MPU=n
    
    CONFIG_BT_RX_STACK_SIZE=1280
    CONFIG_BT_HCI_TX_STACK_SIZE_WITH_PROMPT=y
    CONFIG_BT_HCI_TX_STACK_SIZE=768
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=768
    CONFIG_MPSL_WORK_STACK_SIZE=640
    CONFIG_MAIN_STACK_SIZE=1536
    CONFIG_IDLE_STACK_SIZE=128
    CONFIG_ISR_STACK_SIZE=768
    CONFIG_BT_NUS_THREAD_STACK_SIZE=1024
    
    # Disable features not needed
    CONFIG_TIMESLICING=n
    CONFIG_COMMON_LIBC_MALLOC=n
    CONFIG_ASSERT=n
    CONFIG_USB_DEVICE_STACK=n
    
    # BLE
    CONFIG_BT=y
    CONFIG_BT_PERIPHERAL=y
    CONFIG_BT_DEVICE_NAME="SX"
    CONFIG_BT_DEVICE_NAME_DYNAMIC=y
    CONFIG_BT_DEVICE_NAME_MAX=10
    CONFIG_BT_DEVICE_APPEARANCE=0
    CONFIG_BT_MAX_CONN=1
    CONFIG_BT_SMP=y
    CONFIG_BT_MAX_PAIRED=1
    CONFIG_BT_BONDABLE=n
    CONFIG_BT_NUS=y
    CONFIG_BT_GATT_CLIENT=y
    
    # enable L2CAP CoC Dynamic channels
    CONFIG_BT_L2CAP_DYNAMIC_CHANNEL=y
    CONFIG_BT_L2CAP_SEG_RECV=y
    
    # enable settings to allow storing of bonds
    CONFIG_BT_SETTINGS=y
    CONFIG_SETTINGS=y
    CONFIG_SETTINGS_CUSTOM=y
    
    CONFIG_BT_NUS_AUTHEN=n
    
    # CONFIG_BT_AUTO_PHY_UPDATE=y # PHY disabled at controller level to save space
    # CONFIG_BT_DATA_LEN_UPDATE=n # this caused issues. must be set to y
    CONFIG_BT_DATA_LEN_UPDATE=y
    CONFIG_BT_AUTO_DATA_LEN_UPDATE=y
    CONFIG_BT_GAP_AUTO_UPDATE_CONN_PARAMS=y
    
    CONFIG_BT_CTLR=y
    CONFIG_BT_CTLR_SDC_RX_PACKET_COUNT=12
    
    # Disable Bluetooth features not needed
    CONFIG_BT_DEBUG_LOG=n
    CONFIG_BT_DEBUG_NONE=y
    CONFIG_BT_ASSERT=n
    CONFIG_BT_PHY_UPDATE=n
    CONFIG_BT_GATT_CACHING=n
    CONFIG_BT_GATT_SERVICE_CHANGED=n
    CONFIG_BT_GAP_PERIPHERAL_PREF_PARAMS=n
    # CONFIG_BT_SETTINGS_CCC_LAZY_LOADING=y # this gets disabled in the config adjustment
    CONFIG_BT_HCI_VS_EXT=n
    
    # Disable Bluetooth controller features not needed
    CONFIG_BT_CTLR_PRIVACY=n
    CONFIG_BT_CTLR_PHY_2M=n
    
    # Bluetooth buffers 
    CONFIG_BT_BUF_EVT_DISCARDABLE_COUNT=1
    CONFIG_BT_BUF_EVT_DISCARDABLE_SIZE=43
    CONFIG_BT_BUF_EVT_RX_COUNT=2
    
    CONFIG_BT_L2CAP_TX_BUF_COUNT=2
    CONFIG_BT_BUF_ACL_TX_COUNT=2
    CONFIG_BT_BUF_ACL_RX_COUNT=20
    CONFIG_BT_NUS_UART_BUFFER_SIZE=244
    CONFIG_BT_L2CAP_TX_MTU=247
    CONFIG_BT_BUF_ACL_RX_SIZE=251
    CONFIG_BT_BUF_ACL_TX_SIZE=251
    CONFIG_BT_CTLR_DATA_LENGTH_MAX=251
    
    # Config logger
    CONFIG_LOG=y
    CONFIG_USE_SEGGER_RTT=y
    CONFIG_LOG_BACKEND_RTT=y
    CONFIG_LOG_BACKEND_UART=n
    # this is forced to y CONFIG_LOG_PRINTK=n
    CONFIG_LOG_PROCESS_THREAD_STACK_SIZE=2048
    CONFIG_LOG_BUFFER_SIZE=2048
    
    
    CONFIG_LOG_MAX_LEVEL=3
    CONFIG_LOG_DEFAULT_LEVEL=3
    
    # In order to correctly tune the stack sizes for the threads the following
    # Configurations can enabled to print the current use:
    CONFIG_THREAD_NAME=y
    CONFIG_THREAD_ANALYZER=y
    CONFIG_THREAD_ANALYZER_RUN_UNLOCKED=y
    CONFIG_THREAD_ANALYZER_USE_PRINTK=y
    CONFIG_CONSOLE=y
    CONFIG_RTT_CONSOLE=y
    CONFIG_PRINTK=y
    CONFIG_STACK_CANARIES=y
    CONFIG_STACK_SENTINEL=y
    CONFIG_THREAD_ANALYZER_AUTO=y 
    CONFIG_THREAD_ANALYZER_AUTO_INTERVAL=20

  • Hi

    Can you try increasing CONFIG_BT_CTLR_SDC_TX_PACKET_COUNT and RX_PACKET_COUNT to 20 and see if that changes anything. Based on a discussion taking place last year. If that doesn't help, I'll have to wait for a reply from the developers on this.

    Best regards,

    Simon

Related