Issues building sample LORA send project

Hello all NRF developers. I am newbie NRF developer, previously have worked with STM32 and ESP32 devices. The whole nRF and zephyr thing with device tree is still very new to me and I am just getting grasp of it.

My goal is to get he LoRa send/receive working using:
2x NRF52DK NRF52832 and 2x SX1278 LoRa module

I use VSCode NRF Connect extension.

I have done the following steps so far:

  1. Create a new application and and for Application template I select zephyr/samples/drivers/lora/send
    https://github.com/nrfconnect/sdk-zephyr/tree/main/samples/drivers/lora/send
  2. Create build configuration for my project and select nrf52dk_nrf52832 board
  3. I tried to build the project but it failed with the error message "No default LoRa radio specified in DT"

  4. From what I understand, I need to create board overlay and modify SPI property to include lora0, that is exactly what I have done:
    In my project folder, I have created board/nrf52dk_nrf52832.overlay file that contains:
     the following:
    &spi1 {
    	compatible = "nordic,nrf-spim";
    	status = "okay";
    	cs-gpios = <&gpio0 15 GPIO_ACTIVE_LOW>;
    	pinctrl-0 = <&spi1_default>;
    	pinctrl-1 = <&spi1_sleep>;
    	pinctrl-names = "default", "sleep";
    	lora0: sx1276@0 {
    		compatible = "semtech,sx1276";
    		reg = <0>;
    		reset-gpios = <&gpio0 13 GPIO_ACTIVE_LOW>;
    		dio-gpios = <&gpio0 24 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>,
    					<&gpio0 22 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>,
    					<&gpio0 17 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>;
    		power-amplifier-output = "pa-boost";
    		spi-max-frequency = <125000>;
    	};
    };


  5. Additionally, I have modified the  nrf52dk_nrf52832.dts in my C:\nrf\v2.4.0\boards\arm\nrf52dk_nrf52832 and added lora0 alias:
  6.  I try to build the project again but I am getting the following error:


