Config for using sdc_hci_cmd functions

Hello,

I'm using a nRF5340 DK and ncs version 2.3.0.

What i try is, to use calls like

  •  sdc_hci_cmd_vs_zephyr_read_chip_temp()  that is available in header file sdc_hci_vs.h (ncs/v2.3.0/nrfxlib/softdevice_controller/include) and source file hci_internal.c (\ncs\v2.3.0\nrf\subsys\bluetooth\controller) or
  • bt_ctlr_set_public_addr() that uses sd_hci_cmd_vs_zephyr_write_bd_addr() function that is available in the hci_driver.c and the same header file.

I'm always getting the error messages:

  • undefined reference to `sdc_hci_cmd_vs_zephyr_read_chip_temp' and
  • undefined reference to `bt_ctlr_set_public_addr'

So I'm pretty sure I'm missing a CONFIG in my prj.conf, but can't find the right one. Any Ideas, what i need to add here?

I've started my evaluation with the zephyr beacon sample.

Thanks a lot.

Parents
  • You should not access sdc_hci_cmd_vs_zephyr_read_chip_temp directly from the app, but instead use 

    bt_hci_cmd_create-> SDC_HCI_OPCODE_CMD_VS_ZEPHYR_READ_CHIP_TEMP
    The function sdc_hci_cmd_vs_zephyr_read_chip_temp  is internal to the controller.
  • Hi Susheel,

    thanks for pointing me into that direction. For setting the bluetooth address that work fine for me, like described here: RE: Setting nRF5340 Public BLE Address : So in next step i tried to do the same for the temperature measurement. Inspired by  Error with Bluetooth HCI function: bt_hci_cmd_send_sync I've tried the following to read the temperature:

    int temperature_measure(void)
    {
    
    	int err = 0;
    	struct net_buf *buf, *rsp = NULL;
    	sdc_hci_cmd_vs_zephyr_read_chip_temp_return_t *cmd_params;
    	sdc_hci_cmd_vs_zephyr_read_chip_temp_return_t *rsp_params;
    
    	buf = bt_hci_cmd_create(SDC_HCI_OPCODE_CMD_VS_ZEPHYR_READ_CHIP_TEMP, sizeof(*cmd_params));
    	if (!buf) {
    		LOG_ERR("Could not allocate command buffer");
    		return -ENOMEM;
    	}
    
    	cmd_params = net_buf_add(buf, sizeof(*cmd_params));
    
    	err = bt_hci_cmd_send_sync(SDC_HCI_OPCODE_CMD_VS_ZEPHYR_READ_CHIP_TEMP, buf, &rsp);
    	if (err) {
    		LOG_ERR("bt_hci_cmd_send_sync failed (err: %d)",err);
    		return err;
    	}
    
    	rsp_params = (void *) rsp->data;
    
    	net_buf_unref(rsp);
    
    	return 0;
    }
    

    But always getting a MPU Fault when using bt_hci_cmd_send_sync():

    [00:00:00.253,601] <err> os: ***** MPU FAULT *****
    [00:00:00.253,601] <err> os:   Data Access Violation
    [00:00:00.253,631] <err> os:   MMFAR Address: 0x5e59
    [00:00:00.253,631] <err> os: r0/a1:  0x00000000  r1/a2:  0x00000004  r2/a3:  0x00005e59
    [00:00:00.253,662] <err> os: r3/a4:  0x20005418 r12/ip:  0x0000000c r14/lr:  0x00016477
    [00:00:00.253,662] <err> os:  xpsr:  0x29000000
    [00:00:00.253,662] <err> os: Faulting instruction address (r15/pc): 0x00016bfa
    [00:00:00.253,692] <err> os: >>> ZEPHYR FATAL ERROR 0: CPU exception on CPU 0
    [00:00:00.253,723] <err> os: Current thread: 0x200015a0 (main)
    [00:00:00.938,934] <err> fatal_error: Resetting system

    Looks like net_buf_put() forces this.

    Any Idea, what's wrong with the code?

    Thanks!

    Steffen

  • Hi Susheel,

    we're having holidays in Germany as well this week Smiley So that's no problem.

    Would be great if you could test this next week.

    Thanks a lot!

  • Sure, will test this next week. Have some well deserved holidays until then :)

  • Hi Steffen, I have another colleague who has seen the same issue with another customer and we are trying to dig a bit into this.

    I will be back to you when there are updates, sorry about the delays.

  • Hi Steffen, 

    I'm taking over the case as I have done some more test related to the topic. 

    I haven't tested on SDC_HCI_OPCODE_CMD_VS_ZEPHYR_READ_CHIP_TEMP but instead using  BT_HCI_OP_VS_READ_CHIP_TEMP which is similar to how we control TX Power. 
    And I can get good result out, I can see temperature around 0x19, 0x1a meaning 25-26 Celsius. 

    int temperature_measure(void)
    {
    
    	int err = 0;
    	struct net_buf *buf, *rsp = NULL;
    	struct bt_hci_rp_vs_read_chip_temp *cmd_params;
    	struct bt_hci_rp_vs_read_chip_temp *rsp_params;
    
    	buf = bt_hci_cmd_create(BT_HCI_OP_VS_READ_CHIP_TEMP, sizeof(*cmd_params));
    	if (!buf) {
    		printk("Could not allocate command buffer");
    		return -ENOMEM;
    	}
    
    	cmd_params = net_buf_add(buf, sizeof(*cmd_params));
    
    	err = bt_hci_cmd_send_sync(BT_HCI_OP_VS_READ_CHIP_TEMP, buf, &rsp);
    	if (err) {
    		printk("bt_hci_cmd_send_sync failed (err: %d)",err);
    		return err;
    	}
    
    	rsp_params = (void *) rsp->data;
    	printk("result: 0x%x",rsp_params->temps);
    	net_buf_unref(rsp);
    
    	return 0;
    }

    I attached the project here. 

    peripheral_lbs_txpower_temp.zip

Reply
  • Hi Steffen, 

    I'm taking over the case as I have done some more test related to the topic. 

    I haven't tested on SDC_HCI_OPCODE_CMD_VS_ZEPHYR_READ_CHIP_TEMP but instead using  BT_HCI_OP_VS_READ_CHIP_TEMP which is similar to how we control TX Power. 
    And I can get good result out, I can see temperature around 0x19, 0x1a meaning 25-26 Celsius. 

    int temperature_measure(void)
    {
    
    	int err = 0;
    	struct net_buf *buf, *rsp = NULL;
    	struct bt_hci_rp_vs_read_chip_temp *cmd_params;
    	struct bt_hci_rp_vs_read_chip_temp *rsp_params;
    
    	buf = bt_hci_cmd_create(BT_HCI_OP_VS_READ_CHIP_TEMP, sizeof(*cmd_params));
    	if (!buf) {
    		printk("Could not allocate command buffer");
    		return -ENOMEM;
    	}
    
    	cmd_params = net_buf_add(buf, sizeof(*cmd_params));
    
    	err = bt_hci_cmd_send_sync(BT_HCI_OP_VS_READ_CHIP_TEMP, buf, &rsp);
    	if (err) {
    		printk("bt_hci_cmd_send_sync failed (err: %d)",err);
    		return err;
    	}
    
    	rsp_params = (void *) rsp->data;
    	printk("result: 0x%x",rsp_params->temps);
    	net_buf_unref(rsp);
    
    	return 0;
    }

    I attached the project here. 

    peripheral_lbs_txpower_temp.zip

Children
Related