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

  • I ran your code in the main context and see that it runs without any issues.

    Which context are you running this in? It might not be safe to run this in an interrupt context, try pushing this in a workq thread or similar.

  • Hi Susheel,

    thanks for testing this. Unfortunately i did the testing for temperature measurement before running the bt_enable() call, which will of course fail, because what I'm using here is a bt_hci_cmd. So i will not get the MPU Fault any more.

    But can you confirm, that this is the correct way of measure the temperature? Have you confirmed that the return value make sense? I will always get a 0 as temperature value in return. When manually testing the temperature measurement on network core, by reading and writing registers with nrfjprog.exe I had to trigger the task on register 0x41010000 before i was able to read a temperature value on register 0x41010508? Any ideas, if i have to do something before correct value will be returned?

  • Steffen, 

    SJahnke said:
    But can you confirm, that this is the correct way of measure the temperature? Have you confirmed that the return value make sense?

    No, I have not actually looked at the value of returned as I was just trying to focus on the error you see. We have holidays this week in Norway and so I would be able to test it out next week if you still have this issue.

Reply Children
Related