This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

NCS how to increase NUS max frame size

nRF5340 with NCS 1.4.0.

I'm using the NUS (code derived from central_uart & peripheral_uart sample) and i'm trying to send longer frame.

I have tried to add the following lines in my proj.conf but I was unsuccessful:

CONFIG_BT_DATA_LEN_UPDATE=y
CONFIG_BT_L2CAP_RX_MTU=247
CONFIG_BT_L2CAP_TX_MTU=247
CONFIG_BT_CTLR_TX_BUFFER_SIZE=251
CONFIG_BT_CTLR_DATA_LENGTH_MAX=251

What should i do to allow frame of 251 bytes ?

Edited subject: NCS how to enable DLE -> NCS how to increase NUS max frame size

Parents Reply Children
  • Thanks for the help.

    I have tried the throughput example on 2 nRF5340PDK. After minutes the test was still running, seeing in the doc that it took ~4s, there should be a problem with mine.

    In the sample there is multiple prj.conf, I tried both but they generated the same autoconf.h and hex file.

    The doc say to add for nRF5340 DK:

    CONFIG_BT_CTLR_TX_BUFFER_SIZE=251
    CONFIG_BT_CTLR_DATA_LENGTH_MAX=251
    CONFIG_BT_RX_BUF_LEN=255

    but prj.conf has already those definition but even weirder prj_nrf5340dk_nrf5340_cpuapp.conf didn't have 2 of those definitions.

    throughput.hexautoconf.hautoconf_hci.h

    03.12.2020 17:07:01.233 [RX] - *** Booting Zephyr OS build v2.4.0-ncs1  ***
    Starting Bluetooth Throughput example
    Bluetooth initialized
    Choose device role - type s (slave role) or m (master role): 
    03.12.2020 17:07:02.260 [RX] - [00:00:00.279,052] <inf> bt_hci_core: HW Platform: Nordic Semiconductor (0x0002)
    [00:00:00.279,052] <inf> bt_hci_core: HW Variant: nRF53x (0x0003)
    [00:00:00.279,052] <inf> bt_hci_core: Firmware: Standard Bluetooth controller (0x00) Version 207.3932 Build 3617359889
    [00:00:00.281,311] <wrn> bt_hci_core: ECC HCI commands not available
    [00:00:00.281,402] <inf> bt_hci_core: Identity: ea:b6:af:d6:f9:b3 (random)
    [00:00:00.281,402] <inf> bt_hci_core: HCI: version 5.2 (0x0b) revision 0x2123, manufacturer 0x0059
    [00:00:00.281,433] <inf> bt_hci_core: LMP: version 5.2 (0x0b) subver 0x2123
    
    03.12.2020 17:07:05.039 [TX] - s
    03.12.2020 17:07:05.041 [RX] - 
    Slave role. Starting advertising
    
    03.12.2020 17:07:06.214 [RX] - Connected as slave
    Conn. interval is 320 units
    
    03.12.2020 17:07:13.417 [RX] - 
    
    03.12.2020 17:07:19.817 [RX] - =
    03.12.2020 17:07:25.414 [RX] - =
    03.12.2020 17:07:30.617 [RX] - =
    03.12.2020 17:07:36.215 [RX] - =
    03.12.2020 17:07:41.415 [RX] - =
    03.12.2020 17:07:48.614 [RX] - =
    03.12.2020 17:07:53.815 [RX] - =
    03.12.2020 17:07:59.016 [RX] - =
    03.12.2020 17:08:04.614 [RX] - =
    03.12.2020 17:08:09.814 [RX] - =
    03.12.2020 17:08:16.613 [RX] - =
    03.12.2020 17:08:21.814 [RX] - =
    03.12.2020 17:08:27.014 [RX] - =
    03.12.2020 17:08:32.611 [RX] - =
    03.12.2020 17:08:37.813 [RX] - =
    03.12.2020 17:08:44.613 [RX] - =
    03.12.2020 17:08:50.211 [RX] - =
    03.12.2020 17:08:55.412 [RX] - =
    03.12.2020 17:09:00.613 [RX] - =
    03.12.2020 17:09:06.210 [RX] - =
    03.12.2020 17:09:12.611 [RX] - =
    03.12.2020 17:09:18.210 [RX] - =
    03.12.2020 17:09:23.410 [RX] - =
    03.12.2020 17:09:28.611 [RX] - =
    03.12.2020 17:09:34.211 [RX] - =
    03.12.2020 17:09:41.010 [RX] - =
    03.12.2020 17:09:46.610 [RX] - =
    03.12.2020 17:09:52.208 [RX] - =
    03.12.2020 17:09:57.809 [RX] - =
    03.12.2020 17:10:03.009 [RX] - =
    03.12.2020 17:10:09.808 [RX] - =
    03.12.2020 17:10:15.408 [RX] - =
    03.12.2020 17:10:21.007 [RX] - =
    03.12.2020 17:10:26.208 [RX] - =
    03.12.2020 17:10:31.806 [RX] - =
    03.12.2020 17:10:38.208 [RX] - =
    03.12.2020 17:10:43.806 [RX] - =
    03.12.2020 17:10:49.006 [RX] - =
    03.12.2020 17:10:54.207 [RX] - =
    03.12.2020 17:10:59.805 [RX] - =
    03.12.2020 17:11:06.206 [RX] - =
    03.12.2020 17:11:11.805 [RX] - =
    03.12.2020 17:11:17.005 [RX] - =
    03.12.2020 17:11:22.206 [RX] - =
    03.12.2020 17:11:27.804 [RX] - =
    03.12.2020 17:11:34.205 [RX] - =
    03.12.2020 17:11:39.803 [RX] - =
    03.12.2020 17:11:45.004 [RX] - =
    03.12.2020 17:11:50.204 [RX] - =
    03.12.2020 17:11:55.803 [RX] - =
    03.12.2020 17:12:02.604 [RX] - =
    03.12.2020 17:12:08.202 [RX] - =
    03.12.2020 17:12:13.404 [RX] - =
    03.12.2020 17:07:01.229 [RX] - *** Booting Zephyr OS build v2.4.0-ncs1  ***
    Starting Bluetooth Throughput example
    Bluetooth initialized
    Choose device role - type s (slave role) or m (master role): 
    03.12.2020 17:07:02.253 [RX] - [00:00:00.280,975] <inf> bt_hci_core: HW Platform: Nordic Semiconductor (0x0002)
    [00:00:00.280,975] <inf> bt_hci_core: HW Variant: nRF53x (0x0003)
    [00:00:00.280,975] <inf> bt_hci_core: Firmware: Standard Bluetooth controller (0x00) Version 207.3932 Build 3617359889
    [00:00:00.283,325] <wrn> bt_hci_core: ECC HCI commands not available
    [00:00:00.283,386] <inf> bt_hci_core: Identity: e6:a7:8c:4b:48:5c (random)
    [00:00:00.283,416] <inf> bt_hci_core: HCI: version 5.2 (0x0b) revision 0x2123, manufacturer 0x0059
    [00:00:00.283,416] <inf> bt_hci_core: LMP: version 5.2 (0x0b) subver 0x2123
    
    03.12.2020 17:07:06.030 [TX] - m
    03.12.2020 17:07:06.032 [RX] - 
    Master role. Starting scanning
    Filter not match. Address: 5e:fb:d8:ec:e3:2b (random) connectable: 0
    Filter not match. Address: ec:81:93:15:34:cf (public) connectable: 1
    Filter not match. Address: 4a:03:aa:76:1b:7f (random) connectable: 0
    Filters matched. Address: ea:b6:af:d6:f9:b3 (random) connectable: 1
    Filter not match. Address: ec:81:93:59:40:34 (public) connectable: 1
    
    03.12.2020 17:07:06.214 [RX] - Connected as master
    Conn. interval is 320 units
    
    03.12.2020 17:07:10.216 [RX] - Service discovery completed
    MTU exchange pending
    
    03.12.2020 17:07:11.016 [RX] - MTU exchange successful
    Ready, press any key to start
    
    03.12.2020 17:07:13.118 [TX] - 
    
    03.12.2020 17:07:13.120 [RX] -           
    03.12.2020 17:07:14.217 [RX] -  
    03.12.2020 17:07:15.417 [RX] -  
    03.12.2020 17:07:18.217 [RX] -  
    03.12.2020 17:07:19.416 [RX] -  
    03.12.2020 17:07:21.017 [RX] -  
    03.12.2020 17:07:22.216 [RX] -  
    03.12.2020 17:07:23.417 [RX] -  
    03.12.2020 17:07:25.017 [RX] -  
    03.12.2020 17:07:26.216 [RX] -  
    03.12.2020 17:07:27.416 [RX] -  
    03.12.2020 17:07:29.016 [RX] -   
    03.12.2020 17:07:30.216 [RX] -  
    03.12.2020 17:07:31.816 [RX] -  
    03.12.2020 17:07:33.016 [RX] -  
    03.12.2020 17:07:34.216 [RX] -  
    03.12.2020 17:07:35.816 [RX] -  
    03.12.2020 17:07:37.015 [RX] -  
    03.12.2020 17:07:38.216 [RX] -  
    03.12.2020 17:07:39.816 [RX] -  
    03.12.2020 17:07:41.015 [RX] -  
    03.12.2020 17:07:42.216 [RX] -  
    03.12.2020 17:07:44.215 [RX] -  
    03.12.2020 17:07:45.416 [RX] -  
    03.12.2020 17:07:46.615 [RX] -  
    03.12.2020 17:07:48.215 [RX] -  
    03.12.2020 17:07:49.416 [RX] -  
    03.12.2020 17:07:50.615 [RX] -  
    03.12.2020 17:07:52.215 [RX] -  
    03.12.2020 17:07:53.415 [RX] -  
    03.12.2020 17:07:54.615 [RX] -  
    03.12.2020 17:07:56.214 [RX] -  
    03.12.2020 17:07:57.415 [RX] -  
    03.12.2020 17:07:58.615 [RX] -  
    03.12.2020 17:08:00.215 [RX] -  
    03.12.2020 17:08:01.414 [RX] -  
    03.12.2020 17:08:02.614 [RX] -  
    03.12.2020 17:08:04.214 [RX] -  
    03.12.2020 17:08:05.415 [RX] -  
    03.12.2020 17:08:06.614 [RX] -  
    03.12.2020 17:08:08.214 [RX] -  
    03.12.2020 17:08:09.414 [RX] -  
    03.12.2020 17:08:10.615 [RX] -  
    03.12.2020 17:08:12.214 [RX] -  
    03.12.2020 17:08:13.414 [RX] -  
    03.12.2020 17:08:14.614 [RX] -  
    03.12.2020 17:08:16.214 [RX] -  
    03.12.2020 17:08:17.414 [RX] -  
    03.12.2020 17:08:18.614 [RX] -  
    03.12.2020 17:08:20.214 [RX] -  
    03.12.2020 17:08:21.414 [RX] -  
    03.12.2020 17:08:22.614 [RX] -  
    03.12.2020 17:08:24.213 [RX] -  
    03.12.2020 17:08:25.414 [RX] -  
    03.12.2020 17:08:26.613 [RX] -  
    03.12.2020 17:08:28.213 [RX] -  
    03.12.2020 17:08:29.413 [RX] -  
    03.12.2020 17:08:30.613 [RX] -  
    03.12.2020 17:08:32.213 [RX] -  
    03.12.2020 17:08:33.413 [RX] -  
    03.12.2020 17:08:34.613 [RX] -  
    03.12.2020 17:08:36.213 [RX] -  
    03.12.2020 17:08:37.413 [RX] -  
    03.12.2020 17:08:38.613 [RX] -  
    03.12.2020 17:08:40.213 [RX] -  
    03.12.2020 17:08:41.812 [RX] -  
    03.12.2020 17:08:43.013 [RX] -  
    03.12.2020 17:08:44.213 [RX] -  
    03.12.2020 17:08:45.812 [RX] -  
    03.12.2020 17:08:47.013 [RX] -  
    03.12.2020 17:08:48.212 [RX] - 
    
    03.12.2020 17:08:49.812 [RX] -  
    03.12.2020 17:08:51.012 [RX] -  
    03.12.2020 17:08:52.212 [RX] -  
    03.12.2020 17:08:53.812 [RX] -  
    03.12.2020 17:08:55.012 [RX] -  
    03.12.2020 17:08:56.212 [RX] -  
    03.12.2020 17:08:57.812 [RX] -  
    03.12.2020 17:08:59.012 [RX] -  
    03.12.2020 17:09:00.212 [RX] -  
    03.12.2020 17:09:01.812 [RX] -  
    03.12.2020 17:09:03.012 [RX] -  
    03.12.2020 17:09:04.211 [RX] -  
    03.12.2020 17:09:05.812 [RX] -  
    03.12.2020 17:09:07.011 [RX] -  
    03.12.2020 17:09:08.211 [RX] -  
    03.12.2020 17:09:09.811 [RX] -  
    03.12.2020 17:09:11.012 [RX] -  
    03.12.2020 17:09:12.211 [RX] -  
    03.12.2020 17:09:13.811 [RX] -  
    03.12.2020 17:09:15.011 [RX] -  
    03.12.2020 17:09:16.211 [RX] - ^
    03.12.2020 17:09:17.811 [RX] - .
    03.12.2020 17:09:19.011 [RX] - -
    03.12.2020 17:09:20.210 [RX] - .
    03.12.2020 17:09:21.811 [RX] - ^
    03.12.2020 17:09:23.011 [RX] -  
    03.12.2020 17:09:24.210 [RX] -  
    03.12.2020 17:09:25.810 [RX] -  
    03.12.2020 17:09:27.011 [RX] -  
    03.12.2020 17:09:28.210 [RX] -  
    03.12.2020 17:09:29.810 [RX] -  
    03.12.2020 17:09:31.011 [RX] -  
    03.12.2020 17:09:32.210 [RX] -  
    03.12.2020 17:09:33.810 [RX] -  
    03.12.2020 17:09:35.410 [RX] -  
    03.12.2020 17:09:36.610 [RX] -  
    03.12.2020 17:09:37.810 [RX] -  
    03.12.2020 17:09:39.410 [RX] -  
    03.12.2020 17:09:40.609 [RX] -  
    03.12.2020 17:09:42.209 [RX] -  
    03.12.2020 17:09:43.810 [RX] -  
    03.12.2020 17:09:45.010 [RX] -  
    03.12.2020 17:09:46.210 [RX] -  
    03.12.2020 17:09:47.809 [RX] -  
    03.12.2020 17:09:49.010 [RX] -  
    03.12.2020 17:09:50.210 [RX] -  
    03.12.2020 17:09:51.810 [RX] -  
    03.12.2020 17:09:53.010 [RX] -  
    03.12.2020 17:09:54.209 [RX] -  
    03.12.2020 17:09:56.209 [RX] -  
    03.12.2020 17:09:57.409 [RX] -  
    03.12.2020 17:09:58.609 [RX] -  
    03.12.2020 17:10:00.209 [RX] -  
    03.12.2020 17:10:01.409 [RX] -  
    03.12.2020 17:10:02.609 [RX] -  
    03.12.2020 17:10:04.208 [RX] -  
    03.12.2020 17:10:05.409 [RX] - ^
    03.12.2020 17:10:06.609 [RX] - .
    03.12.2020 17:10:08.209 [RX] - .
    03.12.2020 17:10:09.408 [RX] - ^
    03.12.2020 17:10:10.608 [RX] -  
    03.12.2020 17:10:12.608 [RX] -  
    03.12.2020 17:10:13.809 [RX] -  
    03.12.2020 17:10:15.008 [RX] -  
    03.12.2020 17:10:16.608 [RX] -  
    03.12.2020 17:10:17.808 [RX] -  
    03.12.2020 17:10:19.008 [RX] -  
    03.12.2020 17:10:20.608 [RX] -  
    03.12.2020 17:10:21.808 [RX] -  
    03.12.2020 17:10:23.008 [RX] -  
    03.12.2020 17:10:24.608 [RX] -  
    03.12.2020 17:10:25.807 [RX] -  
    03.12.2020 17:10:27.407 [RX] -  
    03.12.2020 17:10:28.608 [RX] -  
    03.12.2020 17:10:29.808 [RX] -  
    03.12.2020 17:10:31.408 [RX] -  
    03.12.2020 17:10:32.607 [RX] -  
    03.12.2020 17:10:33.807 [RX] -  
    03.12.2020 17:10:35.408 [RX] -  
    03.12.2020 17:10:36.607 [RX] -  
    03.12.2020 17:10:37.807 [RX] - 
    
    03.12.2020 17:10:39.407 [RX] -  
    03.12.2020 17:10:40.607 [RX] -  
    03.12.2020 17:10:41.807 [RX] -  
    03.12.2020 17:10:43.407 [RX] -  
    03.12.2020 17:10:44.607 [RX] -  
    03.12.2020 17:10:45.807 [RX] -  
    03.12.2020 17:10:47.406 [RX] -  
    03.12.2020 17:10:48.607 [RX] -  
    03.12.2020 17:10:49.807 [RX] -  
    03.12.2020 17:10:51.406 [RX] -  
    03.12.2020 17:10:52.607 [RX] -  
    03.12.2020 17:10:53.807 [RX] -  
    03.12.2020 17:10:55.406 [RX] -  
    03.12.2020 17:10:56.606 [RX] -  
    03.12.2020 17:10:57.807 [RX] -  
    03.12.2020 17:10:59.406 [RX] -  
    03.12.2020 17:11:00.606 [RX] -  
    03.12.2020 17:11:01.806 [RX] - ^
    03.12.2020 17:11:03.406 [RX] - -
    03.12.2020 17:11:04.605 [RX] - /
    03.12.2020 17:11:05.806 [RX] - o
    03.12.2020 17:11:07.406 [RX] - o
    03.12.2020 17:11:08.606 [RX] - o
    03.12.2020 17:11:09.805 [RX] - o
    03.12.2020 17:11:11.405 [RX] - o
    03.12.2020 17:11:12.606 [RX] - +
    03.12.2020 17:11:13.805 [RX] - :
    03.12.2020 17:11:15.405 [RX] - .
    03.12.2020 17:11:16.605 [RX] - ^
    03.12.2020 17:11:17.805 [RX] -  
    03.12.2020 17:11:19.405 [RX] -  
    03.12.2020 17:11:20.605 [RX] -  
    03.12.2020 17:11:21.805 [RX] -  
    03.12.2020 17:11:23.405 [RX] -  
    03.12.2020 17:11:24.605 [RX] -  
    03.12.2020 17:11:25.805 [RX] -  
    03.12.2020 17:11:27.405 [RX] -  
    03.12.2020 17:11:28.605 [RX] -  
    03.12.2020 17:11:29.805 [RX] -  
    03.12.2020 17:11:31.405 [RX] -  
    03.12.2020 17:11:32.604 [RX] -  
    03.12.2020 17:11:33.805 [RX] -  
    03.12.2020 17:11:35.405 [RX] -  
    03.12.2020 17:11:36.604 [RX] -  
    03.12.2020 17:11:37.804 [RX] -  
    03.12.2020 17:11:39.404 [RX] -  
    03.12.2020 17:11:40.604 [RX] -  
    03.12.2020 17:11:41.804 [RX] -  
    03.12.2020 17:11:43.404 [RX] -  
    03.12.2020 17:11:44.604 [RX] -  
    03.12.2020 17:11:45.804 [RX] -  
    03.12.2020 17:11:47.404 [RX] -  
    03.12.2020 17:11:48.603 [RX] - ^
    03.12.2020 17:11:49.804 [RX] - .
    03.12.2020 17:11:51.404 [RX] - -
    03.12.2020 17:11:52.603 [RX] - -
    03.12.2020 17:11:53.804 [RX] - :
    03.12.2020 17:11:55.404 [RX] - +
    03.12.2020 17:11:56.603 [RX] - s
    03.12.2020 17:11:57.804 [RX] - y
    03.12.2020 17:11:59.804 [RX] - o
    03.12.2020 17:12:01.003 [RX] - /
    03.12.2020 17:12:02.203 [RX] - .
    03.12.2020 17:12:03.803 [RX] -  
    03.12.2020 17:12:05.003 [RX] -  
    03.12.2020 17:12:06.603 [RX] -  
    03.12.2020 17:12:07.803 [RX] -  
    03.12.2020 17:12:09.003 [RX] -  
    03.12.2020 17:12:10.603 [RX] -  
    03.12.2020 17:12:11.803 [RX] -  
    03.12.2020 17:12:13.002 [RX] -  
    03.12.2020 17:12:14.602 [RX] -  
    03.12.2020 17:12:15.802 [RX] -  
    03.12.2020 17:12:17.002 [RX] -  
    03.12.2020 17:12:18.602 [RX] -  

  • Hi Nicolas,

    Sorry for late reply. Have you made sure you updated CONFIG_BT_CTLR_TX_BUFFER_SIZE and CONFIG_BT_CTLR_DATA_LENGTH_MAX to the hci_rpmsg sample that you flash to the netcore of the nRF53 ? 
    It's described here.

    In my test here I got an memory overflow when compiling with 

    CONFIG_BT_CTLR_TX_BUFFER_SIZE=251
    CONFIG_BT_CTLR_DATA_LENGTH_MAX=251

    But if I do

    CONFIG_BT_CTLR_TX_BUFFER_SIZE=251

    CONFIG_BT_CTLR_DATA_LENGTH_MAX=200


    it worked. I will look into why it doesn't compile with DLE =251 but 200 should be good enough for testing.

    Update: it was because CONFIG_BT_MAX_CONN was 16 in the hci_rpmsg , if you set it to 2 you can compile with

    CONFIG_BT_CTLR_DATA_LENGTH_MAX=251.
  • Thank you, now the throughput sample work correctly for me.

    But why this sample generated a hci_rpmsg.hex that is not correct for him ? It would be better to not generated at all because it's misleading for people like me.

    Now I will try with my code.

  • Hi Nicolas, 
    I guess we just simple build and generate the default hci_rmpsg project without having any special overlay for the configuration. This is something we can improve. 

  • My NUS code is now working with longer frame. Here is the modification I have done to make this works:

    Using hci_rpmsg with the added conf:

    CONFIG_BT_CTLR_TX_BUFFER_SIZE=251
    CONFIG_BT_CTLR_DATA_LENGTH_MAX=251
    CONFIG_BT_MAX_CONN=8

    Added to central and peripheral conf:

    CONFIG_BT_L2CAP_TX_MTU=247
    CONFIG_BT_L2CAP_RX_MTU=247

    Added a call to bt_gatt_exchange_mtu() in the central code:

    static void exchange_func(struct bt_conn *conn, uint8_t att_err,
            struct bt_gatt_exchange_params *params)
    {
        struct bt_conn_info info = {0};
        int err;
    
        LOG_INF("MTU exchange %s", att_err == 0 ? "successful" : "failed");
    
        err = bt_conn_get_info(conn, &info);
        if (err) {
            LOG_ERR("Failed to get connection info %d", err);
        }
    }
    
    static void discovery_complete(struct bt_gatt_dm *dm, void *context)
    {
        struct bt_nus_client *nus = context;
        LOG_INF("Service discovery completed");
    
        bt_gatt_dm_data_print(dm);
    
        bt_nus_handles_assign(dm, nus);
        bt_nus_subscribe_receive(nus);
    
        bt_gatt_dm_data_release(dm);
    
        exchange_params.func = exchange_func;
    
        int err = bt_gatt_exchange_mtu(default_conn, &exchange_params);
        if (err) {
            LOG_ERR("MTU exchange failed (err %d)", err);
        } else {
            LOG_INF("MTU exchange pending");
        }
    }

Related