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/at86rf2xx: Switch SRT mode to get random values. #18290

Merged
merged 1 commit into from
Jul 4, 2022

Conversation

CW-75
Copy link

@CW-75 CW-75 commented Jul 1, 2022

Contribution description

This Pr is dedicated to resolve the random generation numbers from at86rf233, this should establish the device in a basic operation mode states. also needs to the preamble detector is disabled (RX_PDT_DIS=1). Something else that should be considered is the state of Smart Receiver Technology (SRT), this is an element used to manage the Reception Power Consumption (RPC) and it's affecting the random_number_generator() of the at86rf2xx. Well this Pull request add the functionality to disable temporarily the smart_idle_mode because the random number generator needs take values from RSSI register. When the SRT is active could won´t get the wished random values).

Also to integrate the number generator by the driver implementation, also let's to manipulate the functionality by network options (netopts), adding support in the NETOPT_RANDOM

Testing procedure

run and falsh the test/driver_at86rf_2xx.

make -C tests/driver_at86rf2xx flash term

When it has loaded the shell type random ( This is a command added only to the test ).

2022-07-01 16:20:56,261 # random
2022-07-01 16:20:56,267 # Random number for device 0 via native API: a2f979f9
2022-07-01 16:20:56,271 # Random number for device 0 via netopt: c200fa9d

Also try checking resetting the device to be sure that the self value is not repeating.

2022-07-01 16:21:03,653 # main(): This is RIOT! (Version: 2022.07-devel-900-g162cf-feature/at86rf2xx_random_numbers)
2022-07-01 16:21:03,655 # AT86RF2xx device driver test
2022-07-01 16:21:03,659 # Initializing AT86RF2xx radio at SPI_0
2022-07-01 16:21:03,665 # gnrc_netdev: possibly lost interrupt.
2022-07-01 16:21:03,670 # Initialization successful - starting the shell now
> random
2022-07-01 16:21:06,149 # random
2022-07-01 16:21:06,154 # Random number for device 0 via native API: a8f63524
2022-07-01 16:21:06,159 # Random number for device 0 via netopt: c0fe3169
> reboot
2022-07-01 16:21:17,349 # reboot
2022-07-01 16:21:17,381 # main(): This is RIOT! (Version: 2022.07-devel-900-g162cf-feature/at86rf2xx_random_numbers)
2022-07-01 16:21:17,383 # AT86RF2xx device driver test
2022-07-01 16:21:17,386 # Initializing AT86RF2xx radio at SPI_0
2022-07-01 16:21:17,392 # gnrc_netdev: possibly lost interrupt.
2022-07-01 16:21:17,397 # Initialization successful - starting the shell now
> random
2022-07-01 16:21:19,013 # random
2022-07-01 16:21:19,018 # Random number for device 0 via native API: eccf2f1c
2022-07-01 16:21:19,023 # Random number for device 0 via netopt: 7abc92e6

Issues/PRs references

Fix #18285
You can get more information about the SRT in the samr21-xpro-datasheet in the page 1034, section 40.10.

@github-actions github-actions bot added Area: drivers Area: Device drivers Area: tests Area: tests and testing framework labels Jul 1, 2022
@CW-75 CW-75 force-pushed the feature/at86rf2xx_random_numbers branch from a8e7938 to 02e3fad Compare July 1, 2022 18:03
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 PRing a fix. Some nitpicks inline.

@CW-75
Copy link
Author

CW-75 commented Jul 1, 2022

Thanks for your suggestions @maribu, I applied your recommendations, this could be reviewed again

@CW-75 CW-75 requested a review from maribu July 1, 2022 19:37
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.

ACK. I tested on the samr21-xpro and I can confirm that in master 0xff bytes are returned:

> random
2022-07-02 10:05:56,785 # Random number for device 0 via native API: ffffffff
2022-07-02 10:05:56,789 # Random number for device 0 via netopt: 0
> 2022-07-02 10:05:58,269 # random
2022-07-02 10:05:58,274 # Random number for device 0 via native API: ffffffff
2022-07-02 10:05:58,278 # Random number for device 0 via netopt: 0
> 2022-07-02 10:05:58,893 # random
2022-07-02 10:05:58,898 # Random number for device 0 via native API: ffffffff
2022-07-02 10:05:58,902 # Random number for device 0 via netopt: 0

(the netopt version doesn't change the zero-initialized value as it is not implemented in master)

but with this PR, the output appear to contain a high level of entropy:

> random
2022-07-02 10:04:52,783 # random
2022-07-02 10:04:52,788 # Random number for device 0 via native API: 2a613db0
2022-07-02 10:04:52,793 # Random number for device 0 via netopt: 38ec93e2
> random
2022-07-02 10:04:55,725 # random
2022-07-02 10:04:55,730 # Random number for device 0 via native API: dda44bc2
2022-07-02 10:04:55,735 # Random number for device 0 via netopt: 452e984d
> random
2022-07-02 10:04:57,700 # random
2022-07-02 10:04:57,705 # Random number for device 0 via native API: dff3f25d
2022-07-02 10:04:57,710 # Random number for device 0 via netopt: ca0be5c9

Thanks for addressing the issue!

@maribu maribu added Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors) CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Jul 2, 2022
@CW-75 CW-75 force-pushed the feature/at86rf2xx_random_numbers branch from 25dee0b to 66fde61 Compare July 3, 2022 01:52
@CW-75
Copy link
Author

CW-75 commented Jul 3, 2022

Hi, I've updated the PR with the new changes required, Thanks @maribu

@CW-75 CW-75 requested a review from maribu July 3, 2022 03:15
@CW-75 CW-75 force-pushed the feature/at86rf2xx_random_numbers branch from 66fde61 to 72574f4 Compare July 3, 2022 17:35
@CW-75 CW-75 force-pushed the feature/at86rf2xx_random_numbers branch from 72574f4 to 0de24b7 Compare July 3, 2022 18:38
@maribu maribu enabled auto-merge July 3, 2022 19:00
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.

The shell command in the test is making use of the random function even when the driver is not providing, resulting in the remaining compilation errors. But that is quick to fix.

Please squash afterwards :)

auto-merge was automatically disabled July 3, 2022 20:55

Head branch was pushed to by a user without write access

@CW-75 CW-75 force-pushed the feature/at86rf2xx_random_numbers branch from 0de24b7 to e0c82fd Compare July 3, 2022 20:55
@CW-75 CW-75 force-pushed the feature/at86rf2xx_random_numbers branch from e0c82fd to e6a7039 Compare July 3, 2022 21:45
@maribu maribu enabled auto-merge July 4, 2022 04:42
@maribu maribu merged commit df55631 into RIOT-OS:master Jul 4, 2022
@maribu
Copy link
Member

maribu commented Jul 4, 2022

Thanks for fixing the issue!

@CW-75 CW-75 deleted the feature/at86rf2xx_random_numbers branch July 4, 2022 13:58
@CW-75
Copy link
Author

CW-75 commented Jul 4, 2022

I'm happy to contribute with RIOT, thanks for the help @maribu

@chrysn chrysn added this to the Release 2022.07 milestone Aug 25, 2022
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: tests Area: tests and testing framework CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR 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.

at86rf2xx_internal: Don't get a random number with the function at86rf2xx_get_random
3 participants