Skip to content

Conversation

@andysan
Copy link
Contributor

@andysan andysan commented Apr 22, 2020

This pull request adds support for the SX1261 and SX1262 LoRa modems.

Due to a significant overlap between the SX1276 driver and these drives, some common functionality has been factored out into shared source files.

The current version has the following known limitations:

  • The radio switch can only be controlled by DIO2. RF switches controlled by GPIOs are currently not supported (mostly due to a limitation in the HAL).
  • A TCXO, if present, must be controlled by DIO3 or always on. GPIO contol is currently not possible.

Testing:

  • Broadcasting of a continuous wave works.
  • Sending packets has been tested and is working.
  • Packet reception is working.
  • Tested with @Mani-Sadhasivam's LoRaWAN patches. Able to join TTN using OTAA and send packets.

The above was verified in a lab setup with an SX126X connected to an NRF52840 dev board and an SDR through a set of RF splitters and and attenuators. TTN testing was done over the air.

Dependencies:

Copy link
Contributor

@galak galak left a comment

Choose a reason for hiding this comment

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

I'd expected a west.yml update if the module is change, or support for SX126x already in loramac-node?

@zephyrbot zephyrbot added area: Devicetree area: API Changes to public APIs labels Apr 22, 2020
@zephyrbot
Copy link

zephyrbot commented Apr 22, 2020

All checks are passing now.

checkpatch (informational only, not a failure)

-:1212: WARNING:DT_SPLIT_BINDING_PATCH: DT binding docs and includes should be a separate patch. See: Documentation/devicetree/bindings/submitting-patches.txt

-:1236: WARNING:DT_SPLIT_BINDING_PATCH: DT binding docs and includes should be a separate patch. See: Documentation/devicetree/bindings/submitting-patches.txt

- total: 0 errors, 2 warnings, 1151 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

Your patch has style problems, please review.

NOTE: Ignored message types: AVOID_EXTERNS BRACES CONFIG_EXPERIMENTAL CONST_STRUCT DATE_TIME FILE_PATH_CHANGES MINMAX NETWORKING_BLOCK_COMMENT_STYLE PRINTK_WITHOUT_KERN_LEVEL SPDX_LICENSE_TAG SPLIT_STRING VOLATILE

NOTE: If any of the errors are false positives, please report
      them to the maintainers.

Tip: The bot edits this comment instead of posting a new one, so you can check the comment's history to see earlier messages.

@andysan
Copy link
Contributor Author

andysan commented Apr 22, 2020

I'd expected a west.yml update if the module is change, or support for SX126x already in loramac-node?

Yep, that's correct. The pull request can be found here: zephyrproject-rtos/loramac-node#4

I'll update this RFC when that has been merged.

@carlescufi
Copy link
Member

I'd expected a west.yml update if the module is change, or support for SX126x already in loramac-node?

Yep, that's correct. The pull request can be found here: zephyrproject-rtos/loramac-node#4

I'll update this RFC when that has been merged.

No, please update it now with pull/4/head until that is merged. See here:
https://docs.zephyrproject.org/latest/guides/modules.html#changes-to-existing-modules

@andysan
Copy link
Contributor Author

andysan commented Apr 22, 2020

pull/4/head

I'd expected a west.yml update if the module is change, or support for SX126x already in loramac-node?

Yep, that's correct. The pull request can be found here: zephyrproject-rtos/loramac-node#4
I'll update this RFC when that has been merged.

No, please update it now with pull/4/head until that is merged. See here:
https://docs.zephyrproject.org/latest/guides/modules.html#changes-to-existing-modules

I missed that part of the contribution guide, sorry. 🤦 I'll update the pull request right away.

@andysan andysan force-pushed the sx126x branch 2 times, most recently from 64aaa4e to 9c3d461 Compare April 22, 2020 20:27
@carlescufi
Copy link
Member

pull/4/head

I'd expected a west.yml update if the module is change, or support for SX126x already in loramac-node?

Yep, that's correct. The pull request can be found here: zephyrproject-rtos/loramac-node#4
I'll update this RFC when that has been merged.

No, please update it now with pull/4/head until that is merged. See here:
https://docs.zephyrproject.org/latest/guides/modules.html#changes-to-existing-modules

I missed that part of the contribution guide, sorry. 🤦 I'll update the pull request right away.

No worries, thank you for your PR.

@carlescufi
Copy link
Member

@andysan the reason I asked you is that there is no CI in the module repos, so we have to rely on this repository's CI to make sure the module's PR doesn't break anything.

@andysan andysan force-pushed the sx126x branch 2 times, most recently from 52ee6ed to 7ef92ec Compare April 23, 2020 06:45
@andysan andysan changed the title RFC: Add support for SX126x transceivers Add support for SX126x transceivers Apr 23, 2020
@andysan andysan mentioned this pull request Apr 23, 2020
@andysan andysan requested a review from mniestroj May 1, 2020 21:24
Copy link
Member

@mniestroj mniestroj left a comment

Choose a reason for hiding this comment

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

Overall looks okay. I would like to test that on my custom board as soon as you rebase on current master branch.

}
};

const struct spi_buf rx_buf[] = {
Copy link
Member

Choose a reason for hiding this comment

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

You can use the same array of buffers for tx and rx. This would allow to drop req_rx argument. Maybe the same could be done with data_rx, because there is no case when data_tx and data_rx are passed simultaneously. In spi_nor.c and sx1276.c there is a is_write argument instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried that strategy and it didn't seem to work on my nrf52 board. I suspect this is similar to an issues discussed on Slack when the sx1276 is used on that platform. I didn't debug it properly, but I think the DMA operation in the SPI peripheral gets confused when the same pointer is used in both the input and output register.

@carlescufi carlescufi added the DNM This PR should not be merged (Do Not Merge) label Jun 21, 2020
@carlescufi
Copy link
Member

Please update west.yml with a SHA

@carlescufi
Copy link
Member

@Mani-Sadhasivam can you please approve if happy?

@Mani-Sadhasivam
Copy link
Member

@Mani-Sadhasivam can you please approve if happy?

On my TODO list. Will do it in couple of days.

@andysan
Copy link
Contributor Author

andysan commented Jun 23, 2020

Further testing with the LoRaWAN patches suggests that something weird is happening. For some reason, I can’t receive downlinks correctly. Please keep this as DNM until I have investigated that.

@andysan
Copy link
Contributor Author

andysan commented Jun 25, 2020

Further testing with the LoRaWAN patches suggests that something weird is happening. For some reason, I can’t receive downlinks correctly. Please keep this as DNM until I have investigated that.

Turns out this was caused by the LoRaWAN stack performing SPI transactions from an interrupt context. As far as I can tell, the weird errors I was experiencing weren't caused by this driver.

@andysan andysan removed the DNM This PR should not be merged (Do Not Merge) label Jun 25, 2020
Copy link
Member

@mniestroj mniestroj left a comment

Choose a reason for hiding this comment

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

Tested LoRa shell with custom board and sx1262. Just some minor things to improve.

@andysan andysan force-pushed the sx126x branch 2 times, most recently from 3c6de42 to 9cdcb37 Compare June 26, 2020 17:44
Copy link
Member

@mniestroj mniestroj left a comment

Choose a reason for hiding this comment

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

I just noticed minor documentation issues in DT bindings.

Copy link
Member

@mniestroj mniestroj left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@Mani-Sadhasivam Mani-Sadhasivam left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Member

Choose a reason for hiding this comment

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

Showing the IRQ line number would be helpful here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have rephrased this as "Could not set GPIO callback for DIO1 interrupt" I think that should be a bit clearer.

Copy link
Member

Choose a reason for hiding this comment

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

Can we say, DIO1 IRQ callback not defined instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Rephrased as "DIO1 interrupt without valid HAL IRQ callback.".

@andysan andysan force-pushed the sx126x branch 2 times, most recently from b863819 to 6fdd8f7 Compare June 27, 2020 17:48
@andysan
Copy link
Contributor Author

andysan commented Jun 27, 2020

@carlescufi This should be ready to be merged now. The test issue seems unrelated (tests/subsys/logging/log_immediate/logging.log_immediate failing on ARC).

andysan added 3 commits June 30, 2020 23:15
Add a new configuration option, LORA_SX12XX, that is shared for all of
the LoRaMAC-node-based radio drivers. By default, the appropriate
driver for the LoRa radio in the device tree is included is included
in the build.

Signed-off-by: Andreas Sandberg <andreas@sandberg.pp.se>
Add device tree bindings for the Semtech SX1261 and SX1262
radios. These will be used by Zephyr's LoRa drivers.

Signed-off-by: Andreas Sandberg <andreas@sandberg.pp.se>
Add support for the SX126x series of LoRa radios using the
LoRaMAC-Node HAL.

This driver currently makes the following assumptions:

  * DIO1 is used as an interrupt line.

  * There is an RF switch selecting between the TX and RX ports and
    that switch is controlled by DIO2.

  * There is either no TCXO or the TCXO is controlled by DIO3.

Specifically, the limitations above mean that modules that use GPIOs
to control the RF switch are currently not supported. Support for such
modules would need changes to the LoRaMAC-Node code.

Signed-off-by: Andreas Sandberg <andreas@sandberg.pp.se>
@github-actions github-actions bot added the area: Devicetree Binding PR modifies or adds a Device Tree binding label Jun 30, 2020
@nashif nashif merged commit 6a4ebe5 into zephyrproject-rtos:master Jul 2, 2020
@andysan andysan deleted the sx126x branch July 2, 2020 12:40
@holmes81
Copy link

holmes81 commented Sep 1, 2020

Hi,Can please help to check this:
#27915

It can't work property with nrf52840dk,I don't know why.There is no data from MISO,
Thanks a lot.

@holmes81
Copy link

holmes81 commented Sep 1, 2020

Or can please share your firmware bin file,then I can have a test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: API Changes to public APIs area: Devicetree Binding PR modifies or adds a Device Tree binding area: Devicetree area: LoRa area: Modules area: Samples Samples

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants