wireless/lpwan: add SX1301 concentrator, board support and SX127X fixes - #19675
wireless/lpwan: add SX1301 concentrator, board support and SX127X fixes#19675JorgeGzm wants to merge 4 commits into
Conversation
e913b7b to
f677fe3
Compare
f677fe3 to
771232f
Compare
cederom
left a comment
There was a problem hiding this comment.
Thank you @JorgeGzm :-)
I would just put dedicated documentation page for lora / sx / etc and then reference it from a board page. We has too many details scattered across different board, would be nice to have all in one place and then just reference :-)
771232f to
e9141d6
Compare
e9141d6 to
e55adee
Compare
raiden00pl
left a comment
There was a problem hiding this comment.
please split it into more commits and don't mix multiple not related changes in one commit
e8578d1 to
9d65dea
Compare
|
When you use AI to write your PR descriptions, please take some time to reduce down the size to what actually needs to be read. This is a massive wall of text. |
@JorgeGzm I think this comments in the Summary should be included in the Documentation page |
STM32_STM32L0 does not select STM32_HAVE_SYSCFG, so STM32_SYSCFG does not exist for this family and the clock of the peripheral is never enabled. The mapping of a pin to an EXTI line lives in SYSCFG_EXTICR, so every write to it was dropped and a GPIO interrupt on any port other than port A never fired. STM32_SYSCFG is default y, so no configuration changes. Assisted-by: Claude Code 4.8 Signed-off-by: Jorge Guzman <jorge.gzm@gmail.com>
Character driver for the Semtech SX1301, the baseband processor of a LoRaWAN gateway, and the two SX125x radios it drives. Received packets come from read(), downlinks go to write(), and the channel plan, the start and the stop are ioctls. The interface is device independent, in nuttx/wireless/lpwan/lora_gw.h with the commands in the common WLIOC_GW_* space, so another concentrator driver can implement it and the same application drive it. Adds a lorawan_gw configuration for the Nucleo F746ZG with a shield of the LRWAN_GS_HF1 family. Off by default (LPWAN_SX1301). Assisted-by: Claude Code 4.8 Signed-off-by: Jorge Guzman <jorge.gzm@gmail.com>
…only build - The frequency step was truncated to 61 Hz, while it is FXOSC/(2**19), about 61.035 Hz. The error puts a 915 MHz channel more than 500 kHz away from the requested frequency, outside its own bandwidth. - The low or high frequency front end was left at its reset value, so a board wired for 868 or 915 MHz neither transmitted nor received. - sx127x_rx_watchdog() is only used by the FSK and OOK path but was compiled whenever receive support was on, so a LoRa only configuration failed to build with -Werror. nrf52840-dk:sx127x is such a configuration. Adds the sync word, the default bandwidth and the default spreading factor as configuration options, all defaulting to the previous behaviour, and a page for the driver under components/drivers. Assisted-by: Claude Code 4.8 Signed-off-by: Jorge Guzman <jorge.gzm@gmail.com>
9d65dea to
6a017f6
Compare
…gurations The 32 MHz TCXO that clocks the SX1276 is powered from PA12 and was never driven, so the radio had no clock at all. The user button was copied from the Nucleo L073RZ and left on PC13, which carries DIO3 of the radio on this board; it is PB2. Adds lorawan_tx and lorawan_beacon, with the radio defaults of a public LoRaWAN network in the 915 MHz band, and fills in the board page. Assisted-by: Claude Code 4.8 Signed-off-by: Jorge Guzman <jorge.gzm@gmail.com>
6a017f6 to
3692566
Compare
Summary
Adds a character driver for the Semtech SX1301, the baseband processor of a
LoRaWAN gateway, together with the two SX125x radio front ends that it drives
through its internal SPI bridge. The driver resets the chip, loads the three
MCU firmware images, runs the calibration pass and the AGC handshake, and then
exposes the receive FIFO and the transmitter through
read(),write()and asmall set of ioctls. Eight channel plans are provided, from AU915 to IN866, and
the firmware images are
constso that they stay in flash instead of taking24 KiB of RAM.
What an application sees is device independent. A concentrator has no radio
frequency, spreading factor or coding rate of its own, since those belong to
each packet, so the commands of the common wireless API have nothing to act
upon on such a device and the interface it needs is instead a channel plan, a
start and stop, and the counter downlinks are scheduled against. That contract
is
nuttx/wireless/lpwan/lora_gw.h, with the commands allocated in the commonWLIOC_GW_*space rather than in a per chip block, andsx1301.hkeeps onlysx1301_register()and the board hooks. A second concentrator driverimplements the same interface and the same application drives it; the coding
rate is the existing
enum wlioc_lora_cr_e, and the rest of the packet keepsthe layout and the values of the userspace HAL that gateway software is
written against elsewhere, so that such an application ports by replacing
lgw_receive()withread()andlgw_send()withwrite().Two details of the Semtech reference HAL are easy to miss, and both were found
on hardware:
and the read back register. A Linux host gets that for free from the cost of
a spidev transaction; here the register writes are fast enough that the
radios always read back as zero, which looks exactly like a dead board.
network. A gateway that leaves them alone never detects a single frame of a
public LoRaWAN device.
Board support is added for the Nucleo F746ZG carrying a shield of the
LRWAN_GS_HF1 family on SPI4, with a
lorawan_gwconfiguration that brings upEthernet, DHCP and DNS along with the concentrator.
The SX127X driver gains what an SX1276 needs to talk to such a gateway, and
three defects found while making that work are fixed:
SX127X_FSTEPdivided by a step truncated to 61 Hz, while astep is
FXOSC/2**19, about 61.035 Hz. The 0.06 per cent error puts a915 MHz channel more than 500 kHz away from the requested frequency, outside
its own bandwidth: frames were transmitted, but on the wrong channel and
undecodable by anything tuned correctly. Two NuttX radios still talked to
each other, since both were wrong by the same amount.
configured frequency instead of being left at the reset value.
sx127x_rx_watchdog()is only wired into the FSK andOOK receive path, but was compiled whenever receive support was on. A LoRa
only configuration therefore failed to build with the flags of the CI. This
is not hypothetical:
nrf52840-dk:sx127xis such a configuration and doesnot build on master today (see Testing).
On STM32L0 the SYSCFG clock was never enabled, because the symbol that guarded
it does not exist in Kconfig for this chip. The mapping of a pin to an EXTI
line lives in
SYSCFG_EXTICR, so every write to it was dropped and the mappingstayed at its reset value: a GPIO interrupt on any port other than port A
silently never fired.
nucleo-l073rzhas DIO0 of its radio on PA10 and worksby accident, which is probably why this went unnoticed; the B-L072Z-LRWAN1 has
it on PB4, so a transmission never completed and the driver waited forever.
The same pattern is present in the STM32C0 and STM32G0 clock setup and was left
alone, as no board was available to test them.
On the B-L072Z-LRWAN1 the TCXO that clocks the radio is now powered before the
driver is registered, the user button is corrected to PB2 because PC13 carries
DIO3 of the radio on this board, and two configurations are added for use as a
LoRa transmitter.
Impact
New driver, new board support, and one fix per existing area:
drivers/wireless/lpwan/sx1301: new, off by default (LPWAN_SX1301).drivers/wireless/lpwan/sx127x: the frequency and band fixes change thefrequency actually used on the air, in the direction of the requested one.
Anyone who compensated for the old error in an application will notice. The
three new Kconfig options keep the previous behaviour by default (sync word
0x12, 7.8 kHz bandwidth, spreading factor 7).
arch/arm/src/stm32l0: one clock enable. Every STM32L0 board gains workingGPIO interrupts outside port A; nothing that worked before stops working.
nucleo-f746zggains SPI4 and SPI5 pin definitions and theconcentrator glue;
b-l072z-lrwan1gains the TCXO line and the correctedbutton pin.
SX127X driver, under
components/drivers/character/wireless/lpwan, with thetwo board pages trimmed to their wiring and pointing at them. This is what
@cederom asked for in review: what is common to every board using a radio is
written once, in one place, and referenced from the boards.
Testing
Host: Ubuntu 24.04.4 LTS, x86_64, Linux 7.0.0-28-generic
Every build below uses the warning flags of the CI:
make EXTRAFLAGS="-Wno-cpp -Werror".Build
nucleo-f746zg:lorawan_gw(new)nucleo-f746zg:lorawan_gw+WIRELESS_LORA_PKT_FWDnucleo-f746zg:nshb-l072z-lrwan1:lorawan_tx(new)b-l072z-lrwan1:lorawan_beacon(new)b-l072z-lrwan1:sx127xnucleo-l073rz:sx127xnucleo-f091rc:sx127xnrf52840-dk:sx127xheltec_wifi_lora32:sx1276The
lorawan_gwconfiguration does not selectWIRELESS_LORA_PKT_FWD,because that symbol comes from the companion pull request of
nuttx-appsandwould make the defconfig of this repository diverge from what
refresh.shproduces against the master of the other one. The second line above is the
same configuration with the forwarder enabled from
menuconfig, which is whatthe documentation tells the user to do; the line can go into the defconfig once
the application is merged.
All of them build with no warning and no error. The last five are the other
users of the SX127X driver in the tree, built to show that the driver changes
do not regress them.
nrf52840-dk:sx127xdoes not build on master, which is what the unusedfunction fix addresses:
nxstylereports nothing on the changed files,refresh.shleaves everytouched configuration unchanged, and the documentation builds with
sphinx -W.Concentrator, on hardware
Nucleo F746ZG with a RisingHF RHF0M301 shield,
lorawan_gw:Receiving a LoRaWAN device
An end device based on an SX1276 sending its join request, AU915 first
sub-band:
Status 0x10 is a valid CRC, and 23 bytes is the exact length of a join
request. Forwarded to a network server over the internet with the forwarder of
the companion pull request in nuttx-apps:
Receiving an SX127X, which is what the SX127X fixes are for
B-L072Z-LRWAN1 running
lorawan_txand transmitting on 917.2 MHz withsx127x -m 0 -f 917200000 -t -p 0 -l 32.Before the frequency fix the frames arrived on the channel 600 kHz above the
requested one and never passed the CRC:
After it, on the requested channel and with a valid CRC:
Before the SYSCFG fix the same board sent one frame per reset and then blocked
forever waiting for the transmit interrupt; after it, 509 frames in 30 s. The
mapping register, read from the running firmware, confirms why:
Transmitting
The concentrator sends a packet with
lora tx 917200000 7 hello-from-gatewayand two B-L072Z-LRWAN1 boards listening on that frequency receive it:
Five transmissions, five receptions on each board.
The Docker based CI lists were not run locally; they are left to the CI of the
pull request.