I’m using the PlatformIO extension for VSCode. I’m getting a link error in the following example:
#include <Arduino.h>
mbed::InterruptIn chan_a{ PinName::P1_11, MbedPinMode::PullNone };
// mbed::DigitaltIn chan_a{ PinName::P1_11, MbedPinMode::PullNone }; // works
// mbed::InterruptIn chan_a{ PinName::P1_11 }; // also works
void setup()
{
}
void loop()
{
}
The error is:
c:/users/zest/.platformio/packages/toolchain-gccarmnoneeabi/bin/…/lib/gcc/arm-none-eabi/8.2.1/…/…/…/…/arm-none-eabi/bin/ld.exe: .pio\build\nano33ble\src\main.cpp.o: in function __static_initialization_and_destruction_0': C:\Users\Zest\proj\arduino\scratch\minimal/src/main.cpp:3: undefined reference to
mbed::InterruptIn::InterruptIn(PinName, MbedPinMode)’
If I use mbed::DigitalIn instead, it links.
If I remove the PinMode argument in the constructor, it links.
platformio.ini:
[env:nano33ble]
platform = nordicnrf52
board = nano33ble
framework = arduino
This bug also occurs in the Arduino IDE:
Linking everything together...
"C:\\Users\\Maxi\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\arm-none-eabi-gcc\\7-2017q4/bin/arm-none-eabi-g++" "-LC:\\Users\\Maxi\\AppData\\Local\\Temp\\arduino_build_449648" -Wl,--gc-sections -w -Wl,--as-needed "@C:\\Users\\Maxi\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\mbed\\1.1.4\\variants\\ARDUINO_NANO33BLE/ldflags.txt" "-TC:\\Users\\Maxi\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\mbed\\1.1.4\\variants\\ARDUINO_NANO33BLE/linker_script.ld" "-Wl,-Map,C:\\Users\\Maxi\\AppData\\Local\\Temp\\arduino_build_449648/sketch_jun21a.ino.map" --specs=nano.specs --specs=nosys.specs -o "C:\\Users\\Maxi\\AppData\\Local\\Temp\\arduino_build_449648/sketch_jun21a.ino.elf" "C:\\Users\\Maxi\\AppData\\Local\\Temp\\arduino_build_449648\\sketch\\sketch_jun21a.ino.cpp.o" "C:\\Users\\Maxi\\AppData\\Local\\Temp\\arduino_build_449648\\core\\variant.cpp.o" -Wl,--whole-archive "C:\\Users\\Maxi\\AppData\\Local\\Temp\\arduino_build_449648/core\\core.a" "C:\\Users\\Maxi\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\mbed\\1.1.4\\variants\\ARDUINO_NANO33BLE/libs/libmbed.a" "C:\\Users\\Maxi\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\mbed\\1.1.4\\variants\\ARDUINO_NANO33BLE/libs/libcc_310_core.a" "C:\\Users\\Maxi\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\mbed\\1.1.4\\variants\\ARDUINO_NANO33BLE/libs/libcc_310_ext.a" "C:\\Users\\Maxi\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\mbed\\1.1.4\\variants\\ARDUINO_NANO33BLE/libs/libcc_310_trng.a" -Wl,--no-whole-archive -Wl,--start-group -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys -Wl,--end-group
C:\Users\Maxi\AppData\Local\Temp\arduino_build_449648\sketch\sketch_jun21a.ino.cpp.o: In function `__static_initialization_and_destruction_0':
C:\Users\Maxi\Documents\Arduino\sketch_jun21a/sketch_jun21a.ino:3: undefined reference to `mbed::InterruptIn::InterruptIn(PinName, MbedPinMode)'
collect2.exe: error: ld returned 1 exit status
exit status 1
Thus it’s not PIO specific and very likely an error in the Arduino-core provided libmbed.a
which is supposed to contain the precompiled mbed-os kernel and thus also the missing function.
Please file an issue against GitHub - arduino/ArduinoCore-nRF528x-mbedos: [Archived] Arduino core supporting mbed-enabled boards to get the issue corrected.
As a work around, construct the object without the PullMode
and call .mode()
on the object with your wanted parameter in setup(). I think the default is NoPull
anyways, so it makes no difference.
Thank you, Max, for going the extra mile on this.
I will file the issue against Arduino-core as you suggest.
I actually have also tried your workaround of calling .mode() after constructing with one argument.
However it has the same problem. Also my quick look indicated that the default mode is PullUp rather than NoPull, but I’ll double check that.
I think I can work around by calling the lower-level C-style functions that the InterruptIn/DigitalIn classes wrap.