Skip to content

pkg/nordic_softdevice_ble: reset memory in the .hex file#11620

Merged
aabadie merged 1 commit intoRIOT-OS:masterfrom
cladmi:pr/softdevice/ensure_memory_value
Sep 10, 2019
Merged

pkg/nordic_softdevice_ble: reset memory in the .hex file#11620
aabadie merged 1 commit intoRIOT-OS:masterfrom
cladmi:pr/softdevice/ensure_memory_value

Conversation

@cladmi
Copy link
Copy Markdown
Contributor

@cladmi cladmi commented Jun 3, 2019

Contribution description

softdevice needs the memory at 0x2000 to be initialized to 0xffffffff
according to #5893 and testing. However, the addresses [0x8bc, 0x3000[ are not
set in softdevice.hex.

So use a modified hex file with all the memory set to 0xff as it is the rom
reset value anyway.

This change updates the .hex file instead on relying on erasing the
memory.

Testing procedure

Testing procedure adapted from #11470

Hack not needed anymore

Comment FEATURES_OPTIONAL += periph_hwrng in Makefile.dep as it currently prevent gnrc_networking to work even in master.

diff --git a/Makefile.dep b/Makefile.dep
index 3de6f2bf7..b45f78142 100644
--- a/Makefile.dep
+++ b/Makefile.dep
@@ -680,7 +680,7 @@ ifneq (,$(filter random,$(USEMODULE)))
   endif
 
   ifeq (,$(filter puf_sram,$(USEMODULE)))
-    FEATURES_OPTIONAL += periph_hwrng
+    #FEATURES_OPTIONAL += periph_hwrng
   endif
 
   USEMODULE += luid

Then try

BOARD=nrf52dk make -C examples/saul flash
BOARD=nrf52dk make -C examples/gnrc_networking flash term
# The board should reply

2019-06-03 18:38:47,103 - INFO # Connect to serial port /dev/riot/ttyNRF52DK
Welcome to pyterm!
Type '/exit' to exit.
2019-06-03 18:38:48,106 - INFO # main(): This is RIOT! (Version: 2019.07-devel-554-g5ef30-pr/softdevice/ensure_memory_value)
2019-06-03 18:38:48,107 - INFO # RIOT network stack example application
2019-06-03 18:38:48,107 - INFO # All up, running the shell now
> help
2019-06-03 18:38:51,295 - INFO #  help
2019-06-03 18:38:51,298 - INFO # Command              Description
2019-06-03 18:38:51,301 - INFO # ---------------------------------------
2019-06-03 18:38:51,307 - INFO # udp                  send data over UDP and listen on UDP ports
2019-06-03 18:38:51,310 - INFO # reboot               Reboot the node
2019-06-03 18:38:51,316 - INFO # ps                   Prints information about running threads.
2019-06-03 18:38:51,319 - INFO # ping6                Ping via ICMPv6
2019-06-03 18:38:51,322 - INFO # random_init          initializes the PRNG
2019-06-03 18:38:51,327 - INFO # random_get           returns 32 bit of pseudo randomness
2019-06-03 18:38:51,332 - INFO # nib                  Configure neighbor information base
2019-06-03 18:38:51,337 - INFO # ifconfig             Configure network interfaces

Without only removing the erase it would fail.

On my board it worked without the fix… but was not working alone in #11470

Issues/PRs references

Alternative fix done in #5893
Was required to not duplicate the erase in openocd as here the issue is the flashed file, not that erasing memory should be done.
Split out of #11470

@cladmi cladmi added Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation Area: network Area: Networking Area: pkg Area: External package ports labels Jun 3, 2019
@cladmi cladmi requested review from aabadie and kaspar030 June 3, 2019 16:34
@cladmi cladmi added this to the Release 2019.07 milestone Jun 3, 2019
@cladmi cladmi force-pushed the pr/softdevice/ensure_memory_value branch from 5ef3001 to 895a012 Compare August 12, 2019 09:25
@cladmi
Copy link
Copy Markdown
Contributor Author

cladmi commented Aug 12, 2019

Rebased on #11995

@cladmi cladmi force-pushed the pr/softdevice/ensure_memory_value branch from 895a012 to 9dfd59b Compare August 12, 2019 10:02
softdevice needs the memory at 0x2000 to be initialized to 0xffffffff
according to RIOT-OS#5893 and testing. However, the addresses [0x8bc, 0x3000[ are not
set in softdevice.hex.

So use a modified hex file with all the memory set to 0xff as it is the rom
reset value anyway.

This change updates the `.hex` file instead on relying on erasing the
memory.
@cladmi cladmi force-pushed the pr/softdevice/ensure_memory_value branch from 9dfd59b to f3e7200 Compare August 12, 2019 13:55
@cladmi
Copy link
Copy Markdown
Contributor Author

cladmi commented Aug 12, 2019

Rebased again now that #11995 is merged.

@cladmi
Copy link
Copy Markdown
Contributor Author

cladmi commented Aug 12, 2019

@aabadie I updated the documentation now that periph_hwrng works, and is rebased now that #11995 is merged so could be tested on murdock boards
@MrKevinWeiss you may also be able to take a look

@aabadie aabadie added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Reviewed: 1-fundamentals The fundamentals of the PR were reviewed according to the maintainer guidelines Reviewed: 2-code-design The code design of the PR was reviewed according to the maintainer guidelines Reviewed: 4-code-style The adherence to coding conventions by the PR were reviewed according to the maintainer guidelines Reviewed: 5-documentation The documentation details of the PR were reviewed according to the maintainer guidelines labels Sep 9, 2019
@aabadie
Copy link
Copy Markdown
Contributor

aabadie commented Sep 10, 2019

@cladmi, I tried this PR and I can't reproduce the initial problem by following the testing procedure: the flashed firmware always works, even if not gap filling the softdevice.

This is weird. Are you sure this is only required when flashing using OpenOCD ?

@cladmi
Copy link
Copy Markdown
Contributor Author

cladmi commented Sep 10, 2019

No it is not required only for openocd, it started showing with openocd as I tried to not use the erase with it due to being a pain.

You can find the reference why the erase was added here #5893 and this provides, for me, a better fix for the issue as it fixes the file, not configuring the flasher.

In long term fixes, I would even try to generate the Elf file with the .hex included.

@cladmi
Copy link
Copy Markdown
Contributor Author

cladmi commented Sep 10, 2019

Thank you for testing again.

I found the reason. As I did not added $(MAKEFILE_LIST) as dependency to the file, you must clean between the two steps. I can add it if you want. I do not do this by default as it is not done anywhere otherwise, but would be indeed be better!

These automated steps reproduce the issue for me:

BOARD=nrf52dk make -C examples/saul flash
git reset HEAD^ pkg/nordic_softdevice_ble/ ; git checkout pkg/nordic_softdevice_ble/
BOARD=nrf52dk make -C examples/gnrc_networking clean flash term

...
/home/harter/work/git/RIOT/dist/tools/pyterm/pyterm -p "/dev/ttyACM0" -b "115200"
Twisted not available, please install it if you want to use pyterm's JSON capabilities
2019-09-10 13:39:16,413 - INFO # Connect to serial port /dev/ttyACM0
Welcome to pyterm!
Type '/exit' to exit.


help
2019-09-10 13:39:25,610 - INFO # Exiting Pyterm

And I get no interaction.

Then I reset my repository and clean:

git reset HEAD pkg/nordic_softdevice_ble/ ; git checkout pkg/nordic_softdevice_ble/
BOARD=nrf52dk make -C examples/saul flash
BOARD=nrf52dk make -C examples/gnrc_networking clean flash term

...
Type '/exit' to exit.
2019-09-10 13:36:17,535 - INFO # main(): This is RIOT! (Version: 2019.10-devel-374-gf3e72-pr/softdevice/ensure_memory_value)
2019-09-10 13:36:17,536 - INFO # RIOT network stack example application
2019-09-10 13:36:17,536 - INFO # All up, running the shell now
> help
2019-09-10 13:37:03,180 - INFO #  help
2019-09-10 13:37:03,183 - INFO # Command              Description
2019-09-10 13:37:03,186 - INFO # ---------------------------------------
2019-09-10 13:37:03,192 - INFO # udp                  send data over UDP and listen on UDP ports
2019-09-10 13:37:03,195 - INFO # reboot               Reboot the node
2019-09-10 13:37:03,201 - INFO # ps                   Prints information about running threads.
2019-09-10 13:37:03,204 - INFO # ping6                Ping via ICMPv6
2019-09-10 13:37:03,207 - INFO # random_init          initializes the PRNG
2019-09-10 13:37:03,212 - INFO # random_get           returns 32 bit of pseudo randomness
2019-09-10 13:37:03,217 - INFO # nib                  Configure neighbor information base
2019-09-10 13:37:03,222 - INFO # ifconfig             Configure network interfaces
> 2019-09-10 13:37:03,770 - INFO # Exiting Pyterm

@aabadie
Copy link
Copy Markdown
Contributor

aabadie commented Sep 10, 2019

This is funny, because I strictly followed your commands above and I can't reproduce the issue... It always works for me.
What version of JLink do you use ?

SEGGER J-Link Commander V6.40 (Compiled Oct 26 2018 15:08:38)
DLL version V6.40, compiled Oct 26 2018 15:08:28

@cladmi
Copy link
Copy Markdown
Contributor Author

cladmi commented Sep 10, 2019

I have a newer one indeed:

JLinkExe --version
SEGGER J-Link Commander V6.42d (Compiled Feb 15 2019 13:56:53)
DLL version V6.42d, compiled Feb 15 2019 13:56:43

Unknown command line option --version.

And I use this gcc version:

arm-none-eabi-gcc --version
arm-none-eabi-gcc (GNU Tools for Arm Embedded Processors 7-2018-q2-update) 7.3.1 20180622 (release) [ARM/embedded-7-branch revision 261907]
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

@cladmi
Copy link
Copy Markdown
Contributor Author

cladmi commented Sep 10, 2019

I also just retried by setting export BUILD_IN_DOCKER=1 then executing the same commands and it fails as expected.

@aabadie
Copy link
Copy Markdown
Contributor

aabadie commented Sep 10, 2019

I installed a newer version of JLink and could reproduce the issue, yeah!
With the older version this PR is not breaking any thing. So let's merge!

Copy link
Copy Markdown
Contributor

@aabadie aabadie left a comment

Choose a reason for hiding this comment

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

ACK!

@aabadie aabadie merged commit 3059e03 into RIOT-OS:master Sep 10, 2019
@cladmi
Copy link
Copy Markdown
Contributor Author

cladmi commented Sep 10, 2019

Thank you for the review! :) I will rebase the other PRs.

@cladmi cladmi deleted the pr/softdevice/ensure_memory_value branch September 10, 2019 13:57
@kb2ma kb2ma added this to the Release 2019.10 milestone Sep 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: network Area: Networking Area: pkg Area: External package ports CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Reviewed: 1-fundamentals The fundamentals of the PR were reviewed according to the maintainer guidelines Reviewed: 2-code-design The code design of the PR was reviewed according to the maintainer guidelines Reviewed: 4-code-style The adherence to coding conventions by the PR were reviewed according to the maintainer guidelines Reviewed: 5-documentation The documentation details of the PR were reviewed according to the maintainer guidelines Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants