Skip to content
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

pkg/nimble: version bump to NimBLE 1.5.0 RC1 #18029

Merged
merged 8 commits into from
Jun 10, 2022

Conversation

haukepetersen
Copy link
Contributor

Contribution description

NimBLE is about to be released in version 1.5.0. In order to update the NimBLE version in RIOT, too, there are some changes needed to the NimBLE port to cater for internal changes in NimBLE. These are most notably the use of Nordic nrfx headers in the NimBLE radio drivers and an overhaul of the BLE transport implementation in NimBLE.

This PR contains all the needed changes to RIOT to allow for updating NimBLE to its newest version:

  • it adds the official nrfx headers as optional package to RIOT
  • adapts the NimBLE Makefiles to cater for the BLE transport changes
  • and of course updates NimBLE to its current version

Testing procedure

  • run and verify the NimBLE test applications from the examples folder
  • run some IP over BLE tests using gnrc_networking on some NRF hardware

Issues/PRs references

Depends on apache/mynewt-nimble#1249

@haukepetersen haukepetersen added State: waiting for other PR State: The PR requires another PR to be merged first Area: BLE Area: Bluetooth Low Energy support labels Apr 28, 2022
@github-actions github-actions bot added Area: build system Area: Build system Area: cpu Area: CPU/MCU ports Area: doc Area: Documentation Area: Kconfig Area: Kconfig integration Area: pkg Area: External package ports Platform: ARM Platform: This PR/issue effects ARM-based platforms labels Apr 28, 2022
Copy link
Contributor

@fjmolinas fjmolinas left a comment

Choose a reason for hiding this comment

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

Nice this at least still compiles with mynewt-core as well... will test it out once dependencies are in... I trust you will test the BLE side thoroughly... one question on the config files though, where do they come from?

pkg/nrfx/include/nrfx_config.h Show resolved Hide resolved
Comment on lines 37 to 56
#if defined(CPU_FAM_NRF51)
#include <nrfx_config_nrf51.h>
#elif defined(NRF52805_XXAA)
#include <nrfx_config_nrf52805.h>
#elif defined(NRF52810_XXAA)
#include <nrfx_config_nrf52810.h>
#elif defined(NRF52811_XXAA)
#include <nrfx_config_nrf52811.h>
#elif defined(NRF52820_XXAA)
#include <nrfx_config_nrf52820.h>
#elif defined(CPU_MODEL_NRF52832XXAA) || defined (CPU_MODEL_NRF52832_XXAB)
#include <nrfx_config_nrf52832.h>
#elif defined(NRF52833_XXAA)
#include <nrfx_config_nrf52833.h>
#elif defined(NRF52840_XXAA)
#include <nrfx_config_nrf52840.h>
#elif defined(NRF5340_XXAA_APPLICATION)
#include <nrfx_config_nrf5340_application.h>
#elif defined(NRF5340_XXAA_NETWORK)
#include <nrfx_config_nrf5340_network.h>
#elif defined(NRF9160_XXAA)
#include <nrfx_config_nrf9160.h>
#else
#error "Unknown device."
#endif
Copy link
Contributor

Choose a reason for hiding this comment

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

Are these not all part of the nrfx package? Where do they come from? Could we use them similarly as it's done for stm32?

@haukepetersen
Copy link
Contributor Author

The nrfx headers in pkg/nrfx/include are largely copied from the templates folder in the nrfx repo. Although they are needed in the include tree for using the nrfx headers during RIOT build, we never actually use any of the values from these files as we never compile any of the source files from the nrfx package. So there are just there to make the compiler happy for now.

@haukepetersen
Copy link
Contributor Author

Did look at those imported config headers a bit closer: turns out in our current setup where we only use headers from the nrfx package we do not need most of them, so I removed them again from the package and just left the needed essentials.

However, I just discovered that NimBLE is not compiling anymore for any nrf51-based board. There seem to be some define clashes in the nrf51 configuration which I can't figure out how to solve so far. Will need a little more digging I suppose.

