bt_conn: Send auto LE param update failed (err -12)

sometimes the param update will fail and sometimes will not. May I know what the reason is and how to solve this issue?

error case;

[00:02:08.010,101] <wrn> bt_conn: Unable to allocate buffer within timeout
[00:02:08.010,101] <err> bt_l2cap: Unable to allocate buffer for op 0x12
[00:02:08.010,131] <wrn> bt_conn: Send auto LE param update failed (err -12)
[00:02:08.012,268] <err> dsp: write_dsp_remote uart tx prepare failed -2

normal case:

[00:00:17.984,069] <inf> main: Connection parameters updated: interval 8x1.25 ms, latency 0 intervals, timeout 2000 ms

my prj.conf

CONFIG_BT=y
CONFIG_BT_SMP=y
CONFIG_BT_SIGNING=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_DIS=y
CONFIG_BT_ATT_PREPARE_COUNT=5
CONFIG_BT_PRIVACY=n
CONFIG_BT_HCI_VS_EXT=y

CONFIG_BT_DEVICE_NAME="p1"
#0x1E,04 Power Device, Power Supply 
CONFIG_BT_DEVICE_APPEARANCE=28180

CONFIG_BT_DIS_MANUF="xnergy"
CONFIG_BT_DIS_MODEL="phoenix"

CONFIG_BT_MAX_PAIRED=128
CONFIG_BT_KEYS_OVERWRITE_OLDEST=y
CONFIG_BT_SETTINGS=y
CONFIG_FLASH=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_FLASH_MAP=y
CONFIG_NVS=y
CONFIG_SETTINGS=y

CONFIG_BT_PERIPHERAL_PREF_MIN_INT=8
CONFIG_BT_PERIPHERAL_PREF_MAX_INT=8
CONFIG_BT_PERIPHERAL_PREF_TIMEOUT=200
CONFIG_BT_GAP_AUTO_UPDATE_CONN_PARAMS=y

CONFIG_BT_BUF_ACL_RX_SIZE=251
CONFIG_BT_BUF_ACL_TX_SIZE=251
CONFIG_BT_BUF_CMD_TX_SIZE=255

CONFIG_BT_L2CAP_TX_MTU=247

CONFIG_BT_USER_DATA_LEN_UPDATE=y
CONFIG_BT_CTLR_DATA_LENGTH_MAX=251

# CONFIG_BT_MAX_CONN=2

CONFIG_BT_FIXED_PASSKEY=y

CONFIG_UART_CONSOLE=n
CONFIG_RTT_CONSOLE=y

CONFIG_BT_CTLR_CONN_RSSI=y

CONFIG_SERIAL=y
CONFIG_UART_ASYNC_API=y

CONFIG_SENSOR=y
CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC=y

CONFIG_BOOTLOADER_MCUBOOT=y
CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU=y

# In order to correctly tune the stack sizes for the threads the following
# Configurations can enabled to print the current use:
CONFIG_LOG=y
CONFIG_LOG_MODE_MINIMAL=n
CONFIG_LOG_BUFFER_SIZE=8192

#CONFIG_THREAD_NAME=y
#CONFIG_THREAD_ANALYZER=y
#CONFIG_THREAD_ANALYZER_AUTO=y
#CONFIG_THREAD_ANALYZER_RUN_UNLOCKED=y
#CONFIG_THREAD_ANALYZER_USE_PRINTK=y

# optimal for ROM/RAM size 
CONFIG_BT_RX_STACK_SIZE=2048
CONFIG_BT_HCI_TX_STACK_SIZE_WITH_PROMPT=y
CONFIG_BT_HCI_TX_STACK_SIZE=640
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
CONFIG_MPSL_WORK_STACK_SIZE=640
CONFIG_MAIN_STACK_SIZE=1024
CONFIG_IDLE_STACK_SIZE=128
CONFIG_ISR_STACK_SIZE=1024

# Disable features not needed
CONFIG_TIMESLICING=n
CONFIG_MINIMAL_LIBC_MALLOC=n
# CONFIG_LOG=n
CONFIG_ASSERT=n
CONFIG_ASSERT_VERBOSE=n
CONFIG_BOOT_BANNER=n
CONFIG_DEBUG=n

# Disable Bluetooth features not needed
CONFIG_BT_DEBUG_NONE=y
CONFIG_BT_ASSERT=n
# CONFIG_BT_DATA_LEN_UPDATE=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
#CONFIG_BT_HCI_VS_EXT=n

# Disable Bluetooth controller features not needed
CONFIG_BT_CTLR_PRIVACY=n
CONFIG_BT_CTLR_PHY_2M=n

# Reduce 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_CONN_TX_MAX=2
CONFIG_BT_L2CAP_TX_BUF_COUNT=2
CONFIG_BT_BUF_ACL_TX_COUNT=3
# CONFIG_BT_BUF_ACL_TX_SIZE=27

# Drivers and peripherals
CONFIG_I2C=n
CONFIG_WATCHDOG=n
# CONFIG_GPIO=n
CONFIG_SPI=n
# CONFIG_SERIAL=n

CONFIG_BT_CTLR_TX_PWR_ANTENNA=0

peripheral log

0001.txt

Parents
  • The error you are seeing seems to be related to buffer allocation for the L2CAP operation. This could be due to insufficient resources or too many SDUs queued for transmission.
    In the Zephyr Project's Bluetooth API, there are several L2CAP operations that involve buffer allocation, such as bt_l2cap_chan_ops.alloc_buf and bt_l2cap_chan_ops.alloc_seg. If these operations fail, it could be due to not having enough resources available.
    You might want to check your configuration settings related to buffer sizes and counts.
    For instance try these
    CONFIG_BT_L2CAP_TX_MTU=252
    CONFIG_BT_BUF_ACL_RX_SIZE=256
    CONFIG_BT_BUF_EVT_DISCARDABLE_COUNT=1
    CONFIG_BT_BUF_EVT_DISCARDABLE_SIZE=45
    CONFIG_BT_BUF_ACL_RX_COUNT=2
    CONFIG_BT_BUF_EVT_RX_COUNT=2
    CONFIG_BT_CONN_TX_MAX=2
    CONFIG_BT_L2CAP_TX_BUF_COUNT=2
    CONFIG_BT_CTLR_RX_BUFFERS=1
    CONFIG_BT_BUF_ACL_TX_COUNT=3
    CONFIG_BT_BUF_ACL_TX_SIZE=27
    Fine tune those above variables to see if you see any difference. These settings control the maximum transmission unit (MTU) for L2CAP, the size of the ACL RX buffer, and the counts of various types of buffers.
    If you're still encountering issues, you might want to capture a BLE air sniffer trace of your connection to inspect what could be wrong.
Reply
  • The error you are seeing seems to be related to buffer allocation for the L2CAP operation. This could be due to insufficient resources or too many SDUs queued for transmission.
    In the Zephyr Project's Bluetooth API, there are several L2CAP operations that involve buffer allocation, such as bt_l2cap_chan_ops.alloc_buf and bt_l2cap_chan_ops.alloc_seg. If these operations fail, it could be due to not having enough resources available.
    You might want to check your configuration settings related to buffer sizes and counts.
    For instance try these
    CONFIG_BT_L2CAP_TX_MTU=252
    CONFIG_BT_BUF_ACL_RX_SIZE=256
    CONFIG_BT_BUF_EVT_DISCARDABLE_COUNT=1
    CONFIG_BT_BUF_EVT_DISCARDABLE_SIZE=45
    CONFIG_BT_BUF_ACL_RX_COUNT=2
    CONFIG_BT_BUF_EVT_RX_COUNT=2
    CONFIG_BT_CONN_TX_MAX=2
    CONFIG_BT_L2CAP_TX_BUF_COUNT=2
    CONFIG_BT_CTLR_RX_BUFFERS=1
    CONFIG_BT_BUF_ACL_TX_COUNT=3
    CONFIG_BT_BUF_ACL_TX_SIZE=27
    Fine tune those above variables to see if you see any difference. These settings control the maximum transmission unit (MTU) for L2CAP, the size of the ACL RX buffer, and the counts of various types of buffers.
    If you're still encountering issues, you might want to capture a BLE air sniffer trace of your connection to inspect what could be wrong.
Children
No Data
Related