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

cpu/cc2538: mask length byte before checking CRC #20998

Merged
merged 1 commit into from
Nov 18, 2024

Conversation

HavingaThijs
Copy link
Contributor

Contribution description

This is a follow-up for #20956.

I found that the solution applied there wasn’t robust, because when receiving short packets quickly after each other the RX FIFO might be filling up with a new packet while handling the IRQ. Then, the number of bytes in the FIFO will be bigger than the packet length of the first packet. Even though the second packet will be dropped anyway, the length of the first packet can still be correctly obtained from the length byte in the packet.

Namely, from section 23.9.5.1 of the CC2538 User’s Guide it follows that indeed the radio will mask out bit 7 of the length byte:
image

Then, it continues to fill the RX FIFO with this number of bytes as follows from section 23.9.3:
image

This means that with this approach, always the correct byte is used for checking the CRC result.

Testing procedure

Flashed this PR on two devices, and tested with long packets that the error from #20955 didn't appear. When testing short packets quickly after each other, in case the old crc_loc was not equal to the corrected pkt_len, the pkt_len had the expected number of bytes, while crc_loc was usually a couple bytes more than that.

Issues/PRs references

This is a more proper fix for #20955.

@github-actions github-actions bot added Platform: ARM Platform: This PR/issue effects ARM-based platforms Area: cpu Area: CPU/MCU ports labels Nov 16, 2024
@benpicco benpicco requested review from jia200x and maribu November 16, 2024 21:29
@benpicco benpicco added the Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors) label Nov 16, 2024
Copy link
Member

@maribu maribu left a comment

Choose a reason for hiding this comment

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

Thanks for the fix. Please fix the issue pointed out by the CI, so that we can merge this.

Please directly amend / squash the commit.

cpu/cc2538/include/cc2538_rf.h Outdated Show resolved Hide resolved
@maribu maribu added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Nov 18, 2024
@maribu maribu enabled auto-merge November 18, 2024 08:02
@riot-ci
Copy link

riot-ci commented Nov 18, 2024

Murdock results

✔️ PASSED

0c72444 cpu/cc2538: mask length byte before checking CRC

Success Failures Total Runtime
10249 0 10249 18m:48s

Artifacts

@maribu maribu added this pull request to the merge queue Nov 18, 2024
Merged via the queue into RIOT-OS:master with commit c636f34 Nov 18, 2024
27 checks passed
@maribu
Copy link
Member

maribu commented Nov 25, 2024

Backport provided in #21038

I sqaushed the commit of #20956 and this one into a single commit for the backport.

@MrKevinWeiss MrKevinWeiss added this to the Release 2025.01 milestone Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: cpu Area: CPU/MCU ports CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Platform: ARM Platform: This PR/issue effects ARM-based platforms Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants