Skip to content

LoRa: Initial integration of LoRa Basics Modem for LoRa API & SX126x and SX127x #89241

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

JordanYates
Copy link
Collaborator

@JordanYates JordanYates commented Apr 29, 2025

This PR contains the initial integration of LoRa Basics Modem (Semtech's replacement for LoRaMAC-node) with Zephyr.

To limit the scope, only the LoRa API is considered, and only the standalone SX126x and SX127x chipsets are ported.
The new drivers use the same devicetree definitions as the current drivers, so the only change required to use the updated drivers is CONFIG_LORA_MODULE_BACKEND_LORA_BASICS_MODEM=y.

Once this PR is merged, we can start to look at:

  • Basic LoRaWAN support
  • Other LoRa transceivers (stm32wl)

PR has been tested with the lora send and receive samples between a semtech_sx1262mb2das and semtech_sx1272mb2das shield in both directions.
The SX1262 transmitter, SX1272 receiver setup currently receives packets with ~10dB lower RSSI than the reverse, which I will continue to look into.

Issue for the creation of the module: #89251 (DONE).

Copy link

github-actions bot commented Apr 29, 2025

The following west manifest projects have changed revision in this Pull Request:

Name Old Revision New Revision Diff
lora-basics-modem 🆕 N/A (Added) zephyrproject-rtos/lora-basics-modem@9a14f67 (master) N/A

DNM label due to: 1 added project

Note: This message is automatically posted and updated by the Manifest GitHub Action.

@kartben kartben requested a review from Copilot April 29, 2025 08:52
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR integrates the LoRa Basics Modem into Zephyr for the LoRa API, providing initial support for the standalone SX126x and SX127x chipsets.

  • Added new header file (lbm_common.h) containing common data structures, enums, and function prototypes for modem configuration
  • Included an inline helper function for optional GPIO pin configuration
Files not reviewed (11)
  • boards/shields/semtech_sx1262mb2das/semtech_sx1262mb2das.overlay: Language not supported
  • doc/connectivity/lora_lorawan/index.rst: Language not supported
  • drivers/lora/CMakeLists.txt: Language not supported
  • drivers/lora/Kconfig: Language not supported
  • drivers/lora/lora_basics_modem/CMakeLists.txt: Language not supported
  • drivers/lora/lora_basics_modem/Kconfig: Language not supported
  • drivers/lora/loramac_node/CMakeLists.txt: Language not supported
  • modules/Kconfig: Language not supported
  • modules/lora_basics_modem/CMakeLists.txt: Language not supported
  • modules/lora_basics_modem/Kconfig: Language not supported
  • modules/lora_basics_modem/sx126x.cmake: Language not supported

@mathieuchopstm mathieuchopstm removed their request for review May 20, 2025 12:05
@mirzasadiqassb
Copy link

Hi @JordanYates,

I'm testing this PR (#89241) on a custom board with an SX1262 for basic LoRa with the send and receive samples. I'm seeing a fatal exception and "LoRa send failed, -22" (EINVAL). This does not happen with loramac-node driver.

My Setup:

  • Board: ESP32S3 with SX1262.
  • LoRa Usage: LoRa Send/Receive samples.
  • Zephyr Version: 4.1.99

Relevant prj.conf:

CONFIG_LOG=y
CONFIG_LORA=y
CONFIG_PRINTK=y
CONFIG_LORA_LOG_LEVEL_DBG=y
CONFIG_LORA_MODULE_BACKEND_LORA_BASICS_MODEM=y

Console Logs:

[00:00:00.217,000] <dbg> lbm_driver: sx126x_hal_read: CMD[0]=0x1d DATA_LEN=9
[00:00:00.217,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x0d DATA_LEN=9
--- 8 messages dropped ---
[00:00:00.219,000] <dbg> lbm_driver: sx126x_ensure_device_ready: SLEEP -> ACTIVE
--- 2 messages dropped ---
[00:00:00.219,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0xa0 DATA_LEN=0
[00:00:00.219,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x8a DATA_LEN=0
[00:00:00.219,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x86 DATA_LEN=0
[00:00:00.219,000] <dbg> lbm_driver: sx126x_hal_read: CMD[0]=0x1d DATA_LEN=1
[00:00:00.219,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x0d DATA_LEN=1
[00:00:00.220,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x95 DATA_LEN=0
[00:00:00.220,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x8e DATA_LEN=0
[00:00:00.220,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x8b DATA_LEN=0
[00:00:00.220,000] <dbg> lbm_driver: sx126x_hal_read: CMD[0]=0x1d DATA_LEN=1
[00:00:00.220,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x0d DATA_LEN=1
[00:00:00.220,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x8c DATA_LEN=0
[00:00:00.220,000] <dbg> lbm_driver: sx126x_hal_read: CMD[0]=0x1d DATA_LEN=1
[00:00:00.220,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x0d DATA_LEN=1
[00:00:00.221,000] <dbg> lbm_driver: sx126x_hal_read: CMD[0]=0x1d DATA_LEN=2
[00:00:00.221,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x0d DATA_LEN=2
[00:00:00.221,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x84 DATA_LEN=0
[00:00:00.221,000] <dbg> lbm_driver: sx126x_hal_write: ACTIVE -> SLEEP
[00:00:00.222,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x8c DATA_LEN=0
[00:00:00.222,000] <dbg> lbm_driver: sx126x_ensure_device_ready: SLEEP -> ACTIVE
[00:00:05.223,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x84 DATA_LEN=0
[00:00:10.224,000] <err> lora_send: LoRa send failed, -22

Request:
My application code is the same as the samples with the addition of the return code when it failed. It would be helpful to me if you could enlighten or help me regarding this? Thanks for your work on this!

@JordanYates
Copy link
Collaborator Author

Thanks for taking the time to try it out @mirzasadiqassb.

Based on the provided logs, it looks like the TX done interrupt is not being seen by the micro. This is interesting since the logic works on my SX1262 shield. Can you run the test again with the LOG_DBG in sx126x_hal_write and sx126x_hal_read commented out so we don't drop the other messages, and also provide your version of the SX1262 devicetree node?

@sophiekovalevsky
Copy link
Contributor

@JordanYates i will definitely give it a try on this but not during this week, for sure on next week.

@mirzasadiqassb
Copy link

Can you run the test again with the LOG_DBG in sx126x_hal_write and sx126x_hal_read commented out so we don't drop the other messages,

Here is the log when I commented out the LOG_DBG:

[00:00:00.187,000] <dbg> lbm_driver: sx126x_hal_reset: 
[00:00:00.217,000] <dbg> lbm_driver: sx126x_hal_write: ACTIVE -> SLEEP
*** Booting Zephyr OS build v4.1.0-2655-g2fd0ad6b8b6b ***
[00:00:00.218,000] <dbg> lbm_driver: sx126x_ensure_device_ready: SLEEP -> ACTIVE
[00:00:00.222,000] <dbg> lbm_driver: sx126x_hal_write: ACTIVE -> SLEEP
[00:00:00.223,000] <dbg> lbm_driver: sx126x_ensure_device_ready: SLEEP -> ACTIVE
[00:00:10.224,000] <err> lora_send: LoRa send failed, -22

and also provide your version of the SX1262 devicetree node?

And here is my SX1262 devicetree node:

lora0: lora@0 {
	compatible = "semtech,sx1262";
	reg = <0>;
	reset-gpios = <&gpio0 12 (GPIO_OPEN_DRAIN | GPIO_ACTIVE_LOW)>;
	busy-gpios = <&gpio0 13 GPIO_ACTIVE_HIGH>;
	dio1-gpios = <&gpio0 14 GPIO_ACTIVE_HIGH>;
	dio2-tx-enable;
	dio3-tcxo-voltage = <SX126X_DIO3_TCXO_1V8>;
	tcxo-power-startup-delay-ms = <5>;
	spi-max-frequency = <4000000>;
};

@JordanYates
Copy link
Collaborator Author

And here is my SX1262 devicetree node:

My best guess would be a problem related to the external TCXO configuration, which the MBed shield does not have. I should have access to hardware with an external TCXO in the next few weeks, so I can investigate further then.

Don't let that dissuade you from digging deeper if you want, I would appreciate any fixes :)

@sophiekovalevsky
Copy link
Contributor

Running some initials tests is indicating that everything is so far so good.

*** Booting Zephyr OS build v4.1.0-3301-g4d204c5de3c0 ***                                                                          
[00:00:00.296,295] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x9f DATA_LEN=0                                                      
[00:00:00.296,325] <dbg> lbm_driver: sx126x_ensure_device_ready: SLEEP -> ACTIVE                                                   
[00:00:00.297,576] <dbg> lbm[00:00:00.593,566] <dbg> lbm_driver: sx126x_dio1_callback:                                             
[00:00:00.593,627] <dbg> lbm_driver: op_done_work_handler: op_done_work_handler: 1                                                 
[00:00:00.593,627] <dbg> lbm_driver: sx126x_hal_read: CMD[0]=0x12 DATA_LEN=2                                                       
[00:00:00.593,780] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x02 DATA_LEN=0                                                      
[00:00:00.593,872] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x84 DATA_LEN=0                                                      
[00:00:00.593,963] <dbg> lbm_driver: sx126x_hal_write: ACTIVE -> SLEEP                                                             
[00:00:00.595,092] <inf> lora_send: Data sent 0!                                                                                   
[00:00:01.595,153] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x8c DATA_LEN=0                                                      
[00:00:01.595,184] <dbg> lbm_driver: sx126x_ensure_device_ready: SLEEP -> ACTIVE                                                   
[00:00:01.596,466] <dbg> lbm_driver: sx126x_hal_read: CMD[0]=0x1d DATA_LEN=1                                                       
[00:00:01.596,618] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x0d DATA_LEN=1                                                      
[00:00:01.596,740] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x8f DATA_LEN=0                                                      
[00:00:01.596,832] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x0e DATA_LEN=12                                                     
[00:00:01.597,045] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x83 DATA_LEN=0                                                      
[00:00:01.597,167] <dbg> lbm_driver: lbm_lora_send: Expected airtime: 289 ms                                                       
[00:00:01.886,138] <dbg> lbm_driver: sx126x_dio1_callback:                                                                         
[00:00:01.886,199] <dbg> lbm_driver: op_done_work_handler: op_done_work_handler: 1                                                 
[00:00:01.886,199] <dbg> lbm_driver: sx126x_hal_read: CMD[0]=0x12 DATA_LEN=2                                                       
[00:00:01.886,352] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x02 DATA_LEN=0                                                      
[00:00:01.886,444] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x84 DATA_LEN=0                                                      
[00:00:01.886,535] <dbg> lbm_driver: sx126x_hal_write: ACTIVE -> SLEEP                                                             
[00:00:01.887,664] <inf> lora_send: Data sent 1!                                                                                   
[00:00:02.887,756] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x8c DATA_LEN=0                                                      
[00:00:02.887,786] <dbg> lbm_driver: sx126x_ensure_device_ready: SLEEP -> ACTIVE                                                   
[00:00:02.889,068] <dbg> lbm_driver: sx126x_hal_read: CMD[0]=0x1d DATA_LEN=1                                                       
[00:00:02.889,190] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x0d DATA_LEN=1                                                      
[00:00:02.889,312] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x8f DATA_LEN=0                                                      
[00:00:02.889,434] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x0e DATA_LEN=12
[00:00:02.889,648] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x83 DATA_LEN=0
[00:00:02.889,739] <dbg> lbm_driver: lbm_lora_send: Expected airtime: 289 ms
[00:00:03.178,741] <dbg> lbm_driver: sx126x_dio1_callback: 
[00:00:03.178,771] <dbg> lbm_driver: op_done_work_handler: op_done_work_handler: 1
[00:00:03.178,802] <dbg> lbm_driver: sx126x_hal_read: CMD[0]=0x12 DATA_LEN=2
[00:00:03.178,924] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x02 DATA_LEN=0
[00:00:03.179,046] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x84 DATA_LEN=0
[00:00:03.179,138] <dbg> lbm_driver: sx126x_hal_write: ACTIVE -> SLEEP
[00:00:03.180,236] <inf> lora_send: Data sent 2!
[00:00:04.180,297] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x8c DATA_LEN=0
[00:00:04.180,328] <dbg> lbm_driver: sx126x_ensure_device_ready: SLEEP -> ACTIVE
[00:00:04.181,610] <dbg> lbm_driver: sx126x_hal_read: CMD[0]=0x1d DATA_LEN=1
[00:00:04.181,732] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x0d DATA_LEN=1
[00:00:04.181,854] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x8f DATA_LEN=0
[00:00:04.181,976] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x0e DATA_LEN=12
[00:00:04.182,189] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x83 DATA_LEN=0
[00:00:04.182,281] <dbg> lbm_driver: lbm_lora_send: Expected airtime: 289 ms
....
[00:10:01.627,563] <inf> lora_send: Data sent 5!
[00:10:02.627,624] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x8c DATA_LEN=0
[00:10:02.627,655] <dbg> lbm_driver: sx126x_ensure_device_ready: SLEEP -> ACTIVE
[00:10:02.628,936] <dbg> lbm_driver: sx126x_hal_read: CMD[0]=0x1d DATA_LEN=1
[00:10:02.629,058] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x0d DATA_LEN=1
[00:10:02.629,180] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x8f DATA_LEN=0
[00:10:02.629,302] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x0e DATA_LEN=12
[00:10:02.629,516] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x83 DATA_LEN=0
[00:10:02.629,608] <dbg> lbm_driver: lbm_lora_send: Expected airtime: 289 ms
[00:10:02.918,579] <dbg> lbm_driver: sx126x_dio1_callback: 
[00:10:02.918,640] <dbg> lbm_driver: op_done_work_handler: op_done_work_handler: 1
[00:10:02.918,670] <dbg> lbm_driver: sx126x_hal_read: CMD[0]=0x12 DATA_LEN=2
[00:10:02.918,792] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x02 DATA_LEN=0
[00:10:02.918,884] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x84 DATA_LEN=0
[00:10:02.918,975] <dbg> lbm_driver: sx126x_hal_write: ACTIVE -> SLEEP
[00:10:02.920,104] <inf> lora_send: Data sent 6!
[00:10:03.920,166] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x8c DATA_LEN=0
[00:10:03.920,196] <dbg> lbm_driver: sx126x_ensure_device_ready: SLEEP -> ACTIVE
[00:10:03.921,478] <dbg> lbm_driver: sx126x_hal_read: CMD[0]=0x1d DATA_LEN=1
[00:10:03.921,600] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x0d DATA_LEN=1
[00:10:03.921,722] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x8f DATA_LEN=0
[00:10:03.921,844] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x0e DATA_LEN=12
[00:10:03.922,058] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x83 DATA_LEN=0
[00:10:03.922,149] <dbg> lbm_driver: lbm_lora_send: Expected airtime: 289 ms
[00:10:04.211,120] <dbg> lbm_driver: sx126x_dio1_callback: 
[00:10:04.211,181] <dbg> lbm_driver: op_done_work_handler: op_done_work_handler: 1
[00:10:04.211,212] <dbg> lbm_driver: sx126x_hal_read: CMD[0]=0x12 DATA_LEN=2
[00:10:04.211,334] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x02 DATA_LEN=0
[00:10:04.211,456] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x84 DATA_LEN=0
[00:10:04.211,547] <dbg> lbm_driver: sx126x_hal_write: ACTIVE -> SLEEP
[00:10:04.212,646] <inf> lora_send: Data sent 7!
[00:10:05.212,707] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x8c DATA_LEN=0
[00:10:05.212,738] <dbg> lbm_driver: sx126x_ensure_device_ready: SLEEP -> ACTIVE
[00:10:05.214,019] <dbg> lbm_driver: sx126x_hal_read: CMD[0]=0x1d DATA_LEN=1
[00:10:05.214,141] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x0d DATA_LEN=1
[00:10:05.214,263] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x8f DATA_LEN=0
[00:10:05.214,385] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x0e DATA_LEN=12
[00:10:05.214,599] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x83 DATA_LEN=0
[00:10:05.214,691] <dbg> lbm_driver: lbm_lora_send: Expected airtime: 289 ms
[00:10:05.503,662] <dbg> lbm_driver: sx126x_dio1_callback: 
[00:10:05.503,723] <dbg> lbm_driver: op_done_work_handler: op_done_work_handler: 1
[00:10:05.503,753] <dbg> lbm_driver: sx126x_hal_read: CMD[0]=0x12 DATA_LEN=2
[00:10:05.503,875] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x02 DATA_LEN=0
[00:10:05.503,997] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x84 DATA_LEN=0

Tests have been made on a custom board featuring sx1262.

	lora: lora@0 {
		compatible = "semtech,sx1262";
		reg = <0>;
		reset-gpios = <&gpio0 19 GPIO_ACTIVE_LOW>;
		busy-gpios = <&gpio0 20 GPIO_ACTIVE_HIGH>;
		dio1-gpios = <&gpio0 21 GPIO_ACTIVE_HIGH>;
		antenna-enable-gpios = <&gpio0 23 GPIO_ACTIVE_HIGH>;
		dio2-tx-enable;
		tcxo-power-startup-delay-ms = <5>;
		spi-max-frequency = <1000000>;
	};

I just forgot to bring another extra board to completely test the tx/rx modes.

@sophiekovalevsky
Copy link
Contributor

Packets are arriving on receiver:

*** Booting Zephyr OS build v4.1.0-3301-g4d204c5de3c0 ***
[00:00:00.354,827] <inf> lora_receive: Synchronous reception
[00:01:10.010,498] <inf> lora_receive: LoRa RX RSSI: -52 dBm, SNR: 8 dB
[00:01:10.010,528] <inf> lora_receive: LoRa RX payload
                                       68 65 6c 6c 6f 77 6f 72  6c 64 20 30             |hellowor ld 0    
[00:01:11.303,070] <inf> lora_receive: LoRa RX RSSI: -52 dBm, SNR: 9 dB
[00:01:11.303,100] <inf> lora_receive: LoRa RX payload
                                       68 65 6c 6c 6f 77 6f 72  6c 64 20 31             |hellowor ld 1    
[00:01:12.595,642] <inf> lora_receive: LoRa RX RSSI: -52 dBm, SNR: 9 dB
[00:01:12.595,672] <inf> lora_receive: LoRa RX payload
                                       68 65 6c 6c 6f 77 6f 72  6c 64 20 32             |hellowor ld 2    
[00:01:13.888,153] <inf> lora_receive: LoRa RX RSSI: -52 dBm, SNR: 9 dB
[00:01:13.888,183] <inf> lora_receive: LoRa RX payload
                                       68 65 6c 6c 6f 77 6f 72  6c 64 20 33             |hellowor ld 3    
[00:01:13.888,183] <inf> lora_receive: Asynchronous reception
[00:01:15.179,931] <inf> lora_receive: LoRa RX RSSI: -52 dBm, SNR: 8 dB
[00:01:15.179,962] <inf> lora_receive: LoRa RX payload
                                       68 65 6c 6c 6f 77 6f 72  6c 64 20 34             |hellowor ld 4    
[00:01:16.472,503] <inf> lora_receive: LoRa RX RSSI: -52 dBm, SNR: 9 dB
[00:01:16.472,534] <inf> lora_receive: LoRa RX payload
                                       68 65 6c 6c 6f 77 6f 72  6c 64 20 35             |hellowor ld 5    
[00:01:17.765,014] <inf> lora_receive: LoRa RX RSSI: -52 dBm, SNR: 9 dB
[00:01:17.765,045] <inf> lora_receive: LoRa RX payload
                                       68 65 6c 6c 6f 77 6f 72  6c 64 20 36             |hellowor ld 6    
[00:01:19.057,617] <inf> lora_receive: LoRa RX RSSI: -52 dBm, SNR: 10 dB
[00:01:19.057,647] <inf> lora_receive: LoRa RX payload
                                       68 65 6c 6c 6f 77 6f 72  6c 64 20 37             |hellowor ld 7    
[00:01:20.350,128] <inf> lora_receive: LoRa RX RSSI: -52 dBm, SNR: 9 dB
[00:01:20.350,158] <inf> lora_receive: LoRa RX payload
                                       68 65 6c 6c 6f 77 6f 72  6c 64 20 38             |hellowor ld 8    
[00:01:21.642,669] <inf> lora_receive: LoRa RX RSSI: -52 dBm, SNR: 9 dB
[00:01:21.642,700] <inf> lora_receive: LoRa RX payload
                                       68 65 6c 6c 6f 77 6f 72  6c 64 20 39             |hellowor ld 9    
[00:01:22.935,211] <inf> lora_receive: LoRa RX RSSI: -52 dBm, SNR: 8 dB
[00:01:22.935,241] <inf> lora_receive: LoRa RX payload
                                       68 65 6c 6c 6f 77 6f 72  6c 64 20 30             |hellowor ld 0    
[00:01:24.227,722] <inf> lora_receive: LoRa RX RSSI: -52 dBm, SNR: 9 dB
[00:01:24.227,752] <inf> lora_receive: LoRa RX payload
                                       68 65 6c 6c 6f 77 6f 72  6c 64 20 31             |hellowor ld 1    
[00:01:25.520,263] <inf> lora_receive: LoRa RX RSSI: -52 dBm, SNR: 9 dB
[00:01:25.520,294] <inf> lora_receive: LoRa RX payload
                                       68 65 6c 6c 6f 77 6f 72  6c 64 20 32             |hellowor ld 2    
[00:01:26.812,774] <inf> lora_receive: LoRa RX RSSI: -52 dBm, SNR: 8 dB
[00:01:26.812,805] <inf> lora_receive: LoRa RX payload
                                       68 65 6c 6c 6f 77 6f 72  6c 64 20 33             |hellowor ld 3    
[00:01:26.812,805] <inf> lora_receive: Stopping packet receptions

Move the current implementation of the LoRa API using `loramac-node` to
a dedicated folder in preparation for the LoRa basics modem
implementation.

Signed-off-by: Jordan Yates <jordan@embeint.com>
Import the lora-basics-modem module as an alternate backend for LoRa
and LoRaWAN, since loramac-node has been deprecated.

Support is currently limited and experimental.

Signed-off-by: Jordan Yates <jordan@embeint.com>
@JordanYates
Copy link
Collaborator Author

PR updated with official Zephyr fork: https://github.com/zephyrproject-rtos/lora-basics-modem

@github-actions github-actions bot requested a review from MaureenHelm June 18, 2025 04:11
As a first integration of the LoRa Basics Modem backend, implement the
LoRa API for the standard SX126x/SX127x chips.

Much of the logic from `lbm_common.c` is taken from the loramac-node
`sx12xx_common` implementation, but it should now be agnostic for all
LoRa RF transceivers.

Signed-off-by: Jordan Yates <jordan@embeint.com>
Add testcases for `CONFIG_LORA_MODULE_BACKEND_LORA_BASICS_MODEM` in the
LoRa API samples.

Signed-off-by: Jordan Yates <jordan@embeint.com>
Document the current status of LoRaMAC-node and LoRa Basics Modem.

Signed-off-by: Jordan Yates <jordan@embeint.com>
@JordanYates
Copy link
Collaborator Author

@mirzasadiqassb I have found an issue with the TCXO startup delay handling and pushed a fix, it would be great if you could try again.

@mirzasadiqassb
Copy link

So I've just tested this PR on a board with a TCXO and a SX1262 definition that looks almost identical to yours Seeed-WIO and transmissions work fine.

	wio_sx1262: sx1262@2 {
		compatible = "semtech,sx1262";
		status = "okay";
		reg = <2>;
		spi-max-frequency = <4000000>;
		reset-gpios = <&gpio1 8 GPIO_ACTIVE_LOW>;
		busy-gpios = <&gpio1 14 GPIO_ACTIVE_HIGH>;
		antenna-enable-gpios = <&gpio0 4 GPIO_ACTIVE_HIGH>;
		dio1-gpios = <&gpio1 13 GPIO_ACTIVE_HIGH>;
		dio2-tx-enable;
		dio3-tcxo-voltage = <SX126X_DIO3_TCXO_1V8>;
		tcxo-power-startup-delay-ms = <5>;
	};

Huh, that's weird. For your reference I am using this board Heltec Wi-Fi Lora32 (V3). When I dig further I found out that my board got stuck during the sx126x_set_lora_pkt_params().

Here is the log:

I (142) spi_flash: flash io: dio
W (142) spi_flash: Detected size(8192k) larger than the size in the binary image header(4096k). Using the size in the binary image header.
--->sx126x_reset called
[00:00:00.187,000] <dbg> lbm_driver: sx126x_hal_reset: 
--->sx126x_init_retention_list called
--->sx126x_read_register called
[00:00:00.217,000] <dbg> lbm_driver: sx126x_hal_read: CMD[0]=0x1d DATA_LEN=9
--->sx126x_write_register called
[00:00:00.217,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x0d DATA_LEN=9
--->sx126x_set_reg_mode called
[00:00:00.217,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x96 DATA_LEN=0
--->sx126x_set_dio2_as_rf_sw_ctrl called
[00:00:00.217,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x9d DATA_LEN=0
--->sx126x_convert_timeout_in_ms_to_rtc_step called
--->sx126x_set_dio3_as_tcxo_ctrl called
[00:00:00.217,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x97 DATA_LEN=0
--->sx126x_cal called
[00:00:00.217,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x89 DATA_LEN=0
--->sx126x_cfg_rx_boosted called
--->sx126x_write_register called
[00:00:00.217,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x0d DATA_LEN=1
--->sx126x_set_dio_irq_params called
[00:00:00.218,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x08 DATA_LEN=0
--->sx126x_set_standby called
[00:00:00.218,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x80 DATA_LEN=0
--->sx126x_set_sleep called
[00:00:00.218,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x84 DATA_LEN=0
[00:00:00.218,000] <dbg> lbm_driver: sx126x_hal_write: ACTIVE -> SLEEP
*** Booting Zephyr OS build v4.1.0-2655-g2fd0ad6b8b6b ***
--->sx126x_stop_timer_on_preamble called
[00:00:00.219,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x9f DATA_LEN=0
[00:00:00.219,000] <dbg> lbm_driver: sx126x_ensure_device_ready: SLEEP -> ACTIVE
--->sx126x_set_lora_symb_nb_timeout called
[00:00:00.219,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0xa0 DATA_LEN=0
--->sx126x_set_pkt_type called
[00:00:00.219,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x8a DATA_LEN=0
--->sx126x_set_rf_freq called
--->sx126x_convert_freq_in_hz_to_pll_step called
--->sx126x_set_rf_freq_in_pll_steps called
[00:00:00.219,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x86 DATA_LEN=0
--->sx126x_cfg_tx_clamp called
--->sx126x_read_register called
[00:00:00.219,000] <dbg> lbm_driver: sx126x_hal_read: CMD[0]=0x1d DATA_LEN=1
--->sx126x_write_register called
[00:00:00.219,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x0d DATA_LEN=1
--->sx126x_set_pa_cfg called
[00:00:00.219,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x95 DATA_LEN=0
--->sx126x_set_tx_params called
[00:00:00.219,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x8e DATA_LEN=0
--->sx126x_set_lora_mod_params called
[00:00:00.219,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x8b DATA_LEN=0
--->sx126x_tx_modulation_workaround called
--->sx126x_read_register called
[00:00:00.219,000] <dbg> lbm_driver: sx126x_hal_read: CMD[0]=0x1d DATA_LEN=1
--->sx126x_write_register called
[00:00:00.219,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x0d DATA_LEN=1
--->sx126x_set_lora_pkt_params called
[00:00:00.219,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x8c DATA_LEN=0
--->sx126x_read_register called
[00:00:00.219,000] <dbg> lbm_driver: sx126x_hal_read: CMD[0]=0x1d DATA_LEN=1
--->sx126x_write_register called
[00:00:00.219,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x0d DATA_LEN=1
--->sx126x_set_lora_sync_word called
--->sx126x_read_register called
[00:00:00.220,000] <dbg> lbm_driver: sx126x_hal_read: CMD[0]=0x1d DATA_LEN=2
--->sx126x_write_register called
[00:00:00.221,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x0d DATA_LEN=2
--->sx126x_set_sleep called
[00:00:00.221,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x84 DATA_LEN=0
[00:00:00.221,000] <dbg> lbm_driver: sx126x_hal_write: ACTIVE -> SLEEP
--->sx126x_set_lora_pkt_params called
[00:00:00.222,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x8c DATA_LEN=0
[00:00:00.222,000] <dbg> lbm_driver: sx126x_ensure_device_ready: SLEEP -> ACTIVE
[00:00:05.222,000] <err> lbm_driver: DEVICE NOT READY FOR WRITE
--->sx126x_set_sleep called
[00:00:05.222,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x84 DATA_LEN=0
[00:00:10.223,000] <err> lbm_driver: DEVICE NOT READY FOR WRITE
[00:00:10.223,000] <err> lbm_driver: lbm_lora_send_async fail status: -22
[00:00:10.223,000] <err> lora_send: LoRa send failed

After further investigation, I found that adding ral_set_standby() in lbm_lora_config(), just before releasing the modem, allowed me to get past the previous issue. However, DIO1 is still never triggered, which causes the LoRa send to fail.

Here’s the log:

I (142) spi_flash: flash io: dio
W (142) spi_flash: Detected size(8192k) larger than the size in the binary image header(4096k). Using the size in the binary image header.
--->sx126x_reset called
[00:00:00.187,000] <dbg> lbm_driver: sx126x_hal_reset: 
--->sx126x_init_retention_list called
--->sx126x_read_register called
[00:00:00.217,000] <dbg> lbm_driver: sx126x_hal_read: CMD[0]=0x1d DATA_LEN=9
--->sx126x_write_register called
[00:00:00.217,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x0d DATA_LEN=9
--->sx126x_set_reg_mode called
[00:00:00.217,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x96 DATA_LEN=0
--->sx126x_set_dio2_as_rf_sw_ctrl called
[00:00:00.217,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x9d DATA_LEN=0
--->sx126x_convert_timeout_in_ms_to_rtc_step called
--->sx126x_set_dio3_as_tcxo_ctrl called
[00:00:00.217,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x97 DATA_LEN=0
--->sx126x_cal called
[00:00:00.217,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x89 DATA_LEN=0
--->sx126x_cfg_rx_boosted called
--->sx126x_write_register called
[00:00:00.217,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x0d DATA_LEN=1
--->sx126x_set_dio_irq_params called
[00:00:00.218,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x08 DATA_LEN=0
--->sx126x_set_standby called
[00:00:00.218,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x80 DATA_LEN=0
--->sx126x_set_sleep called
[00:00:00.218,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x84 DATA_LEN=0
[00:00:00.218,000] <dbg> lbm_driver: sx126x_hal_write: ACTIVE -> SLEEP
*** Booting Zephyr OS build v4.1.0-2655-g2fd0ad6b8b6b ***
--->sx126x_stop_timer_on_preamble called
[00:00:00.219,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x9f DATA_LEN=0
[00:00:00.219,000] <dbg> lbm_driver: sx126x_ensure_device_ready: SLEEP -> ACTIVE
--->sx126x_set_lora_symb_nb_timeout called
[00:00:00.219,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0xa0 DATA_LEN=0
--->sx126x_set_pkt_type called
[00:00:00.219,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x8a DATA_LEN=0
--->sx126x_set_rf_freq called
--->sx126x_convert_freq_in_hz_to_pll_step called
--->sx126x_set_rf_freq_in_pll_steps called
[00:00:00.219,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x86 DATA_LEN=0
--->sx126x_cfg_tx_clamp called
--->sx126x_read_register called
[00:00:00.219,000] <dbg> lbm_driver: sx126x_hal_read: CMD[0]=0x1d DATA_LEN=1
--->sx126x_write_register called
[00:00:00.219,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x0d DATA_LEN=1
--->sx126x_set_pa_cfg called
[00:00:00.219,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x95 DATA_LEN=0
--->sx126x_set_tx_params called
[00:00:00.219,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x8e DATA_LEN=0
--->sx126x_set_lora_mod_params called
[00:00:00.219,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x8b DATA_LEN=0
--->sx126x_tx_modulation_workaround called
--->sx126x_read_register called
[00:00:00.219,000] <dbg> lbm_driver: sx126x_hal_read: CMD[0]=0x1d DATA_LEN=1
--->sx126x_write_register called
[00:00:00.219,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x0d DATA_LEN=1
--->sx126x_set_lora_pkt_params called
[00:00:00.219,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x8c DATA_LEN=0
--->sx126x_read_register called
[00:00:00.219,000] <dbg> lbm_driver: sx126x_hal_read: CMD[0]=0x1d DATA_LEN=1
--->sx126x_write_register called
[00:00:00.219,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x0d DATA_LEN=1
--->sx126x_set_lora_sync_word called
--->sx126x_read_register called
[00:00:00.220,000] <dbg> lbm_driver: sx126x_hal_read: CMD[0]=0x1d DATA_LEN=2
--->sx126x_write_register called
[00:00:00.221,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x0d DATA_LEN=2
--->sx126x_set_standby called
[00:00:00.221,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x80 DATA_LEN=0
--->sx126x_set_sleep called
[00:00:00.221,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x84 DATA_LEN=0
[00:00:00.221,000] <dbg> lbm_driver: sx126x_hal_write: ACTIVE -> SLEEP
--->sx126x_set_lora_pkt_params called
[00:00:00.222,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x8c DATA_LEN=0
[00:00:00.222,000] <dbg> lbm_driver: sx126x_ensure_device_ready: SLEEP -> ACTIVE
--->sx126x_read_register called
[00:00:00.223,000] <dbg> lbm_driver: sx126x_hal_read: CMD[0]=0x1d DATA_LEN=1
--->sx126x_write_register called
[00:00:00.223,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x0d DATA_LEN=1
--->sx126x_set_buffer_base_address called
[00:00:00.224,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x8f DATA_LEN=0
--->sx126x_write_buffer called
[00:00:00.224,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x0e DATA_LEN=10
--->sx126x_convert_timeout_in_ms_to_rtc_step called
--->sx126x_set_tx called
--->sx126x_convert_timeout_in_ms_to_rtc_step called
--->sx126x_set_tx_with_timeout_in_rtc_step called
[00:00:00.224,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x83 DATA_LEN=0
[00:00:00.224,000] <dbg> lbm_driver: sx126x_hal_write: TX SET
[00:00:00.224,000] <dbg> lbm_driver: sx126x_hal_write: DIO1 level: 0
--->sx126x_get_lora_time_on_air_in_ms called
--->sx126x_get_lora_time_on_air_numerator called
--->sx126x_get_lora_bw_in_hz called
[00:00:00.224,000] <dbg> lbm_driver: lbm_lora_send: Expected airtime: 289 ms
--->sx126x_set_sleep called
[00:00:00.802,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x84 DATA_LEN=0
[00:00:00.802,000] <dbg> lbm_driver: sx126x_hal_write: ACTIVE -> SLEEP
[00:00:00.803,000] <err> lbm_driver: Packet transmission failed!
[00:00:00.803,000] <err> lora_send: LoRa send failed

Also, I’m not sure if this could be related, but could you share your SPI devicetree node just in case?

@JordanYates
Copy link
Collaborator Author

Huh, that's weird. For your reference I am using this board Heltec Wi-Fi Lora32 (V3). When I dig further I found out that my board got stuck during the sx126x_set_lora_pkt_params().

Please disregard my original message finding no issue (I deleted it), I did find issues when I tested again (maybe I still had configuration from the loramac-node implementation applied).

If you could try with the PR as of my push 10 minutes ago that would be helpful.

Copy link

@kartben
Copy link
Collaborator

kartben commented Jun 18, 2025

@JordanYates should this be labeled as "4.2"?

@mirzasadiqassb
Copy link

If you could try with the PR as of my push 10 minutes ago that would be helpful.

I did try again with your newest push. However, the problem is still the same as before. Not sure what went wrong.

Here is the log:

I (142) spi_flash: flash io: dio
W (142) spi_flash: Detected size(8192k) larger than the size in the binary image header(4096k). Using the size in the binary image header.
--->sx126x_reset called
[00:00:00.187,000] <dbg> lbm_driver: sx126x_hal_reset: 
--->sx126x_init_retention_list called
--->sx126x_read_register called
[00:00:00.217,000] <dbg> lbm_driver: sx126x_hal_read: CMD[0]=0x1d DATA_LEN=9
--->sx126x_write_register called
[00:00:00.217,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x0d CMD_LEN=3 DATA_LEN=9
--->sx126x_set_reg_mode called
[00:00:00.217,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x96 CMD_LEN=2 DATA_LEN=0
--->sx126x_set_dio2_as_rf_sw_ctrl called
[00:00:00.217,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x9d CMD_LEN=2 DATA_LEN=0
--->sx126x_convert_timeout_in_ms_to_rtc_step called
--->sx126x_set_dio3_as_tcxo_ctrl called
[00:00:00.217,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x97 CMD_LEN=5 DATA_LEN=0
--->sx126x_cal called
[00:00:00.217,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x89 CMD_LEN=2 DATA_LEN=0
--->sx126x_cfg_rx_boosted called
--->sx126x_write_register called
[00:00:00.217,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x0d CMD_LEN=3 DATA_LEN=1
--->sx126x_set_dio_irq_params called
[00:00:00.218,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x08 CMD_LEN=9 DATA_LEN=0
--->sx126x_set_standby called
[00:00:00.218,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x80 CMD_LEN=2 DATA_LEN=0
--->sx126x_set_sleep called
[00:00:00.218,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x84 CMD_LEN=2 DATA_LEN=0
[00:00:00.218,000] <dbg> lbm_driver: sx126x_hal_write: ACTIVE -> SLEEP
*** Booting Zephyr OS build v4.1.0-2655-g2fd0ad6b8b6b ***
--->sx126x_stop_timer_on_preamble called
[00:00:00.219,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x9f CMD_LEN=2 DATA_LEN=0
[00:00:00.219,000] <dbg> lbm_driver: sx126x_ensure_device_ready: SLEEP -> ACTIVE
--->sx126x_set_lora_symb_nb_timeout called
[00:00:00.219,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0xa0 CMD_LEN=2 DATA_LEN=0
--->sx126x_set_pkt_type called
[00:00:00.219,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x8a CMD_LEN=2 DATA_LEN=0
--->sx126x_set_rf_freq called
--->sx126x_convert_freq_in_hz_to_pll_step called
--->sx126x_set_rf_freq_in_pll_steps called
[00:00:00.219,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x86 CMD_LEN=5 DATA_LEN=0
--->sx126x_cfg_tx_clamp called
--->sx126x_read_register called
[00:00:00.219,000] <dbg> lbm_driver: sx126x_hal_read: CMD[0]=0x1d DATA_LEN=1
--->sx126x_write_register called
[00:00:00.219,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x0d CMD_LEN=3 DATA_LEN=1
--->sx126x_set_pa_cfg called
[00:00:00.219,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x95 CMD_LEN=5 DATA_LEN=0
--->sx126x_set_tx_params called
[00:00:00.219,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x8e CMD_LEN=3 DATA_LEN=0
--->sx126x_set_lora_mod_params called
[00:00:00.219,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x8b CMD_LEN=5 DATA_LEN=0
--->sx126x_tx_modulation_workaround called
--->sx126x_read_register called
[00:00:00.219,000] <dbg> lbm_driver: sx126x_hal_read: CMD[0]=0x1d DATA_LEN=1
--->sx126x_write_register called
[00:00:00.219,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x0d CMD_LEN=3 DATA_LEN=1
--->sx126x_set_lora_pkt_params called
[00:00:00.219,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x8c CMD_LEN=7 DATA_LEN=0
--->sx126x_read_register called
[00:00:00.219,000] <dbg> lbm_driver: sx126x_hal_read: CMD[0]=0x1d DATA_LEN=1
--->sx126x_write_register called
[00:00:00.219,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x0d CMD_LEN=3 DATA_LEN=1
--->sx126x_set_lora_sync_word called
--->sx126x_read_register called
[00:00:00.220,000] <dbg> lbm_driver: sx126x_hal_read: CMD[0]=0x1d DATA_LEN=2
--->sx126x_write_register called
[00:00:00.221,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x0d CMD_LEN=3 DATA_LEN=2
--->sx126x_set_sleep called
[00:00:00.221,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x84 CMD_LEN=2 DATA_LEN=0
[00:00:00.221,000] <dbg> lbm_driver: sx126x_hal_write: ACTIVE -> SLEEP
--->sx126x_set_lora_pkt_params called
[00:00:00.222,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x8c CMD_LEN=7 DATA_LEN=0
[00:00:00.222,000] <dbg> lbm_driver: sx126x_ensure_device_ready: SLEEP -> ACTIVE
[00:00:01.223,000] <err> lbm_driver: DEVICE NOT READY FOR WRITE
--->sx126x_set_sleep called
[00:00:01.223,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x84 CMD_LEN=2 DATA_LEN=0
[00:00:02.224,000] <err> lbm_driver: DEVICE NOT READY FOR WRITE
[00:00:02.224,000] <err> lbm_driver: lbm_lora_send_async fail status: -22
[00:00:02.224,000] <err> lora_send: LoRa send failed

@JordanYates
Copy link
Collaborator Author

@JordanYates should this be labeled as "4.2"?

That depends on whether we can get enough reviews and resolve the observed issues.
I would guess that the feature freeze is too soon to make it in.

@kartben
Copy link
Collaborator

kartben commented Jun 18, 2025

OK, fair, and thanks!

@JordanYates
Copy link
Collaborator Author

I did try again with your newest push. However, the problem is still the same as before. Not sure what went wrong.
Here is the log:

What check is failing to output the DEVICE NOT READY FOR WRITE message? I'm guessing you added it since its not part of this PR.

@mirzasadiqassb
Copy link

What check is failing to output the DEVICE NOT READY FOR WRITE message? I'm guessing you added it since its not part of this PR.

Yup I added it inside sx126x_hal_write()

	LOG_DBG("CMD[0]=0x%02x CMD_LEN=%d DATA_LEN=%d", command[0], command_length, data_length);

	ret = sx126x_ensure_device_ready(dev, K_SECONDS(1));
	if (ret) {
		LOG_ERR("DEVICE NOT READY FOR WRITE");
		return SX126X_HAL_STATUS_ERROR;
	}
	

I notice that this is during the lbm_lora_config() inside ralf_setup_lora(). Only after I added ral_set_standby() right before modem release that I get past it:

	status = ralf_setup_lora(&config->ralf, &params);
	ret = status == RAL_STATUS_OK ? 0 : -EIO;

	/* -> Set Standby*/
	status = ral_set_standby(&config->ralf.ral, RAL_STANDBY_CFG_RC);
	if (status != RAL_STATUS_OK) {
		LOG_ERR("RAL set standby fail (%d)", status);
		return -EIO;
	}

release:
	modem_release(dev);
	return ret;

However, DIO1 still never triggered for me:

I (142) spi_flash: flash io: dio
W (142) spi_flash: Detected size(8192k) larger than the size in the binary image header(4096k). Using the size in the binary image header.
--->sx126x_reset called
[00:00:00.187,000] <dbg> lbm_driver: sx126x_hal_reset: 
--->sx126x_init_retention_list called
--->sx126x_read_register called
[00:00:00.217,000] <dbg> lbm_driver: sx126x_hal_read: CMD[0]=0x1d DATA_LEN=9
--->sx126x_write_register called
[00:00:00.217,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x0d CMD_LEN=3 DATA_LEN=9
--->sx126x_set_reg_mode called
[00:00:00.217,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x96 CMD_LEN=2 DATA_LEN=0
--->sx126x_set_dio2_as_rf_sw_ctrl called
[00:00:00.217,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x9d CMD_LEN=2 DATA_LEN=0
--->sx126x_convert_timeout_in_ms_to_rtc_step called
--->sx126x_set_dio3_as_tcxo_ctrl called
[00:00:00.217,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x97 CMD_LEN=5 DATA_LEN=0
--->sx126x_cal called
[00:00:00.217,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x89 CMD_LEN=2 DATA_LEN=0
--->sx126x_cfg_rx_boosted called
--->sx126x_write_register called
[00:00:00.217,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x0d CMD_LEN=3 DATA_LEN=1
--->sx126x_set_dio_irq_params called
[00:00:00.218,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x08 CMD_LEN=9 DATA_LEN=0
--->sx126x_set_standby called
[00:00:00.218,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x80 CMD_LEN=2 DATA_LEN=0
--->sx126x_set_sleep called
[00:00:00.218,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x84 CMD_LEN=2 DATA_LEN=0
[00:00:00.218,000] <dbg> lbm_driver: sx126x_hal_write: ACTIVE -> SLEEP
*** Booting Zephyr OS build v4.1.0-2655-g2fd0ad6b8b6b ***
--->sx126x_stop_timer_on_preamble called
[00:00:00.219,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x9f CMD_LEN=2 DATA_LEN=0
[00:00:00.219,000] <dbg> lbm_driver: sx126x_ensure_device_ready: SLEEP -> ACTIVE
--->sx126x_set_lora_symb_nb_timeout called
[00:00:00.219,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0xa0 CMD_LEN=2 DATA_LEN=0
--->sx126x_set_pkt_type called
[00:00:00.219,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x8a CMD_LEN=2 DATA_LEN=0
--->sx126x_set_rf_freq called
--->sx126x_convert_freq_in_hz_to_pll_step called
--->sx126x_set_rf_freq_in_pll_steps called
[00:00:00.219,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x86 CMD_LEN=5 DATA_LEN=0
--->sx126x_cfg_tx_clamp called
--->sx126x_read_register called
[00:00:00.219,000] <dbg> lbm_driver: sx126x_hal_read: CMD[0]=0x1d DATA_LEN=1
--->sx126x_write_register called
[00:00:00.219,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x0d CMD_LEN=3 DATA_LEN=1
--->sx126x_set_pa_cfg called
[00:00:00.219,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x95 CMD_LEN=5 DATA_LEN=0
--->sx126x_set_tx_params called
[00:00:00.219,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x8e CMD_LEN=3 DATA_LEN=0
--->sx126x_set_lora_mod_params called
[00:00:00.219,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x8b CMD_LEN=5 DATA_LEN=0
--->sx126x_tx_modulation_workaround called
--->sx126x_read_register called
[00:00:00.219,000] <dbg> lbm_driver: sx126x_hal_read: CMD[0]=0x1d DATA_LEN=1
--->sx126x_write_register called
[00:00:00.219,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x0d CMD_LEN=3 DATA_LEN=1
--->sx126x_set_lora_pkt_params called
[00:00:00.219,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x8c CMD_LEN=7 DATA_LEN=0
--->sx126x_read_register called
[00:00:00.219,000] <dbg> lbm_driver: sx126x_hal_read: CMD[0]=0x1d DATA_LEN=1
--->sx126x_write_register called
[00:00:00.219,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x0d CMD_LEN=3 DATA_LEN=1
--->sx126x_set_lora_sync_word called
--->sx126x_read_register called
[00:00:00.220,000] <dbg> lbm_driver: sx126x_hal_read: CMD[0]=0x1d DATA_LEN=2
--->sx126x_write_register called
[00:00:00.221,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x0d CMD_LEN=3 DATA_LEN=2
--->sx126x_set_standby called
[00:00:00.221,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x80 CMD_LEN=2 DATA_LEN=0
--->sx126x_set_sleep called
[00:00:00.221,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x84 CMD_LEN=2 DATA_LEN=0
[00:00:00.221,000] <dbg> lbm_driver: sx126x_hal_write: ACTIVE -> SLEEP
--->sx126x_set_lora_pkt_params called
[00:00:00.222,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x8c CMD_LEN=7 DATA_LEN=0
[00:00:00.222,000] <dbg> lbm_driver: sx126x_ensure_device_ready: SLEEP -> ACTIVE
--->sx126x_read_register called
[00:00:00.223,000] <dbg> lbm_driver: sx126x_hal_read: CMD[0]=0x1d DATA_LEN=1
--->sx126x_write_register called
[00:00:00.223,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x0d CMD_LEN=3 DATA_LEN=1
--->sx126x_set_buffer_base_address called
[00:00:00.224,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x8f CMD_LEN=3 DATA_LEN=0
--->sx126x_write_buffer called
[00:00:00.224,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x0e CMD_LEN=2 DATA_LEN=10
--->sx126x_convert_timeout_in_ms_to_rtc_step called
--->sx126x_set_tx called
--->sx126x_convert_timeout_in_ms_to_rtc_step called
--->sx126x_set_tx_with_timeout_in_rtc_step called
[00:00:00.224,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x83 CMD_LEN=4 DATA_LEN=0
[00:00:00.224,000] <dbg> lbm_driver: sx126x_hal_write: TX SET
[00:00:00.224,000] <dbg> lbm_driver: sx126x_hal_write: DIO1 level: 0
--->sx126x_get_lora_time_on_air_in_ms called
--->sx126x_get_lora_time_on_air_numerator called
--->sx126x_get_lora_bw_in_hz called
[00:00:00.224,000] <dbg> lbm_driver: lbm_lora_send: Expected airtime: 289 ms
--->sx126x_set_sleep called
[00:00:00.802,000] <dbg> lbm_driver: sx126x_hal_write: CMD[0]=0x84 CMD_LEN=2 DATA_LEN=0
[00:00:00.802,000] <dbg> lbm_driver: sx126x_hal_write: ACTIVE -> SLEEP
[00:00:00.803,000] <err> lbm_driver: Packet transmission failed!
[00:00:00.803,000] <err> lora_send: LoRa send failed

@github-actions github-actions bot added manifest-lora-basics-modem DNM (manifest) This PR should not be merged (controlled by action-manifest) labels Jun 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: LoRa area: Process area: Samples Samples area: Shields Shields (add-on boards) DNM (manifest) This PR should not be merged (controlled by action-manifest) manifest manifest-lora-basics-modem platform: STM32 ST Micro STM32
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants