Skip to content
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

drivers/at86rf215: Add driver for the AT86RF215 dual-band IEEE 802.15.4-2015 radio #12128

Closed
wants to merge 25 commits into from

Conversation

benpicco
Copy link
Contributor

@benpicco benpicco commented Aug 30, 2019

Contribution description

This adds a driver for the SPI based AT86RF215 transceiver.
The chip supports the IEEE 802.15.4-2015 and IEEE 802.15.4g-2012 standard.

This driver supports two versions of the chip:

  • AT86RF215: sub-GHz & 2.4 GHz radio & baseband
  • AT86RF215M: sub-GHz radio & baseband only

The AT86RF215 behaves like two chips in one package. There is a radio fronted and a baseband controller for both bands and they operate independently. They share the SPI interface and IRQ pin, it is the necessary to check the interrupt status registers to find out which of the two radios caused the interrupt. Each interface is an independent netdev_ieee802154.

Both radios support the following PHY modes:

  • MR-FSK
  • MR-OFDM
  • MR-O-QPKS
  • O-QPSK (legacy)

All modulations are implemented and configurable through ifconfig.
The driver defaults to O-QPSK (legacy) at 250 kb/s on both bands for compatibility with existing 802.15.4 devices.

Each radio has a separate RX and TX framebuffer that can hold 2047 bytes each. The device is able to transmit 2047 byte frames according to IEEE 802.15.4g-2012 when operating in non-legacy mode.
The larger frame size is automatically used by RIOT when switching to such mode.

What works:

  • normal 6LoWPAN operation
  • dual-band operation
  • software based automatic re-transmission
  • switching modulation at run-time with ifconfig set page
  • sleep mode & wakeup (ifconfig set state sleep/ifconfig set state idle)
  • sending > 127 byte frames in non-legacy mode
  • reduced power consumption

Whhat's missing:

  • proper interface to configure modulation
  • driver should handle ping6 -i 0 as graceful as at86rf2xx - currently all packets but one are dropped. (-i >= 10 ms works fine)
  • displayed / configured TX dBm do not match reality

Testing procedure

An example configuration is provided for connecting the ATREB215-XPRO module to EXT3 on the same54-xpro evaluation board.

Configuration for EXT1 on samr21-xpro

#define AT86RF215_PARAM_SPI        SPI_DEV(1)
#define AT86RF215_PARAM_CS         GPIO_PIN(PB, 3)
#define AT86RF215_PARAM_INT        GPIO_PIN(PA, 22)
#define AT86RF215_PARAM_RESET      GPIO_PIN(PA, 18)

Configuration for esp32-wroom-32 with a bunch of wires

#define AT86RF215_PARAM_SPI        SPI_DEV(0)
#define AT86RF215_PARAM_SPI_CLK    SPI_CLK_1MHZ // loose wires
#define AT86RF215_PARAM_CS         GPIO16
#define AT86RF215_PARAM_INT        GPIO34
#define AT86RF215_PARAM_RESET      GPIO17

In examples/gnrc_networking add the following to the Makefile:

USEMODULE += at86rf215
GNRC_NETIF_NUMOF := 2

You should now be able to communicate with other 802.15.4 radios.
(Tested with samr21-xpro (at86rf2xx) and mrf24j40 as communication partners)

OpenMote-B

The OpenMote-B board is supported by RIOT and contains an at86rf215 chip.
I do not have that hardware and could not find proper documentation, but I provided a configuration anyway based on the OpenWSN-fw code. This is entirely untested.
@MrKevinWeiss kindly provided me with documentation, this revealed that defines regarding the antenna switch were wrongly named. Sub-GHz is always connected to the at86rf215 whereas 2.4 GHz can be switched between cc2538 and at86rf215.

With this PR, at86rf215 will always be used for both sub-GHz and 2.4 GHz.

TODO

Channel Pages / Modulation selection

The device provides 3 different PHY modes that all come with different options.
IEEE 802.15.4-2012g Amendment 3: Physical Layer (PHY) Specifications for LowData-Rate, Wireless, Smart Metering Utility Networks puts those modes to channel pages 9 & 10, but introduces 'sub-fields' to select the modulation & mode. The standard does not provide a nice numerical mapping though (or I did not find it?) and I honestly have no idea how to map this to the channel page used in Riot.

I now added options to ifconfig to configure the PHY modes and modulation options individually.

Since they depend on the modulation, the values for getting/setting txpower are also somewhat bogus right now.

Issues/PRs references

#12082 allows for a small optimization where we can route the interrupt to the sibling device that last called _send(). This may save us the wake-up of the other thread in the common case.

@benpicco benpicco added Area: network Area: Networking Type: new feature The issue requests / The PR implemements a new feature for RIOT Discussion: RFC The issue/PR is used as a discussion starting point about the item of the issue/PR Area: drivers Area: Device drivers labels Aug 30, 2019
@benpicco benpicco requested a review from jia200x August 30, 2019 16:37
@benpicco benpicco force-pushed the at86rf215 branch 2 times, most recently from 369990b to 791f334 Compare September 5, 2019 01:03
@MrKevinWeiss
Copy link
Contributor

I can try to help with the testing on the openmote. I really don't deal that much with radios but can do my best!

@MrKevinWeiss
Copy link
Contributor

I know the sub-GHz was wanted for quite some time. It would be nice to support it.

@benpicco
Copy link
Contributor Author

benpicco commented Sep 9, 2019

rebased to the changes made in #12171

@MrKevinWeiss Is there a data sheet for the openmote-b somewhere, so I can already prepare a setup for you to test?

@MrKevinWeiss
Copy link
Contributor

The best I can do is email you the schematics... I don't know if they are public though so if you email me [email protected] I can forward them.

