Skip to content

Commit

Permalink
samples: Bluetooth: hci_ipc: Fix Newton's Cradle, reduce RAM usage
Browse files Browse the repository at this point in the history
The required ISO Tx buffers have to match the Read Buffer
Size values, otherwise the difference in the value cause a
similar amount of buffers to be stalled in the IPC driver.

Use reduced HEAP size to make room for increase in RAM
usage.

(cherry picked from commit 398b915)

Original-Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
GitOrigin-RevId: 398b915
Cr-Build-Id: 8730286630880259329
Cr-Build-Url: https://cr-buildbucket.appspot.com/build/8730286630880259329
Copybot-Job-Name: zephyr-main-copybot-downstream
Change-Id: I12922cb9de9b2d20966caebc4c0cfc8f007b3c09
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/zephyr/+/6045785
Reviewed-by: Fabio Baltieri <fabiobaltieri@google.com>
Tested-by: ChromeOS Prod (Robot) <chromeos-ci-prod@chromeos-bot.iam.gserviceaccount.com>
Commit-Queue: Fabio Baltieri <fabiobaltieri@google.com>
  • Loading branch information
Vinayak Kariappa Chettimada authored and Chromeos LUCI committed Nov 26, 2024
1 parent 6b7a31b commit 4d8ad6d
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ CONFIG_ISR_STACK_SIZE=1024
CONFIG_IDLE_STACK_SIZE=256
CONFIG_MAIN_STACK_SIZE=512
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=512
CONFIG_HEAP_MEM_POOL_SIZE=8192
CONFIG_HEAP_MEM_POOL_SIZE=6144

CONFIG_BT=y
CONFIG_BT_HCI_RAW=y
Expand Down Expand Up @@ -40,7 +40,11 @@ CONFIG_BT_ISO_PERIPHERAL=n

# ISO Streams
CONFIG_BT_ISO_MAX_CHAN=4
CONFIG_BT_ISO_TX_BUF_COUNT=1
# In theory, CONFIG_BT_ISO_TX_BUF_COUNT=1, should be sufficient but this count
# is used in the context of IPC which falls into a "Newton's Cradle" effect
# where probably (CONFIG_BT_CTLR_ISO_TX_BUFFERS - CONFIG_BT_ISO_TX_BUF_COUNT)
# buffers get throttled. Hence, always have the value equal or greater.
CONFIG_BT_ISO_TX_BUF_COUNT=12
CONFIG_BT_ISO_RX_BUF_COUNT=1

# Controller
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
CONFIG_IPC_SERVICE=y
CONFIG_MBOX=y

CONFIG_HEAP_MEM_POOL_SIZE=8192
CONFIG_HEAP_MEM_POOL_SIZE=6144

CONFIG_MAIN_STACK_SIZE=512
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=512
Expand Down
10 changes: 7 additions & 3 deletions samples/bluetooth/hci_ipc/nrf5340_cpunet_cis-bt_ll_sw_split.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ CONFIG_ISR_STACK_SIZE=1024
CONFIG_IDLE_STACK_SIZE=256
CONFIG_MAIN_STACK_SIZE=512
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=512
CONFIG_HEAP_MEM_POOL_SIZE=8192
CONFIG_HEAP_MEM_POOL_SIZE=6144

CONFIG_BT=y
CONFIG_BT_HCI_RAW=y
Expand Down Expand Up @@ -39,7 +39,11 @@ CONFIG_BT_ISO_PERIPHERAL=y

# ISO Streams
CONFIG_BT_ISO_MAX_CHAN=4
CONFIG_BT_ISO_TX_BUF_COUNT=1
# In theory, CONFIG_BT_ISO_TX_BUF_COUNT=1, should be sufficient but this count
# is used in the context of IPC which falls into a "Newton's Cradle" effect
# where probably (CONFIG_BT_CTLR_ISO_TX_BUFFERS - CONFIG_BT_ISO_TX_BUF_COUNT)
# buffers get throttled. Hence, always have the value equal or greater.
CONFIG_BT_ISO_TX_BUF_COUNT=12
CONFIG_BT_ISO_RX_BUF_COUNT=1

