Closed ArminJo closed 1 year ago
is this an Arduino library detection bug
No. This is the expected result from the system working as designed:
https://arduino.github.io/arduino-cli/latest/sketch-build-process/#dependency-resolution
The two libraries have the same score for "architecture matching", "library name", and "folder name" priorities, so the tie-breaker is the "location priority" score:
The "location priority" is determined as follows (in order of highest to lowest priority): [...]
- The library is under the libraries subfolder of the IDE's sketchbook or Arduino CLI's user directory
- The library is bundled with the board platform/core (
{runtime.platform.path}/libraries
)
Something to note is most users will have an additional copy of the global Servo library installed in a separate location. This location has lower priority than the platform bundled library:
- The library is bundled with the Arduino IDE (this location is determined by the Arduino CLI configuration setting
directories.builtin.libraries
)
This means that after uninstalling the Servo library from the sketchbook folder, a global installation of Servo library would still be available when compiling for other boards without a platform bundled Servo library, while the platform bundled library gets priority when compiling for a MegaCoreX board.
Do you know any workaround apart from deleting the Arduino Servo library manually?
For your GitHub Actions workflow, simple remove Servo
from the env.REQUIRED_LIBRARIES
key and add it to the matrix.required-libraries
key (example) of the boards that don't have a platform bundled version of the Servo library.
As for normal human usage of MegaCoreX, the workaround would be to add a header file with a unique name (e.g., ServoMegaCoreX.h
to the platform bundled library). If the program contains an #include
directive for this header before the #include
directive for Servo.h
, this will cause the intended platform bundled library to be discovered instead of the one in the sketchbook. The header could be empty, or even act as a substitute for including Servo.h
:
ServoMegaCoreX.h
#include <Servo.h>
https://arduino.github.io/arduino-cli/latest/sketch-build-process/#dependency-resolution
Thanks for the link, I searched for it for half an hour, before starting this issue.
For your GitHub Actions workflow, simple remove Servo from the env.REQUIRED_LIBRARIES key and add it to the matrix.required-libraries key (example) of the boards that don't have a platform bundled version of the Servo library.
This indeed works for me 😀 👍 T H A N K S ! ! !
@MCUdude How can I decide, that the MEGAX kernel is used? I am looking for something like this
@ All Happy new year
How can I decide, that the MEGAX kernel is used?
It's all there in the README: https://github.com/MCUdude/MegaCoreX#identifying-megacorex
Thanks for adding ServoMegaCoreX.h 👍
I try to compile Servo code for a ATmega4808, as can be found here: This is the error i get:
I get the same error on my windows Arduino 1.8 and 2.0 IDEs. The compile error vanishes if I enable
USE_TIMERB1
instead ofUSE_TIMERB2
in the Arduino Servo megaavr/ServoTimers.h file.Do you know any workaround apart from deleting the Arduino Servo library manually? And what is the use case of having a Servo library not used by Arduino? Or is this an Arduino library detection bug (which will never be fixed, I assume)?
Thanks for caring Armin