LoRa send sample gets stuck when no LoRa module is connected

Hello,

Basically I'm using NCS SDK (1.7.0 - see Generated Info in the end) and Zephyr.

The board I'm adventuring on is the nRF52840 DK.

In the project, I have 1 main function (actual main(), not a custom RTOS thread) running BLE advertising.

Also, I have 4 other threads, 3 for running blinky sample and another thread for running a UARTE sample using interrupt driven configuration.

// thread for blinky sample
K_THREAD_DEFINE(blink0_id, STACKSIZE, blink0, NULL, NULL, NULL,
		PRIORITY, 0, 0);
K_THREAD_DEFINE(blink1_id, STACKSIZE, blink1, NULL, NULL, NULL,
		PRIORITY, 0, 0);
K_THREAD_DEFINE(uart_out_id, STACKSIZE, uart_out, NULL, NULL, NULL,
		PRIORITY, 0, 0);
		
// thread uses UARTE with interrupt driven
K_THREAD_DEFINE(uarte_sample_task_id, STACKSIZE, uarte_task, NULL, NULL, NULL,
		PRIORITY, 0, 0);

Everything works fine until here, the Zephyr system boots up and logs everything, from BLE adv to UARTE debug communication.

The problem started when I added the LoRa sample thread.

P.S.: I don't have the LoRa module connected yet.

The project with the LoRa send sample thread compiles just right.

However, after flashing, the NRF Terminal shows the following LOG, and it doesn't print anything else (not even the RTOS entry log):

[00:00:00.200,561] <inf> sx127x: SX127x version 0xff found

There is no other logs other than that. The board simply prints this and kind of stops running. If resetted, prints that log again and stops.

If I exclude this thread from the build the system boots up just right as before.

What am I missing?

Below the prj.conf with all the configs used:

# -- Bluetooth LE
CONFIG_BT=y
CONFIG_BT_BROADCASTER=y
CONFIG_BT_DEBUG_LOG=y
CONFIG_BT_CENTRAL=y
CONFIG_BT_SCAN=y

CONFIG_BT_EXT_ADV=y
CONFIG_BT_LL_SW_SPLIT=n

# -- Lora
CONFIG_SPI=y
CONFIG_LORA=y
CONFIG_LORA_SX12XX=y
CONFIG_LORA_SX127X=y

# -- Blinky
CONFIG_HEAP_MEM_POOL_SIZE=256
CONFIG_ASSERT=y

# -- UART
CONFIG_UART_INTERRUPT_DRIVEN=y

Below is my .overlay file:

/ {
    aliases {
        lora0 = &lora;
        gpsuart = &uart1;
    };
};


&spi3 {
	compatible = "nordic,nrf-spim";
	status = "okay";
	sck-pin = <17>;
	mosi-pin = <18>;
	miso-pin = <22>;
	cs-gpios = <&gpio0 14 GPIO_ACTIVE_LOW>;
	
	lora: sx1276@0 {
		compatible = "semtech,sx1276";
		reg = <0>;
		label = "sx1276";
		reset-gpios = <&gpio0 20 GPIO_ACTIVE_LOW>;
		dio-gpios = <&gpio0 21 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>;
		spi-max-frequency = <1000000>;
		power-amplifier-output = "pa-boost";
	};
};

&uart1 {
    compatible = "nordic,nrf-uarte";
    status = "okay";
    current-speed = <9600>;
	rx-pin = <32>;
	tx-pin = <41>;
};

Infos by the Generated Support Information:

 