# Controller
Expand Down Expand Up @@ -82,8 +86,8 @@ CONFIG_BT_CTLR_LLCP_LOCAL_PROC_CTX_BUF_NUM=6
# ISO Connection Oriented
CONFIG_BT_CTLR_CENTRAL_ISO=y
CONFIG_BT_CTLR_PERIPHERAL_ISO=y
CONFIG_BT_CTLR_CONN_ISO_STREAMS=2
CONFIG_BT_CTLR_CONN_ISO_GROUPS=1
CONFIG_BT_CTLR_CONN_ISO_STREAMS=2
CONFIG_BT_CTLR_CONN_ISO_STREAMS_PER_GROUP=2
CONFIG_BT_CTLR_CONN_ISO_SDU_LEN_MAX=247
CONFIG_BT_CTLR_CONN_ISO_PDU_LEN_MAX=251
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ CONFIG_ISR_STACK_SIZE=1024
CONFIG_IDLE_STACK_SIZE=256
CONFIG_MAIN_STACK_SIZE=512
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=512
CONFIG_HEAP_MEM_POOL_SIZE=8192
CONFIG_HEAP_MEM_POOL_SIZE=6144

CONFIG_BT=y
CONFIG_BT_HCI_RAW=y
Expand Down
18 changes: 11 additions & 7 deletions samples/bluetooth/hci_ipc/nrf5340_cpunet_iso-bt_ll_sw_split.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ CONFIG_ISR_STACK_SIZE=1024
CONFIG_IDLE_STACK_SIZE=256
CONFIG_MAIN_STACK_SIZE=512
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=512
CONFIG_HEAP_MEM_POOL_SIZE=8192
CONFIG_HEAP_MEM_POOL_SIZE=6144
CONFIG_CBPRINTF_REDUCED_INTEGRAL=y

CONFIG_ISR_TABLES_LOCAL_DECLARATION=y
Expand Down Expand Up @@ -46,7 +46,11 @@ CONFIG_BT_ISO_PERIPHERAL=y
CONFIG_BT_ISO_TX_MTU=310
CONFIG_BT_ISO_RX_MTU=310
CONFIG_BT_ISO_MAX_CHAN=4
CONFIG_BT_ISO_TX_BUF_COUNT=1
# In theory, CONFIG_BT_ISO_TX_BUF_COUNT=1, should be sufficient but this count
# is used in the context of IPC which falls into a "Newton's Cradle" effect
# where probably (CONFIG_BT_CTLR_ISO_TX_BUFFERS - CONFIG_BT_ISO_TX_BUF_COUNT)
# buffers get throttled. Hence, always have the value equal or greater.
CONFIG_BT_ISO_TX_BUF_COUNT=8
CONFIG_BT_ISO_RX_BUF_COUNT=1

# Controller
Expand Down Expand Up @@ -100,8 +104,8 @@ CONFIG_BT_CTLR_ADV_EXT=y
CONFIG_BT_CTLR_ADV_PERIODIC=y
CONFIG_BT_CTLR_SYNC_TRANSFER_SENDER=y
CONFIG_BT_CTLR_ADV_ISO=y
CONFIG_BT_CTLR_ADV_ISO_SET=2
CONFIG_BT_CTLR_ADV_ISO_STREAM_COUNT=4
CONFIG_BT_CTLR_ADV_ISO_SET=1
CONFIG_BT_CTLR_ADV_ISO_STREAM_COUNT=2
CONFIG_BT_CTLR_ADV_ISO_STREAM_MAX=2
CONFIG_BT_CTLR_ADV_ISO_PDU_LEN_MAX=247

Expand All @@ -118,16 +122,16 @@ CONFIG_BT_CTLR_SYNC_ISO_PDU_LEN_MAX=251
# ISO Connection Oriented
CONFIG_BT_CTLR_CENTRAL_ISO=y
CONFIG_BT_CTLR_PERIPHERAL_ISO=y
CONFIG_BT_CTLR_CONN_ISO_STREAMS=2
CONFIG_BT_CTLR_CONN_ISO_GROUPS=1
CONFIG_BT_CTLR_CONN_ISO_STREAMS=2
CONFIG_BT_CTLR_CONN_ISO_STREAMS_PER_GROUP=2
CONFIG_BT_CTLR_CONN_ISO_SDU_LEN_MAX=247
CONFIG_BT_CTLR_CONN_ISO_PDU_LEN_MAX=251
CONFIG_BT_CTLR_CONN_ISO_LOW_LATENCY_POLICY=y

# ISO Transmissions
CONFIG_BT_CTLR_ISOAL_SOURCES=4
CONFIG_BT_CTLR_ISO_TX_BUFFERS=12
CONFIG_BT_CTLR_ISOAL_SOURCES=2
CONFIG_BT_CTLR_ISO_TX_BUFFERS=8
CONFIG_BT_CTLR_ISO_TX_BUFFER_SIZE=255

# ISO Receptions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ CONFIG_ISR_STACK_SIZE=1024
CONFIG_IDLE_STACK_SIZE=256
CONFIG_MAIN_STACK_SIZE=512
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=512
CONFIG_HEAP_MEM_POOL_SIZE=8192
CONFIG_HEAP_MEM_POOL_SIZE=6144

CONFIG_BT=y
CONFIG_BT_HCI_RAW=y
Expand All @@ -20,11 +20,18 @@ CONFIG_BT_OBSERVER=n
CONFIG_BT_EXT_ADV=y
CONFIG_BT_PER_ADV=y
CONFIG_BT_ISO_BROADCASTER=y
CONFIG_BT_ISO_MAX_CHAN=4
CONFIG_BT_ISO_TX_BUF_COUNT=1
CONFIG_BT_CENTRAL=n
CONFIG_BT_PERIPHERAL=n

# ISO Streams
CONFIG_BT_ISO_MAX_CHAN=4
# In theory, CONFIG_BT_ISO_TX_BUF_COUNT=1, should be sufficient but this count
# is used in the context of IPC which falls into a "Newton's Cradle" effect
# where probably (CONFIG_BT_CTLR_ISO_TX_BUFFERS - CONFIG_BT_ISO_TX_BUF_COUNT)
# buffers get throttled. Hence, always have the value equal or greater.
CONFIG_BT_ISO_TX_BUF_COUNT=12
CONFIG_BT_ISO_RX_BUF_COUNT=1

# ISO Broadcast Controller
CONFIG_BT_LL_SW_SPLIT=y
CONFIG_BT_CTLR_ADV_PERIODIC=y
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ CONFIG_ISR_STACK_SIZE=1024
CONFIG_IDLE_STACK_SIZE=256
CONFIG_MAIN_STACK_SIZE=512
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=512
CONFIG_HEAP_MEM_POOL_SIZE=8192
CONFIG_HEAP_MEM_POOL_SIZE=6144

CONFIG_BT=y
CONFIG_BT_HCI_RAW=y
Expand Down Expand Up @@ -35,7 +35,11 @@ CONFIG_BT_ISO_PERIPHERAL=n

# ISO Streams
CONFIG_BT_ISO_MAX_CHAN=2
CONFIG_BT_ISO_TX_BUF_COUNT=1
# In theory, CONFIG_BT_ISO_TX_BUF_COUNT=1, should be sufficient but this count
# is used in the context of IPC which falls into a "Newton's Cradle" effect
# where probably (CONFIG_BT_CTLR_ISO_TX_BUFFERS - CONFIG_BT_ISO_TX_BUF_COUNT)
# buffers get throttled. Hence, always have the value equal or greater.
CONFIG_BT_ISO_TX_BUF_COUNT=12
CONFIG_BT_ISO_RX_BUF_COUNT=1

