Skip to content

nRF52 Fix softdevice.hex flashing issue#5893

Merged
kaspar030 merged 1 commit intoRIOT-OS:masterfrom
jfbortolotti:nRF52_flashing
Oct 4, 2016
Merged

nRF52 Fix softdevice.hex flashing issue#5893
kaspar030 merged 1 commit intoRIOT-OS:masterfrom
jfbortolotti:nRF52_flashing

Conversation

@jfbortolotti
Copy link
Copy Markdown
Contributor

I found the following issue with nRF52DK board:
When flashing the microcoap_server example after the hello_world example, the microcoap_server application will not work (nothing on the serial interface).
This is due to the fact that the microcoap_server uses the softdevice.hex stack and this stack is checking that value at 0x2000 is 0xFFFFFFFF. This address is not present in the softdevice.hex.
The work around found on the forums is to do an "nrfjprog --family NRF52 --recover" before flashing the microcoap_server application(and the softdevice).

This patch avoid to do a manual "nrfjprog --family NRF52 --recover" by including an erase command to the JLink pre flash command before flashing the softdevice.hex.

@kaspar030 kaspar030 added Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors) Area: build system Area: Build system labels Sep 29, 2016
@kaspar030 kaspar030 self-assigned this Sep 29, 2016
# special options when using SoftDevice
ifneq (,$(filter nordic_softdevice_ble,$(USEPKG)))
export JLINK_PRE_FLASH := loadfile $(BINDIR)/softdevice.hex
export JLINK_PRE_FLASH := erase\nloadfile $(BINDIR)/softdevice.hex
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Like this, on my system, it leads to

erase\nloadfile <path>/softdevice.hex

being the first line of burn.seg, which results in an error message.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Humm .. what is your system ?
I have tried this on my Ubuntu 14.04.
This may be a side effect of the shell as the JLink.sh is executed by a sh -c.
My system has /bin/sh pointing to dash.
Can you check on your system ? ls -l which sh ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I confirmed with a quick test that this is related to bash versus dash.
in bash, echo "erase\nloadfile" will output erase\nloadfile. You will need to add -e to have the \n handled: echo -e "erase\nloadfile" will output:
erase
loadfile

Using dash, echo -e is not supported and the escape characters are handled.
echo "erase\nloadfile" will output:
erase
loadfile
While echo -e "erase\nloadfile" will output:
-e erase
loadfile
It is recommended to use printf for portability as per : https://wiki.ubuntu.com/DashAsBinSh#echo
This will mean: replace echo "${JLINK_PRE_FLASH}" >> pathtobin/burn.seg
by
printf "${JLINK_PRE_FLASH}\n" >> pathtobin/burn.seg

Let me know what you think

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

another solution is to use /bin/echo instead of echo like it is done some lines above in dist/tools/jlink/jlink.sh.
/bin/echo behaves as the bash version, so we will need to call it with -e .
Let me if you have a preference.
For portability I would better move to printf but for linux based system /bin/echo should work.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Then printf is the way to go.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ok, I'll update the patch and push it.
Jeff.

@kaspar030
Copy link
Copy Markdown
Contributor

Then printf is the way to go.

Would you mind creating another PR for the jlink.sh change?

@jfbortolotti
Copy link
Copy Markdown
Contributor Author

I updated the PR with a new commit for the printf in jlink.sh.
Then I realized you were looking for a different PR with a different PR with just the jlink.sh change ...
Just let me know what you want so I can help make it.

@kaspar030
Copy link
Copy Markdown
Contributor

I updated the PR with a new commit for the printf in jlink.sh.
Then I realized you were looking for a different PR with a different PR with just the jlink.sh change ...
Just let me know what you want so I can help make it.

Sorry, I was too slow. Please rename the jlink.sh change commit so it says sth like "dist: tools: jlink.sh: use printf for JLINK_*_FLASH to allow use of backslash escapes", and make it also fix JLINK_POST_FLASH to use printf.

@jfbortolotti
Copy link
Copy Markdown
Contributor Author

So, I updated this branch to only have the addition of the "Erase" in the boards/nrf52/Makefile.include and I created another PR for just the printf for JLINK_*_FLASH variables: #5900

Copy link
Copy Markdown
Contributor

@kaspar030 kaspar030 left a comment

Choose a reason for hiding this comment

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

ACK.

@kaspar030 kaspar030 added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Sep 30, 2016
@kaspar030
Copy link
Copy Markdown
Contributor

So, I updated this branch to only have the addition of the "Erase" in the boards/nrf52/Makefile.include and I created another PR for just the printf for JLINK_*_FLASH variables: #5900

Thanks a lot for finding this and also thank you for taking the time to polish the PRs!

@jfbortolotti
Copy link
Copy Markdown
Contributor Author

jfbortolotti commented Oct 1, 2016

I checked the CI errors:
x86: problem to download the newlib from http://download.riot-os.org/i586-newlib_2.2.0.20150623_tlsf-3337.tar.bz2
Other cortex_m4_1/2 & m0_1 errors are due to issue to access git.savannah.nongnu.org to clone lwip repository. Nothing to do with this PR per say.

@miri64 miri64 added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Oct 3, 2016
@kaspar030 kaspar030 added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Oct 4, 2016
@kaspar030
Copy link
Copy Markdown
Contributor

ACK&go!

@kaspar030 kaspar030 merged commit ab2a255 into RIOT-OS:master Oct 4, 2016
@OlegHahm OlegHahm added this to the Release 2016.10 milestone Oct 13, 2016
cladmi added a commit to cladmi/RIOT that referenced this pull request Jun 3, 2019
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 that memory set to 0xff as it is the rom
reset value.

This change updates the `.hex` file instead on relying on erasing the
memory.
cladmi added a commit to cladmi/RIOT that referenced this pull request Jun 3, 2019
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 added a commit to cladmi/RIOT that referenced this pull request Jun 26, 2019
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 added a commit to cladmi/RIOT that referenced this pull request Jul 1, 2019
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 added a commit to cladmi/RIOT that referenced this pull request Jul 5, 2019
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 added a commit to cladmi/RIOT that referenced this pull request Jul 8, 2019
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 added a commit to cladmi/RIOT that referenced this pull request Jul 18, 2019
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 added a commit to cladmi/RIOT that referenced this pull request Jul 18, 2019
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 added a commit to cladmi/RIOT that referenced this pull request Jul 24, 2019
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 added a commit to cladmi/RIOT that referenced this pull request Jul 25, 2019
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 added a commit to cladmi/RIOT that referenced this pull request Jul 29, 2019
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 added a commit to cladmi/RIOT that referenced this pull request Aug 12, 2019
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 added a commit to cladmi/RIOT that referenced this pull request Aug 12, 2019
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 added a commit to cladmi/RIOT that referenced this pull request Aug 12, 2019
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 added a commit to cladmi/RIOT that referenced this pull request Aug 16, 2019
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 added a commit to cladmi/RIOT that referenced this pull request Aug 21, 2019
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 added a commit to cladmi/RIOT that referenced this pull request Aug 21, 2019
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 added a commit to cladmi/RIOT that referenced this pull request Aug 22, 2019
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 added a commit to cladmi/RIOT that referenced this pull request Aug 26, 2019
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 added a commit to cladmi/RIOT that referenced this pull request Aug 27, 2019
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 added a commit to cladmi/RIOT that referenced this pull request Aug 29, 2019
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 added a commit to cladmi/RIOT that referenced this pull request Sep 2, 2019
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 added a commit to cladmi/RIOT that referenced this pull request Sep 9, 2019
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: build system Area: Build system CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants