nRF5340, how to set MTU

I am developing a BLE peripheral using the nRF5340.
I want to set MTU to change notificatio packet size.

I tried as below

<prj.conf>

CONFIG_BT_BUF_ACL_RX_SIZE=251
CONFIG_BT_BUF_ACL_TX_SIZE=251
CONFIG_BT_L2CAP_TX_MTU=247
CONFIG_BT_CTLR_DATA_LENGTH_MAX=251

<\child_image\hci_rpmsg.conf>

CONFIG_BT_BUF_ACL_RX_SIZE=251
CONFIG_BT_BUF_ACL_TX_SIZE=251
CONFIG_BT_L2CAP_TX_MTU=247
CONFIG_BT_CTLR_DATA_LENGTH_MAX=251

When building, the following warning message is displayed.

warning: BT_CTLR_DATA_LENGTH_MAX (defined at
C:/ncs/v2.2.99-dev3/nrf\subsys\bluetooth\services\fast_pair/Kconfig.fast_pair:93,
subsys/bluetooth\controller/Kconfig:432) was assigned the value '251' but got the value ''. Check
these unsatisfied dependencies: ((BT_FAST_PAIR_GATT_SERVICE && BT_FAST_PAIR && BT) ||
(BT_CTLR_DATA_LENGTH && BT_CONN && BT_CTLR && BT_HCI && BT)) (=n).

