SD library dependency issue on ESP8266

Hi, I’ve got an issue with a library which depends on SD. Already tried to track this down as far as I can.

contents of platformio.ini

[env:d1]
platform = espressif8266
framework = arduino
upload_speed = 921600
monitor_speed = 115200
board = d1

lib_deps =
  Adafruit VS1053 Library

code:

#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <SPI.h>
#include <SD.h>

void setup() {
}

void loop() {
}

When trying to compile it with pio run, the build fails. I guess that it includes the Arduino SD library instead of using the Espressif one.

Processing d1 (platform: espressif8266; framework: arduino; board: d1)
--------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif8266/d1.html
PLATFORM: Espressif 8266 (3.2.0) > WEMOS D1 R1
HARDWARE: ESP8266 80MHz, 80KB RAM, 4MB Flash
PACKAGES:
 - framework-arduinoespressif8266 3.30002.0 (3.0.2)
 - tool-esptool 1.413.0 (4.13)
 - tool-esptoolpy 1.30000.201119 (3.0.0)
 - toolchain-xtensa 2.100300.210717 (10.3.0)
Converting main.ino
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Library Manager: Installing git+https://github.com/jalr/Adafruit_VS1053_Library#attempt-to-fix-platformio-dependency-issue
git version 2.33.1
Cloning into '/home/jalr/.platformio/.cache/tmp/pkg-installing-2org4py8'...
Library Manager: Adafruit VS1053 Library @ 1.2.1+sha.b80d50d has been installed!
Found 38 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <Adafruit VS1053 Library> 1.2.1+sha.b80d50d
|   |-- <SD> 0.0.0-alpha+sha.041f788250
|   |   |-- <SPI> 1.0
|   |-- <SPI> 1.0
|-- <ESP8266WiFi> 1.0
|-- <SD> 0.0.0-alpha+sha.041f788250
|   |-- <SPI> 1.0
|-- <SPI> 1.0
Building in release mode
Compiling .pio/build/d1/src/main.ino.cpp.o
Generating LD script .pio/build/d1/ld/local.eagle.app.v6.common.ld
Compiling .pio/build/d1/lib57c/SPI/SPI.cpp.o
Compiling .pio/build/d1/lib929/SD/File.cpp.o
Compiling .pio/build/d1/lib929/SD/SD.cpp.o
Compiling .pio/build/d1/lib929/SD/utility/Sd2Card.cpp.o
Compiling .pio/build/d1/lib929/SD/utility/SdFile.cpp.o
Compiling .pio/build/d1/lib929/SD/utility/SdVolume.cpp.o
In file included from .pio/libdeps/d1/SD/utility/Sd2Card.h:26,
                 from .pio/libdeps/d1/SD/utility/SdFat.h:29,
                 from .pio/libdeps/d1/SD/utility/SdFile.cpp:20:
.pio/libdeps/d1/SD/utility/Sd2PinMap.h:371:2: error: #error Architecture or board not supported.

I forked the Adafruit VS1053 library, and removed the SD dependency in library.properties file:

diff --git a/library.properties b/library.properties
index d225261..a77ff6e 100644
--- a/library.properties
+++ b/library.properties
@@ -7,4 +7,4 @@ paragraph=This is a library for the Adafruit VS1053 Codec Breakout and Music Mak
 category=Device Control
 url=https://github.com/adafruit/Adafruit_VS1053_Library
 architectures=*
-depends=SD
+depends=

When using the forked library my code compiles. I’m not very familiar with the platformio build system and don’t know how this issue can be fixed properly. Please let me know where I can report this issue. Does it need to be fixed in the Adafruit lib, in platform-core or platform-espressif8266?

Very good point. I think since the core contains the library searcher and decides which library will be built, it’s good to open an issue there. I don’t think the Adafruit people will want to modify their library.properties in regards to removing the depends=SD line just so that PlatformIO will work properly.

If I remember correctly, previously, you could use lib_ignore = SD and then inject the correct SD libary, named SD(esp8266), but this does not work anyore as the name has apparently changed. The Arduino library naming situation is not good, there are too many SD libaries and there’s no distinction as to which exact one is meant.

You can also use a workaround where you redirect the SD library to the good local framework version.

[env:d1]
platform = espressif8266
board = d1
framework = arduino
lib_deps =
  Adafruit VS1053 Library
  SD=file://C:\Users\Max\.platformio\packages\framework-arduinoespressif8266\libraries\SD

worked for my system.

1 Like

Thank you. I’ve opened an issue: Arduino SD library dependency issue on ESP8266 · Issue #4176 · platformio/platformio-core · GitHub
Your workaround also works fine for me.

@maxgerhardt Any update on this issue? I am seeing the same issue with Teensy. Some Adafruit libraries are pulling in the wrong version of the SD library. The workaround above works, but it’s rather hacky IMO.