But the nrf52 and the nrf52840 both seem to work as expected when running some NimBLE examples in RIOT.

Copy link
Contributor

@fjmolinas fjmolinas left a comment

Choose a reason for hiding this comment

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

Nice to see the amount of headers reduced did you modify the ones that are still here? Can we copy them from the package in the makefile?

@fjmolinas
Copy link
Contributor

However, I just discovered that NimBLE is not compiling anymore for any nrf51-based board. There seem to be some define clashes in the nrf51 configuration which I can't figure out how to solve so far. Will need a little more digging I suppose.

Can you show the logs?

@haukepetersen
Copy link
Contributor Author

Nice to see the amount of headers reduced did you modify the ones that are still here? Can we copy them from the package in the makefile?

The nrfx_glue.h header is copied from the template directory of the nrfx sources and adapted to comply with RIOT coding style. We could indeed copy this file instead of keeping a copy in RIOT.
The nrfx_config.h header is an empty header file now, this one we can easily keep. But looking at this file right now, I notice that I forgot to put it under the RIOT license header instead of the Nordic one... Will fix.

Can you show the logs?

Of course:

DUMP
2 hauke@schelm:~/dev/riot/RIOT/examples/nimble_gatt$ BOARD=nrf51dk make -j
Building application "nimble_gatt" for "nrf51dk" with MCU "nrf51".

"make" -C /home/hauke/dev/riot/RIOT/pkg/nimble/ 
"make" -C /home/hauke/dev/riot/RIOT/build/pkg/nimble/nimble/controller/src/ -f /home/hauke/dev/riot/RIOT/Makefile.base MODULE=nimble_controller
"make" -C /home/hauke/dev/riot/RIOT/build/pkg/nimble/nimble/drivers/nrf51/src/ -f /home/hauke/dev/riot/RIOT/Makefile.base MODULE=nimble_drivers_nrf5x
"make" -C /home/hauke/dev/riot/RIOT/build/pkg/nimble/nimble/host/src/ -f /home/hauke/dev/riot/RIOT/pkg/nimble/nimble.host.mk
"make" -C /home/hauke/dev/riot/RIOT/build/pkg/nimble/nimble/host/store/ram/src/ -f /home/hauke/dev/riot/RIOT/Makefile.base MODULE=nimble_host_store_ram
"make" -C /home/hauke/dev/riot/RIOT/build/pkg/nimble/nimble/host/util/src/ -f /home/hauke/dev/riot/RIOT/Makefile.base MODULE=nimble_host_util
"make" -C /home/hauke/dev/riot/RIOT/build/pkg/nimble/porting/npl/riot/src/ -f /home/hauke/dev/riot/RIOT/Makefile.base MODULE=nimble_npl_riot
"make" -C /home/hauke/dev/riot/RIOT/build/pkg/nimble/porting/nimble/src/ -f /home/hauke/dev/riot/RIOT/pkg/nimble/nimble.porting.mk MODULE=nimble_porting_nimble
"make" -C /home/hauke/dev/riot/RIOT/pkg/nimble/contrib/
"make" -C /home/hauke/dev/riot/RIOT/build/pkg/nimble/nimble/host/services/gap/src/ -f /home/hauke/dev/riot/RIOT/Makefile.base MODULE=nimble_svc_gap
"make" -C /home/hauke/dev/riot/RIOT/build/pkg/nimble/nimble/host/services/gatt/src/ -f /home/hauke/dev/riot/RIOT/Makefile.base MODULE=nimble_svc_gatt
"make" -C /home/hauke/dev/riot/RIOT/build/pkg/nimble/nimble/transport/src/ -f /home/hauke/dev/riot/RIOT/Makefile.base MODULE=nimble_transport
In file included from /home/hauke/dev/riot/RIOT/build/pkg/nrfx/mdk/nrf_peripherals.h:41,
                 from /home/hauke/dev/riot/RIOT/build/pkg/nrfx/drivers/nrfx_common.h:42,
                 from /home/hauke/dev/riot/RIOT/build/pkg/nrfx/nrfx.h:38,
                 from /home/hauke/dev/riot/RIOT/build/pkg/nimble/nimble/drivers/nrf51/src/ble_phy.c:31:
/home/hauke/dev/riot/RIOT/build/pkg/nrfx/mdk/nrf51_peripherals.h:59: error: "GPIO_COUNT" redefined [-Werror]
   59 | #define GPIO_COUNT 1
      | 
In file included from /home/hauke/dev/riot/RIOT/core/lib/include/irq.h:26,
                 from /home/hauke/dev/riot/RIOT/sys/include/event.h:104,
                 from /home/hauke/dev/riot/RIOT/sys/include/event/callback.h:39,
                 from /home/hauke/dev/riot/RIOT/build/pkg/nimble/porting/npl/riot/include/nimble/nimble_npl_os.h:25,
                 from /home/hauke/dev/riot/RIOT/build/pkg/nimble/nimble/include/nimble/nimble_npl.h:53,
                 from /home/hauke/dev/riot/RIOT/build/pkg/nimble/porting/nimble/include/os/os.h:38,
                 from /home/hauke/dev/riot/RIOT/build/pkg/nimble/nimble/drivers/nrf51/src/ble_phy.c:24:
/home/hauke/dev/riot/RIOT/cpu/nrf51/include/cpu_conf.h:63: note: this is the location of the previous definition
   63 | #define GPIO_COUNT              (1U)
      | 
In file included from /home/hauke/dev/riot/RIOT/build/pkg/nrfx/mdk/nrf_peripherals.h:41,
                 from /home/hauke/dev/riot/RIOT/build/pkg/nrfx/drivers/nrfx_common.h:42,
                 from /home/hauke/dev/riot/RIOT/build/pkg/nrfx/nrfx.h:38,
                 from /home/hauke/dev/riot/RIOT/build/pkg/nimble/nimble/drivers/nrf51/src/ble_hw.c:28:
/home/hauke/dev/riot/RIOT/build/pkg/nrfx/mdk/nrf51_peripherals.h:59: error: "GPIO_COUNT" redefined [-Werror]
   59 | #define GPIO_COUNT 1
      | 
In file included from /home/hauke/dev/riot/RIOT/core/lib/include/irq.h:26,
                 from /home/hauke/dev/riot/RIOT/sys/include/event.h:104,
                 from /home/hauke/dev/riot/RIOT/sys/include/event/callback.h:39,
                 from /home/hauke/dev/riot/RIOT/build/pkg/nimble/porting/npl/riot/include/nimble/nimble_npl_os.h:25,
                 from /home/hauke/dev/riot/RIOT/build/pkg/nimble/nimble/include/nimble/nimble_npl.h:53,
                 from /home/hauke/dev/riot/RIOT/build/pkg/nimble/porting/nimble/include/os/os.h:38,
                 from /home/hauke/dev/riot/RIOT/build/pkg/nimble/nimble/drivers/nrf51/src/ble_hw.c:24:
/home/hauke/dev/riot/RIOT/cpu/nrf51/include/cpu_conf.h:63: note: this is the location of the previous definition
   63 | #define GPIO_COUNT              (1U)
      | 
/home/hauke/dev/riot/RIOT/build/pkg/nimble/nimble/drivers/nrf51/src/ble_phy.c: In function 'ble_phy_rx_start_isr':
/home/hauke/dev/riot/RIOT/build/pkg/nimble/nimble/drivers/nrf51/src/ble_phy.c:720:13: error: implicit declaration of function 'os_cputime_usecs_to_ticks' [-Werror=implicit-function-declaration]
  720 |     ticks = os_cputime_usecs_to_ticks(usecs);
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~
/home/hauke/dev/riot/RIOT/build/pkg/nimble/nimble/drivers/nrf51/src/ble_phy.c:721:34: error: implicit declaration of function 'os_cputime_ticks_to_usecs' [-Werror=implicit-function-declaration]
  721 |     ble_hdr->rem_usecs = usecs - os_cputime_ticks_to_usecs(ticks);
      |                                  ^~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/hauke/dev/riot/RIOT/build/pkg/nrfx/mdk/nrf_peripherals.h:41,
                 from /home/hauke/dev/riot/RIOT/build/pkg/nrfx/drivers/nrfx_common.h:42,
                 from /home/hauke/dev/riot/RIOT/build/pkg/nrfx/nrfx.h:38,
                 from /home/hauke/dev/riot/RIOT/build/pkg/nimble/porting/nimble/src/hal_timer.c:25:
/home/hauke/dev/riot/RIOT/build/pkg/nrfx/mdk/nrf51_peripherals.h:59: error: "GPIO_COUNT" redefined [-Werror]
   59 | #define GPIO_COUNT 1
      | 
In file included from /home/hauke/dev/riot/RIOT/core/lib/include/irq.h:26,
                 from /home/hauke/dev/riot/RIOT/sys/include/event.h:104,
                 from /home/hauke/dev/riot/RIOT/sys/include/event/callback.h:39,
                 from /home/hauke/dev/riot/RIOT/build/pkg/nimble/porting/npl/riot/include/nimble/nimble_npl_os.h:25,
                 from /home/hauke/dev/riot/RIOT/build/pkg/nimble/nimble/include/nimble/nimble_npl.h:53,
                 from /home/hauke/dev/riot/RIOT/build/pkg/nimble/porting/nimble/include/os/os.h:38,
                 from /home/hauke/dev/riot/RIOT/build/pkg/nimble/porting/nimble/src/hal_timer.c:24:
/home/hauke/dev/riot/RIOT/cpu/nrf51/include/cpu_conf.h:63: note: this is the location of the previous definition
   63 | #define GPIO_COUNT              (1U)
      | 
cc1: all warnings being treated as errors
make[2]: *** [/home/hauke/dev/riot/RIOT/Makefile.base:146: /home/hauke/dev/riot/RIOT/examples/nimble_gatt/bin/nrf51dk/nimble_drivers_nrf5x/ble_hw.o] Error 1
make[2]: *** Waiting for unfinished jobs....
cc1: all warnings being treated as errors
cc1: all warnings being treated as errors
make[2]: *** [/home/hauke/dev/riot/RIOT/Makefile.base:146: /home/hauke/dev/riot/RIOT/examples/nimble_gatt/bin/nrf51dk/nimble_porting_nimble/hal_timer.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: *** [/home/hauke/dev/riot/RIOT/Makefile.base:146: /home/hauke/dev/riot/RIOT/examples/nimble_gatt/bin/nrf51dk/nimble_drivers_nrf5x/ble_phy.o] Error 1
make[1]: *** [Makefile:75: nimble_drivers_nrf5x] Error 2
make[1]: *** Waiting for unfinished jobs....
make[1]: *** [Makefile:41: nimble_porting_nimble] Error 2
make: *** [/home/hauke/dev/riot/RIOT/examples/nimble_gatt/../../Makefile.include:809: pkg-build] Error 2

I see two major problems:

  • the GPIO_COUNT define redefinition: for the nrf52-familiy we get this from the vendor headers, for the nrf51 we define it in the RIOT headers. I guess there will be some sort of unification that would solve this?!
  • the missing os_cputime_usecs_to_ticks function - I have not yet looked into this

@haukepetersen
Copy link
Contributor Author

Finally, fixed the nrf51 - its now building and working just fine again. Needed to include one additional vendor header as done for the nrf52 variants already. Let me know, if I should put the latest commit in its own PR or if we can live with including this fix here...

@fjmolinas
Copy link
Contributor

The nrfx_glue.h header is copied from the template directory of the nrfx sources and adapted to comply with RIOT coding style. We could indeed copy this file instead of keeping a copy in RIOT.

IMO this seems like a more maintainable approach, and avoid including vendor files in the tree

Let me know, if I should put the latest commit in its own PR or if we can live with including this fix here

With the current CI times I'm fine with having it here.

@fjmolinas
Copy link
Contributor

Just did some integration test using mynewt-core, everything is still fine!

@fjmolinas
Copy link
Contributor

Regarding the os_cputime_usecs_to_ticks function, there is now issue with that if using mynewt-core pkg:

USEPKG=mynewt-core BOARD=nrf51dk make -C examples/nimble_gatt/ -j7
Building application "nimble_gatt" for "nrf51dk" with MCU "nrf51".

"make" -C /home/francisco/workspace/RIOT/pkg/mynewt-core/ 
"make" -C /home/francisco/workspace/RIOT/build/pkg/mynewt-core/hw/mcu/nordic/nrf51xxx/src/ -f /home/francisco/workspace/RIOT/pkg/mynewt-core/mynewt-core_nrf5x_hal.mk MODULE=mynewt-core_nrf5x_hal
"make" -C /home/francisco/workspace/RIOT/build/pkg/mynewt-core/kernel/os/src -f /home/francisco/workspace/RIOT/pkg/mynewt-core/mynewt-core_os.mk MODULE=mynewt-core_os
"make" -C /home/francisco/workspace/RIOT/build/pkg/mynewt-core/util/mem/src -f /home/francisco/workspace/RIOT/pkg/mynewt-core/mynewt-core_util.mk MODULE=mynewt-core_util
"make" -C /home/francisco/workspace/RIOT/pkg/nimble/ 
"make" -C /home/francisco/workspace/RIOT/build/pkg/nimble/nimble/controller/src/ -f /home/francisco/workspace/RIOT/Makefile.base MODULE=nimble_controller
"make" -C /home/francisco/workspace/RIOT/build/pkg/nimble/nimble/drivers/nrf51/src/ -f /home/francisco/workspace/RIOT/Makefile.base MODULE=nimble_drivers_nrf5x
"make" -C /home/francisco/workspace/RIOT/build/pkg/nimble/nimble/host/src/ -f /home/francisco/workspace/RIOT/pkg/nimble/nimble.host.mk
"make" -C /home/francisco/workspace/RIOT/build/pkg/nimble/nimble/host/store/ram/src/ -f /home/francisco/workspace/RIOT/Makefile.base MODULE=nimble_host_store_ram
"make" -C /home/francisco/workspace/RIOT/build/pkg/nimble/nimble/host/util/src/ -f /home/francisco/workspace/RIOT/Makefile.base MODULE=nimble_host_util
"make" -C /home/francisco/workspace/RIOT/build/pkg/nimble/porting/nimble/src/ -f /home/francisco/workspace/RIOT/pkg/nimble/nimble.porting.mk MODULE=nimble_porting_nimble
"make" -C /home/francisco/workspace/RIOT/pkg/nimble/contrib/
"make" -C /home/francisco/workspace/RIOT/build/pkg/nimble/nimble/host/services/gap/src/ -f /home/francisco/workspace/RIOT/Makefile.base MODULE=nimble_svc_gap
"make" -C /home/francisco/workspace/RIOT/build/pkg/nimble/nimble/host/services/gatt/src/ -f /home/francisco/workspace/RIOT/Makefile.base MODULE=nimble_svc_gatt
"make" -C /home/francisco/workspace/RIOT/build/pkg/nimble/nimble/transport/src/ -f /home/francisco/workspace/RIOT/Makefile.base MODULE=nimble_transport
"make" -C /home/francisco/workspace/RIOT/pkg/nrfx/ 
"make" -C /home/francisco/workspace/RIOT/pkg/tinycrypt/ 
"make" -C /home/francisco/workspace/RIOT/build/pkg/tinycrypt/lib/source/ -f /home/francisco/workspace/RIOT/pkg/tinycrypt/Makefile.tinycrypt -f /home/francisco/workspace/RIOT/Makefile.base MODULE=tinycrypt
"make" -C /home/francisco/workspace/RIOT/boards/common/init
"make" -C /home/francisco/workspace/RIOT/boards/nrf51dk
"make" -C /home/francisco/workspace/RIOT/core
"make" -C /home/francisco/workspace/RIOT/core/lib
"make" -C /home/francisco/workspace/RIOT/cpu/nrf51
"make" -C /home/francisco/workspace/RIOT/drivers
"make" -C /home/francisco/workspace/RIOT/pkg/mynewt-core/contrib
"make" -C /home/francisco/workspace/RIOT/drivers/periph_common
"make" -C /home/francisco/workspace/RIOT/cpu/cortexm_common
"make" -C /home/francisco/workspace/RIOT/pkg/nimble/autoadv
"make" -C /home/francisco/workspace/RIOT/cpu/cortexm_common/periph
"make" -C /home/francisco/workspace/RIOT/cpu/nrf51/periph
"make" -C /home/francisco/workspace/RIOT/sys
"make" -C /home/francisco/workspace/RIOT/sys/auto_init
"make" -C /home/francisco/workspace/RIOT/sys/div
"make" -C /home/francisco/workspace/RIOT/sys/event
"make" -C /home/francisco/workspace/RIOT/sys/fmt
"make" -C /home/francisco/workspace/RIOT/sys/frac
"make" -C /home/francisco/workspace/RIOT/cpu/nrf5x_common
"make" -C /home/francisco/workspace/RIOT/cpu/nrf5x_common/periph
"make" -C /home/francisco/workspace/RIOT/sys/malloc_thread_safe
"make" -C /home/francisco/workspace/RIOT/sys/net/ble/bluetil
"make" -C /home/francisco/workspace/RIOT/sys/net/ble/bluetil/bluetil_ad
"make" -C /home/francisco/workspace/RIOT/sys/newlib_syscalls_default
"make" -C /home/francisco/workspace/RIOT/sys/net/ble/bluetil/bluetil_addr
"make" -C /home/francisco/workspace/RIOT/sys/sema
"make" -C /home/francisco/workspace/RIOT/sys/stdio_uart
"make" -C /home/francisco/workspace/RIOT/sys/ztimer
   text	   data	    bss	    dec	    hex	filename
  78336	    596	  14480	  93412	  16ce4	/home/francisco/workspace/RIOT/examples/nimble_gatt/bin/nrf51dk/nimble_gatt.elf

I don't know what the issue is on the NimBLE part that it does not work. Depending on how much time you want to spend on this I would suggest:

  • for nrf51 force mynewt-core use
  • get this one in
  • add a new PR so that mynewt-core is always use by default (if you can test that the performance is the same), I think this will make all our lives easier :)

@fjmolinas
Copy link
Contributor

If you agree with the suggested approach (at least the first two points), then you can go ahead and squash IMO, would be nice if you ran your benchmarks as well.

@haukepetersen haukepetersen force-pushed the verbump_nimble_nrfx2022 branch from 5f5dea3 to 842698e Compare May 24, 2022 09:30
@haukepetersen
Copy link
Contributor Author

Sorry for the delay...

Actually the nrf51 works just fine with apache/mynewt-nimble@6f77746 - but it seems that I did not update the NimBLE version commit to the right commit hash. Sorry, did forgot to update...

Did update it now and I sucessfully build (without mynewt-core) and flashed nimble_gatt to an airfy-beacon -> everything works as expected:

2022-05-24 11:29:56,303 # main(): This is RIOT! (Version: 2022.07-devel-535-g8d67b-verbump_nimble_nrfx2022)            
2022-05-24 11:29:56,304 # NimBLE GATT Server Example                                                                                                                                                                                          
2022-05-24 11:30:12,695 # service 'device info: manufacturer' callback triggered
2022-05-24 11:30:12,704 # This is RIOT! (Version: 2022.07-devel-535-g8d67b-verbump_nimble_nrfx2022)
2022-05-24 11:30:12,704 # 
2022-05-24 11:30:12,704 # 
2022-05-24 11:30:12,785 # service 'device info: manufacturer' callback triggered
2022-05-24 11:30:12,794 # This is RIOT! (Version: 2022.07-devel-535-g8d67b-verbump_nimble_nrfx2022)
...

