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

[nrfconnect] Improve SoftwareUpdateCompleted boot reason detection #21851

Merged
merged 1 commit into from
Aug 16, 2022

Conversation

Damian-Nordic
Copy link
Contributor

Problem

The existing code relies on a specific bootloader mode to detect that the last reboot was due to software update.
This method will not work correctly if a user chooses a different bootloader mode, or clears the "tentative" flag in the current firmware image before the diagnostic data provider is initialized.

Change overview

Store the software reboot reason explicitly in one of the retention registers on nRF SOCs.
Kept the previous implementation for other Zephyr platforms.

Testing

Tested OTA on nRF52 and nRF53, observed that correct boot reason (5) is detected after applying new firmware.

The existing code relies on a specific bootloader mode
to detect that the last reboot was due to software update.
This method will not work correctly if a user chooses
a different bootloader mode, or clears the "tentative"
flag in the current firmware image before the diagnostic
data provider is initialized.

Store the software reboot reason explicitly in one of the
retention registers on nRF SOCs.

Signed-off-by: Damian Krolik <[email protected]>
@github-actions
Copy link

github-actions bot commented Aug 12, 2022

PR #21851: Size comparison from afd4ab7 to 37bf10e

Increases (3 builds for bl602, nrfconnect, telink)
platform target config section afd4ab7 37bf10e8 change % change
bl602 lighting-app bl602+rpc (read/write) 1426586 1426594 8 0.0
.text 1080836 1080840 4 0.0
nrfconnect lighting-app nrf52840dongle_nrf52840 (read/write) 1074571 1074603 32 0.0
text 748232 748264 32 0.0
telink lighting-app tlsr9518adk80d text 588770 588772 2 0.0
Decreases (9 builds for nrfconnect)
platform target config section afd4ab7 37bf10e8 change % change
nrfconnect all-clusters-app nrf52840dk_nrf52840 (read/write) 1179215 1178751 -464 -0.0
rodata 143008 142848 -160 -0.1
text 814012 813708 -304 -0.0
all-clusters-minimal-app nrf52840dk_nrf52840 (read/write) 1159111 1158643 -468 -0.0
rodata 134704 134540 -164 -0.1
text 803000 802700 -300 -0.0
lighting-app nrf52840dk_nrf52840 (read/write) 1168395 1167931 -464 -0.0
rodata 124172 124012 -160 -0.1
text 820504 820204 -300 -0.0
nrf52840dk_nrf52840+rpc (read/write) 1139067 1138551 -516 -0.0
rodata 115644 115496 -148 -0.1
text 797732 797356 -376 -0.0
nrf5340dk_nrf5340_cpuapp (read/write) 1071966 1071482 -484 -0.0
rodata 116588 116424 -164 -0.1
text 733068 732752 -316 -0.0
lock-app nrf52840dk_nrf52840 (read/write) 1128203 1127735 -468 -0.0
rodata 142156 141992 -164 -0.1
text 771408 771104 -304 -0.0
nrf5340dk_nrf5340_cpuapp (read/write) 1031946 1031478 -468 -0.0
rodata 134632 134468 -164 -0.1
text 684032 683716 -316 -0.0
pump-app nrf52840dk_nrf52840 (read/write) 1080067 1079599 -468 -0.0
rodata 117508 117344 -164 -0.1
text 748964 748668 -296 -0.0
pump-controller-app nrf52840dk_nrf52840 (read/write) 1066579 1066127 -452 -0.0
rodata 113988 113824 -164 -0.1
text 739264 738964 -300 -0.0
Full report (51 builds for bl602, cc13x2_26x2, cyw30739, efr32, esp32, k32w, linux, mbed, nrfconnect, p6, telink)
platform target config section afd4ab7 37bf10e8 change % change
bl602 lighting-app bl602 (read/write) 1381338 1381338 0 0.0
.bss 119826 119826 0 0.0
.data 4480 4480 0 0.0
.text 1049336 1049336 0 0.0
bl602+rpc (read/write) 1426586 1426594 8 0.0
.bss 127266 127266 0 0.0
.data 4600 4600 0 0.0
.text 1080836 1080840 4 0.0
cc13x2_26x2 all-clusters-app LP_CC2652R7 (read only) 671751 671751 0 0.0
(read/write) 179704 179704 0 0.0
.bss 74348 74348 0 0.0
.data 3372 3372 0 0.0
.rodata 88567 88567 0 0.0
.text 582868 582868 0 0.0
all-clusters-minimal-app LP_CC2652R7 (read only) 637159 637159 0 0.0
(read/write) 157924 157924 0 0.0
.bss 73636 73636 0 0.0
.data 3372 3372 0 0.0
.rodata 77823 77823 0 0.0
.text 559012 559012 0 0.0
lock-ftd LP_CC2652R7 (read only) 673507 673507 0 0.0
(read/write) 168140 168140 0 0.0
.bss 71428 71428 0 0.0
.data 3296 3296 0 0.0
.rodata 76507 76507 0 0.0
.text 596520 596520 0 0.0
lock-mtd LP_CC2652R7 (read only) 656123 656123 0 0.0
(read/write) 181212 181212 0 0.0
.bss 67116 67116 0 0.0
.data 3296 3296 0 0.0
.rodata 101467 101467 0 0.0
.text 554176 554176 0 0.0
pump-app LP_CC2652R7 (read only) 683915 683915 0 0.0
(read/write) 158540 158540 0 0.0
.bss 71468 71468 0 0.0
.data 3296 3296 0 0.0
.rodata 89523 89523 0 0.0
.text 593908 593908 0 0.0
pump-controller-app LP_CC2652R7 (read only) 668367 668367 0 0.0
(read/write) 174208 174208 0 0.0
.bss 71588 71588 0 0.0
.data 3292 3292 0 0.0
.rodata 85071 85071 0 0.0
.text 582816 582816 0 0.0
shell LP_CC2652R7 (read only) 664426 664426 0 0.0
(read/write) 182548 182548 0 0.0
.bss 76668 76668 0 0.0
.data 3376 3376 0 0.0
.rodata 85514 85514 0 0.0
.text 578596 578596 0 0.0
cyw30739 light cyw930739m2evb_01 (read/write) 585614 585614 0 0.0
.app_xip_area 462336 462336 0 0.0
.bss 65720 65720 0 0.0
.data 744 744 0 0.0
.rodata 0 0 0 0.0
.text 112 112 0 0.0
lock cyw930739m2evb_01 (read/write) 591430 591430 0 0.0
.app_xip_area 463368 463368 0 0.0
.bss 70504 70504 0 0.0
.data 748 748 0 0.0
.rodata 0 0 0 0.0
.text 112 112 0 0.0
ota-requestor-no-progress-logging cyw930739m2evb_01 (read/write) 598258 598258 0 0.0
.app_xip_area 475700 475700 0 0.0
.bss 65032 65032 0 0.0
.data 716 716 0 0.0
.rodata 0 0 0 0.0
.text 112 112 0 0.0
efr32 lighting-app BRD4161A (read/write) 1098172 1098172 0 0.0
.bss 132924 132924 0 0.0
.data 2068 2068 0 0.0
.text 963156 963156 0 0.0
BRD4161A+rpc (read/write) 1152436 1152436 0 0.0
.bss 149612 149612 0 0.0
.data 2280 2280 0 0.0
.text 1000524 1000524 0 0.0
BRD4161A+rs911x (read/write) 987596 987596 0 0.0
.bss 162264 162264 0 0.0
.data 2056 2056 0 0.0
.text 823256 823256 0 0.0
lock-app BRD4161A+wf200 (read/write) 1137676 1137676 0 0.0
.bss 144904 144904 0 0.0
.data 2064 2064 0 0.0
.text 990688 990688 0 0.0
window-app BRD4161A (read/write) 1089608 1089608 0 0.0
.bss 134356 134356 0 0.0
.data 2096 2096 0 0.0
.text 953136 953136 0 0.0
esp32 all-clusters-app c3devkit (read only) 1027004 1027004 0 0.0
(read/write) 1487762 1487762 0 0.0
.dram0.bss 70424 70424 0 0.0
.dram0.data 14600 14600 0 0.0
.flash.rodata 217296 217296 0 0.0
.flash.text 1027004 1027004 0 0.0
.iram0.text 62902 62902 0 0.0
m5stack (read only) 1080391 1080391 0 0.0
(read/write) 489712 489712 0 0.0
.dram0.bss 75928 75928 0 0.0
.dram0.data 34144 34144 0 0.0
.flash.rodata 247644 247644 0 0.0
.flash.text 1075007 1075007 0 0.0
.iram0.text 123267 123267 0 0.0
k32w light k32w0+release (read/write) 644548 644548 0 0.0
.bss 69792 69792 0 0.0
.data 2044 2044 0 0.0
.text 569984 569984 0 0.0
lock k32w0+release (read/write) 701836 701836 0 0.0
.bss 70264 70264 0 0.0
.data 2052 2052 0 0.0
.text 626792 626792 0 0.0
linux all-clusters-app debug (read only) 3030041 3030041 0 0.0
(read/write) 155760 155760 0 0.0
.bss 61888 61888 0 0.0
.data 2096 2096 0 0.0
.data.rel.ro 85416 85416 0 0.0
.dynamic 608 608 0 0.0
.got 4568 4568 0 0.0
.init 27 27 0 0.0
.init_array 1160 1160 0 0.0
.rodata 273771 273771 0 0.0
.text 2577314 2577314 0 0.0
all-clusters-minimal-app debug (read only) 2869833 2869833 0 0.0
(read/write) 147496 147496 0 0.0
.bss 61152 61152 0 0.0
.data 2064 2064 0 0.0
.data.rel.ro 78008 78008 0 0.0
.dynamic 608 608 0 0.0
.got 4488 4488 0 0.0
.init 27 27 0 0.0
.init_array 1152 1152 0 0.0
.rodata 273899 273899 0 0.0
.text 2419682 2419682 0 0.0
bridge-app debug+rpc (read only) 2368721 2368721 0 0.0
(read/write) 127456 127456 0 0.0
.bss 50624 50624 0 0.0
.data 3600 3600 0 0.0
.data.rel.ro 67368 67368 0 0.0
.dynamic 608 608 0 0.0
.got 4392 4392 0 0.0
.init 27 27 0 0.0
.init_array 824 824 0 0.0
.rodata 202760 202760 0 0.0
.text 2003458 2003458 0 0.0
chip-tool debug (read only) 10656833 10656833 0 0.0
(read/write) 650816 650816 0 0.0
.bss 25240 25240 0 0.0
.data 3266 3266 0 0.0
.data.rel.ro 615784 615784 0 0.0
.dynamic 608 608 0 0.0
.got 5096 5096 0 0.0
.init 27 27 0 0.0
.init_array 768 768 0 0.0
.rodata 552021 552021 0 0.0
.text 8599140 8599140 0 0.0
chip-tool-ipv6only arm64 (read only) 10067092 10067092 0 0.0
(read/write) 698545 698545 0 0.0
.bss 33281 33281 0 0.0
.data 3272 3272 0 0.0
.data.rel.ro 643320 643320 0 0.0
.dynamic 560 560 0 0.0
.got 13712 13712 0 0.0
.init 24 24 0 0.0
.init_array 192 192 0 0.0
.rodata 483044 483044 0 0.0
.text 7947236 7947236 0 0.0
lighting-app debug+rpc (read only) 2592705 2592705 0 0.0
(read/write) 130048 130048 0 0.0
.bss 49760 49760 0 0.0
.data 2096 2096 0 0.0
.data.rel.ro 72248 72248 0 0.0
.dynamic 608 608 0 0.0
.got 4392 4392 0 0.0
.init 27 27 0 0.0
.init_array 920 920 0 0.0
.rodata 219504 219504 0 0.0
.text 2202610 2202610 0 0.0
lock-app debug (read only) 2576665 2576665 0 0.0
(read/write) 125416 125416 0 0.0
.bss 48288 48288 0 0.0
.data 1712 1712 0 0.0
.data.rel.ro 69416 69416 0 0.0
.dynamic 608 608 0 0.0
.got 4464 4464 0 0.0
.init 27 27 0 0.0
.init_array 896 896 0 0.0
.rodata 236592 236592 0 0.0
.text 2173538 2173538 0 0.0
ota-provider-app debug (read only) 2353825 2353825 0 0.0
(read/write) 118848 118848 0 0.0
.bss 47808 47808 0 0.0
.data 1936 1936 0 0.0
.data.rel.ro 63224 63224 0 0.0
.dynamic 608 608 0 0.0
.got 4488 4488 0 0.0
.init 27 27 0 0.0
.init_array 760 760 0 0.0
.rodata 208568 208568 0 0.0
.text 1981906 1981906 0 0.0
ota-requestor-app debug (read only) 2519553 2519553 0 0.0
(read/write) 127192 127192 0 0.0
.bss 50304 50304 0 0.0
.data 2304 2304 0 0.0
.data.rel.ro 68632 68632 0 0.0
.dynamic 608 608 0 0.0
.got 4480 4480 0 0.0
.init 27 27 0 0.0
.init_array 848 848 0 0.0
.rodata 215328 215328 0 0.0
.text 2131778 2131778 0 0.0
shell debug (read only) 2598377 2598377 0 0.0
(read/write) 141912 141912 0 0.0
.bss 57800 57800 0 0.0
.data 1264 1264 0 0.0
.data.rel.ro 77024 77024 0 0.0
.dynamic 608 608 0 0.0
.got 4136 4136 0 0.0
.init 27 27 0 0.0
.init_array 1032 1032 0 0.0
.rodata 233906 233906 0 0.0
.text 2206242 2206242 0 0.0
thermostat-no-ble arm64 (read only) 2353460 2353460 0 0.0
(read/write) 141681 141681 0 0.0
.bss 55313 55313 0 0.0
.data 1672 1672 0 0.0
.data.rel.ro 75880 75880 0 0.0
.dynamic 560 560 0 0.0
.got 5040 5040 0 0.0
.init 24 24 0 0.0
.init_array 408 408 0 0.0
.rodata 139980 139980 0 0.0
.text 1975952 1975952 0 0.0
tv-app debug (read only) 3170585 3170585 0 0.0
(read/write) 257872 257872 0 0.0
.bss 167480 167480 0 0.0
.data 4736 4736 0 0.0
.data.rel.ro 79096 79096 0 0.0
.dynamic 608 608 0 0.0
.got 4856 4856 0 0.0
.init 27 27 0 0.0
.init_array 1072 1072 0 0.0
.rodata 258536 258536 0 0.0
.text 2722354 2722354 0 0.0
tv-casting-app debug (read only) 5411001 5411001 0 0.0
(read/write) 158992 158992 0 0.0
.bss 51448 51448 0 0.0
.data 2432 2432 0 0.0
.data.rel.ro 98672 98672 0 0.0
.dynamic 608 608 0 0.0
.got 4776 4776 0 0.0
.init 27 27 0 0.0
.init_array 1040 1040 0 0.0
.rodata 341777 341777 0 0.0
.text 4800994 4800994 0 0.0
mbed lock-app CY8CPROTO_062_4343W+release (read only) 6224 6224 0 0.0
(read/write) 2453528 2453528 0 0.0
.bss 214636 214636 0 0.0
.data 5872 5872 0 0.0
.text 1416172 1416172 0 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 (read/write) 1179215 1178751 -464 -0.0
bss 143294 143294 0 0.0
rodata 143008 142848 -160 -0.1
text 814012 813708 -304 -0.0
all-clusters-minimal-app nrf52840dk_nrf52840 (read/write) 1159111 1158643 -468 -0.0
bss 142532 142532 0 0.0
rodata 134704 134540 -164 -0.1
text 803000 802700 -300 -0.0
lighting-app nrf52840dk_nrf52840 (read/write) 1168395 1167931 -464 -0.0
bss 144875 144875 0 0.0
rodata 124172 124012 -160 -0.1
text 820504 820204 -300 -0.0
nrf52840dk_nrf52840+rpc (read/write) 1139067 1138551 -516 -0.0
bss 145288 145288 0 0.0
rodata 115644 115496 -148 -0.1
text 797732 797356 -376 -0.0
nrf52840dongle_nrf52840 (read/write) 1074571 1074603 32 0.0
bss 152090 152090 0 0.0
rodata 93116 93116 0 0.0
text 748232 748264 32 0.0
nrf5340dk_nrf5340_cpuapp (read/write) 1071966 1071482 -484 -0.0
bss 141246 141246 0 0.0
rodata 116588 116424 -164 -0.1
text 733068 732752 -316 -0.0
lock-app nrf52840dk_nrf52840 (read/write) 1128203 1127735 -468 -0.0
bss 135831 135831 0 0.0
rodata 142156 141992 -164 -0.1
text 771408 771104 -304 -0.0
nrf5340dk_nrf5340_cpuapp (read/write) 1031946 1031478 -468 -0.0
bss 132234 132234 0 0.0
rodata 134632 134468 -164 -0.1
text 684032 683716 -316 -0.0
pump-app nrf52840dk_nrf52840 (read/write) 1080067 1079599 -468 -0.0
bss 134730 134730 0 0.0
rodata 117508 117344 -164 -0.1
text 748964 748668 -296 -0.0
pump-controller-app nrf52840dk_nrf52840 (read/write) 1066579 1066127 -452 -0.0
bss 134513 134513 0 0.0
rodata 113988 113824 -164 -0.1
text 739264 738964 -300 -0.0
p6 all-clusters-app default (read only) 881448 881448 0 0.0
(read/write) 1695348 1695348 0 0.0
.bss 149240 149240 0 0.0
.data 2656 2656 0 0.0
.text 1535064 1535064 0 0.0
all-clusters-minimal-app default (read only) 882168 882168 0 0.0
(read/write) 1639388 1639388 0 0.0
.bss 148520 148520 0 0.0
.data 2656 2656 0 0.0
.text 1479824 1479824 0 0.0
light-app default (read only) 890488 890488 0 0.0
(read/write) 1558068 1558068 0 0.0
.bss 140408 140408 0 0.0
.data 2448 2448 0 0.0
.text 1406824 1406824 0 0.0
lock-app default (read only) 885992 885992 0 0.0
(read/write) 1595236 1595236 0 0.0
.bss 144888 144888 0 0.0
.data 2464 2464 0 0.0
.text 1439496 1439496 0 0.0
telink light-switch-app tlsr9518adk80d (read/write) 807296 807296 0 0.0
bss 71040 71040 0 0.0
noinit 43488 43488 0 0.0
text 570694 570694 0 0.0
lighting-app tlsr9518adk80d (read/write) 829216 829216 0 0.0
bss 71896 71896 0 0.0
noinit 43488 43488 0 0.0
text 588770 588772 2 0.0