@benpicco benpicco force-pushed the at86rf215 branch 3 times, most recently from dbf0718 to d477617 Compare September 16, 2019 23:19
@benpicco benpicco marked this pull request as ready for review September 24, 2019 13:32
@benpicco benpicco added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed Discussion: RFC The issue/PR is used as a discussion starting point about the item of the issue/PR labels Sep 24, 2019
@benpicco benpicco force-pushed the at86rf215 branch 2 times, most recently from dfebf8c to 209b2ac Compare September 24, 2019 14:47
@benpicco
Copy link
Contributor Author

Rebased to include #12295 so the build on AVR will not fail due to the added case in _print_netopt.

@tinstructor
Copy link

Let's say I have 2 OpenMote B nodes and I'd want to run a quick test, then how would you suggest I do that? @benpicco

@benpicco
Copy link
Contributor Author

benpicco commented Sep 27, 2019

@tinstructor make -C examples/gnrc_networking BOARD=openmote-b GNRC_NETIF_NUMOF=2 -j flash should do.

Then when you run ifconfig you should see two interfaces.

If you ping the other node using the link-local address you have to make sure to specify the interface over which you want to reach it, so e.g ping6 fe80::f874:8230:d3e:1b8f%8 if you want to ping fe80::f874:8230:d3e:1b8f using the 2.4 GHz interface.

You can use ifconfig <id> phy_mode [FSK|OFDM|O-QPSK] to select different modulations.
ifconfig has also gained some options to further configure the individual modulations.

Of course you have to have the same settings on both nodes for them to be able to communicate 😉

@tinstructor
Copy link

tinstructor commented Sep 27, 2019

@benpicco I don't seem to be able to get a response and I'm sure both nodes have the same config. However, is it possible that I first need to set the TX-Power and radio states? Also how can I see which interface is 2.4GHz/Sub-GHz respectively?

@benpicco
Copy link
Contributor Author

You shouldn't need to configure anything, they default to legacy O-QPSK on both interfaces for compatibility with 802.15.4-2003.

Can you post your ifconfig output?

Also, try ping6 ff02::1%7 and ping6 ff02::1%8 for a boardcast ping on the sub-GHz (7) and 2.4 GHz (8) interface.

benpicco added 5 commits March 9, 2020 19:28
The internal oscillator can be tuned by adding up to 16*0.3pF to the
RC circuit.
To do so connect a frequency counter to the chip's clock output
(and set AT86RF215_USE_CLOCK_OUTPUT to 1), then tune the value until the
measured frequency is closest to 26 MHz.

This should improve the radio characteristics of the transceiver.
If the device is in deep sleep it will not answer to reads of the PN
register.
We have to reset it before.
@benpicco
Copy link
Contributor Author

benpicco commented Mar 9, 2020

#13598 should fix the issues on the openmote-b.

@roberthartung
Copy link
Member

@benpicco Regarding #12128 (comment) - Fragmentation should not be an issue of the radio driver. If higher layers need fragmentation, this should be handled on higher layers, not here! There should be a higher level queue for this purpose.

@benpicco
Copy link
Contributor Author

Fragmentation should not be an issue of the radio driver. If higher layers need fragmentation, this should be handled on higher layers, not here!

The driver does not handle fragmentation. It will just ensure that send() blocks while a transmission is still ongoing. This is the behavior seen on other radio drivers in RIOT as well.

There should be a higher level queue for this purpose.

#11263 would implement this.

benpicco and others added 11 commits March 11, 2020 18:50
we want to keep the diff small.
When the radio is in DEEP SLEEP, reading the state register will return 0.
This makes the reset routine abort early even though the device is connected
and still waking up.

Instead, just add a timeout to the polling of the WAKEUP IRQ bit.
In practise it has shown that the loop will be taken two times on 'normal'
reset and four times when the radio was in DEEP SLEEP.

Polling 255 times sure does not hurt.

To reproduce the issue, put both interfaces into SLEEP mode,
then reboot the module:

    ifconfig 7 set state sleep
    ifconfig 8 set state sleep
    reboot
@fjmolinas
Copy link
Contributor

@benpicco are there futures in this PR still missing in master?

@benpicco
Copy link
Contributor Author

benpicco commented Jun 19, 2020

are there futures in this PR still missing in master?

  • MR-FSK - I have a WIP branch for that
    • KConfig integration
    • ACK / CCA timeouts need to be calculated with the proper formula
  • Reduced Power Consumption - will cut it out of this branch after MR-FSK as this requires some additional handling in the MR-FSK case
  • Battery Monitor - I want to move it away from a callback based solution to posing a message on a message bus

TODO but not implemented anywhere:

  • TX dBm values are still bogus. Not sure if having large look-up tables is worth it just for a nice ifconfig output
  • small optimisation: currently the radio switches RX -> TXPREP -> RX for CCA. This is not needed - it can just start CCA in state RX
  • we need a layer on top that makes sure the frequency / modulation options comply with local regulations. Right now the user has to ensure the configuration is legal, we should have a way to just be able to set a config for EU/US/… to spare users the burden of meticulously going to the standards to figure out what combination they can use in their region.

@benpicco benpicco added the State: demonstrator State: This PR (loosely) demonstrates a concept and is not necessarily meant to be merged. label Jun 19, 2020
@benpicco
Copy link
Contributor Author

benpicco commented Sep 8, 2020

All features from this PR have now been split off to separate PRs or have been merged.

@benpicco benpicco closed this Sep 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: drivers Area: Device drivers Area: network Area: Networking State: demonstrator State: This PR (loosely) demonstrates a concept and is not necessarily meant to be merged. Type: new feature The issue requests / The PR implemements a new feature for RIOT
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants