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

furi_hal_random returns values when RNG output is not ready #3932

Closed
n1kolasM opened this issue Oct 4, 2024 · 1 comment · Fixed by #3933
Closed

furi_hal_random returns values when RNG output is not ready #3932

n1kolasM opened this issue Oct 4, 2024 · 1 comment · Fixed by #3933
Assignees
Labels
Bug Build System & Scripts fbt, scripts and toolchain-related

Comments

@n1kolasM
Copy link
Contributor

n1kolasM commented Oct 4, 2024

Describe the bug.

furi_hal_random does not check error and ready conditions of random generators and returns empty generator output.

Reproduction

Fill buffer of size at least 40 bytes with furi_hal_random_fill_bufand view it somehow(e. g. print on screen), 8 bytes of the buffer are filled with zeroes

Target

Flipper Zero

Logs

No response

Anything else?

In #2569 logic of error checks of random generator was changed.

  • Before furi_hal_random waited for ready state (DRDY=1) and crashed on error conditions (CECS=1 or SECS=1)
  • After furi_hal_random waits for (DRDY=1 or CECS=0 or SECS=0)

I think valid condition to sample random (DRDY=1 and CECS=0 and SECS=0) and valid condition for furi_hal_random_read_rng is

while(LL_RNG_IsActiveFlag_CECS(RNG) || LL_RNG_IsActiveFlag_SECS(RNG) ||
          !LL_RNG_IsActiveFlag_DRDY(RNG)) {
    // error check logic
}
@n1kolasM
Copy link
Contributor Author

n1kolasM commented Oct 4, 2024

Simple app code for checking random output in gist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Build System & Scripts fbt, scripts and toolchain-related
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants