BBC Microbit v2 cannot compile BLEPeripheral library

Searched everywhere and connot figure out how to get pio to work with BBC microbit v2 and Adafruit libraries for the board.

Specifically the BLEPeripheral library cannot find ble_gatts.h which seems to be with board support for a different platform. The only info I can find is seems very specific to microbit v1 and depending on “softdevice” being set to 110 in Arduino IDE and installation of a few specific libraries that seem to be related to v1.

Anyone know the recipe for getting this to work with platform io?

Thanks.

No, the Adafruit core does not support the BBC Microbit V2, there is no variant for it. (variants folder).

Support for the BBC microbit is provided by the sandeep/arduino-nRF5 core, see here.

Hence you cannot compile libraries intended for the Adafruit core for the BBC microbit, the cores are architectured differently. This is the recommended library.

Thanks for the link but that is exactly where I am getting my information. Take a look farther down the page and there’s a section on “BLEPeripheral library” which is where the problem lies.

The author answers this specific question ages ago but only for Arduino IDE which does not seem to work/ignored in the Platform IO configuration no matter what “softdevice_ver” value I use in there and the only place that header file exists is in an SDK for the family of chips used on the V1 as far as I can see.

Do you have BLEPeripheral library compiling properly for the microbit v2 on platform io? If so I’d live to know what dependencies you are using. Here’s mine:

[env:bbcmicrobit_v2]
platform = nordicnrf52
framework = arduino
board = bbcmicrobit_v2
softdevice_ver = "s132"
lib_deps = 
adafruit/Adafruit microbit Library@^1.3.1
adafruit/Adafruit GFX Library@^1.10.13
sandeepmistry/BLEPeripheral@^0.4.0

The other stuff is directly from the Adafruit tutorial on the BBC microbit. The issue seems be coming from the BLEPeripheral library which is part of the bbcmicro support you linked to. In Arduino IDE setting the soft device somehow jiggers the include paths or something 110 seems to include a set of libs for v1. v2 seems to use a different soft device version and I am assuming those change the dependencies to that BLEPeripheral doesn’t even try to include the problem file but I am not familiar at all with those chips.

If anything it would have to be

build_flags = -DNRF52_S132

due to how the builder script works.

I’ll try and reproduce your problems.

I am failing to reproduce your problem.

[env:bbcmicrobit_v2]
platform = nordicnrf52
board = bbcmicrobit_v2
framework = arduino
build_flags = -DNRF52_S132
lib_deps =
   adafruit/Adafruit microbit Library@^1.3.1
   adafruit/Adafruit GFX Library@^1.10.13
   adafruit/Adafruit BusIO@^1.10.3
   sandeepmistry/BLEPeripheral@^0.4.0
   SPI
   Wire
#include <Arduino.h>
#include <Adafruit_Microbit.h>
#include <Adafruit_GFX.h>
#include <BLEPeripheral.h>

BLEPeripheral blePeripheral = BLEPeripheral();
Adafruit_Microbit microbit;

void setup(){

}
void loop(){
}
Linking .pio\build\bbcmicrobit_v2\firmware.elf
c:/users/max/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/bin/ld.exe: warning: changing start of section .heap by 4 bytes
c:/users/max/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/bin/ld.exe: warning: changing start of section .stack_dummy by 4 bytes
c:/users/max/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/bin/ld.exe: warning: changing start of section .heap by 4 bytes
c:/users/max/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/bin/ld.exe: warning: changing start of section .stack_dummy by 4 bytes
c:/users/max/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/bin/ld.exe: warning: changing start of section .heap by 4 bytes
c:/users/max/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/bin/ld.exe: warning: changing start of section .stack_dummy by 4 bytes
c:/users/max/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/bin/ld.exe: warning: changing start of section .heap by 4 bytes
c:/users/max/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/bin/ld.exe: warning: changing start of section .stack_dummy by 4 bytes
c:/users/max/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/bin/ld.exe: warning: changing start of section .heap by 4 bytes
c:/users/max/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/bin/ld.exe: warning: changing start of section .stack_dummy by 4 bytes
Building .pio\build\bbcmicrobit_v2\userfirmware.hex
Checking size .pio\build\bbcmicrobit_v2\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   0.9% (used 1148 bytes from 131072 bytes)
Flash: [          ]   3.2% (used 17032 bytes from 524288 bytes)
Building .pio\build\bbcmicrobit_v2\firmware.hex
=============== [SUCCESS] Took 2.48 seconds ===============

The board definition should probably have the flag to enable its softdevice by default. I’ve opened Enable inclusion of softdevice by maxgerhardt · Pull Request #139 · platformio/platform-nordicnrf52 · GitHub for this.

The example projects have this flag though, as per

This seems to have fixed it thanks a lot.

The -DNRF52_S132

completely unstuck the debugging effort on my end and then it was clear what else I was missing.

I think that flag might be different depending on bbcmicro v1 and v2 based on my research of the two chips used. Also I guess there is some automagic that’s not clear when setting the soft device version in the Arduino IDE but the confusing part is that other board libs that use those chips seem to depend on “softdevice_ver” in discussions I’ve run across.

Did it work with S132 as soft device during runtime? There’s some discussion on Enable inclusion of softdevice by maxgerhardt · Pull Request #139 · platformio/platform-nordicnrf52 · GitHub that this soft device isn’t even made for the BBC Microbit v2’s nRF chip that’s being used.