-- Build files have been written to: D:/Programming/NRF/LORA_TEST/send/build
[1/14] Generating misc/generated/syscalls.json, misc/generated/struct_tags.json
[2/14] Generating linker_zephyr_pre0.cmd
[3/14] Generating linker_zephyr_pre1.cmd
[4/14] Linking C executable zephyr\zephyr_pre0.elf
FAILED: zephyr/zephyr_pre0.elf zephyr/zephyr_pre0.map
cmd.exe /C "cd . && C:\nrf\toolchains\31f4403e35\opt\zephyr-sdk\arm-zephyr-eabi\bin\arm-zephyr-eabi-gcc.exe -gdwarf-4 zephyr/CMakeFiles/zephyr_pre0.dir/misc/empty_file.c.obj -o zephyr\zephyr_pre0.elf -fuse-ld=bfd -Wl,-T zephyr/linker_zephyr_pre0.cmd -Wl,-Map=D:/Programming/NRF/LORA_TEST/send/build/zephyr/zephyr_pre0.map -Wl,--whole-archive app/libapp.a zephyr/libzephyr.a zephyr/arch/common/libarch__common.a zephyr/arch/arch/arm/core/aarch32/libarch__arm__core__aarch32.a zephyr/arch/arch/arm/core/aarch32/cortex_m/libarch__arm__core__aarch32__cortex_m.a zephyr/arch/arch/arm/core/aarch32/mpu/libarch__arm__core__aarch32__mpu.a zephyr/lib/libc/minimal/liblib__libc__minimal.a zephyr/soc/arm/common/cortex_m/libsoc__arm__common__cortex_m.a zephyr/soc/arm/nordic_nrf/nrf52/libsoc__arm__nordic_nrf__nrf52.a zephyr/drivers/clock_control/libdrivers__clock_control.a zephyr/drivers/console/libdrivers__console.a zephyr/drivers/gpio/libdrivers__gpio.a zephyr/drivers/lora/libloramac-node.a zephyr/drivers/pinctrl/libdrivers__pinctrl.a zephyr/drivers/serial/libdrivers__serial.a zephyr/drivers/spi/libdrivers__spi.a zephyr/drivers/timer/libdrivers__timer.a modules/nrf/lib/fatal_error/lib..__nrf__lib__fatal_error.a modules/hal_nordic/nrfx/libmodules__hal_nordic__nrfx.a modules/segger/libmodules__segger.a -Wl,--no-whole-archive zephyr/kernel/libkernel.a zephyr/CMakeFiles/offsets.dir/./arch/arm/core/offsets/offsets.c.obj -L"c:/nrf/toolchains/31f4403e35/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/thumb/v7e-m/nofp" -LD:/Programming/NRF/LORA_TEST/send/build/zephyr -lgcc zephyr/arch/common/libisr_tables.a -mcpu=cortex-m4 -mthumb -mabi=aapcs -Wl,--gc-sections -Wl,--build-id=none -Wl,--sort-common=descending -Wl,--sort-section=alignment -Wl,-u,_OffsetAbsSyms -Wl,-u,_ConfigAbsSyms -nostdlib -static -Wl,-X -Wl,-N -Wl,--orphan-handling=warn -Wl,-no-pie && cmd.exe /C "cd /D D:\Programming\NRF\LORA_TEST\send\build\zephyr && C:\nrf\toolchains\31f4403e35\opt\bin\cmake.exe -E echo ""
c:/nrf/toolchains/31f4403e35/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe: zephyr/drivers/lora/libloramac-node.a(sx127x.c.obj): in function `sx127x_read':
C:\nrf\v2.4.0\zephyr\drivers\lora\sx127x.c:422: undefined reference to `__device_dts_ord_107'
c:/nrf/toolchains/31f4403e35/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe: zephyr/drivers/lora/libloramac-node.a(sx127x.c.obj): in function `sx127x_lora_init':
C:\nrf\v2.4.0\zephyr\drivers\lora\sx127x.c:622: undefined reference to `__device_dts_ord_107'
c:/nrf/toolchains/31f4403e35/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe: zephyr/drivers/lora/libloramac-node.a(sx127x.c.obj): in function `sx127x_write':
C:\nrf\v2.4.0\zephyr\drivers\lora\sx127x.c:427: undefined reference to `__device_dts_ord_107'
c:/nrf/toolchains/31f4403e35/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe: zephyr/drivers/lora/libloramac-node.a(sx127x.c.obj):(.rodata.dev_config+0x0): undefined reference to `__device_dts_ord_107'
collect2.exe: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
FATAL ERROR: command exited with status 1: 'C:\nrf\toolchains\31f4403e35\opt\bin\cmake.EXE' --build 'd:\Programming\NRF\LORA_TEST\send\build'

What could be the cause of this issue and how to solve it? I am hoping to receive some advice and clarification on how to move forwards and build the lora sample projects.

You can access my project here:

https://github.com/krupis/nrf52_lora

Parents
  • Hi Lukas

    Could you revert the changes you have done to :\nrf\v2.4.0\boards\arm\nrf52dk_nrf52832.dts? We don't recommending changing the dts in the zephyr folders and rather use an overlay. This so that other projects are not affected by changes you do for this project. 

    I had a look through Zephyr's semtech bindings and could unfortuntly not find the 1278. However from the datasheet it looks like the Semtech 1278 is an 1276 with a narrower frequency band. So I would presume that we can use the same driver. So what we then need to do is to create a devicetree binding for the Semtech1278. Here is an simple example created by one of my collauges at support.  

    1. Create the folders structure dts/bindings inside your application folder

    2. Create the filde semtech,sx1278.yaml inside the bindings folder and populated it with the following

    description: Semtech SX1278 LoRa Modem
    
    compatible: "semtech,sx1278"
    
    include: semtech,sx127x-base.yaml
    

    3. Update your overlay to use the semtech 1278 radio

     

    Regards

    Runar

     

  • Thanks for your response.

    I have reverted all changes I have done to C:\nrf\v2.4.0\boards\arm\nrf52dk_nrf52832.dts and added alias to my .overlay instead.

    &spi1 {
    	compatible = "nordic,nrf-spim";
    	status = "okay";
    	cs-gpios = <&gpio0 15 GPIO_ACTIVE_LOW>;
    	pinctrl-0 = <&spi1_default>;
    	pinctrl-1 = <&spi1_sleep>;
    	pinctrl-names = "default", "sleep";
    	lora0: sx1276@0 {
    		compatible = "semtech,sx1276";
    		reg = <0>;
    		reset-gpios = <&gpio0 13 GPIO_ACTIVE_LOW>;
    		dio-gpios = <&gpio0 24 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>,
    					<&gpio0 22 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>,
    					<&gpio0 17 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>;
    		power-amplifier-output = "pa-boost";
    		spi-max-frequency = <125000>;
    	};
    };
    
    / {
         aliases {
                 lora0 = &lora0;
         };
    };
    

    Regarding creating device tree binding for sx1278, I dont think it is necessary at this stage of the project but I understand what you are talking about. I aggree it would make more sense to use sx1278 binding if I am using sx1278 hardware. But since changes between sx1278 and sx1276 are minor, I should be able to use sx1276 binding and get it to work with my sx1278 device as a temporary solution. 

    At this moment, I am more concerned about the other compilation issue I am having that I cannot wrap my head around:

    Please could you look at the compilation log that I have added to my initial posted. It complains about :

    undefined reference to `__device_dts_ord_107'

    I havent managed to find any useful information regarding this particular error. 

  • Hi, 

    I will look more into the case over the weekend. However the error you see is normally caused by errors in the devicetree, and that is why I wanted to create the correct binding, just to make sure it was not the problem. 

    The best help I can offer right now is to read this part https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/build/dts/troubleshooting.html 

    Regards

    Runar

  • It is not relevant at this point what binding I am trying to use since I am not even trying to physically flash the device at this point.  All I am trying to do at this stage is to compile sample lora project for any lora module, it could be sx1276 or even some other lora module. I am just simply trying to confirm if lora send sample project is working.

    For the time being, we can assume that I have sx1276 lora module and not sx1278. Lets forget everything I said about sx1278.

    Since this is a sample project provided by nRF sdk, and since I barely changed anything apart from adding the following to  the overlay,

    &spi1 {
    	compatible = "nordic,nrf-spim";
    	status = "okay";
    	cs-gpios = <&gpio0 15 GPIO_ACTIVE_LOW>;
    	pinctrl-0 = <&spi1_default>;
    	pinctrl-1 = <&spi1_sleep>;
    	pinctrl-names = "default", "sleep";
    	lora0: sx1276@0 {
    		compatible = "semtech,sx1276";
    		reg = <0>;
    		reset-gpios = <&gpio0 13 GPIO_ACTIVE_LOW>;
    		dio-gpios = <&gpio0 24 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>,
    					<&gpio0 22 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>,
    					<&gpio0 17 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>;
    		power-amplifier-output = "pa-boost";
    		spi-max-frequency = <125000>;
    	};
    };
    
    / {
         aliases {
                 lora0 = &lora0;
         };
    };
    

    I would expect this to be some kind of small issue that we are not seeing.

    Il read through what you have suggested and see what I can do.. I also hope I will be hearing back from you when you had some time to look through this issue. Thank you very much for your time.

  • I have managed to solve the issue. It was so silly! I have replaced:
    compatible = "nordic,nrf-spim";
    with 
    compatible = "nordic,nrf-spi";

    And that fixed the issue. I can now fully build the project without any compilation errors.


    I have one more little question that I want to clarify regarding device tree, bindings and properties. My current overlay:

    &spi1 {
    	compatible = "nordic,nrf-spi";
    	status = "okay";
    	cs-gpios = <&gpio0 15 GPIO_ACTIVE_LOW>;
    	pinctrl-0 = <&spi1_default>;
    	pinctrl-1 = <&spi1_sleep>;
    	pinctrl-names = "default", "sleep";
    	lora0: sx1276@0 {
    		compatible = "semtech,sx1276";
    		reg = <0>;
    		reset-gpios = <&gpio0 13 GPIO_ACTIVE_LOW>;
    		dio-gpios = <&gpio0 24 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>,
    					<&gpio0 22 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>,
    					<&gpio0 17 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>;
    		power-amplifier-output = "pa-boost";
    		spi-max-frequency = <125000>;
    	};
    };
    
    / {
         aliases {
                 lora0 = &lora0;
         };
    };
    

    I am not fully understanding what does pinctrl-0 and pinctrl-1 mean.

    I have opened C::\nrf\v2.4.0\boards\arm\nrf52dk_nrf52832-pinctrl.dtsi and I see the following:

    	spi1_default: spi1_default {
    		group1 {
    			psels = <NRF_PSEL(SPIM_SCK, 0, 31)>,
    				<NRF_PSEL(SPIM_MOSI, 0, 30)>,
    				<NRF_PSEL(SPIM_MISO, 0, 29)>;
    		};
    	};
    
    	spi1_sleep: spi1_sleep {
    		group1 {
    			psels = <NRF_PSEL(SPIM_SCK, 0, 31)>,
    				<NRF_PSEL(SPIM_MOSI, 0, 30)>,
    				<NRF_PSEL(SPIM_MISO, 0, 29)>;
    			low-power-enable;
    		};
    	};

    Does that mean that for the SPI, I should connect my lora module to the following pins:

    SCK - GPIO0 31

    MOSI - GPIO0 30

    MISO - GPIO0 29

Reply
  • I have managed to solve the issue. It was so silly! I have replaced:
    compatible = "nordic,nrf-spim";
    with 
    compatible = "nordic,nrf-spi";

    And that fixed the issue. I can now fully build the project without any compilation errors.


    I have one more little question that I want to clarify regarding device tree, bindings and properties. My current overlay:

    &spi1 {
    	compatible = "nordic,nrf-spi";
    	status = "okay";
    	cs-gpios = <&gpio0 15 GPIO_ACTIVE_LOW>;
    	pinctrl-0 = <&spi1_default>;
    	pinctrl-1 = <&spi1_sleep>;
    	pinctrl-names = "default", "sleep";
    	lora0: sx1276@0 {
    		compatible = "semtech,sx1276";
    		reg = <0>;
    		reset-gpios = <&gpio0 13 GPIO_ACTIVE_LOW>;
    		dio-gpios = <&gpio0 24 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>,
    					<&gpio0 22 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>,
    					<&gpio0 17 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>;
    		power-amplifier-output = "pa-boost";
    		spi-max-frequency = <125000>;
    	};
    };
    
    / {
         aliases {
                 lora0 = &lora0;
         };
    };
    

    I am not fully understanding what does pinctrl-0 and pinctrl-1 mean.

    I have opened C::\nrf\v2.4.0\boards\arm\nrf52dk_nrf52832-pinctrl.dtsi and I see the following:

    	spi1_default: spi1_default {
    		group1 {
    			psels = <NRF_PSEL(SPIM_SCK, 0, 31)>,
    				<NRF_PSEL(SPIM_MOSI, 0, 30)>,
    				<NRF_PSEL(SPIM_MISO, 0, 29)>;
    		};
    	};
    
    	spi1_sleep: spi1_sleep {
    		group1 {
    			psels = <NRF_PSEL(SPIM_SCK, 0, 31)>,
    				<NRF_PSEL(SPIM_MOSI, 0, 30)>,
    				<NRF_PSEL(SPIM_MISO, 0, 29)>;
    			low-power-enable;
    		};
    	};

    Does that mean that for the SPI, I should connect my lora module to the following pins:

    SCK - GPIO0 31

    MOSI - GPIO0 30

    MISO - GPIO0 29

Children
Related