PlatformIO Community

Arduino Nano RP2040 with ArduinoBLE-library

I am trying to use RP2040 board with ArduinoBLE-library. This lib accesses HCIUartTransport, giving error

.pio\libdeps\nanorp2040connect\ArduinoBLE\src\utility\HCIUartTransport.cpp:33:2: error: #error "Unsupported board selected!"
   33 | #error "Unsupported board selected!"
      |  ^~~~~
*** [.pio\build\nanorp2040connect\libd5f\ArduinoBLE\utility\HCIUartTransport.cpp.o] Error 1

Looking at the code in that file:

#if !defined(ARDUINO_ARCH_MBED) || defined(TARGET_NANO_RP2040_CONNECT)

#include "HCIUartTransport.h"

#define SerialHCI Serial2
#elif defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_NANO_RP2040_CONNECT)
// SerialHCI is already defined in the variant
#elif defined(ARDUINO_PORTENTA_H7_M4)
// SerialHCI is already defined in the variant
#elif defined(ARDUINO_PORTENTA_H7_M7)
#define SerialHCI Serial2
#error "Unsupported board selected!"

I added the following build flags to platform.ini:

build_flags = -DTARGET_NANO_RP2040_CONNECT

But it still gives the same error.

This is related to my previous
question: Arduino Nano RP2040 Connect, blinking RGB led does not compile - #4 by maxgerhardt

What is wrong in my build-flags ?

I have no problems building a sketch with ArduinoBLE and the current raspberrypi platform version.

platformio.ini does not need to be specially modified with build flags.

platform = raspberrypi
board = nanorp2040connect
framework = arduino
lib_deps =
     arduino-libraries/ArduinoBLE @ ^1.2.1

with src\main.cpp

#include <Arduino.h>
#include <ArduinoBLE.h>

void setup() {}
void loop() {}

gives me

Checking size .pio\build\nanorp2040connect\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [==        ]  19.2% (used 51996 bytes from 270336 bytes)
Flash: [          ]   4.5% (used 94272 bytes from 2093056 bytes)
Building .pio\build\nanorp2040connect\firmware.bin
========================= [SUCCESS] Took 22.61 seconds =========================

Try opening a CLI and execute

pio platform update raspberrypi

to make sure you have the latest version.

If that does not help, post the complete platformio.ini and minimal code.

Thanks a lot, updating from 1.1.0 to version 1.2.0 solved the issue,
and build flags are not needed anymore !