@khoih-prog created a great library for using the RTC in the Arduino RP2040 Connect. It works great when building from the Arduino IDE (1.8), however when I try to build the same example in PlatformIO IDE it fails.
Disclaimer: I am new to PlatformIO, Arduino and the whole world of microcontrollers.
I opened an issue in the GitHub repository as well, however as it seems like a problem with PlatformIO builds probably it’s better to ask here
I was trying to run the WifiNINA example from the PlatformIO IDE but the build fails like this:
In file included from include/defines.h:69,
from src/main.cpp:24:
.pio/libdeps/nanorp2040connect/RP2040_RTC/src/RP2040_RTC.h:48:28: error: 'datetime_t' was not declared in this scope
48 | bool rtc_set_datetime (datetime_t *t);
If I run the exact same code (copying to code from src/main.cpp to the ino file in a new sketch) in the Arduino IDE it works without issues.
datetime_t
is definied in the pico-sdk in the types.h header and it seems to be included in a later stage of the build because if I define the struct in my code for testing, the build fails with duplicate definitions.
In file included from /Users/efpe/.platformio/packages/framework-arduino-mbed/cores/arduino/mbed/targets/TARGET_RASPBERRYPI/TARGET_RP2040/pico-sdk/common/pico_base/include/pico.h:16,
from /Users/efpe/.platformio/packages/framework-arduino-mbed/cores/arduino/mbed/targets/TARGET_RASPBERRYPI/TARGET_RP2040/objects.h:30,
from /Users/efpe/.platformio/packages/framework-arduino-mbed/cores/arduino/mbed/targets/TARGET_RASPBERRYPI/TARGET_RP2040/device.h:35,
from /Users/efpe/.platformio/packages/framework-arduino-mbed/cores/arduino/mbed/platform/include/platform/platform.h:28,
from /Users/efpe/.platformio/packages/framework-arduino-mbed/cores/arduino/mbed/platform/include/platform/FileHandle.h:25,
from /Users/efpe/.platformio/packages/framework-arduino-mbed/cores/arduino/macros.h:41,
from /Users/efpe/.platformio/packages/framework-arduino-mbed/variants/NANO_RP2040_CONNECT/pins_arduino.h:2,
from /Users/efpe/.platformio/packages/framework-arduino-mbed/cores/arduino/Arduino.h:76,
from .pio/libdeps/nanorp2040connect/WiFiNINA_Generic/src/WiFiClient_Generic.h:56,
from .pio/libdeps/nanorp2040connect/WiFiNINA_Generic/src/WiFi_Generic.h:76,
from .pio/libdeps/nanorp2040connect/WiFiNINA_Generic/src/WiFiNINA_Generic.h:60,
from include/defines.h:70,
from src/main.cpp:24:
/Users/efpe/.platformio/packages/framework-arduino-mbed/cores/arduino/mbed/targets/TARGET_RASPBERRYPI/TARGET_RP2040/pico-sdk/common/pico_base/include/pico/types.h: At global scope:
/Users/efpe/.platformio/packages/framework-arduino-mbed/cores/arduino/mbed/targets/TARGET_RASPBERRYPI/TARGET_RP2040/pico-sdk/common/pico_base/include/pico/types.h:77:3: error: conflicting declaration 'typedef struct datetime_t datetime_t'
77 | } datetime_t;
| ^~~~~~~~~~
Steps to reproduce
- Create a new project, use the following config:
platformio.ini:
[platformio]
default_envs = nanorp2040connect
[env:nanorp2040connect]
platform = raspberrypi
board = nanorp2040connect
framework = arduino
upload_port = /dev/cu.usbmodem145201 ; change this to yours
lib_ldf_mode = deep+
lib_compat_mode = off ; I had to turn this off to be able to install RP2040_RTC (see platforms in library.json)
lib_deps =
paulstoffregen/Time@^1.6.1
khoih-prog/WiFiNINA_Generic@^1.8.13
khoih-prog/RP2040_RTC@^1.0.5
khoih-prog/Timezone_Generic@^1.7.1
- If dependencies are not installed, run
pio lib install
. cp .pio/libdeps/nanorp2040connect/RP2040_RTC/examples/Time/RP2040_RTC_Time_WiFiNINA/RP2040_RTC_Time_WiFiNINA.ino src/main.cpp
cp .pio/libdeps/nanorp2040connect/RP2040_RTC/examples/Time/RP2040_RTC_Time_WiFiNINA/defines.h include/
- Modify wifi settings in
define.h
-
pio run --target upload
→ build will fail
Versions
- PlatformIO version: 5.2.1 (I tried with 5.2.2a1 as well, same results)
-
RP2040
Core Version: Arduino-mbed 2.4.1 -
RP2040
Board type NANO_RP2040_CONNECT Darwin Viktors-MBP.localdomain 20.6.0 Darwin Kernel Version 20.6.0: Mon Aug 30 06:12:21 PDT 2021; root:xnu-7195.141.6~3/RELEASE_X86_64 x86_64
Log output
It is in the GitHub issue (I cannot add more links
Many thanks for your help guys! Let me know if I missed something.