# Controller
Expand All @@ -46,8 +50,8 @@ CONFIG_BT_CTLR_SCAN_DATA_LEN_MAX=191
# ISO Connection Oriented
CONFIG_BT_CTLR_CENTRAL_ISO=y
CONFIG_BT_CTLR_PERIPHERAL_ISO=n
CONFIG_BT_CTLR_CONN_ISO_STREAMS=2
CONFIG_BT_CTLR_CONN_ISO_GROUPS=1
CONFIG_BT_CTLR_CONN_ISO_STREAMS=2
CONFIG_BT_CTLR_CONN_ISO_STREAMS_PER_GROUP=2
CONFIG_BT_CTLR_CONN_ISO_SDU_LEN_MAX=247
CONFIG_BT_CTLR_CONN_ISO_PDU_LEN_MAX=251
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ CONFIG_ISR_STACK_SIZE=1024
CONFIG_IDLE_STACK_SIZE=256
CONFIG_MAIN_STACK_SIZE=512
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=512
CONFIG_HEAP_MEM_POOL_SIZE=8192
CONFIG_HEAP_MEM_POOL_SIZE=6144

CONFIG_BT=y
CONFIG_BT_HCI_RAW=y
Expand Down Expand Up @@ -35,7 +35,11 @@ CONFIG_BT_ISO_PERIPHERAL=y

# ISO Streams
CONFIG_BT_ISO_MAX_CHAN=2
CONFIG_BT_ISO_TX_BUF_COUNT=1
# In theory, CONFIG_BT_ISO_TX_BUF_COUNT=1, should be sufficient but this count
# is used in the context of IPC which falls into a "Newton's Cradle" effect
# where probably (CONFIG_BT_CTLR_ISO_TX_BUFFERS - CONFIG_BT_ISO_TX_BUF_COUNT)
# buffers get throttled. Hence, always have the value equal or greater.
CONFIG_BT_ISO_TX_BUF_COUNT=12
CONFIG_BT_ISO_RX_BUF_COUNT=1

# Controller
Expand All @@ -46,8 +50,8 @@ CONFIG_BT_CTLR_ADV_DATA_LEN_MAX=191
# ISO Connection Oriented
CONFIG_BT_CTLR_CENTRAL_ISO=n
CONFIG_BT_CTLR_PERIPHERAL_ISO=y
CONFIG_BT_CTLR_CONN_ISO_STREAMS=2
CONFIG_BT_CTLR_CONN_ISO_GROUPS=1
CONFIG_BT_CTLR_CONN_ISO_STREAMS=2
CONFIG_BT_CTLR_CONN_ISO_STREAMS_PER_GROUP=2
CONFIG_BT_CTLR_CONN_ISO_SDU_LEN_MAX=247
CONFIG_BT_CTLR_CONN_ISO_PDU_LEN_MAX=251
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ CONFIG_ISR_STACK_SIZE=1024
CONFIG_IDLE_STACK_SIZE=256
CONFIG_MAIN_STACK_SIZE=512
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=512
CONFIG_HEAP_MEM_POOL_SIZE=8192
CONFIG_HEAP_MEM_POOL_SIZE=6144

CONFIG_BT=y
CONFIG_BT_HCI_RAW=y
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Reduce from 310 bytes, in nrf5340_cpunet_iso-bt_ll_sw_split.conf
# to be able to fit in 64KB RAM.
CONFIG_BT_ISO_TX_MTU=247
CONFIG_BT_ISO_RX_MTU=251
# to be able to fit in 64KB RAM, in case needed in the future.

# Example:
# CONFIG_BT_ISO_TX_MTU=247
# CONFIG_BT_ISO_RX_MTU=251

0 comments on commit 4d8ad6d

Please sign in to comment.