-
Notifications
You must be signed in to change notification settings - Fork 2.1k
pkg/nordic_softdevice_ble: fix broken package #8068
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
Conversation
I think the title is very misleading. This is more about the interaction with the build system, not the shell. When first reading the description I thought you were talking about |
I know but I didn't find a suitable title for this one because the main issue was that the shell was dead with softdevice enable (#6379) but when I investigate this issue, I found that shell was OK but the CPU die early in the init process (within |
I think the title should in general explain what the PR does. If it (coincidentally or not) fixes an issue that might describe other symptoms caused due to a bug the PR fixes, that should be mentioned in the PRs description.
I'm not sure was your PR does exactly, so I don't know to what ;-) |
I've made a few changes on this, I had to change the Finally I set the dedicated GPIO to the reset function which is (I think) important. Any help on this PR is welcome :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small problem when not using softdevice, otherwise I tested and the thing seem to work again. Thanks for the patch!
boards/nrf52dk/Makefile.include
Outdated
@@ -10,7 +10,7 @@ PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*))) | |||
export JLINK_DEVICE := nrf52 | |||
|
|||
# special options when using SoftDevice | |||
ifneq (,$(filter nordic_softdevice_ble,$(USEPKG))) | |||
ifeq (,$(filter nordic_softdevice_ble,$(USEPKG))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change works when nordic_softdevice_ble is necessary, but for instance the hello-world example doesn't work... This needs to be defined somewhere else (after USEPKG += nordic_softdevice_ble
is declared), but I don't have in mind right now where it's suitable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As tested with @kYc0o, this check cannot work as nordic_softdevice_ble
is added to USEPKG
only during dependency resolution with happens after including Makefile.include
.
Thanks for testing @kYc0o ! |
Well as far as I see there's not too much that can be done, the softdevice takes priority over RIOT since it has most of initialisation code, vector table assignation, etc. so I don't see how can RIOT co-exist with such a blob without those modifications. I'd say let's leave it as it is for now, since there are plans to add support for that radio on RIOT natively. By then maybe we'll deprecate softdevice. |
AFAIK this is not possible, the linker script is already linking RIOT at that address and thus the flasher needs to know where to flash it, unless we flash HEX or ELF using openocd, which is not the case for nrf52dk, the only board supported by the softdevice. |
Then forget it. I'll try to find a fix for the USEPKG and I think this PR will be good to go :) |
I found a quick workaround for the last issue. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments below. I think we can avoid to touch the general cortexm init code.
boards/nrf52dk/Makefile.include
Outdated
@@ -10,6 +10,7 @@ PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*))) | |||
export JLINK_DEVICE := nrf52 | |||
|
|||
# special options when using SoftDevice | |||
include $(RIOTBOARD)/$(BOARD)/Makefile.dep |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As this is a workaround, I guess it can be valid. However, I think we need to put a note here stating that this is incorrect. We shouldn't include the dependencies makefile here, but only in another Makefile.dep. @cladmi might have a proposition about the needed comment.
I noticed this is also done for some arduino boards, I'll check why it's there and if we can avoid it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then I'll wait for your inputs for this point :)
cpu/cortexm_common/cortexm_init.c
Outdated
extern const void *_isr_vectors; | ||
#else | ||
#undef _isr_vectors | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this block can belong to the nrf52 cpu code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll give it a try
cpu/cortexm_common/cortexm_init.c
Outdated
SCB->VTOR = (uint32_t)&_isr_vectors; | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm... maybe this one you can also modify it in the cpu.c of nrf52. You might assign it to the starting of the flash, where I guess the vector table is located when using the specific softdevice hex firmware.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But then it will call twice during init
It is a bit weird isn't it ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be, but we have no choice. I prefer to initialise it twice than having this #ifdef
s in the cortexm code.
cpu/cortexm_common/cortexm_init.c
Outdated
/* set SVC interrupt to same priority as the rest */ | ||
NVIC_SetPriority(SVCall_IRQn, CPU_DEFAULT_IRQ_PRIO); | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this really necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RIOT is running wild if I call this line when I used softdevice. I didn't figure out why yet but I guess the softdevice does some black magic with this interrupt.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, let's think about a way to get it out of here. I suppose we can also re-setting it at the nrf52 cpu level.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about skipping the cortexm_init when softdevice is used ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're totally right!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok then, I'll try to push something like that :)
Thanks for your review @kYc0o ! I'll try to fix it this weekend or maybe next week. I'm really busy with company stuff right now. |
a3eb0f3
to
16c9e4c
Compare
@kYc0o I completely redo this PR with a I didn't rebase this PR yet as I prefer we're all agree on the changes before last test and merge. |
/* fixup swi0 (used as softdevice PendSV trampoline) */ | ||
NVIC_EnableIRQ(SWI0_EGU0_IRQn); | ||
NVIC_SetPriority(SWI0_EGU0_IRQn, 6); | ||
#else | ||
/* call cortexm default initialization */ | ||
cortexm_init(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm... are you sure all the functions there are unnecessary? You'll also need to increase the priority as you did before isn't it? Or with this configuration it works normally?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well It works so far but I guess I could still add some part of the cortexm_init.
But since we have no clue of what the softdevice is doing maybe we should stay like this...
What do you think ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say as long as it works properly (and several initialisations are certainly done by the softdevice), we can leave it as is. I'll try to make some extensive tests soon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great ! many thanks @kYc0o
16c9e4c
to
e3c2aef
Compare
Rebased on lastest master. |
I tried this again but still fails in the flashing step. Apparently the problem of knowing the dependencies is still present. Do you have a different behaviour @dylad ? |
Prevent CPU from using cortexm_init() when softdevice is used for NRF52 devices as the softdevice already do some obscur inits Also ensure the softdevice pkg will be used by hacking Makefile due to RIOT's build system limitations (will be fix later with the new build system)
f72f94b
to
f6ec8b3
Compare
Seems Murdock complains about unrelated stuff... |
Is this unrelated? gnrc_netif.c: In function '_update_l2addr_from_dev':
gnrc_netif.c:1132:5: error: expected expression before '||' token
|| defined(MODULE_NORDIC_SOFTDEVICE_BLE) |
sys/net/gnrc/netif/gnrc_netif.c
Outdated
@@ -1121,6 +1129,8 @@ static void _update_l2addr_from_dev(gnrc_netif_t *netif) | |||
|
|||
switch (netif->device_type) { | |||
#if defined(MODULE_NETDEV_IEEE802154) || defined(MODULE_XBEE) | |||
|| defined(MODULE_NORDIC_SOFTDEVICE_BLE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the preprocessor needs a backslash here.
f6ec8b3
to
1a78ea2
Compare
Oops sorry I did not pay attention enough... |
Murdock doesn't like your message @cladmi I'm getting some funny outputs. |
Add a warning message in user's console to inform them routing capabilities will be disabled with the softdevice
1a78ea2
to
6db9baf
Compare
Thanks @kaspar030 that did the trick ! Murdock is happy :) |
Alright, let's get this in! @kYc0o you happy here? :) |
Alright! |
It's finally over !!!!!! |
Yeah, this was probably painful. Thanks a lot for following it through! |
@smlng Backport to release branch or is this too big for a hotfix? |
its mentioned as broken in the release notes, so at least it is a known bug. However, if anyone cares to provide a backport, I'd still merge that into the release. |
release branch. The release is already out and immutable ;-). |
yeah sure, merge into release branch ... but we could make a 2018.01.1 release later, too 😉 |
ACK |
I'll try to submit the backport tonight. |
This PR intends to fix #6379
Interaction with shell is now working when the
nordic_softdevice_ble
pkg is enabledThis PR is WIP & RFC because this is a very ugly revert of f656a31 (#6638) when the
nordic_softdevice_ble
package is used.What must be done before merging :
Find a proper fix for VTOR when softdevice is enabled (not this ugly hack)EDIT: DoneFix the reset (when I push the reset button, the shell is not restart. How it is even possible ?)Remove export FLASH_ADDR := 0x1f000 within boards/makefile.include and use the linker script instead (Is it possible ?)(unfeasible right now)I'll need the help of more experienced users to get this PR merged.
Related discussions #6379 #6638 #6865