I checked in another ticket that I need to set the CONFIG of network core
But I can't find how to set it up
How can I change the MTU?
I would like a detailed answer


  • Hi John,

    I checked in another ticket that I need to set the CONFIG of network core
    But I can't find how to set it up

    A way to set it up is to put the necessary configurations into <\child_image\hci_rpmsg.conf>, which is exactly what you did.

    That also means that the configurations shouldn't also be in prj.conf, which is the file for the application core. In the build log, you should see some warnings about those configurations during the application core Kconfig build.

    At which stage of the build did this warning happen? Application core or network core build?

    If it happens during application core build, please just remove the configs from prj.conf.

    If it happens during network core build, could you please look into <build directory>/hci_rpmsg/zephyr/.config and check all the dependencies mentioned in the warning, see if anything is not satisfied inadvertently?

    Hieu

  • A warning occurred in the network core build
    I set it as below, and now the build warning doesn't occur
    <prj.conf>

    CONFIG_BT_L2CAP_TX_MTU=247

    <\child_image\hci_rpmsg.conf>
    CONFIG_BT_CTLR_DATA_LENGTH_MAX=251
    CONFIG_BT_BUF_ACL_RX_SIZE=251
    CONFIG_BT_BUF_ACL_TX_SIZE=251

    but the build fails with error 1
    The error is below.

    [216/228] Linking C executable zephyr\zephyr_pre0.elf
    FAILED: zephyr/zephyr_pre0.elf zephyr/zephyr_pre0.map
    cmd.exe /C "cd . && C:\ncs\toolchains\v2.2.99-dev3\opt\zephyr-sdk\arm-zephyr-eabi\bin\arm-zephyr-eabi-gcc.exe -gdwarf-4 zephyr/CMakeFiles/zephyr_pre0.dir/misc/empty_file.c.obj -o zephyr\zephyr_pre0.elf -Wl,-T zephyr/linker_zephyr_pre0.cmd -Wl,-Map=C:/Local/L_Work/NRF5340/EOPatch_nRF5340/build/hci_rpmsg/zephyr/zephyr_pre0.map -Wl,--whole-archive app/libapp.a zephyr/libzephyr.a zephyr/arch/common/libarch__common.a zephyr/arch/arch/arm/core/aarch32/libarch__arm__core__aarch32.a zephyr/arch/arch/arm/core/aarch32/cortex_m/libarch__arm__core__aarch32__cortex_m.a zephyr/arch/arch/arm/core/aarch32/cortex_m/cmse/libarch__arm__core__aarch32__cortex_m__cmse.a zephyr/arch/arch/arm/core/aarch32/mpu/libarch__arm__core__aarch32__mpu.a zephyr/lib/libc/minimal/liblib__libc__minimal.a zephyr/soc/arm/common/cortex_m/libsoc__arm__common__cortex_m.a zephyr/subsys/bluetooth/common/libsubsys__bluetooth__common.a zephyr/subsys/bluetooth/host/libsubsys__bluetooth__host.a zephyr/subsys/net/libsubsys__net.a zephyr/subsys/random/libsubsys__random.a zephyr/drivers/clock_control/libdrivers__clock_control.a zephyr/drivers/console/libdrivers__console.a zephyr/drivers/gpio/libdrivers__gpio.a zephyr/drivers/serial/libdrivers__serial.a zephyr/drivers/entropy/libdrivers__entropy.a zephyr/drivers/timer/libdrivers__timer.a zephyr/drivers/pinctrl/libdrivers__pinctrl.a zephyr/drivers/mbox/libdrivers__mbox.a modules/nrf/lib/multithreading_lock/lib..__nrf__lib__multithreading_lock.a modules/nrf/lib/fatal_error/lib..__nrf__lib__fatal_error.a modules/nrf/subsys/bluetooth/controller/lib..__nrf__subsys__bluetooth__controller.a modules/nrf/subsys/mpsl/init/lib..__nrf__subsys__mpsl__init.a modules/nrf/subsys/mpsl/fem/lib..__nrf__subsys__mpsl__fem.a modules/nrf/drivers/mpsl/clock_control/lib..__nrf__drivers__mpsl__clock_control.a modules/hal_nordic/nrfx/libmodules__hal_nordic__nrfx.a modules/libmetal/libmetal/lib/libmetal.a modules/open-amp/open-amp/lib/libopen_amp.a -Wl,--no-whole-archive zephyr/kernel/libkernel.a zephyr/CMakeFiles/offsets.dir/./arch/arm/core/offsets/offsets.c.obj -L"c:/ncs/toolchains/v2.2.99-dev3/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.1.0/thumb/v8-m.main/nofp" -LC:/Local/L_Work/NRF5340/EOPatch_nRF5340/build/hci_rpmsg/zephyr -lgcc zephyr/arch/common/libisr_tables.a C:/ncs/v2.2.99-dev3/nrfxlib/crypto/nrf_oberon/lib/cortex-m33+nodsp/soft-float/liboberon_3.0.12.a -no-pie -mcpu=cortex-m33+nodsp -mthumb -mabi=aapcs -mfp16-format=ieee -Wl,--gc-sections -Wl,--build-id=none -Wl,--sort-common=descending -Wl,--sort-section=alignment -Wl,-u,_OffsetAbsSyms -Wl,-u,_ConfigAbsSyms -nostdlib -static -Wl,-X -Wl,-N -Wl,--orphan-handling=warn C:/ncs/v2.2.99-dev3/nrfxlib/mpsl/lib/cortex-m33+nodsp/soft-float/libmpsl.a C:/ncs/v2.2.99-dev3/nrfxlib/softdevice_controller/lib/cortex-m33+nodsp/soft-float/libsoftdevice_controller_multirole.a && cmd.exe /C "cd /D C:\Local\L_Work\NRF5340\EOPatch_nRF5340\build\hci_rpmsg\zephyr && C:\ncs\toolchains\v2.2.99-dev3\opt\bin\cmake.exe -E echo ""
    c:/ncs/toolchains/v2.2.99-dev3/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.1.0/../../../../arm-zephyr-eabi/bin/ld.exe: zephyr\zephyr_pre0.elf section `noinit' will not fit in region `RAM'
    c:/ncs/toolchains/v2.2.99-dev3/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.1.0/../../../../arm-zephyr-eabi/bin/ld.exe: region `RAM' overflowed by 5548 bytes
    collect2.exe: error: ld returned 1 exit status
    ninja: build stopped: subcommand failed.
    [59/351] Generating ../../tfm/CMakeCache.txt
    -- The C compiler identification is GNU 12.1.0
    -- The ASM compiler identification is GNU
    -- Found assembler: C:/ncs/toolchains/v2.2.99-dev3/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc.exe
    -- Found Python3: C:/ncs/toolchains/v2.2.99-dev3/opt/bin/python.exe (found version "3.8.2") found components: Interpreter
    -- Found Python3: C:/ncs/toolchains/v2.2.99-dev3/opt/bin/python.exe (found suitable exact version "3.8.2") found components: Interpreter
    -- Cache files will be written to: C:/ncs/v2.2.99-dev3/zephyr/.cache
    -- Configuring done
    -- Generating done
    -- Build files have been written to: C:/Local/L_Work/NRF5340/EOPatch_nRF5340/build/tfm
    [66/351] No configure step for 'tfm'
    FAILED: modules/nrf/samples/hci_rpmsg_subimage-prefix/src/hci_rpmsg_subimage-stamp/hci_rpmsg_subimage-build hci_rpmsg/zephyr/zephyr.hex hci_rpmsg/zephyr/zephyr.elf hci_rpmsg/zephyr/merged_CPUNET.hex
    cmd.exe /C "cd /D C:\Local\L_Work\NRF5340\EOPatch_nRF5340\build\hci_rpmsg && C:\ncs\toolchains\v2.2.99-dev3\opt\bin\cmake.exe --build . --"
    ninja: build stopped: subcommand failed.
    FATAL ERROR: command exited with status 1: 'c:\ncs\toolchains\v2.2.99-dev3\opt\bin\cmake.EXE' --build 'c:\Local\L_Work\NRF5340\EOPatch_nRF5340\build'

    How can I fix the problem?
    My understanding of NCS is low, so please explain in detail

  • Hi John,

    This is the key part of that log:

    John Lee said:
    -Map=C:/Local/L_Work/NRF5340/EOPatch_nRF5340/build/hci_rpmsg/zephyr/zephyr_pre0.map

    These and other parameters in the command with the full path to the build location reveals that the problem happened during the network core child image build, because the network core child image is built int <build folder>/hci_rpmsg.

    John Lee said:
    c:/ncs/toolchains/v2.2.99-dev3/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.1.0/../../../../arm-zephyr-eabi/bin/ld.exe: zephyr\zephyr_pre0.elf section `noinit' will not fit in region `RAM'
    c:/ncs/toolchains/v2.2.99-dev3/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.1.0/../../../../arm-zephyr-eabi/bin/ld.exe: region `RAM' overflowed by 5548 bytes
    collect2.exe: error: ld returned 1 exit status
    ninja: build stopped: subcommand failed.

    This tells us that the problem is the image is using more RAM than available.

    What sample are you building? Besides the Kconfig discussed, what changes have you made to it?

  • I had a project before using the nRF5340. (nRF52832, nRF5 SDK 17.1.0)
    So I started the project in an empty local workspace.
    Source files and header files have been moved, and CMakeLists.txt and prj.conf files have been created.

    <CMakeLists.txt>

    #
    # Copyright (c) 2021 Nordic Semiconductor ASA
    #
    # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
    #
    cmake_minimum_required(VERSION 3.20.0)
    
    find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
    project(EOPatch_nRF5340)
    
    FILE(GLOB app_sources src/*.c)
    # NORDIC SDK APP START
    target_sources(app PRIVATE ${app_sources})
    
    # NORDIC SDK APP END
    
    zephyr_library_include_directories(include)
    zephyr_library_include_directories(.)

    <prj.conf>
    #
    # Copyright (c) 2018 Nordic Semiconductor
    #
    # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
    #
    
    CONFIG_GPIO=y
    
    CONFIG_BT=y
    CONFIG_BT_PERIPHERAL=y
    CONFIG_BT_SMP=y
    CONFIG_BT_SMP_SC_ONLY=y
    CONFIG_BT_TINYCRYPT_ECC=y
    CONFIG_BT_DEVICE_NAME="EOPatch_nRF5340"
    CONFIG_BT_DEVICE_APPEARANCE=3396
    CONFIG_BT_MAX_CONN=1
    CONFIG_BT_MAX_PAIRED=1
    
    # Enable bonding
    CONFIG_BT_SETTINGS=y
    CONFIG_FLASH=y
    CONFIG_FLASH_PAGE_LAYOUT=y
    CONFIG_FLASH_MAP=y
    CONFIG_NVS=y
    CONFIG_SETTINGS=y
    
    # This example requires more workqueue stack
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
    
    # Config logger
    CONFIG_LOG=y
    CONFIG_LOG_BACKEND_SHOW_COLOR=n
    CONFIG_LOG_BUFFER_SIZE=8192
    CONFIG_LOG_DEFAULT_LEVEL=3
    CONFIG_USE_SEGGER_RTT=y
    CONFIG_LOG_BACKEND_RTT=y
    CONFIG_LOG_BACKEND_UART=n
    
    # math.h
    CONFIG_NEWLIB_LIBC=y
    
    CONFIG_ASSERT=y


    The build completes without errors.
    The build configuration and memory usage are shown below.

    - build configuration

    - network core

    - application core


    Adding a configuration to change the MTU causes a build error.
    (\child_image\hci_rpmsg.conf, prj.conf - CONFIG_BT_L2CAP_TX_MTU=247)

    did i do something wrong?

  • Hi John,

    I understand your starting point as basically as empty as the Hello World sample, so I tried starting from that.

    There I was able to reproduce your issue. It seems that with your configuration, the RAM usage is just too high.

    How many connections do your project need? The default maximum number of connection is 16. I reduced it to 10 and my build now works.

    // hci_rpmsg.conf
    CONFIG_BT_MAX_CONN=10
    CONFIG_BT_BUF_ACL_RX_SIZE=251
    CONFIG_BT_BUF_ACL_TX_SIZE=251
    CONFIG_BT_CTLR_DATA_LENGTH_MAX=251


    CONFIG_BT_L2CAP_TX_MTU is not the culprit for your netcore build failure. L2CAP is a part of the Host layer, so the config doesn't even have any effect on the netcore build.

    It needs to be on the application core. Please move it to the app core .conf file. I should have caught this earlier. Sorry about that.

    Update: I reread your replies and see that you already figured out that CONFIG_BT_L2CAP_TX_MTU should be on the application core even though I gave you the incorrect direction with my first reply. Sorry about that.

Related