From f3e72009e8ac8a149f315910bc808aff2baaddf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Mon, 27 May 2019 15:13:28 +0200 Subject: [PATCH] pkg/nordic_softdevice_ble: reset memory in the .hex file 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. --- boards/common/nrf52/Makefile.include | 2 +- pkg/nordic_softdevice_ble/Makefile | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/boards/common/nrf52/Makefile.include b/boards/common/nrf52/Makefile.include index 46dd5fffbd..21b20b001f 100644 --- a/boards/common/nrf52/Makefile.include +++ b/boards/common/nrf52/Makefile.include @@ -21,7 +21,7 @@ ifeq (jlink,$(PROGRAMMER)) # special options when using SoftDevice ifneq (,$(filter nordic_softdevice_ble,$(USEPKG))) - export JLINK_PRE_FLASH := erase\nloadfile $(BINDIR)/softdevice.hex + export JLINK_PRE_FLASH := loadfile $(BINDIR)/softdevice.hex export FLASH_ADDR := 0x1f000 export LINKER_SCRIPT ?= $(RIOTCPU)/$(CPU)/ldscripts/$(CPU_MODEL)_sd.ld # murdock: softdevice.hex file is used for flashing diff --git a/pkg/nordic_softdevice_ble/Makefile b/pkg/nordic_softdevice_ble/Makefile index 4b9ae428b1..02a2822559 100644 --- a/pkg/nordic_softdevice_ble/Makefile +++ b/pkg/nordic_softdevice_ble/Makefile @@ -21,8 +21,11 @@ prepare: $(PKG_SRCDIR)/.extracted $(BINDIR)/ble_6lowpan.a: $(PKG_SRCDIR)/.extracted cp $(PKG_SRCDIR)/$(BLE_6LOWPAN_LIB) $@ +# softdevice.hex has the `[0x8bc, 0x3000[` addresses not set. +# However, it requires that the value at `0x2000` is 0xFFFFFFFF +# We just put all the undefined memory to 0xff as it is the rom reset value anyway. $(BINDIR)/softdevice.hex: $(PKG_SRCDIR)/.extracted - cp $(PKG_SRCDIR)/$(SOFTDEVICE) $@ + $(Q)$(OBJCOPY) $(OFLAGS) -Oihex --gap-fill 0xff $(PKG_SRCDIR)/$(SOFTDEVICE) $@ $(PKG_SRCDIR)/.extracted: $(PKG_BUILDDIR)/$(PKG_FILE) rm -rf $(@D)