BT_Enable Function stuck in bt_rpmsg_platform_endpoint_is_bound() for nrf5340

Hello, 

I am having an issue with board bring up for a custom board I developed using the nrf5340 processor. 

I have created firmware based off the peripheral_uart sample that works on the nrf5340-dk.

My issue is my code is in bt_enable() only on the custom board, the code works perfectly fine on the dk board. 

It appears there is something wrong within the communication between the app and network core. When I step through the bt_enable function it looks like we are hung up in the following lines of code:

 

 

 

In the past I have been able to unlock the network core when running into issues on the dk boards with the following recovery/unlock commands but that didn’t seem to remedy the issue:

 

nrfjprog -f NRF53 --coprocessor CP_NETWORK --recover

nrfjprog -f NRF53 --coprocessor CP_NETWORK --program merged_CPUNET.hex --chiperase

nrfjprog --pinreset

 

It looks like quite a few people have had similar issues on the Dev Zone, but I don’t see a lot of answered tickets. 

Any help would be appreciated. 

Thanks, 

Matt 

Parents
  • Hello Matt,

    Does your custom board include the optional LF crystal shown in the ref. schematics below?

    If not, and assuming you are using the DK board files,  please make sure you have selected the internal RC oscillator as the clock source for the netcore image too. These clock settings can be applied by adding a new config file in the child_image folder (/peripheral_uart/child_image/hci_rpmsg/boards). You can make a copy of the existing thingy53_nrf5340_cpunet.conf file and rename it to nrf5340dk_nrf5340_cpunet.conf.

    Best regards,

    Vidar

  • Hi Vidar, 

    Thanks for your reply. 

    No, I do not have an external LF crystal. 

    The program is still stuck in bt_enable() after making the following changes: 

    1. Add the following lines to proj.conf: 

    #config internal crystal for XL1/Xl2 oscillator
    CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC=y
    CONFIG_BT_SMP=y
    CONFIG_CLOCK_CONTROL_NRF_K32SRC_500PPM=y

    2. Copy and rename following file /peripheral_uart/child_image/hci_rpmsg/boards/thingy53_nrf5340_cpunet.conf

    3. Added the following lines to the nrf5340dk_nrf5340_cpunet.conf file:

    #config internal crystal for XL1/Xl2 oscillator
    CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC=y
    CONFIG_BT_SMP=y
    CONFIG_CLOCK_CONTROL_NRF_K32SRC_500PPM=y
    Any other suggestions? 
    Kind regards, 
    Matt 
  • Hi Vidar, 

    Ive tried connecting to the device with a version of peripheral_central on another DK board and I am not able to connect to the custom board despite it clearing bt_Enable in the debugger. 

    Note: this code works when I use it to connect to 2 DK boards so its not a software issue. 

    I've added the following config: 

    CONFIG_RESET_ON_FATAL_ERROR=n

    In addition to adding the above lines of code and my program doesnt appear to be hanging in the following line as I can step over it (which seems promising): 

    while(NRF_CLOCK->EVENTS_HFCLKSTARTED == 0);

    Do you have any other suggestions? 

    Thanks for all your help, 

    Matt 
     

  • Hi Matt,

    I noticed you had provided your board schematics in a previous ticket, so I had a look at those, and I see you have opted to use external load capacitors for the 32M crystal. This is perfectly fine, but it is different from DK design where we use the internal load capacitors (Using internal capacitors).

    Please add CONFIG_SOC_HFXO_CAP_EXTERNAL=y to your prj.conf file. This should ensure the XOSC32MCAPS (Retained) register stays at its reset value with the internal caps disabled.  You can start a debug session for the application core if you want to confirm the register setting afterwards:

    If the current load capacitance is wrong as I suspect, you will end up with nominal frequency that is slightly off and shift the RADIO carrier frequency enough to make your advertisement packets "invisible" to your Bluetooth central device.

    I hope this helps.

    Vidar

  • Hi Vidar, 

    I added the following config:

    CONFIG_SOC_HFXO_CAP_EXTERNAL=y to both app and network core. 

    And confirmed the internal caps were disabled in ozone:

    And it appears to be connecting (tested by sending a 240 byte buffer of dummy data to central) but the connection is not stable, it appears to be working, sending a few packets then the connection drops and I have to reset my board to reconnect where it again sends a few packets, then drops and requires a reset.    

    This code was tested on the dk board so I dont believe it to be a software issue. 

    Do you have any other suggestions? 

    Thanks for your help, 

    Matt 

     

  • Hi Matt,

    The connection loss could be a symptom of poor link quality. Do you have debug logging enabled in your peripheral project? It would be good to know what the disconnect reason is. For a bad connection I would expect the reason to be BT_HCI_ERR_CONN_TIMEOUT in most cases.

    Also, it would be good if you could try to connect with it using the nRF connect app on Android or iOS to see if it gives you the same result.

    Disconnect reason is logged over RTT if you use the peripheral_uart example as you can see here: https://github.com/nrfconnect/sdk-nrf/blob/2bee52d57e51cbe3108f0bbcb9ed68743bcd4e40/samples/bluetooth/peripheral_uart/src/main.c#L346

    Vidar

  • Hi Vedar, 

    You are correct, I am getting the  BT_HCI_ERR_CONN_TIMEOUT  error when viewing the RTT logs. 

    In my code, I am able to reliably connect to the other nrf5340-dk I am using as a central device, but it cuts out after a while and requires a reset to re-connect. 

    As a test, I have an LED that turns on when the device is connected over BLE on my board. Then turns off when its disconnected. When connecting over nrf connect for IOS I am able to toggle the LED manually and the connection appears to be stable. It is when I try to send data over my service to the nrf5340-dk that is running the modified central application that I am running into this issue. 

    Do you have any suggestions for what could be causing the  BT_HCI_ERR_CONN_TIMEOUT?

    I already tried investigating the XFXO oscillator as a possible source of the issue since I was originally using external caps, so I re-configured the following for internal caps: 

    1. Removing the external caps I had connected to the HFXO oscillator 

    2. Calculating the internal CL values as 12.5pF for my XTal with a CL of 8pF 

    3. Adding the following configs to both cores config files: 

    CONFIG_SOC_HFXO_CAP_INTERNAL=y
    CONFIG_SOC_HFXO_CAP_INT_VALUE_X2=25

    Thanks again for all your help, 

    Matt 

Reply
  • Hi Vedar, 

    You are correct, I am getting the  BT_HCI_ERR_CONN_TIMEOUT  error when viewing the RTT logs. 

    In my code, I am able to reliably connect to the other nrf5340-dk I am using as a central device, but it cuts out after a while and requires a reset to re-connect. 

    As a test, I have an LED that turns on when the device is connected over BLE on my board. Then turns off when its disconnected. When connecting over nrf connect for IOS I am able to toggle the LED manually and the connection appears to be stable. It is when I try to send data over my service to the nrf5340-dk that is running the modified central application that I am running into this issue. 

    Do you have any suggestions for what could be causing the  BT_HCI_ERR_CONN_TIMEOUT?

    I already tried investigating the XFXO oscillator as a possible source of the issue since I was originally using external caps, so I re-configured the following for internal caps: 

    1. Removing the external caps I had connected to the HFXO oscillator 

    2. Calculating the internal CL values as 12.5pF for my XTal with a CL of 8pF 

    3. Adding the following configs to both cores config files: 

    CONFIG_SOC_HFXO_CAP_INTERNAL=y
    CONFIG_SOC_HFXO_CAP_INT_VALUE_X2=25

    Thanks again for all your help, 

    Matt 

Children
Related