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

[zephyr] Added random module seed initialization. #8989

Merged

Conversation

kkasperczyk-no
Copy link
Contributor

Problem

It seems that currently random module seed for Zephyr platform is not properly initialized, as on every boot rand methods return
the same values.

Change overview

Added getting entropy source and initializing srand seed with it.

Testing

Small change, verified manually that GetRandU64() method used for generating commissionable advertising service instance name returns pseudo-random value on every attempt.

Fixes: #8931

It seems that currently random module seed for Zephyr platform
is not properly initialized, as on every boot rand methods return
the same values.

Added getting entropy source and initializing srand seed with it.
@github-actions
Copy link

Size increase report for "nrfconnect-example-build" from 1c1e161

File Section File VM
chip-shell.elf text 180 180
chip-shell.elf rodata 32 28
chip-shell.elf device_handles -4 -4
chip-lock.elf text 180 180
chip-lock.elf rodata 32 28
chip-lock.elf device_handles -4 -4
Full report output
BLOAT REPORT

Files found only in the build output:
    report.csv

Comparing ./master_artifact/chip-shell.elf and ./pull_artifact/chip-shell.elf:

sections,vmsize,filesize
.debug_info,0,921
.debug_loc,0,296
.debug_line,0,250
text,180,180
.symtab,0,80
rodata,28,32
.debug_ranges,0,24
.debug_abbrev,0,13
.debug_frame,0,8
.strtab,0,6
.shstrtab,0,2
device_handles,-4,-4

Comparing ./master_artifact/chip-lock.elf and ./pull_artifact/chip-lock.elf:

sections,vmsize,filesize
.debug_info,0,921
.debug_line,0,250
.debug_loc,0,248
text,180,180
.symtab,0,80
rodata,28,32
.debug_ranges,0,24
.debug_abbrev,0,13
.debug_frame,0,8
.strtab,0,6
.shstrtab,0,2
device_handles,-4,-4


Copy link
Contributor

@bzbarsky-apple bzbarsky-apple left a comment

Choose a reason for hiding this comment

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

This is OK as far as it goes, but do other platforms ever call srand? As in, is this a Zephyr bug, or is it a cross-platform bug to do with the (mis?)use of RandUtils to generate things?

I filed #9017 to track figuring out what should be going on here.

@kkasperczyk-no
Copy link
Contributor Author

This is OK as far as it goes, but do other platforms ever call srand? As in, is this a Zephyr bug, or is it a cross-platform bug to do with the (mis?)use of RandUtils to generate things?

I filed #9017 to track figuring out what should be going on here.

@bzbarsky-apple I don't know the status of other platforms. I haven't seen other problems reported regarding that, so I assumed that it's a Zephyr platform bug. But you might be right that it's something wider, so thanks for creating an issue.

@andy31415 andy31415 merged commit 9c48524 into project-chip:master Aug 16, 2021
nikita-s-wrk pushed a commit to nikita-s-wrk/connectedhomeip that referenced this pull request Sep 23, 2021
It seems that currently random module seed for Zephyr platform
is not properly initialized, as on every boot rand methods return
the same values.

Added getting entropy source and initializing srand seed with it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Accessories assign the same instance name for Commissionable Node Service
6 participants