pkg/nimble: adapt to nrf51 family#11463
Conversation
|
Nice one, wanted to do this for a while now :-) See my review comments below. |
haukepetersen
left a comment
There was a problem hiding this comment.
I just see a problem when (in the near future) building Nimble for non-Nordic platforms. But easy to fix...
|
|
||
| nimble_drivers_nrf52: | ||
| "$(MAKE)" -C $(PDIR)/nimble/drivers/nrf52/src/ -f $(TDIR)/drivers.nrf52.mk | ||
| nimble_drivers: |
There was a problem hiding this comment.
I would leave this as NRF specific submodule, as it is only valid for these CPUs at the moment. So how about nimble_drivers_nrf5x?!
| PKG_NAME = nimble | ||
| PKG_URL = https://github.com/apache/mynewt-nimble.git | ||
| PKG_VERSION = a7b3c939146e735b59d55bff740c906bde6f86f9 | ||
| PKG_VERSION = 976bb8f84bf9547efdea444ae79a62d5a355a613 |
There was a problem hiding this comment.
If we merge #11273, this line should not be needed, right?
There was a problem hiding this comment.
Not sure, because apache/mynewt-nimble@976bb8f was merged this morning so it's more recent.
There was a problem hiding this comment.
No problem, this is not urgent.
| ifeq (nrf52,$(CPU_FAM)) | ||
| USEMODULE += nimble_drivers_nrf52 | ||
| endif | ||
| USEMODULE += nimble_drivers |
There was a problem hiding this comment.
don't drop the ifdef, as the nimble_drivers submodule should only be included for nordic boards...
| #endif | ||
|
|
||
| #ifdef MODULE_NIMBLE_CONTROLLER | ||
| #ifdef CPU_FAM_NRF52 |
There was a problem hiding this comment.
the ifdef needs to stay, and simply be extended with the CPU_FAM_NRF51. Otherwise we get in trouble when building for non Nordic targets (in the future...).
|
Comments addressed, @haukepetersen ! |
|
Looks good! However, I would like to wait until the issues from #11273 are resolved. I will look into this, but also have a paper deadline next Friday with a slightly higher prio :-) |
No problem, there is no hurry. I did some more testing on microbit and nrf51dk and there are problems:
|
|
So, now that #11273 is merged, please rebase. |
Done! |
|
I had multiple errors on
Sadly we dont have a nrf52dk here to verify this PR atm. |
Do you mean nrf51dk ? If yes try one on IoT-LAB :) |
Yes, sorry for the confusion ;) |
|
We found a problem with the xtimer module with this adaption. We used an airfy-beacon board (nrf51822) for testing. xtimer functions without the nimble package are working properly. But if we just add the nimble pkg into our project/makefile xtimer does not work anymore. xtimer_sleep therefore no longer behaves in a comprehensible way. Sometimes the device wakes up after a short time, sometimes it takes minutes or probably infinite . nimble itself seems to work properly. Advertising, scanning works. |
|
I can confirm the issue using the This will need more investigation :-) |
|
I might have found something interesting (still using the So it seems to me, that something regarding interrupt handling is clashing between RIOT and Nimble on the nrf51. So more debugging :-) |
|
found it: Nimbles radio driver is also using Quick fix: mapping xtimer to use So I guess we need to include some nimble specific xtimer configuration?! |
|
Good catch @haukepetersen :)
All nrf51 based boards share the same xtimer defines (in board_common.h) and, except microbit and calliope-mini, the same timer peripherals configuration. So this is doable without too many changes. We could also have some conditional macros to use timer 1 if nimble pkg is loaded and timer 0 otherwise. |
+1! I was thinking the same thing. We should just put a comment to it, stating that with nimble xtimer falls back to a 16-bit timer -> more wakeups... |
Do you want this in another PR or I can just update this one ? |
Definitely in this PR. Wanted to PR something against your branch, but couldn't find the time so far. So just go ahead, I will happlily review it then :-) |
|
I will look into refactoring the code accordingly right now, so please wait for a PR from my side before addressing this issue. |
|
Well, I've found a new bug :) The random module makes problem. Compiled together with the package nimble the board does not react anymore after flashing. Tested on airfy-beacon and nrf51dk (iotlab). It works on nrf52dk! |
|
@j-brodbeck the So as roadmap for this PR I would like to proceed as follows:
|
Done :) |
haukepetersen
left a comment
There was a problem hiding this comment.
Works as expected and code looks good -> ACK
Note: so far, this PR does not enable the ble_nimble feature for any nrf51-based board. I think we should leave it like this and I/we can do this an a separate PR...
|
oh, and please squash :-) |
I'll update this PR otherwise the adaption for nrf51 is not built by Murdock for nrf51 based boards. |
|
true, makes sense. |
|
made a PR against your branch, fixing the |
|
@haukepetersen, I applied your commit directly, squashed and rebased. Let's now see how Murdock behaves. |
|
thanks! Go Murdock, go :-) |
|
It's all green @haukepetersen, ok to merge ? |
|
yes. -> go :-) |
Contribution description
This PR is adapting the Nimble package to make it compliant with nrf51 based boards.
For the moment it needs a specific branch on my Apache-nimble fork (see apache/mynewt-nimble#429).Some changes were applied on the upstream project, so the package version had to be updated.I tested
examples/nimble_gattand it worked withnrf51dk. Theexamples/nimble_scannerdoesn't work, maybe because of insufficient memory.Testing procedure
Build and flash
examples/nimble_gatton an nrf51 based board. It should appear in NRF connect application running on a Phone or using bluetoothctl on a Linux with bluetooth radio enabled.Issues/PRs references
None