NRF5340: net core crashes in sdc_hci_cmd_le_set_adv_enable() if CONFIG_CLOCK_CONTROL_NRF_CALIBRATION_MAX_SKIP=0

The NRF5340 net core crashes in sdc_hci_cmd_le_set_adv_enable() if I have CONFIG_CLOCK_CONTROL_NRF_CALIBRATION_MAX_SKIP set to 0.

To reproduce the issue, do the following:

1) Use the attached peripheral_gatt_dm project. In that project, I enabled MCUBOOT which caused a linking issue that I temporarily resolved by setting CONFIG_CLOCK_CONTROL_NRF_CALIBRATION_MAX_SKIP to 0. See devzone.nordicsemi.com/.../bug-in-ncs-v1-7-1-with-32khz-rc-oscillator-and-mcuboot-enabled as to the reason why I had to set CONFIG_CLOCK_CONTROL_NRF_CALIBRATION_MAX_SKIP=0.

2) Add the following lines into the C:\ncs\v1.8.0\zephyr\boards\arm\nrf5340dk_nrf5340\nrf5340dk_nrf5340_cpunet_defconfig file:

CONFIG_CLOCK_CONTROL_NRF_K32SRC_XTAL=n
CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC=y
CONFIG_CLOCK_CONTROL_NRF_CALIBRATION_MAX_SKIP=0

3) Use the following command to build and flash the image:

west build -p -b nrf5340dk_nrf5340_cpuapp
west flash --erase

4) In the app core side, you'll see the following console logs:

*** Booting Zephyr OS build v2.7.0-ncs1 (Jan 21 2022 13:27:32) ***
Starting GATT Discovery Manager example
[00:00:00.082,641] <inf> bt_hci_core: HW Platform: Nordic Semiconductor (0x0002)
[00:00:00.082,672] <inf> bt_hci_core: HW Variant: nRF53x (0x0003)
[00:00:00.082,672] <inf> bt_hci_core: Firmware: Standard Bluetooth controller (0x00) Version 223.20160 Build 1719410646
[00:00:00.089,691] <inf> bt_hci_core: Identity: ED:B3:AF:58:A1:9C (random)
[00:00:00.089,691] <inf> bt_hci_core: HCI: version 5.2 (0x0b) revision 0x22b0, manufacturer 0x0059
[00:00:00.089,691] <inf> bt_hci_core: LMP: version 5.2 (0x0b) subver 0x22b0
ASSERTION FAIL [err == 0] @ WEST_TOPDIR/zephyr/subsys/bluetooth/host/hci_core.c:306
k_sem_take failed with err -11
[00:00:10.113,281] <err> os: r0/a1: 0x00000003 r1/a2: 0x00022004 r2/a3: 0x00000001
[00:00:10.113,311] <err> os: r3/a4: 0x00018061 r12/ip: 0x00001000 r14/lr: 0x00010cf9
[00:00:10.113,311] <err> os: xpsr: 0x49000000
[00:00:10.113,311] <err> os: Faulting instruction address (r15/pc): 0x00010d04
[00:00:10.113,311] <err> os: >>> ZEPHYR FATAL ERROR 3: Kernel oops on CPU 0
[00:00:10.113,311] <err> os: Current thread: 0x20000f88 (unknown)

The k_sem_take failure is caused by the net core crashing.


I would like to know if there's a way to not have to set CONFIG_CLOCK_CONTROL_NRF_CALIBRATION_MAX_SKIP=0 to fix the linking issue or is there a work-around to prevent this crash?

The crash only occurs with the Nordic Bluetoooth Controller. It does not crash with the Zephyr Bluetooth Controller.peripheral_gatt_dm.zip

