Error: #error Architecture or board not supported. - Problem with ESP8266 libs on linux

Hello, I have problem with compilation this sample of code (or any code with SD card lib usage)

#include "SPI.h"
#include "SD.h"
#include "Wire.h"
#include "SdFat.h"

void setup() {
  Serial.begin(9600);
}

void loop() {
  
  File dataFile = SD.open("datalog.txt", FILE_WRITE);

  if (dataFile) {
    dataFile.println("arek");
    dataFile.close();
    Serial.println("arek");
  }
  else {
    Serial.println("error opening datalog.txt");
  }

  delay(2000);
}

I get this error:
.pio/libdeps/nodemcuv2/SD/src/utility/Sd2PinMap.h:524:2: error: #error Architecture or board not supported.

My lib_deps looks like:

lib_deps = 
	adafruit/Adafruit SSD1306@^2.5.1
	adafruit/Adafruit GFX Library@^1.10.13
	paulstoffregen/Time@^1.6.1
	adafruit/Adafruit BusIO@^1.11.0
	arduino-libraries/SD@^1.2.4
	greiman/SdFat@^2.1.2

Output of console: https://www.toptal.com/developers/hastebin/lajohibepo.yaml

There problem also appears on original arduino ide, I’m using linux ubuntu 20.04

Please, help me :confused:

No, this is the Arduino (AVR) SD library.

You never declare libaries that are built into the framework via lib_deps. As per Arduino/libraries at master · esp8266/Arduino · GitHub, the SD library is built into the Arduino-ESP8266 framework.

If I use your code with the platformio.ini

[env:nodemcuv2]
platform = espressif8266
board = nodemcuv2
framework = arduino
lib_deps =
        adafruit/Adafruit SSD1306@^2.5.1
        adafruit/Adafruit GFX Library@^1.10.13
        paulstoffregen/Time@^1.6.1
        adafruit/Adafruit BusIO@^1.11.0

it already compiles successfully.

Linking .pio\build\nodemcuv2\firmware.elf
Retrieving maximum program size .pio\build\nodemcuv2\firmware.elf
Checking size .pio\build\nodemcuv2\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [===       ]  34.8% (used 28528 bytes from 81920 bytes)
Flash: [===       ]  28.6% (used 298881 bytes from 1044464 bytes)
Building .pio\build\nodemcuv2\firmware.bin
Creating BIN file ".pio\build\nodemcuv2\firmware.bin" using "C:\Users\Max\.platformio\packages\framework-arduinoespressif8266\bootloaders\eboot\eboot.elf" and ".pio\build\nodemcuv2\firmware.elf"
===================[SUCCESS] Took 19.67 seconds ===================

And as you can see in the project task Advanced → Verbose Build, the library is sourced from the framework folder.

|-- <SD> 2.0.0 (C:\Users\Max\.platformio\packages\framework-arduinoespressif8266\libraries\SD)
|   |-- <SDFS> 0.1.0 (C:\Users\Max\.platformio\packages\framework-arduinoespressif8266\libraries\SDFS)
|   |   |-- <ESP8266SdFat> 2.0.2 (C:\Users\Max\.platformio\packages\framework-arduinoespressif8266\libraries\ESP8266SdFat)

So, just use the same platformio.ini as I do and remove the .pio folder of the project (downloaded libraries are stored in there) and recompile the project.

1 Like