app: Read Tx power err: -5/bt_hci_core: opcode 0xfc0e status 0x01 when running get_tx_power on nrf5340dk

I am trying to get the hci_pwre_ctrl demo working with a nrf5340dk using nrfconnect 3.1. I got it running with a nrf52840dk and it works fine. I created a 2nd build for the nrf5340dk but am getting these errors:

[00:01:30.299,316] <inf> app: Set Tx power level to 0
[00:01:30.299,957] <wrn> bt_hci_core: opcode 0xfc0e status 0x01 
[00:01:30.299,987] <err> app: Set Tx power err: -5

I have been trying to get the get_tx_power and set_tx_power working on a different build but was getting the same errors so I tried to simpliy and get it working on the base example first. My goal is to set and test ble range with various boards and configurations. I started with trying to read the value in the other build but am getting the same error. I saw this post hci_power_ctrl throws bt_hci_core: opcode 0xfc0f status 0x01 on my nRF5340 but did not see a solution.

Here was one change I made to support the nrf5340dk:

#ifdef CONFIG_BOARD_NRF5340DK_NRF5340_CPUAPP
static const int8_t txpower[DEVICE_BEACON_TXPOWER_NUM] = {3, 0, -3, -8,-15, -18, -23, -30};
#else
static const int8_t txpower[DEVICE_BEACON_TXPOWER_NUM] = {4, 0, -3, -8,-15, -18, -23, -30};
#endif


In debugging I see this:


and the since the status=1 the -5 value is returned:

Here are some more log entries:

[00:20:27.732,666] <inf> app: Set Tx power level to 3
[00:20:27.732,666] <dbg> bt_hci_core: bt_hci_cmd_alloc: buf 0x200094e0
[00:20:27.732,696] <dbg> bt_hci_core: bt_hci_cmd_send_sync: buf 0x200094e0 opcode 0xfc0e len 4
[00:20:27.732,696] <dbg> bt_hci_core: bt_hci_cmd_send: opcode 0xfc0e param_len 4
[00:20:27.732,727] <dbg> bt_hci_core: bt_tx_irq_raise: kick TX
[00:20:27.732,757] <dbg> bt_hci_core: tx_processor: TX process start
[00:20:27.732,757] <dbg> bt_hci_core: hci_core_send_cmd: fetch cmd
[00:20:27.732,788] <dbg> bt_hci_core: hci_core_send_cmd: Sending command 0xfc0e (buf 0x200094e0) to driver
[00:20:27.732,788] <dbg> bt_hci_core: bt_send: buf 0x200094e0 len 8 type 1
[00:20:27.732,818] <dbg> bt_hci_core: bt_tx_irq_raise: kick TX
[00:20:27.732,849] <dbg> bt_hci_core: tx_processor: TX process start
[00:20:27.733,337] <dbg> bt_hci_core: bt_recv_unsafe: buf 0x20009174 len 7
[00:20:27.733,367] <dbg> bt_hci_core: hci_cmd_status: opcode 0xfc0e
[00:20:27.733,398] <dbg> bt_hci_core: hci_cmd_done: opcode 0xfc0e status 0x01  buf 0x20009174
[00:20:27.733,398] <dbg> bt_hci_core: hci_cmd_done: sync cmd released
[00:20:27.733,428] <dbg> bt_hci_core: bt_tx_irq_raise: kick TX
[00:20:27.733,489] <wrn> bt_hci_core: opcode 0xfc0e status 0x01 
[00:20:27.733,489] <err> app: Set Tx power err: -5
[00:20:27.733,520] <dbg> bt_hci_core: tx_processor: TX process start
[00:20:32.733,581] <inf> app: Get Tx power level -> 
[00:20:32.733,612] <dbg> bt_hci_core: bt_hci_cmd_alloc: buf 0x200094e0
[00:20:32.733,612] <dbg> bt_hci_core: bt_hci_cmd_send_sync: buf 0x200094e0 opcode 0xfc0f len 3
[00:20:32.733,642] <dbg> bt_hci_core: bt_hci_cmd_send: opcode 0xfc0f param_len 3
[00:20:32.733,642] <dbg> bt_hci_core: bt_tx_irq_raise: kick TX
[00:20:32.733,673] <dbg> bt_hci_core: tx_processor: TX process start
[00:20:32.733,703] <dbg> bt_hci_core: hci_core_send_cmd: fetch cmd
[00:20:32.733,703] <dbg> bt_hci_core: hci_core_send_cmd: Sending command 0xfc0f (buf 0x200094e0) to driver
[00:20:32.733,703] <dbg> bt_hci_core: bt_send: buf 0x200094e0 len 7 type 1
[00:20:32.733,764] <dbg> bt_hci_core: bt_tx_irq_raise: kick TX
[00:20:32.733,795] <dbg> bt_hci_core: tx_processor: TX process start
[00:20:32.734,283] <dbg> bt_hci_core: bt_recv_unsafe: buf 0x20009174 len 7
[00:20:32.734,283] <dbg> bt_hci_core: hci_cmd_status: opcode 0xfc0f
[00:20:32.734,344] <dbg> bt_hci_core: hci_cmd_done: opcode 0xfc0f status 0x01  buf 0x20009174
[00:20:32.734,344] <dbg> bt_hci_core: hci_cmd_done: sync cmd released
[00:20:32.734,375] <dbg> bt_hci_core: bt_tx_irq_raise: kick TX
[00:20:32.734,436] <wrn> bt_hci_core: opcode 0xfc0f status 0x01 
[00:20:32.734,436] <err> app: Read Tx power err: -5

