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
  }
}

Parents
  • Hi Thiago,

    I was able to reproduce this behavior. I copied your overlay and prj.conf into a new hello_world sample and I observed the same output to the terminal.

    It looks like the sx127x driver fails during initialization when it tries to read the device. This is probably why you are not seeing Zephyr boot in the terminal.

    Do you have access to any sx1276 module?

    Best regards,

    HĂĄkon

  • Hello!

    Yes, I have two LoRa modules. One of them is an SX1276 module, the other is a LoRa ESP32 board which has an SX1276/78.

    I tested connecting the LoRa module to the DK, and it runs when the module is connected.

    But the issue still exists when there is no LoRa module connected to the DK. 

    Also, I couldn't be able to send data from the nRF52840DK to the LoRa ESP32 board yet.

    The nRF52840DK logs the following success messages of sending, but it doesn't seem to reach the LoRa ESP32 board.

    Any suggestions on this as well?

    *** Booting Zephyr OS build v2.6.99-ncs1  ***
    Starting Scanner/Advertiser Demo
    Bluetooth initialized
    [00:00:00.200,531] <inf> sx127x: SX127x version 0x12 found
    [00:00:00.231,750] <inf> sdc_hci_driver: SoftDevice Controller build revision: 
                                             3f 47 70 8e 81 95 4e 86  9d d3 a2 95 88 f6 30 0a |?Gp...N. ......0.
                                             7f 53 49 fd                                      |.SI.             
    [00:00:00.235,748] <inf> bt_hci_core: HW Platform: NHOLYSHITordic Semiconductor (0x0002)
    [00:00:00.235,778] <inf> bt_hci_core: HW Variant: nRF52x (0x0002)
    [00:00:00.235,778] <inf> bt_hci_core: Firmware: Standard Bluetooth controller (0x00) Version 63.28743 Build 1318420878
    [00:00:00.237,274] <inf> bt_hci_core: Identity: D5:25:14:3C:44:5C (random)
    [00:00:00.237,304] <inf> bt_hci_core: HCI: version 5.2 (0x0b) revision 0x125b, manufacturer 0x0059
    [00:00:00.237,304] <inf> bt_hci_core: LMP: version 5.2 (0x0b) subver 0x125b
    [00:00:00.245,666] <inf> lora_send: Data sent!
    [00:00:01.247,192] <inf> lora_send: Data sent!
    GPS -> $GPRMC,7,4.72,3.50*00
    GPS -> $GPGSV,3,3,12,25,56,197,27,29,47,244,26,31,07,218,33,32,02,271,*73
    GPS -> $GPRMC,164337.00,A,2612.44648,S,05241.75649,W,0.118,,211021,,,A*74
    GPS -> $GPGSA,A,3,29,25,12,31,02,,,,,,,,5.87,4.72,3.50*00
    GPS -> $GPGSV,3,2,12,12,62,126,36,18,17,329,,20,28,088,12,24,34,359,08*76
    GPS -> $GPRMC,164338.00,A,2612.44641,S,05241.75651,W,0.236,,211021,,,A*74
    [00:00:02.248,809] <inf> lora_send: Data sent!
    [00:00:03.250,396] <inf> lora_send: Data sent!
    GPS -> $GPGSA,A,3,29,25,12,31,02,,,,,,,,5.87,4.72,3.50*00
    GPS -> $GPGSV,3,2,12,12,62,126,36,18,17,329,,20,28,088,15,24,34,359,07*7E
    GPS -> $GPRMC,164339.00,A,2612.44641,S,05241.75655,W,0.361,,211021,,,A*72
    GPS -> $GPGGA,164339.00,2612.44641,S,05241.75655,W,1,05,4.72,812.9,M,4.2,M,,*6B
    GPS -> $GPGSV,3,2,12,12,62,126,36,18,17,329,,20,28,088,15,24,34,359,*79
    GPS -> $GPGLL,2612.44641,S,05241.75655,W,164339.00,A,A*6E
    GPS -> $GPRMC,164340.00,A,2612.44647,S,05241.75658,W,0.080,,211021,,,A*7B
    GPS -> $GPGGA,164340.00,2612.44647,S,05241.75658,W,1,05,4.72,813.0,M,4.2,M,,*66
    [00:00:04.252,075] <inf> lora_send: Data sent!
    [00:00:05.253,692] <inf> lora_send: Data sent!

  • The LoRa protocol is not our expertise. However, here are some thoughts:

    Have you tried the opposite, sending messages with LoRa ESP32 and receiving them on the nRF52840?

    Do you have two nRF52840 boards available so that you could test them together?

  • Regarding the first quote:

    Actually, it is in case of a hardware problem in the field.

    Let's say that SX1276 fails because of bad soldering or any other reason regarding production process (or even that the user broke it). It should be able to inform the user that there is a problem with this part of the device and still be able to do other stuff.

    It could inform the user via bluetooth, LEDs or other ways. But if the nRF52840 gets stuck, it will not be able to tell the user that there is a problem with the device.

    Regarding the second quote:

    I will try your suggestion as soon as I can. I have the dongle modules so I will wire up with another LoRa module and try it too.

  • 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>;
    };
    

Reply
  • 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>;
    };
    

Children
No Data
Related