Device tree configuration for SX1261 on a Insight 4520 SIP based on nRF52832

Hello,

I have a Insight ISP4520 SIp which include a nRF52832 chip and a SX1261 for Lora radio https://www.insightsip.com/products/combo-smart-modules/isp4520
The internal connection of the module are available in this pdf page 13 https://www.insightsip.com/fichiers_insightsip/pdf/ble/ISP4520/isp_lora_DS4520.pdf


I have sucessfully done the nordic academy beginner, BLE and intermediate courses (very interesting) on this chip.

Now I try to make the SX1261 working using this sample https://github.com/zephyrproject-rtos/zephyr/tree/main/samples/drivers/lora/send without success for the moment.

I got this log when running the sample :

[00:00:00.323,364] <dbg> sx126x: sx126x_lora_init: Initializing sx126x
[00:00:00.323,394] <dbg> sx126x: SX126xReset: Resetting radio
[00:00:00.353,576] <dbg> sx126x: SX126xIoIrqInit: Configuring DIO IRQ callback
--- 38 messages dropped ---
[00:00:00.358,795] <dbg> sx126x: SX126xWriteCommand: Issuing opcode 0x8b w. 4 bytes of data
[00:00:00.358,917] <dbg> sx126x: SX126xWriteCommand: Issuing opcode 0x8c w. 6 bytes of data
[00:00:00.359,069] <dbg> sx126x: SX126xReadRegisters: Reading 1 registers @ 0x889
[00:00:00.359,222] <dbg> sx126x: SX126xReadRegisters: register_value
                                 00                                               |.                
[00:00:00.359,222] <dbg> sx126x: SX126xWriteRegisters: Writing 1 registers @ 0x889: 0x4 , ...
[00:00:00.359,344] <dbg> sx126x: SX126xSetRfTxPower: power: 4
[00:00:00.359,375] <dbg> sx126x: SX126xWriteCommand: Issuing opcode 0x95 w. 4 bytes of data
[00:00:00.359,497] <dbg> sx126x: SX126xWriteCommand: Issuing opcode 0x8e w. 2 bytes of data
[00:00:00.359,619] <dbg> sx126x: SX126xWriteCommand: Issuing opcode 0x8a w. 1 bytes of data
[00:00:00.359,710] <dbg> sx126x: SX126xWriteRegisters: Writing 1 registers @ 0x740: 0x14 , ...
[00:00:00.359,832] <dbg> sx126x: SX126xWriteRegisters: Writing 1 registers @ 0x741: 0x24 , ...
[00:00:00.359,954] <dbg> sx126x: SX126xAntSwOff: No antenna switch configured
[00:00:00.359,985] <dbg> sx126x: SX126xWriteCommand: Issuing opcode 0x84 w. 1 bytes of data
[00:00:00.360,137] <dbg> sx126x: SX126xSetOperatingMode: SetOperatingMode: SLEEP (0)
[00:00:00.362,243] <dbg> sx126x: SX126xWriteCommand: Issuing opcode 0x8c w. 6 bytes of data
[00:00:00.362,274] <dbg> sx126x: SX126xWakeup: Sending GET_STATUS
[00:00:00.362,335] <dbg> sx126x: SX126xWakeup: Waiting for device...
[00:00:00.362,365] <dbg> sx126x: SX126xWakeup: Device ready
[00:00:00.362,396] <dbg> sx126x: SX126xAntSwOn: No antenna switch configured
[00:00:00.362,548] <dbg> sx126x: SX126xWriteCommand: Issuing opcode 0x8 w. 8 bytes of data
[00:00:00.362,701] <dbg> sx126x: SX126xWriteCommand: Issuing opcode 0x8c w. 6 bytes of data
[00:00:00.362,854] <dbg> sx126x: SX126xWriteBuffer: Writing buffers @ 0x0 (10 bytes)
[00:00:00.363,037] <dbg> sx126x: SX126xSetOperatingMode: SetOperatingMode: TX (4)
[00:00:00.363,067] <dbg> sx126x: SX126xWriteCommand: Issuing opcode 0x83 w. 3 bytes of data
[00:00:00.363,220] <dbg> sx12xx_common: sx12xx_lora_send: Expected air time of 10 bytes = 289ms
[00:00:00.941,314] <err> sx12xx_common: Packet transmission failed!
[00:00:00.941,345] <dbg> sx126x: SX126xAntSwOff: No antenna switch configured
[00:00:00.941,375] <dbg> sx126x: SX126xWriteCommand: Issuing opcode 0x84 w. 1 bytes of data
[00:00:00.941,497] <dbg> sx126x: SX126xSetOperatingMode: SetOperatingMode: SLEEP (0)
[00:00:00.943,572] <err> lora_send: LoRa send failed

Here is the device tree I tried to configure for the Lora0 device :

/ {
    aliases {
        lora0 = &lora0;
    };
};

&spi1 {
    compatible = "nordic,nrf-spi"; 
    status = "okay";
    pinctrl-0 = <&spi1_default>;
    pinctrl-1 = <&spi1_sleep>;
    pinctrl-names = "default", "sleep";
    cs-gpios = <&gpio0 24 GPIO_ACTIVE_LOW>;

    lora0: sx1261@0 {
    	compatible = "semtech,sx1261";
    	reg = <0>;

        spi-max-frequency = <1000000>; 
        dio1-gpios = <&gpio0 11 (GPIO_PUSH_PULL | GPIO_ACTIVE_HIGH)>;
        reset-gpios = <&gpio0 19 (GPIO_PUSH_PULL | GPIO_ACTIVE_LOW)>;
        busy-gpios = <&gpio0 27 (GPIO_PUSH_PULL | GPIO_ACTIVE_HIGH)>;
        dio2-tx-enable;
        dio3-tcxo-voltage = <7>;
    };
};

And the pinctrl :

&pinctrl {
    spi1_default: spi1_default {
        group1 {
            psels = <NRF_PSEL(SPIM_SCK, 0, 23)>,					 
                    <NRF_PSEL(SPIM_MOSI, 0, 26)>,
                    <NRF_PSEL(SPIM_MISO, 0, 25)>;
        };
    };
    spi1_sleep: spi1_sleep {
        group1 {
            psels = <NRF_PSEL(SPIM_SCK, 0, 23)>,
                    <NRF_PSEL(SPIM_MOSI, 0, 26)>,
                    <NRF_PSEL(SPIM_MISO, 0, 25)>;
            low-power-enable;
        };
    };
};

What is wrong with my device tree configuration ? And why I can use the the SPI0 ?

Many thanks by adavance and feel free to ask more details if needed.