Parents
  • Hello,

    Try adding this kconfig.sysbuild file:

    #
    # Copyright (c) 2023 Nordic Semiconductor
    #
    # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
    #
    
    source "share/sysbuild/Kconfig"
    
    config NRF_DEFAULT_IPC_RADIO
    	default y
    
    config NETCORE_IPC_RADIO_BT_HCI_IPC
    	default y
    

    And this file located in sysbuild\ipc_radio\prj.conf:

    CONFIG_HEAP_MEM_POOL_SIZE=8192
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
    
    CONFIG_MBOX=y
    CONFIG_IPC_SERVICE=y
    
    CONFIG_BT=y
    CONFIG_BT_HCI_RAW=y
    CONFIG_BT_CTLR_ASSERT_HANDLER=y
    #CONFIG_BT_MAX_CONN=16
    
    # Enable and adjust the below value as necessary
    # CONFIG_BT_BUF_EVT_RX_COUNT=16
    # CONFIG_BT_BUF_EVT_RX_SIZE=255
    # CONFIG_BT_BUF_ACL_RX_SIZE=255
    # CONFIG_BT_BUF_ACL_TX_SIZE=251
    # CONFIG_BT_BUF_CMD_TX_SIZE=255
    
    CONFIG_BT_CTLR_SDC_MAX_CONN_EVENT_LEN_DEFAULT=4000000
    
    CONFIG_BT_CTLR_DATA_LENGTH_MAX=251
    CONFIG_BT_BUF_ACL_RX_SIZE=502
    CONFIG_BT_BUF_ACL_TX_SIZE=502
    
    CONFIG_BT_MAX_CONN=2
    
    CONFIG_ASSERT=y
    CONFIG_DEBUG_INFO=y
    CONFIG_EXCEPTION_STACK_TRACE=y
    
    CONFIG_IPC_RADIO_BT=y
    CONFIG_IPC_RADIO_BT_HCI_IPC=y
    CONFIG_BT_CTLR_TX_PWR_DYNAMIC_CONTROL=y

    And see if that helps. If you already have a file in sysbuild\ipc_radio\prj.conf, just  try to add the last line from this file to it. If you don't have that file, or the sysbuild\ipc_radio folder in your application, try creating it, and put the prj.conf file in there.

    If that doesn't work, can you please upload what you already have, and I can have a look?

    Best regards,

    Edvin

Reply
  • Hello,

    Try adding this kconfig.sysbuild file:

    #
    # Copyright (c) 2023 Nordic Semiconductor
    #
    # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
    #
    
    source "share/sysbuild/Kconfig"
    
    config NRF_DEFAULT_IPC_RADIO
    	default y
    
    config NETCORE_IPC_RADIO_BT_HCI_IPC
    	default y
    

    And this file located in sysbuild\ipc_radio\prj.conf:

    CONFIG_HEAP_MEM_POOL_SIZE=8192
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
    
    CONFIG_MBOX=y
    CONFIG_IPC_SERVICE=y
    
    CONFIG_BT=y
    CONFIG_BT_HCI_RAW=y
    CONFIG_BT_CTLR_ASSERT_HANDLER=y
    #CONFIG_BT_MAX_CONN=16
    
    # Enable and adjust the below value as necessary
    # CONFIG_BT_BUF_EVT_RX_COUNT=16
    # CONFIG_BT_BUF_EVT_RX_SIZE=255
    # CONFIG_BT_BUF_ACL_RX_SIZE=255
    # CONFIG_BT_BUF_ACL_TX_SIZE=251
    # CONFIG_BT_BUF_CMD_TX_SIZE=255
    
    CONFIG_BT_CTLR_SDC_MAX_CONN_EVENT_LEN_DEFAULT=4000000
    
    CONFIG_BT_CTLR_DATA_LENGTH_MAX=251
    CONFIG_BT_BUF_ACL_RX_SIZE=502
    CONFIG_BT_BUF_ACL_TX_SIZE=502
    
    CONFIG_BT_MAX_CONN=2
    
    CONFIG_ASSERT=y
    CONFIG_DEBUG_INFO=y
    CONFIG_EXCEPTION_STACK_TRACE=y
    
    CONFIG_IPC_RADIO_BT=y
    CONFIG_IPC_RADIO_BT_HCI_IPC=y
    CONFIG_BT_CTLR_TX_PWR_DYNAMIC_CONTROL=y

    And see if that helps. If you already have a file in sysbuild\ipc_radio\prj.conf, just  try to add the last line from this file to it. If you don't have that file, or the sysbuild\ipc_radio folder in your application, try creating it, and put the prj.conf file in there.

    If that doesn't work, can you please upload what you already have, and I can have a look?

    Best regards,

    Edvin