However, if I build and flash the same application using mynewt-core, it triggers a failed assertion:
(examples/nimble_gatt$ CFLAGS=-DDEBUG_ASSERT_VERBOSE USEPKG=mynewt-core BOARD=airfy-beacon make -j flash term):

2022-05-24 11:33:17,430 # pkg/mynewt-core/contrib/core.c:35 => 0x38d
2022-05-24 11:33:17,430 # *** RIOT kernel panic:
2022-05-24 11:33:17,430 # FAILED ASSERTION.
2022-05-24 11:33:17,430 # 
2022-05-24 11:33:17,430 # *** halted.
2022-05-24 11:33:17,430 #

So there is actually rather a problem using mynewt-core with the nrf51 in the current state of this PR... So how do we proceed? As the vanilla non-mynewt-core version of NimBLE seems to work fine, I would actually suggest to get this version dump in and then fix the mynewt-core issue in a follow-up PR. Do you agree?

@haukepetersen haukepetersen force-pushed the verbump_nimble_nrfx2022 branch from 842698e to 4d77265 Compare May 25, 2022 06:43
@haukepetersen
Copy link
Contributor Author

updated the nimble commit hash once more (after squashing the Nimble upstream PR) and reabsed

@fjmolinas
Copy link
Contributor

On my side this will have to wait for next week, I'm sadly on a paper deadline :(

@fjmolinas
Copy link
Contributor

fjmolinas commented Jun 3, 2022

Actually there is something missing, can you apply this patch and squash:

diff --git a/pkg/Kconfig b/pkg/Kconfig
index f6bd78aad4..8c0a894325 100644
--- a/pkg/Kconfig
+++ b/pkg/Kconfig
@@ -54,6 +54,7 @@ rsource "mynewt-core/Kconfig"
 rsource "nanocbor/Kconfig"
 rsource "nanopb/Kconfig"
 rsource "nanors/Kconfig"
+rsource "nrfx/Kconfig"
 rsource "qcbor/Kconfig"
 rsource "qdsa/Kconfig"
 rsource "qr-code-generator/Kconfig"
diff --git a/pkg/mynewt-core/Kconfig b/pkg/mynewt-core/Kconfig
index 11fc88a87c..53e822bca2 100644
--- a/pkg/mynewt-core/Kconfig
+++ b/pkg/mynewt-core/Kconfig
@@ -37,5 +37,6 @@ config MODULE_MYNEWT-CORE_UTIL

 config MODULE_MYNEWT-CORE_NRF5X_HAL
     bool "mynewt-core nrf52 and nrf51 timer hal"
+    select PACKAGE_NRFX

 endif # PACKAGE_MYNEWT-CORE
diff --git a/pkg/mynewt-core/Makefile.dep b/pkg/mynewt-core/Makefile.dep
index 8131c03595..9555b3d619 100644
--- a/pkg/mynewt-core/Makefile.dep
+++ b/pkg/mynewt-core/Makefile.dep
@@ -5,5 +5,9 @@ USEMODULE += mynewt-core

 DEFAULT_MODULE += auto_init_mynewt-core

+ifneq (,$(filter mynewt-core_nrf5x_hal,$(USEMODULE)))
+  USEPKG += nrfx
+endif
+
 # esp frequency is not pow2 so is incompatible with os_cputime
 FEATURES_BLACKLIST += arch_esp

@fjmolinas
Copy link
Contributor

Pushed the patch

@fjmolinas fjmolinas enabled auto-merge June 7, 2022 06:28
@haukepetersen
Copy link
Contributor Author

thanks!

There is one other issue I am looking into: Murdock is not building some examples for the nrf51 due to not enough RAM. Seems like the they trip just very lightly over the RAM limit... But with the help of the mynewt devs I think I found an optimization that should give us 1-2kb of free RAM and fix those issues for good. I in the progress of testing them.

@fjmolinas
Copy link
Contributor

thanks!

There is one other issue I am looking into: Murdock is not building some examples for the nrf51 due to not enough RAM. Seems like the they trip just very lightly over the RAM limit... But with the help of the mynewt devs I think I found an optimization that should give us 1-2kb of free RAM and fix those issues for good. I in the progress of testing them.

Should we leave it as a follow-up? If not please stop the CI from running before those optimizations.

@haukepetersen
Copy link
Contributor Author

Done. Finished the testing and everything works as expected, also did some backward testing with nrf52 boards to make sure extended advertisings are too working as they should. Hopefully all Murdock issues should be resolved now.

@fjmolinas
Copy link
Contributor

ACK still stands

These boards have insufficient RAM to build this test.
@github-actions github-actions bot added the Area: tests Area: tests and testing framework label Jun 8, 2022
@haukepetersen
Copy link
Contributor Author

The tests/nimble_ext_adv test failed to compile for nrf51 boards due to RAM overflow by 48 bytes, so I blacklisted them for this test. Weirdly, the current master doesn't even let me build this example for these boards due to a memcpy offset warning in the old NimBLE code... Anyway, that was the only thing Murdock complained about, so we should be good now.

@maribu maribu 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 Jun 8, 2022
@benpicco benpicco 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 Jun 8, 2022
@haukepetersen
Copy link
Contributor Author

Does it make sense to replace jrand48 by random_uin32 then?

Done: apache/mynewt-nimble#1272

Will do another version update after this PR is in.

@fjmolinas
Copy link
Contributor

Does it make sense to replace jrand48 by random_uin32 then?

Done: apache/mynewt-nimble#1272

Will do another version update after this PR is in.

Awesome!

@benpicco benpicco 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 Jun 9, 2022
@fjmolinas fjmolinas merged commit e5c7e3b into RIOT-OS:master Jun 10, 2022
@haukepetersen haukepetersen deleted the verbump_nimble_nrfx2022 branch June 10, 2022 06:57
@fjmolinas
Copy link
Contributor

Good to see this in!

@gschorcht
Copy link
Contributor

gschorcht commented Aug 17, 2022

Done. Finished the testing and everything works as expected, also did some backward testing with nrf52 boards to make sure extended advertisings are too working as they should. Hopefully all Murdock issues should be resolved now.

@haukepetersen While testing PR #18439 I noticed that since this PR all tests/nimble_*_ext fail and it is no longer possible to connect two nRF52840 nodes together when using Advertising Extension. I directly tested last commit of your branch 9be4316 and the last commit before merge f4691db. Before this PR everything works as expected. Could you please check it?

@gschorcht
Copy link
Contributor

@haukepetersen I figured out the problem. If Advertising Extension is used, the event queue MYNEWT_VAL_BLE_TRANSPORT_EVT_COUNT with 2 elements is too small. During the connection setup, 3 events are coming in

LE Enhanced Connection Complete event
LE Channel Selection Algorithm event
LE Advertising Set Terminated event

before they are processed. With only 2 elements in that queue, the LE Advertising Set Terminated event is lost and the connection setup fail at slave side.

I will provide a fix which increases the queue size if nimble_adv_ext is used as for other. I'm not sure whether we should use 3 or 4, because each queue entry has a size of 257 bytes.

@gschorcht
Copy link
Contributor

PR #18467 fixes the problem.

@chrysn chrysn added this to the Release 2022.07 milestone Aug 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: BLE Area: Bluetooth Low Energy support Area: build system Area: Build system Area: cpu Area: CPU/MCU ports Area: doc Area: Documentation Area: Kconfig Area: Kconfig integration Area: pkg Area: External package ports Area: tests Area: tests and testing framework CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Platform: ARM Platform: This PR/issue effects ARM-based platforms
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants