CONFIG_OPENTHREAD stalls cpu

Hi,

I'm preparing to run some openthread code on an nRF5340DK using the latest SDK and toolchain v3.1.1. A simple program works fine until I set the CONFIG_OPENTHREAD. Then the app cpu just stalls and the LEDs remain off. Same for a Thingy53 device.

Program:-

   #include <zephyr/kernel.h>
   #include <dk_buttons_and_leds.h>

   #define ALL_LEDS_ON dk_set_leds(DK_ALL_BTNS_MSK)
   #define ALL_LEDS_OFF dk_set_leds(0)

   int main(void)
   {
      if(dk_leds_init() != 0)
         return -1;

      while(1)
      {
         ALL_LEDS_ON; 
         k_msleep(250);
         ALL_LEDS_OFF;
         k_msleep(250);
      }
  }

Prj.conf:-
   CONFIG_DK_LIBRARY=y 
   CONFIG_OPENTHREAD=y
   CONFIG_OPENTHREAD_NORDIC_LIBRARY_MASTER=y

Could someone confirm I should definately set the CONFIG_OPENTHREAD directive for openthread use, in addition to CONFIG_OPENTHREAD_NORDIC_LIBRARY_MASTER? And if so, what's the solution to this problem.

Thanks in advance,

Anthony.

Parents Reply Children
  • Hi,

    To reproduce the fault, just create an empty project and write a main.c source file from original message above and edit the prj.conf as shown. Then build for nrf5340dk/nrf5340/cpuapp target with SDK v3.1.1 and SDK Toolchain v3.1.1. Finally, flash the DK and you will observe the LEDs on the board remain off. If you re-build with CONFIG_OPENTHREAD=y commented-out and re-program the DK, the LEDs will flash as expected.

    Regards,

    Anthony.

  • I tried this with the blinky sample (NCS\zephyr\samples\basic\blinky), added CONFIG_OPENTHREAD=y in prj.conf, built and flashed, and the LED1 is still flashing.

    Anthony Moulds said:
    just create an empty project and write a main.c source

    What exactly do you mean by this? How do you create an empty project in your case?

    Best regards,

    Edvin

  • Hi, I've just now tried the blinky sample and, as before, all's well until I add the following to the prj.conf, i.e. the LED fails to blink:-

    CONFIG_OPENTHREAD=y
    CONFIG_OPENTHREAD_NORDIC_LIBRARY_MASTER=y

    Very odd since we're both using the same build!

    Anthony.

  • Sorry. My bad. I tested on the wrong board. Yes, it is a bit more complicated on a multicore device. The blinky sample doesn't use the radio core, and when you try to enable openthread on an nRF5340 (or if you were to try to enable BLE, for that matter), as long as the sample doesn't have any idea that it needs to build the image for the radio core as well, it will not. Then the app core will assume that the radio core has it's required FW, and it will wait forever for that core to reply.

    So, whenever you are struggling with these kinds of issues, please refer to one of the samples that already have e.g. the openthread stack up and running, and compare the two. What you will probably see is if you look at e.g. the sample:

    NCS\nrf\samples\openthread\coap_client, is that there is a file located in boards\nrf5340dk_nrf5340_cpuapp.conf. It contains:

    CONFIG_XOSHIRO_RANDOM_GENERATOR=y
    

    Add this, as it is required for the network core to enable it's random generator.

    Then you can see that there is another file:

    Kconfig.sysbuild

    Include this file in the blinky folder to tell the build system (sysbuild) that it needs to build the image for the network core as well as the application core.

    Then there are these files:

    sysbuild\ipc_radio\prj.conf
    sysbuild\ipc_radio\prj_ble.conf

    These are for configuring the application running on the network core. Strictly speaking, you only need the one called prj.conf, but if you later also want to add BLE, you may want it to have the prj_ble.conf as well. 

    So add these 4 files to your application folder, and it should build and run as expected (blinking LEDs). Copy the files from NCS\nrf\samples\openthread\coap_client

    boards\nrf5340dk_nrf5340_cpuapp.conf

    Kconfigu.sysbuild

    sysbuild\ipc_radio\prj.conf

    sysbuild\ipc_radio\prj_ble.conf

    (Include the folders they are located in, so that the relative path from the application root folder is the same)

    Attaching the modified blinky sample for reference:

    1050.blinky.zip

    Best regards,

    Edvin

  • Thanks Edvin for the info, which resolved the problem.

    Regards,

    Anthony.

Related