Parents
  • Hi Vincent

    Which version of NCS are you using? Just by looking at the log I can't see anything that stands out in the devicetree, however I think you need to add the antenna-enable-gipo as seen in the semtech sx1262 shield  

    I will see if I can find any lora radio and try to replicate it on my part. 

    Regards

    Runar

  • Sorry for forgtotting the NCS version : I'm using the latest v2.8.0

    Here is a screenshot of my VS code window where you can see it is v2.8.0 :

    The SIP manufacturer (Insight) has a Github repo with some samples but they use the previous NCS version (v1.x.x) without using devicetree. 
    Please have a look to their repo here : https://github.com/insightsip/ISP4520-examples

    I also asked the manufacturer (french company) if they have the devicetree configuration for their SIP because they are the most placed people to write it due to the fact they are the deisgners of the SIP.

    I'm gonna have a look to the overlay you mentionned in your post.

    Thanks for your help !

  • Hi 
    Here's the overlay from my compiled code. As I used the shield I did not have to do anything regarding the overlay

    		spi2: arduino_spi: spi@40023000 {
    			compatible = "nordic,nrf-spi";
    			#address-cells = < 0x1 >;
    			#size-cells = < 0x0 >;
    			reg = < 0x40023000 0x1000 >;
    			interrupts = < 0x23 0x1 >;
    			max-frequency = < 0x7a1200 >;
    			easydma-maxcnt-bits = < 0x8 >;
    			status = "okay";
    			cs-gpios = < &arduino_header 0xd 0x1 >;
    			pinctrl-0 = < &spi2_default >;
    			pinctrl-1 = < &spi2_sleep >;
    			pinctrl-names = "default", "sleep";
    			lora_semtech_sx1262mb2das: sx1262@0 {
    				compatible = "semtech,sx1262";
    				reg = < 0x0 >;
    				spi-max-frequency = < 0xf42400 >;
    				label = "SX1262";
    				reset-gpios = < &arduino_header 0x0 0x1 >;
    				busy-gpios = < &arduino_header 0x9 0x0 >;
    				antenna-enable-gpios = < &arduino_header 0xe 0x0 >;
    				dio1-gpios = < &arduino_header 0xb 0x0 >;
    				dio2-tx-enable;
    				tcxo-power-startup-delay-ms = < 0x5 >;
    			};

    The log itself is nothing interesting at all really 

    *** Booting nRF Connect SDK v2.8.0-a2386bfc8401 ***
    *** Using Zephyr OS v3.7.99-0bc3393fb112 ***
    [00:00:00.810,699] <inf> lora_send: Data sent!
    [00:00:02.105,773] <inf> lora_send: Data sent!
    [00:00:03.400,817] <inf> lora_send: Data sent!
    [00:00:04.695,861] <inf> lora_send: Data sent!
    [00:00:05.990,905] <inf> lora_send: Data sent!
    [00:00:07.285,949] <inf> lora_send: Data sent!
    [00:00:08.580,993] <inf> lora_send: Data sent!
    

    Something just hit me. Do you use external LF crystal or the internal one? All our DK's have external crystals which is set in the config for the DK. If you don't have one you need to add 

    CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC=y
    Regards
    Runar
  • There is 2 crystals on SIP : 

    - Y1 is 32 Mhz 
    - Y2 is 32.768 kHz 

    So I think the Kconfig symbol CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC is not required in my case.

  • Update : something is going to work, I was able to send TXCW but I still have error sending Lora packet.

  • vincent_itk said:


    So I think the Kconfig symbol CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC is not required in my case.

    I agree. But just to verify, which board target do you use in your application? 

    vincent_itk said:
    : something is going to work, I was able to send TXCW but I still have error sending Lora packet

    Is it the same error you are seeing now?

    Regards

    Runar

  • Hello,

    But just to verify, which board target do you use in your application? 

    I use the ISP4520 DK (please have a look at the bottom of this page https://www.insightsip.com/products/combo-smart-modules/isp4520), which has not DTS provided.
    So I have to write my own DTS (which is a bit tricky when you know anything about devicetree).

    Is it the same error you are seeing now?

    No and there is no more error. I got the embbedded SX1261 working as you got (except you have a SX1262).

    I get rid of the error by disabling this symbol in my Kconfig file : 

    CONFIG_LOG_MODE_IMMEDIATE=y

    And this make sens : the SX1261 driver is logging much data, so this take some time to print them on UART and the printing time ate all the sending data exepected time so the IRQ was missed.
    Disabling the synchronous logging makes the system responding without timeout (and so working).

    And I think you can reproduce the bug on your boad by adding these symbols to your test project :

    CONFIG_LORA_LOG_LEVEL_DBG=y
    CONFIG_LOG_MODE_IMMEDIATE=y

    Please let me know if you go the same result - would be interesting.

    Anyway, many thanks for your help about this case.

Reply
  • Hello,

    But just to verify, which board target do you use in your application? 

    I use the ISP4520 DK (please have a look at the bottom of this page https://www.insightsip.com/products/combo-smart-modules/isp4520), which has not DTS provided.
    So I have to write my own DTS (which is a bit tricky when you know anything about devicetree).

    Is it the same error you are seeing now?

    No and there is no more error. I got the embbedded SX1261 working as you got (except you have a SX1262).

    I get rid of the error by disabling this symbol in my Kconfig file : 

    CONFIG_LOG_MODE_IMMEDIATE=y

    And this make sens : the SX1261 driver is logging much data, so this take some time to print them on UART and the printing time ate all the sending data exepected time so the IRQ was missed.
    Disabling the synchronous logging makes the system responding without timeout (and so working).

    And I think you can reproduce the bug on your boad by adding these symbols to your test project :

    CONFIG_LORA_LOG_LEVEL_DBG=y
    CONFIG_LOG_MODE_IMMEDIATE=y

    Please let me know if you go the same result - would be interesting.

    Anyway, many thanks for your help about this case.

Children
No Data
Related