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 
Reply
  • 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 
Children
  • Hi Matt,

    Thanks for confirming. At least it should not become stuck waiting for the LF crystal to ramp up now. The next step I would suggest is that you try to debug the netcore to try to find out exactly where the program is hanging (multicore debugging). Maybe the problem is with the 32 MHz crystal oscillator (HFXO) not starting up (The bluetooth controller will request this clock source whenever it is using the RADIO).

    In vscode:

    1. Make sure application core is selected.

    2. Start debug session using vs code's debug extension or Ozone

    1. Make sure the hci_rpmsg child image is selected

    2. Start the 2nd debug session for the netcore

    Kind regards,

    Vidar

  • Hi Vidar, 

    Thanks for your detailed response. 

    I should also note that I am using an nrf5340-dk with VTG and VDD_nrf shorted together to re-direct the J-Link as my debugger for my custom board, where the SWD pins are connected to my custom board via the DKs Debug out port - if this information has any impact on your guidance. 

    First I debugged netcore of my DK board using your above instructions and I was able to step through the network core to confirm proper procedure: 

    Then I attempted to perform the same procedure you provided on my custom board and I wasnt able to step through at all, it appears to be locked out entirely. 

    Do you have any other suggestions? 

    Thanks for all your help. 

    Matt  

  • Hi Matt,

    mattmacleod said:
    I should also note that I am using an nrf5340-dk with VTG and VDD_nrf shorted together to re-direct the J-Link as my debugger for my custom board, where the SWD pins are connected to my custom board via the DKs Debug out port - if this information has any impact on your guidance. 

    This should be fine as long as the DK and custom board share the same VDD voltage (there is no built-in level shifter). I don't think this is the problem here considering you are able to program and debug the application core just fine.

    mattmacleod said:
    Then I attempted to perform the same procedure you provided on my custom board and I wasnt able to step through at all, it appears to be locked out entirely. 

    Just to make sure, did you try to start the debug session for the application core first as suggested in the the documentation here: multicore debugging? This step is important as the app core is responsible for powering up the network core.

  • Hi Vidar, 

    I am now able to debug the network core and I dont see any issues when stepping through the networkcore of the custom board compared to when I step through with my DK board. 

    Strange finding:

    The bt_enable function was hanging before debugging the network core, now after debugging the network core I can get out of the bt_enable function in VSCode... So that issue appears to be fixed. 

    Is there some way that the network core got unlocked during this process? 

    Thanks again for all your help, 

    Matt 

  • Hi Matt,

    This sounds promising. Are you able to connect to it over BLE as well? Also, does it still work after you exit debug mode?

    mattmacleod said:
    Is there some way that the network core got unlocked during this process? 

    The network core is booted by the application core's FW on startup, so it should get powered on as long as the app core FW is being executed (link).

    mattmacleod said:
    I am now able to debug the network core and I dont see any issues when stepping through

    The network core may be entering a bootloop if there is a failing assert in the hci_rpmsg FW and maybe mask the problem if there is one. You can set CONFIG_RESET_ON_FATAL_ERROR=n for the hci_rpmsg image to make it easier to catch such problems.

    Lastly, as test, please try to run the code snippet below before bt_enable() to see if you are able to manually start the HF crystal (the program will get stuck in the while loop if not).

    	NRF_TIMER1->BITMODE = TIMER_BITMODE_BITMODE_32Bit << TIMER_BITMODE_BITMODE_Pos;
    	NRF_TIMER1->TASKS_CLEAR = 1;
    	NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
    	NRF_TIMER1->TASKS_START = 1;
    	NRF_CLOCK->TASKS_HFCLKSTART = 1;
    	while(NRF_CLOCK->EVENTS_HFCLKSTARTED == 0);
    	NRF_TIMER1->TASKS_CAPTURE[0] = 1;
    
    	printk("HF Clock has started. Startup time: %d uS\n", NRF_TIMER1->CC[0]);

Related