This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nRF9160 Lora SPI

Dear Community;

We are trying to send data via Lora using a nRF9160. The Lora transreceiver we are using is a RFM95W(Semtech SX1272). There are samples of code to receive and send messages under /zephyr/samples/drivers/lora/ . I can open any of those prejects with SEGGER but not compile them. It pops up this error: 

"No default LoRa radio specified in DT"

We don´t know how to specify Lora device in DT, so far we have tried this in .overlay:

&spi3 { 
    compatible = "nordic,nrf-spim"; 
    status = "okay";
    sck-pin = <20>;
    mosi-pin = <21>;
    miso-pin = <22>;
    cs-gpios = <&gpio0 19 GPIO_ACTIVE_LOW>;
};

and this in prj.conf:

CONFIG_LOG=y
CONFIG_SPI=y
CONFIG_GPIO=y
CONFIG_LORA=y
CONFIG_LORA_SX12XX=y
CONFIG_PRINTK=y
CONFIG_SPI_3=y

Any help is appreciated.

Regards.

  • Hi,

     

    You need to define the sx12xx device in dts as well, similar like in this thread:

    https://devzone.nordicsemi.com/f/nordic-q-a/68747/board-nrf52dk_nrf52832-do-not-work-with-zephyr/291141#291141

     

    Could you try this and see if this works?

     

    Kind regards,

    Håkon

  • Hi,

    Thank you for your fast answer. We are using the Actinius Icarus nRF9160 board. If I have understood well the file to modified would be /boards/arm/actinius_icarus/actinius_icarus_ns.dts,  and there I need to add 

    		lora0 = &lora;

    and

    &spi3 {
    	compatible = "nordic,nrf-spi";
    	status = "okay";
    	sck-pin = <25>;
    	mosi-pin = <23>;
    	miso-pin = <24>;
    	cs-gpios = <&gpio0 22 GPIO_ACTIVE_LOW>;
    
    	lora: sx1276@0 {
    		compatible = "semtech,sx1276";
    		reg = <0>;
    		label = "sx1276";
    
    		dio-gpios = <&gpio0 13 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>,
    					<&gpio0 14 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>,
    					<&gpio0 15 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>,
    					<&gpio0 16 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>,
    					<&gpio0 29 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>;
    		reset-gpios = <&gpio0 3 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
    		rfo-enable-gpios		 = 	<&gpio0 30 GPIO_ACTIVE_HIGH>;
    		spi-max-frequency		 = 	<1000000>;
    		power-amplifier-output	 = "rfo";
    
    /*
    		rfi-enable-gpios			= <&gpio0 xx GPIO_ACTIVE_HIGH>;
    		power-amplifier-output		= "pa-boost";
    		pa-boost-enable-gpios		= <&gpio0 xx GPIO_ACTIVE_HIGH>;
    		antenna-enable-gpios		= <&gpio0 xx GPIO_ACTIVE_HIGH>;
    		tcxo-power-gpios			= <&gpio0 xx GPIO_ACTIVE_HIGH>;
    		tcxo-power-startup-delay-ms	= <5>;
    */
    	};
    };

    Right?

    Regards.

  • Hi,

     

    You could add this to your specific project instead of altering the board file.

    This is done by creating a file named $(BOARD).overlay (actinius_icarus_ns.overlay in your case), and placing it in your application folder (where your prj.conf also lies).

    Then add the specific overlay, in your case for &spi3.

     

    Kind regards,

    Håkon

  • Hi, 

    That makes more sense, however I was not sure...

    Now, I have in samples/drivers/lora/send this actinius_icarus_ns.overlay file:

    &uart0 {
        current-speed = <115200>;
        status = "okay";
        tx-pin = <23>;
        rx-pin = <24>;
    };
    
    &uart1 {
        status = "disabled";
    };
    
    &spi3 {
        compatible = "nordic,nrf-spi";
        status = "okay";
        sck-pin = <20>;
        mosi-pin = <21>;
        miso-pin = <22>;
        cs-gpios = <&gpio0 19 GPIO_ACTIVE_LOW>;
        lora: sx1276@0 {
    	compatible = "semtech,sx1276";
    	reg = <0>;
    	label = "sx1276";
    
    	dio-gpios = <&gpio0 13 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>,
    		<&gpio0 14 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>,
    		<&gpio0 15 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>,
    		<&gpio0 16 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>,
    		<&gpio0 29 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>;
    	reset-gpios = <&gpio0 3 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
    	rfo-enable-gpios		 = 	<&gpio0 30 GPIO_ACTIVE_HIGH>;
    	spi-max-frequency		 = 	<1000000>;
    	power-amplifier-output	 = "rfo";
    
    /*
    	rfi-enable-gpios			= <&gpio0 xx GPIO_ACTIVE_HIGH>;
    	power-amplifier-output		= "pa-boost";
    	pa-boost-enable-gpios		= <&gpio0 xx GPIO_ACTIVE_HIGH>;
    	antenna-enable-gpios		= <&gpio0 xx GPIO_ACTIVE_HIGH>;
    	tcxo-power-gpios			= <&gpio0 xx GPIO_ACTIVE_HIGH>;
    	tcxo-power-startup-delay-ms	= <5>;
    */
    	};
    };

    and this prj.conf:

    CONFIG_LOG=y
    CONFIG_SPI=y
    CONFIG_GPIO=y
    CONFIG_LORA=y
    CONFIG_LORA_SX12XX=y
    CONFIG_PRINTK=y
    CONFIG_SPI_3=y

    With that configuration I can´t even open the project with Segger:

    CMake Error at ../../../../cmake/extensions.cmake:398 (add_library):
      No SOURCES given to target: drivers__spi
    Call Stack (most recent call first):
      ../../../../cmake/extensions.cmake:375 (zephyr_library_named)
      ../../../../drivers/spi/CMakeLists.txt:3 (zephyr_library)
    
    
    
    error: cmake failed
    create_nordic_project.py failed (1)


    Regards.
  • Hi,

     

    My apologies. The nrf9160 (and nrf53-series) does not have the legacy "spi" module, so you need to specify it to be "nordic,nrf-spim" instead.

    The sample asks for "lora0" device, so we also need to provide an alias from "lora" to "lora0" in the overlay file.

    Here's an example .overlay that I used to test-compile this project:

    / {
    	aliases {
    		lora0 = &lora;
    	};
    };
    
    &uart0 {
        current-speed = <115200>;
        status = "okay";
        tx-pin = <23>;
        rx-pin = <24>;
    };
    
    &uart1 {
        status = "disabled";
    };
    
    &spi3 {
        compatible = "nordic,nrf-spim";
        status = "okay";
        sck-pin = <20>;
        mosi-pin = <21>;
        miso-pin = <22>;
        cs-gpios = <&gpio0 19 GPIO_ACTIVE_LOW>;
        lora: sx1276@0 {
    		compatible = "semtech,sx1276";
    		reg = <0>;
    		label = "sx1276";
    
    		dio-gpios = <&gpio0 13 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>,
    			<&gpio0 14 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>,
    			<&gpio0 15 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>,
    			<&gpio0 16 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>,
    			<&gpio0 29 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>;
    		reset-gpios = <&gpio0 3 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
    		rfo-enable-gpios		 = 	<&gpio0 30 GPIO_ACTIVE_HIGH>;
    		spi-max-frequency		 = 	<1000000>;
    		power-amplifier-output	 = "rfo";
    
    	/*
    		rfi-enable-gpios			= <&gpio0 xx GPIO_ACTIVE_HIGH>;
    		power-amplifier-output		= "pa-boost";
    		pa-boost-enable-gpios		= <&gpio0 xx GPIO_ACTIVE_HIGH>;
    		antenna-enable-gpios		= <&gpio0 xx GPIO_ACTIVE_HIGH>;
    		tcxo-power-gpios			= <&gpio0 xx GPIO_ACTIVE_HIGH>;
    		tcxo-power-startup-delay-ms	= <5>;
    	*/
    	};
    };
    

     

    Could you try this one and see if it works better at your end?

     

    Kind regards,

    Håkon

Related