Children
  • This is what I have in the sysbuild\ipc_radio\prj.conf:

    CONFIG_BT_CTLR_VS_TX_POWER_WRITE_SUPPORT=y
    
    CONFIG_BT_CTLR_HCI_VS=y
    CONFIG_BT_CTLR_VS_TX_POWER_READ_SUPPORT=y
    CONFIG_BT_CTLR_ADV_TX_POWER_CONTROL=y
    
    CONFIG_BT_CTLR_TX_PWR_DYNAMIC_CONTROL=y

    I've seen kconfig files but never created a kconfig.sysbuild. What directory does that go in? The only time I've edited the Kconfig is to create new settings.

    In case it helps here is what is in the prj.conf:

    CONFIG_BT=y
    CONFIG_LOG=y
    CONFIG_BT_PERIPHERAL=y
    CONFIG_BT_HRS=y
    CONFIG_BT_DEVICE_APPEARANCE=833
    CONFIG_BT_DEVICE_NAME="Dynamic test beacon"
    CONFIG_BT_CTLR_ADVANCED_FEATURES=y
    CONFIG_BT_CTLR_CONN_RSSI=y
    CONFIG_BT_CTLR_TX_PWR_DYNAMIC_CONTROL=y
    CONFIG_BT_HCI_CORE_LOG_LEVEL_DBG=n
    
    CONFIG_LOG_BUFFER_SIZE=8192
    
    CONFIG_BT_CTLR_PHY_2M=n
    CONFIG_BT_CTLR_PHY_CODED=n


    and the extra kconfig fragment for the nrf5340dk build:
    CONFIG_BT_LL_SOFTDEVICE=y
    CONFIG_BT_LL_SW_SPLIT=y

    6457.hci_pwr_ctrl.zip

  • This is what I see when flashing your application.

    I removed the CONFIG_BT_LL_SW_SPLIT=y from your nrf5340dk_nrf5340_cpuapp.conf, as it is conflicting with the CONFIG_BT_SOFTDEVICE_CONTROLLER=y.

    lcj said:
    I've seen kconfig files but never created a kconfig.sysbuild. What directory does that go in? The only time I've edited the Kconfig is to create new settings.

    It is what generates the image for the network core on the nRF5340. (What NCS version are you using, by the way?)

    As you can see here, nothing with BLE is working. If it behaves different on your end, it is because the network core is still flashed from a previous application, and since your application doesn't contain anything for the network core, it is not erased or flashed.

    I also commented out these Kconfigs from sysbuild\ipc_radio\prj.conf, because they were not defined (and made the build fail, once sysbuild\ipc_radio\prj.conf was actually included) :

    #CONFIG_BT_CTLR_VS_TX_POWER_WRITE_SUPPORT=y
    #CONFIG_BT_CTLR_HCI_VS=y
    #CONFIG_BT_CTLR_VS_TX_POWER_READ_SUPPORT=y
    #CONFIG_BT_CTLR_ADV_TX_POWER_CONTROL=y

    Also, I fixed some of the warnings from your build log:

    hci_pwr_ctrl2.zip

    Test the attached project (I tested in v3.1.1, and it seemed to work)

    And let me know if it doesn't work as intended.

    Best regards,

    Edvin

  • Interesting. I wasn’t getting the hci core errors. I was getting the warning and app error for tx write and read. I will try your code this evening. I’m on version 3.1. Thank you.

    When I ran it on a nrf5340dk I could see it in the iPhone nrfConnect app as "Dynamic test beacon" and my logs looked like this:

    I'm going to try your code now.

  • I suspect, since your app didn't include anything for the network core, that the network core was flashed with something from another application, and hence was flashed with a default BLE controller, without the Kconfig allowing it to change TX power. 

    If you were to --recover the nRF5340 before flashing it, you would see that you will have an empty network core when you run your application:

    "west flash -d build --recover", or:

    (and then flash the application).

    Best regards,

    Edvin

  • I did a recover from here:


    Flashed again and got this:

    I couldn't get to testing your code yesterday. I will do it tonight.

Related