{
  "platform": {
    "os": "darwin",
    "osVersion": "Darwin Kernel Version 19.6.0: Thu Sep 16 20:58:47 PDT 2021; root:xnu-6153.141.40.1~1/RELEASE_X86_64",
    "osKernel": "19.6.0",
    "vscode": "1.61.2",
    "electron": "13.5.1",
    "node": "v14.16.0"
  },
  "system": {
    "date": "2021-10-21T03:48:30.370Z",
    "vscodeRoot": "/Applications/Visual Studio Code.app/Contents/Resources/app",
    "nrfConnectForDesktopInstalled": true,
    "vscodeUptime": "00:27:36",
    "osUptime": "06:45:11",
    "cpu": {
      "model": "Intel(R) Core(TM) i5-3210M CPU @ 2.50GHz",
      "speed": "2500 MHz",
      "count": 2
    },
    "memory": {
      "total": "6.00 GB",
      "free": "0.12 GB"
    }
  },
  "workspace": {
    "name": "dewave (Workspace)",
    "workspaceFile": "/Users/thiago/nRF52_apps/dewave.code-workspace",
    "folders": [
      "/Users/thiago/nRF52_apps/cracha"
    ]
  },
  "extensions": {
    "internal": {
      "nordic-semiconductor.nrf-connect": {
        "version": "2021.10.103",
        "path": "/Users/thiago/.vscode/extensions/nordic-semiconductor.nrf-connect-2021.10.103",
        "isActive": true
      },
      "nordic-semiconductor.nrf-terminal": {
        "version": "2021.9.26",
        "path": "/Users/thiago/.vscode/extensions/nordic-semiconductor.nrf-terminal-2021.9.26",
        "isActive": true
      },
      "nordic-semiconductor.devicetree": null,
      "nordic-semiconductor.kconfig": null
    },
    "external": {
      "marus25.cortex-debug": "0.4.7",
      "ms-vscode.cpptools": "1.7.1",
      "ms-vscode.js-debug": "1.61.0",
      "ms-vscode.js-debug-companion": "1.0.15",
      "ms-vscode.references-view": "0.0.81",
      "ms-vscode.vscode-js-profile-table": "0.0.18",
      "bbenoist.Doxygen": "1.0.0",
      "betwo.vscode-doxygen-runner": "1.7.2",
      "cschlosser.doxdocgen": "1.3.2",
      "DotJoshJohnson.xml": "2.5.1",
      "eamodio.gitlens": "11.6.1",
      "johnpapa.winteriscoming": "1.4.4",
      "ms-azuretools.vscode-docker": "1.17.0",
      "ms-python.python": "2021.10.1365161279",
      "ms-python.vscode-pylance": "2021.10.2",
      "ms-toolsai.jupyter": "2021.9.1101343141",
      "ms-toolsai.jupyter-keymap": "1.0.0",
      "ms-toolsai.jupyter-renderers": "1.0.3",
      "ms-vscode.cpptools-themes": "1.0.0",
      "PKief.material-icon-theme": "4.10.0",
      "redhat.vscode-yaml": "1.0.0",
      "trond-snekvik.gnu-mapfiles": "1.1.0",
      "twxs.cmake": "0.0.17"
    }
  },
  "tools": {
    "jlink": "Not found",
    "/usr/local/bin/nrfjprog": "10.14.0",
    "/opt/nordic/ncs/v1.7.0/toolchain/bin/cmake": "3.21.1",
    "/opt/nordic/ncs/v1.7.0/toolchain/bin/west": "0.11.1",
    "/Users/thiago/opt/anaconda3/bin/python": "3.9.6",
    "/opt/nordic/ncs/v1.7.0/toolchain/bin/ninja": "1.10.2",
    "/opt/nordic/ncs/v1.7.0/toolchain/bin/gperf": "3.1",
    "/opt/nordic/ncs/v1.7.0/toolchain/bin/dtc": "1.6.1",
    "gnuarmemb": "Not found",
    "/opt/nordic/ncs/v1.7.0/toolchain/bin/gn": "1937"
  },
  "config": {
    "nordic-semiconductor.nrf-connect": {
      "topdir": "/opt/nordic/ncs/v1.7.0",
      "toolchain": {
        "path": "/opt/nordic/ncs/v1.7.0/toolchain"
      },
      "ozonePath": "",
      "applications": [
        "/Users/thiago/nRF52_apps/cracha"
      ],
      "jlink": {
        "rtosPlugin": ""
      },
      "kconfig": {
        "interface": "menuconfig"
      },
      "welcome": {
        "showOnStartup": true
      },
      "west": {
        "env": {
          "$base": "terminal"
        }
      },
      "boardRoots": []
    },
    "nordic-semiconductor.nrf-terminal": {
      "terminalMode": "character"
    },
    "nordic-semiconductor.devicetree": {
      "modules": [
        "${zephyrBase}",
        "${zephyrBase}/../nrf",
        "."
      ],
      "zephyr": "",
      "ctxFile": "",
      "defaultBoard": ""
    },
    "nordic-semiconductor.kconfig": {
      "root": "",
      "env": {},
      "cfiles": true,
      "disable": false,
      "zephyr": {
        "board": {
          "board": "nrf52840dongle_nrf52840",
          "arch": "arm",
          "dir": "/opt/nordic/ncs/v1.7.0/zephyr/boards/arm/nrf52840dongle_nrf52840"
        },
        "west": "/opt/nordic/ncs/v1.7.0/toolchain/bin/west",
        "base": "/opt/nordic/ncs/v1.7.0/zephyr",
        "soc_roots": []
      }
    },
    "marus25.cortex-debug": {
      "armToolchainPath": null,
      "armToolchainPrefix": "arm-none-eabi",
      "gdbPath": null,
      "JLinkGDBServerPath": null,
      "openocdPath": null,
      "pyocdPath": null,
      "PEGDBServerPath": null,
      "stutilPath": null,
      "stlinkPath": null,
      "stm32cubeprogrammer": null,
      "enableTelemetry": true,
      "flattenAnonymous": false,
      "registerUseNaturalFormat": true,
      "variableUseNaturalFormat": true
    }
  },
  "environment": {
    "westExe": "/opt/nordic/ncs/v1.7.0/toolchain/bin/west",
    "westEnv": {
      "ELECTRON_RUN_AS_NODE": "1",
      "GIT_EXEC_PATH": "/opt/nordic/ncs/v1.7.0/toolchain/Cellar/git/2.32.0_1/libexec/git-core",
      "HOME": "/Users/thiago",
      "PATH": "/opt/nordic/ncs/v1.7.0/toolchain/bin:/Users/thiago/opt/anaconda3/bin:/Users/thiago/opt/anaconda3/condabin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Applications/Wireshark.app/Contents/MacOS",
      "ZEPHYR_BASE": "/opt/nordic/ncs/v1.7.0/zephyr",
      "GNUARMEMB_TOOLCHAIN_PATH": "/opt/nordic/ncs/v1.7.0/toolchain",
      "ZEPHYR_TOOLCHAIN_VARIANT": "gnuarmemb",
      "USER": "thiago"
    },
    "toolchainPath": "/opt/nordic/ncs/v1.7.0/toolchain",
    "toolchainBinPath": "/opt/nordic/ncs/v1.7.0/toolchain/bin",
    "toolchainVersion": "1.7.0"
  },
  "terminal": {
    "shell": null,
    "defaultProfile": null
  }
}

  • Thank you for the clarification, good to know what the goal is.

    One observation so far: If I comment out all Bluetooth related configs, the application runs and does not output anything about LoRa:

    *** Booting Zephyr OS build v2.6.99-ncs1  ***

    Hello World! nrf52840dk_nrf52840

    I will take another look at this tomorrow.

  • FYI, here is another customer experiencing the same problem when the module is disconnected:

    https://devzone.nordicsemi.com/f/nordic-q-a/74370/unable-to-send-receive-lora-data

    The customer opened an issue on github describing this:

    https://github.com/zephyrproject-rtos/zephyr/issues/34581

    Unfortunately, the case was closed as soon as the customer was able to send data.

    The two discussions above might provide some insight. It seems like the solution is to modify the driver and include checks for the device. 0x12 and 0x22 should be supported, 0xff should not be accepted.

  • Hello again ,

    I wired up another LoRa module to an nRF dongle, then checked the wires again.

    I wasn't connecting the DIO pins, as they are used as IRQ signals. Then I found out that the SX127x driver that is present in the Zephyr base actually requires the DIOs to be connected so it knows when a valid packet arrived (if I'm not mistaken).

    So, after connecting the DIO0-2 pins, the sender sample as well as the receiver sample work as expected!

    I tried to simulate the problem of the Zephyr not booting up again when there is no communication with the LoRa module, but wasn't able to do it.

    I guess there's something to do with the overlay config I first used.

    I will let the current overlay code here if anyone needs this.

    Thank you for the help, I really appreciate it.

    / {
        aliases {
            lora0 = &lora;
            gpsuart = &uart1;
        };
    };
    
    
    &spi1 {
    	compatible = "nordic,nrf-spi";
    	status = "okay";
    	cs-gpios = <&gpio0 28 GPIO_ACTIVE_LOW>;
    	mosi-pin = <29>;
    	miso-pin = <30>;
    	sck-pin = <31>;
    	
    	lora: sx1276@0 {
    		compatible = "semtech,sx1276";
    		reg = <0>;
    		label = "sx1276";
    		reset-gpios = <&gpio0 4 GPIO_ACTIVE_LOW>;
    		dio-gpios = <&gpio1 13 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>,
    					<&gpio1 12 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>,
    					<&gpio1 11 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>;
    		spi-max-frequency = <1000000>;
    		power-amplifier-output = "pa-boost";
    	};
    };
    
    &uart1 {
        compatible = "nordic,nrf-uarte";
        status = "okay";
        current-speed = <9600>;
    	rx-pin = <32>;
    	tx-pin = <41>;
    };
    

Related