Setting the CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC_CALIBRATION=n or CONFIG_CLOCK_CONTROL_NRF_K32SRC_SYNTH=y instead of CONFIG_CLOCK_CONTROL_NRF_CALIBRATION_MAX_SKIP=0 is not an option that I could use.

  • Hi

    Thanks for the report. I have shared your findings with the developers, and they will help look into this. It seems the issue is related to the code getting stuck waiting for the LFCLK to start, but we need more time to find the root cause. 

    I will do my best to get back to within the next couple of days. 

    Best regards
    Torbjørn

  • Hi 

    Sorry for the slow response on this. 

    The developers have looked into it, and found that for legacy reasons the MPSL library considers a CONFIG_CLOCK_CONTROL_NRF_CALIBRATION_MAX_SKIP value of 0 special, and won't function properly in this case. 

    A possible workaround is to change the value in the code here to anything but 1 (the developer tested with 0 and 2, and neither produced a crash). 

    This issue will be fixed by this pull request, which will be included in the first NCS release after v1.9.0. 

    Best regards
    Torbjørn

  • Hi Torbjørn,

    The pull request link that you sent doesn't seem to work. I get a blank page saying the site can't be reached.

    Thanks,

    Ronald

  • Hi Torbjørn,

    Will the pull request also fix the CLOCK_CONTROL_NRF_USES_TEMP_SENSOR dependency with the NET bootloader. This is the error that I get if I don't set CONFIG_CLOCK_CONTROL_NRF_CALIBRATION_MAX_SKIP=0.

    === child image b0n - CPUNET (inherited) begin ===
    CMake Warning (dev) at C:/ncs/projects/SP-1253/build_nrf5340_cliplav_cpuapp/hci_rpmsg/b0n/child_image_preload.cmake:12 (set):
      Syntax error in cmake code at
    
        C:/ncs/projects/SP-1253/build_nrf5340_cliplav_cpuapp/hci_rpmsg/b0n/child_image_preload.cmake:12
    
      when parsing string
    
        C:\ncs\v1.7.1\toolchain\segger_embedded_studio/html/configure_nordic_project_menuconfig.py
    
      Invalid escape sequence \v
    
      Policy CMP0010 is not set: Bad variable reference syntax is an error.  Run
      "cmake --help-policy CMP0010" for policy details.  Use the cmake_policy
      command to set the policy and suppress this warning.
    This warning is for project developers.  Use -Wno-dev to suppress it.
    
    Including boilerplate (Zephyr base): C:/ncs/v1.9.0/zephyr/cmake/app/boilerplate.cmake
    -- Using NCS Toolchain 1.9.0 for building. (C:/ncs/v1.9.0/toolchain/cmake)
    
    warning: TEMP_NRF5 (defined at drivers/sensor/nrf5/Kconfig:13) has direct dependencies HAS_HW_NRF_TEMP && (MULTITHREADING || TEMP_NRF5_FORCE_ALT) && SENSOR with value n, but is currently being y-selected by the following symbols:
     - CLOCK_CONTROL_NRF_USES_TEMP_SENSOR (defined at drivers/clock_control/Kconfig.nrf:119), with value y, direct dependencies HAS_HW_NRF_TEMP && CLOCK_CONTROL_NRF_DRIVER_CALIBRATION && CLOCK_CONTROL_NRF_K32SRC_RC_CALIBRATION && CLOCK_CONTROL_NRF && CLOCK_CONTROL (value: y), and select condition HAS_HW_NRF_TEMP && CLOCK_CONTROL_NRF_DRIVER_CALIBRATION && CLOCK_CONTROL_NRF_K32SRC_RC_CALIBRATION && CLOCK_CONTROL_NRF && CLOCK_CONTROL (value: y)
    
    error: Aborting due to Kconfig warnings
    

  • Hi Ronald 

    Sorry for the slow response, I was out in travel last week. 

    I didn't realize the PR was for the MPSL library source code, which is not publicly available, my bad. 

    The NCS PR can be found here: https://github.com/nrfconnect/sdk-nrfxlib/pull/675

    It doesn't show the code changes, but you should be able to apply the PR to your local repo if you want to test it. 

    ronbo999 said:
    Will the pull request also fix the CLOCK_CONTROL_NRF_USES_TEMP_SENSOR dependency with the NET bootloader.

    I have asked the team for input on this and will let you know once I hear from them. 

    Best regards
    Torbjørn

Related