Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

alevy
Copy link
Member

@alevy alevy commented Apr 19, 2021

Pull Request Overview

This pull request accomplishes two main things:

  1. Add 802.15.4 & the UDP driver to the Nano 33 Sense board (thanks @hudson-ayers!)
  2. Fixes a bug in the nrf52 ieee802154 driver that was causing a state machine failure (i.e. the driver just got stuck) upon frame transmission when CCA fails.

What was the bug and how did you fix it?

Very simply, if ever in preparation for a transmission, the radio performed a CCA check and it failed (i.e. someone else is already transmitting on that channel), it's supposed to wait a specified period of time then retry. What was happening prior to this PR is there would never be a retry. So, if there was ever a CCA check failure, there could be no more transmission/receptions.

The problem was that while the timer was setup properly, the radio never got reconfigured in response to the timer expiring. I don't actually know the exact reason the strategy coded in the previous coding wasn't working, however, I just went with a more straight forward (though in the long run, worse) approach. At least it works.

Instead of using the Prorgammable Peripheral Interconnect on the NRF52's
ieee802154 radio driver to retry CCA after a timer expires when it
fails, use simple software logic instead. PPI invokes tasks in one
peripheral (the radio) in response to an event in another (the timer),
without requiring an interrupts serviced in software.

The best thing to do would be to use PPI as well as shortcuts to
simplify the radio logic significantly, as well as likely improve
transition time performance. I'll leave that for another adventure.

Why is this PR touching so many files?

Most of the changes are small refactoring in the NRF52-based boards. The NRF52's ieee802154 driver no longer requires a PPI, which had been passed down all the way from the board (it's not clear this was ever a good thing, this was required even for boards that used an nrf52 with no ieee802154 driver). So now, each board that relies on any nrf52 chip has a couple line changes removing the PPI initializing.

Testing Strategy

If anyone has ideas on how to test this reliably, please share. Meanwhile, I tested this by running the examples/tests/udp/udp_send app from libtock-c with a much smaller interval than the default (I used 50 ms) and waiting for a CCA to fail (probably because randomly some other 2.4GHz device was transmitting---maybe those Philips Hues I have are not completely useless after all). Without this change eventually transmissions stop. With the changes, they continue.

To help my debugging I added some debug statements in the kernel to identify when a CCA failed, confirming that (a) this was the problem and (b) that my fix addresses the problem. You might consider adding similar debug statements if you want to test---again, it's otherwise pretty hard to tell whether you got a collision.

TODO or Help Wanted

Documentation Updated

  • Updated the relevant files in /docs, or no updates are required.

Formatting

  • Ran make prepush.

hudson-ayers and others added 3 commits April 18, 2021 22:08
Instead of using the Prorgammable Peripheral Interconnect on the NRF52's
ieee802154 radio driver to retry CCA after a timer expires when it
fails, use simple software logic instead. PPI invokes tasks in one
peripheral (the radio) in response to an event in another (the timer),
without requiring an interrupts serviced in software. PPI is probably _better_ but
it wasn't working and I couldn't quite figure out why it wasn't. The
software logic is just emulating what the PPI is supposed to do.

Because this only gets triggered on a CCA failure, it's pretty
cumbersome to debug.

The best thing to do would be to use PPI as well as shortcuts to
simplify the radio logic significantly, as well as likely improve
transition time performance. I'll leave that for another adventure.
@alevy alevy requested review from hudson-ayers and bradjc April 19, 2021 05:36
hudson-ayers
hudson-ayers previously approved these changes Apr 19, 2021
Copy link
Contributor

@hudson-ayers hudson-ayers left a comment

Choose a reason for hiding this comment

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

This generally looks good to me! Not passing the ppi for all the nordic chips is an added bonus.

@github-actions github-actions bot added the chips/nrf Change pertains to the nRF5x family of MCUs. label Apr 19, 2021
@alevy
Copy link
Member Author

alevy commented Apr 19, 2021

bors r+

@bors
Copy link
Contributor

bors bot commented Apr 19, 2021

@bors bors bot merged commit a66504c into master Apr 19, 2021
@bors bors bot deleted the bug/nrf-radio branch April 19, 2021 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chips/nrf Change pertains to the nRF5x family of MCUs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants