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

[Telink]: Fix entropy source failed crash on boot #9635

Merged
merged 6 commits into from
Sep 14, 2021
Merged

[Telink]: Fix entropy source failed crash on boot #9635

merged 6 commits into from
Sep 14, 2021

Conversation

rikorsev
Copy link
Contributor

Problem

Fix crash on startup for Telink platform with following log:

*** Booting Zephyr OS build zephyr-v2.5.0-7511-g083f3065b44a  ***
I: Notifier: StateChanged (0x00000001) [Ip6+]
I: Init CHIP stack
E: 75 [CR]mbedTLS error: CTR_DRBG - The entropy source failed
E: 80 [DL]Entropy initialization failed: Error CHIP:0x000000AC
E: PlatformMgr().InitChipStack() failed
E: Exited with code ac
I: 8 Sectors of 256 bytes
I: alloc wra: 0, e8
I: data wra: 0, 0
I: Notifier: StateChanged (0x00038200) [NetData PanId NetName ExtPanId]

Investigation shows that the issue occurs due to changes made by this #9420 PR

Did previous solution works for nRF platform?

Any way, according to previous solution, srand() were called twice.
First time in ${chip_root}/src/platform/Zephyr/PlatformManagerImpl.cpp in _InitChipStack
Second time in ${chip_root}/src/platform/Entropy.cpp in InitEntropy

Change overview

  • Remove srand call from ${chip_root}/src/platform/Zephyr/PlatformManagerImpl.cpp
  • Move Zephyr related entropy driver calls to app_entropy_source function
  • Add chip::Crypto::add_entropy_source call in _InitChipStack method

Testing

Manually. Steps:

  1. Build lighting example
  2. Flash it on Telink device
  3. Check if it does not crash on boot
  4. Pair device over chip-tool
  5. Send chip-tool onoff on 1 command
  6. Check if it works correctly

@github-actions
Copy link

Size increase report for "esp32-example-build" from e945d16

File Section File VM
chip-ipv6only-app.elf .flash.text 172 172
chip-temperature-measurement-app.elf .flash.text 32 32
chip-shell.elf .flash.text 43 48
Full report output
BLOAT REPORT

Files found only in the build output:
    report.csv

Comparing ./master_artifact/chip-ipv6only-app.elf and ./pull_artifact/chip-ipv6only-app.elf:

sections,vmsize,filesize
[Unmapped],0,3924
.flash.text,172,172

Comparing ./master_artifact/chip-temperature-measurement-app.elf and ./pull_artifact/chip-temperature-measurement-app.elf:

sections,vmsize,filesize
.flash.text,32,32
[Unmapped],0,-32

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

sections,vmsize,filesize

Comparing ./master_artifact/chip-pigweed-app.elf and ./pull_artifact/chip-pigweed-app.elf:

sections,vmsize,filesize

Comparing ./master_artifact/chip-persistent-storage.elf and ./pull_artifact/chip-persistent-storage.elf:

sections,vmsize,filesize

Comparing ./master_artifact/chip-bridge-app.elf and ./pull_artifact/chip-bridge-app.elf:

sections,vmsize,filesize

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

sections,vmsize,filesize
[Unmapped],0,4053
.flash.text,48,43

Comparing ./master_artifact/chip-all-clusters-app.elf and ./pull_artifact/chip-all-clusters-app.elf:

sections,vmsize,filesize


@github-actions
Copy link

Size increase report for "nrfconnect-example-build" from e945d16

File Section File VM
chip-lock.elf text 104 104
chip-lock.elf device_handles -8 -8
chip-shell.elf text 104 104
chip-shell.elf device_handles -8 -8
Full report output
BLOAT REPORT

Files found only in the build output:
    report.csv

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

sections,vmsize,filesize
.debug_info,0,864
.debug_loc,0,217
.debug_line,0,125
text,104,104
.strtab,0,103
.symtab,0,96
.debug_abbrev,0,59
.debug_frame,0,28
.debug_str,0,19
.debug_ranges,0,16
.debug_aranges,0,8
.shstrtab,0,1
device_handles,-8,-8

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

sections,vmsize,filesize
.debug_info,0,864
.debug_loc,0,185
.debug_line,0,125
text,104,104
.strtab,0,103
.symtab,0,96
.debug_abbrev,0,59
.debug_frame,0,28
.debug_str,0,19
.debug_ranges,0,16
.debug_aranges,0,8
.shstrtab,0,1
device_handles,-8,-8


Copy link
Contributor

@kghost kghost left a comment

Choose a reason for hiding this comment

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

Is it possible to automactically verify the issue by CI ? In case we may have regression problems like this one.

src/platform/Zephyr/PlatformManagerImpl.cpp Outdated Show resolved Hide resolved
src/platform/nrfconnect/BUILD.gn Outdated Show resolved Hide resolved
@bzbarsky-apple bzbarsky-apple merged commit 181ab66 into project-chip:master Sep 14, 2021
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.

7 participants