Ble Nano 2 + MBED + PlatformIO wont run

Hey there,

I’m pretty much a Newbie and still struggling with setting up a MBED project for my redbearlab ble nano 2 on Platform IO with Visual Studio code. As my project was built on Mbed Os 5, i cant use the Arduino framework.
My steps till now:
New Pio project ( board: nrf52-dk, framework: mbed)

here’s my platformio.ini:

platform = nordicnrf52
board = nrf52_dk
framework = mbed
debug_tool = custom
debug_server = pyocd-gdbserver
upload_protocol = cmsis-dap

my project builds without problems, i can even upload it. But after that, its not running and theres no way to debug (serial monitor, Pio Debugger, pyocd-gdbserver + arm-none-eabi-gdb)
Is there a softdevice missing maybe?

it would be great if someone could help me on that.


Why do you use this target instead of redbear_blenano2? (PlatformIO Registry)

theres currently no support for mbed on blenano 2. At least when i tried to configure a project using blenano 2 as target, the wizzard allowed me just to select arduino framework.

You’re right, PIO doesn’t support this yet although it is a valid target (mbed-os/targets.json at master · ARMmbed/mbed-os · GitHub). And the chip on the nrf52_dk and the BLE Nano2 are the same (NRF52832)…

Does the board work with the Arduino framework?

Unfortunetly I don’t have the hardware to reproduce. Is there any error when trying to debug / halt the target while it’s running with the debugger?

Pio claims building and uploading succeeded, but there arent any messages visible on the serial monitor.
The serial monitor worked as i tested with some mbed code compiled with Atom (arm-gcc).

Ok i got it working with following configuration:
pyocd-gdbserver + arm-none-eabi-gdb
defined with following settings in the platformio.ini file:

platform = GitHub - platformio/platform-nordicnrf52: Nordic nRF52: development platform for PlatformIO
framework = mbed
board = nrf52_dk
upload_protocol = mbed
upload_port = /run/media/philipp/DAPLINK

it uploads and runs just fine.
Nevertheless, using printf statements from mbed make the code stop. Accordingly it only works if i disable all my print statements / printf debugging by #define method.

#define NEED_CONSOLE_OUTPUT 0 //set zero to disable, use DEBUG(“some text\n”) instead printf("

#define DEBUG(…) { printf(VA_ARGS); } //Defaults to stdio without having to wirte pcUart explicitly
#define DEBUG(…) /* nothing /
#endif /