@woody-apple woody-apple enabled auto-merge (squash) August 15, 2022 23:15
@woody-apple woody-apple merged commit 815902c into project-chip:master Aug 16, 2022
Damian-Nordic added a commit to Damian-Nordic/connectedhomeip that referenced this pull request Sep 1, 2022
…on detection (project-chip#21851)

The existing code relies on a specific bootloader mode
to detect that the last reboot was due to software update.
This method will not work correctly if a user chooses
a different bootloader mode, or clears the "tentative"
flag in the current firmware image before the diagnostic
data provider is initialized.

Store the software reboot reason explicitly in one of the
retention registers on nRF SOCs.

Signed-off-by: Damian Krolik <[email protected]>

Signed-off-by: Damian Krolik <[email protected]>
(cherry picked from commit 815902c)
Damian-Nordic pushed a commit to Damian-Nordic/connectedhomeip that referenced this pull request Sep 1, 2022
isiu-apple pushed a commit to isiu-apple/connectedhomeip that referenced this pull request Sep 16, 2022
…roject-chip#21851)

The existing code relies on a specific bootloader mode
to detect that the last reboot was due to software update.
This method will not work correctly if a user chooses
a different bootloader mode, or clears the "tentative"
flag in the current firmware image before the diagnostic
data provider is initialized.

Store the software reboot reason explicitly in one of the
retention registers on nRF SOCs.

Signed-off-by: Damian Krolik <[email protected]>

Signed-off-by: Damian Krolik <[email protected]>
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.

2 participants