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

802.15.4 HIL updates; nRF52840 IEEE 802.15.4 Driver Updates #3995

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

bradjc
Copy link
Contributor

@bradjc bradjc commented May 17, 2024

Pull Request Overview

This pull request is a pass over the nRF52840 15.4 driver. The changes are fairly well encapsulated in commits, but listed here:

  • Implement the config and power callbacks with a deferred call.
  • Do not enter RX mode on init. RX mode is entered on start(). Otherwise the radio is always on, even if nothing is using it.
  • Change constants to defines in the HIL.
  • Remove setting RX and TX addresses as these functions were not doing anything and this support does not exist in the hardware.
  • Change the catch for a "too long" packet to just set the 8th bit of the length to 0. This avoids both dropping the packet and any buffer index errors.
  • Pass the ACK transmission error to the callback instead of the CRC result. Also rename the CRC variable. Also we know the CRC passed if we sent an ACK, so no need to check in the second RX case.
  • Return OFF error if try to TX when radio is off.
  • Format comments

This required some changes to the constants in the HIL.

  • Add PHR_SIZE and PHR_OFFSET.
  • Remove MIN_MHR_SIZE as it is incorrect (should be 7, as the minimum PHR is 9, and the MFR is 2, so that leaves 7).
  • Add comments.

Testing Strategy

Need to do this.

TODO or Help Wanted

n/a

Documentation Updated

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

Formatting

  • Ran make prepush.

@github-actions github-actions bot added nrf Change pertains to the nRF5x family of MCUs. HIL This affects a Tock HIL interface. WG-Network In the purview of the Network working group. labels May 17, 2024
@bradjc bradjc mentioned this pull request May 20, 2024
22 tasks
let lqi = rbuf[data_len];

// We drop the CRC bytes (the MFR) from our frame.
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we are dropping the CRC, I do not think this should be called frame_len since the MFR is technically part of the frame.

edit: this linked to line 854 when it should be to 855 the line below
let frame_len = data_len - radio::MFR_SIZE;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do you recommend? That variable is there from before.

Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps changing this to buffer_len? buffer_len too feels suboptimal.

This gets at the issue with needing this field to be passed up the stack to denote the active length since we are passing the entire unused buffer upwards (so that it can later be reset by framer). These issues all seem like they would be solved by using a subslice. Is there a reason that we did not originally do this? In my opinion it seems the radio driver itself should be the only entity setting/resetting the receive buffer it interacts with (not the framer or some other "higher" element).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This gets at the issue with needing this field to be passed up the stack to denote the active length since we are passing the entire unused buffer upwards (so that it can later be reset by framer). These issues all seem like they would be solved by using a subslice. Is there a reason that we did not originally do this? In my opinion it seems the radio driver itself should be the only entity setting/resetting the receive buffer it interacts with (not the framer or some other "higher" element).

The first 15.4 code was probably written before subslice/leasablebuffer existed.

I agree this should use subslice. But, the stack needs to edit both the start and end of the buffer, and that is more complex than many use cases. It sounded like the networking WG was thinking about that.

I would like to see the stack be clarified, and then updated to subslice once we have a good story for reserving space at the start of the buffer.

chips/nrf52840/src/ieee802154_radio.rs Outdated Show resolved Hide resolved
return Err((ErrorCode::BUSY, buf));
} else if radio::PSDU_OFFSET + frame_len >= buf.len() {
} else if buf.len() < radio::PSDU_OFFSET + frame_len + radio::MFR_SIZE {
// Not enough room for CRC
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Not enough room for CRC
// Provided buffer does not have adequate space.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This seems less clear to me.

Copy link
Contributor

Choose a reason for hiding this comment

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

Only mentioning the CRC here is inaccurate since it may be that there is not enough room for the PHR or that there is not enough room for the CRC. Perhaps updating then to:
// Not enough room for CRC and/or PHR.

@@ -1298,24 +1349,24 @@ impl<'a> kernel::hil::radio::RadioData<'a> for Radio<'a> {
buf: &'static mut [u8],
frame_len: usize,
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not entirely sure what the correct name is for this, but once again, frame_len seems somewhat misleading here since the frame does not contain the CRC here (that is to be added by hardware). There may not be a better name for this.

bradjc and others added 11 commits May 23, 2024 16:56
No address filtering for nrf52840 in 15.4 mode.
Calling `radio_initialize()` in the HIL::init function puts the radio in
to RX mode. That means the radio is on unconditionally in any board that
includes the 15.4. The HIL::start() function should be used to start the
radio and put it in RX mode.
Avoid an issue where the radio is off but the state is not.
This matches the HIL and the rf233
Co-authored-by: Tyler Potyondy <77175673+tyler-potyondy@users.noreply.github.com>
@bradjc bradjc force-pushed the nrf52840-ieee802154-updates branch from f722b2d to 9479df2 Compare May 23, 2024 20:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
HIL This affects a Tock HIL interface. nrf Change pertains to the nRF5x family of MCUs. WG-Network In the purview of the Network working group.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants