M5stack doesn't compile

hi guys, im having some issues trying to compile my m5stack board with platform

[env:m5stack-core-esp32]
platform = espressif32
board = m5stack-core-esp32
framework = arduino


  • Looking for m5stack.h dependency? Check our library registry!
  • CLI > platformio lib search “header:m5stack.h”
  • Web > PlatformIO Registry

compilation terminated.
Compiling .pioenvs/m5stack-core-esp32/FrameworkArduino/Esp.cpp.o
Compiling .pioenvs/m5stack-core-esp32/FrameworkArduino/HardwareSerial.cpp.o
Compiling .pioenvs/m5stack-core-esp32/FrameworkArduino/IPAddress.cpp.o
Compiling .pioenvs/m5stack-core-esp32/FrameworkArduino/IPv6Address.cpp.o
*** [.pioenvs/m5stack-core-esp32/src/main.cpp.o] Error 1
Compiling .pioenvs/m5stack-core-esp32/FrameworkArduino/MD5Builder.cpp.o
==================================================================== [ERROR] Took 1.43 seconds ====================================================================
The terminal process terminated with exit code: 1

Terminal will be reused by tasks, press any key to close it.

could does anyone compile m5stack with platform??

BR

The compilation error comes from your code which you didn’t show. I’m assuming you’re using the m5stack.h header. This comes from the web link as shown above. Add lib_deps = M5Stack to your platformio.ini to auto-download the dependency.

actually im trying with an empty code now, coz allay had errors:

#include <Arduino.h>
#include <m5stack.h>

void setup() {
// put your setup code here, to run once:
}

void loop() {
// put your main code here, to run repeatedly:
}

I downloaded the m5stack.h form library manager in platformio

BR

You didn’t ask a further question, so I guess it’s solved now?

no, isn’t solved, I still having this issue:

Processing m5stack-core-esp32 (platform: espressif32; board: m5stack-core-esp32; framework: arduino)

Verbose mode can be enabled via -v, --verbose option
PLATFORM: Espressif 32 > M5Stack Core ESP32
SYSTEM: ESP32 240MHz 320KB RAM (4MB Flash)
Library Dependency Finder → Library Dependency Finder (LDF) — PlatformIO latest documentation
LDF MODES: FINDER(chain) COMPATIBILITY(soft)
Collected 41 compatible libraries
Scanning dependencies…
Dependency Graph
|-- 1.0
Compiling .pioenvs/m5stack-core-esp32/src/main.cpp.o
src/main.cpp:2:21: fatal error: m5stack.h: No such file or directory


  • Looking for m5stack.h dependency? Check our library registry!
  • CLI > platformio lib search “header:m5stack.h”
  • Web > PlatformIO Registry

compilation terminated.
Compiling .pioenvs/m5stack-core-esp32/FrameworkArduino/esp32-hal-ledc.c.o
Compiling .pioenvs/m5stack-core-esp32/FrameworkArduino/esp32-hal-matrix.c.o
Compiling .pioenvs/m5stack-core-esp32/FrameworkArduino/esp32-hal-misc.c.o
Compiling .pioenvs/m5stack-core-esp32/FrameworkArduino/esp32-hal-psram.c.o
Compiling .pioenvs/m5stack-core-esp32/FrameworkArduino/esp32-hal-sigmadelta.c.o
Compiling .pioenvs/m5stack-core-esp32/FrameworkArduino/esp32-hal-spi.c.o
*** [.pioenvs/m5stack-core-esp32/src/main.cpp.o] Error 1
Compiling .pioenvs/m5stack-core-esp32/FrameworkArduino/esp32-hal-time.c.o
==================================================================== [ERROR] Took 1.59 seconds ====================================================================
The terminal process terminated with exit code: 1

Terminal will be reused by tasks, press any key to close it.

[env:m5stack-core-esp32]
platform = espressif32
board = m5stack-core-esp32
framework = arduino
lib_deps = M5Stack@=0.1.9
lib_deps = Wire
lib_deps = SPI

i don’t know why say “src/main.cpp:2:21: fatal error: m5stack.h: No such file or directory” I downloaded that library in library manager…

If you have multiple librares either seperate them by comma in the same line or write each of them in a new line with preceeding tab.

Correct form is

lib_deps = M5Stack, Wire, SPI

Though I’m unsure if you even need to specify Wire and SPI here explicitly.

wow, now Im having a looooottt of errors, lol

[env:m5stack-core-esp32]
platform = espressif32
board = m5stack-core-esp32
framework = arduino
lib_deps = M5Stack, Wire, SPI, FS, SD

Executing task: platformio run <

Processing m5stack-core-esp32 (platform: espressif32; board: m5stack-core-esp32; framework: arduino)

Verbose mode can be enabled via -v, --verbose option
PLATFORM: Espressif 32 > M5Stack Core ESP32
SYSTEM: ESP32 240MHz 320KB RAM (4MB Flash)
Library Dependency Finder → Library Dependency Finder (LDF) — PlatformIO latest documentation
LDF MODES: FINDER(chain) COMPATIBILITY(soft)
Collected 42 compatible libraries
Scanning dependencies…
Dependency Graph
|-- 0.2.2
| |-- 1.0
| |-- 1.0
| |--
| | |-- 1.0
| |-- 1.0
|-- 1.0
|-- 1.0
|-- 1.0
|--
| |-- 1.0
Compiling .pioenvs/m5stack-core-esp32/src/main.cpp.o
Archiving .pioenvs/m5stack-core-esp32/lib4a2/libWire.a
Indexing .pioenvs/m5stack-core-esp32/lib4a2/libWire.a
In file included from .piolibdeps/SD_ID161/utility/Sd2Card.h:26:0,
from .piolibdeps/SD_ID161/utility/SdFat.h:29,
from .piolibdeps/SD_ID161/SD.h:25,
from .piolibdeps/M5Stack_ID1851/src/m5stack.h:92,
from src/main.cpp:2:
.piolibdeps/SD_ID161/utility/Sd2PinMap.h:371:2: error: #error Architecture or board not supported.
#error Architecture or board not supported.
^
In file included from .piolibdeps/M5Stack_ID1851/src/m5stack.h:92:0,
from src/main.cpp:2:
.piolibdeps/SD_ID161/SD.h:28:0: warning: “FILE_READ” redefined
#define FILE_READ O_READ
^
In file included from .piolibdeps/M5Stack_ID1851/src/m5stack.h:91:0,
from src/main.cpp:2:
/Users/juan/.platformio/packages/framework-arduinoespressif32/libraries/FS/src/FS.h:30:0: note: this is the location of the previous definition
#define FILE_READ “r”
^
In file included from .piolibdeps/M5Stack_ID1851/src/m5stack.h:92:0,
from src/main.cpp:2:
.piolibdeps/SD_ID161/SD.h:29:0: warning: “FILE_WRITE” redefined
#define FILE_WRITE (O_READ | O_WRITE | O_CREAT)
^
In file included from .piolibdeps/M5Stack_ID1851/src/m5stack.h:91:0,
from src/main.cpp:2:
/Users/juan/.platformio/packages/framework-arduinoespressif32/libraries/FS/src/FS.h:31:0: note: this is the location of the previous definition
#define FILE_WRITE “w”
^
Compiling .pioenvs/m5stack-core-esp32/lib8c3/SD_ID161/File.cpp.o
Compiling .pioenvs/m5stack-core-esp32/lib8c3/SD_ID161/SD.cpp.o
Compiling .pioenvs/m5stack-core-esp32/lib8c3/SD_ID161/utility/Sd2Card.cpp.o
Compiling .pioenvs/m5stack-core-esp32/lib8c3/SD_ID161/utility/SdFile.cpp.o
In file included from .piolibdeps/SD_ID161/utility/Sd2Card.h:26:0,
from .piolibdeps/SD_ID161/utility/SdFat.h:29,
from .piolibdeps/SD_ID161/SD.h:25,
from .piolibdeps/SD_ID161/File.cpp:15:
.piolibdeps/SD_ID161/utility/Sd2PinMap.h:371:2: error: #error Architecture or board not supported.
#error Architecture or board not supported.
^
Compiling .pioenvs/m5stack-core-esp32/lib8c3/SD_ID161/utility/SdVolume.cpp.o
In file included from .piolibdeps/SD_ID161/utility/Sd2Card.h:26:0,
from .piolibdeps/SD_ID161/utility/SdFat.h:29,
from .piolibdeps/SD_ID161/SD.h:25,
from .piolibdeps/SD_ID161/SD.cpp:53:
.piolibdeps/SD_ID161/utility/Sd2PinMap.h:371:2: error: #error Architecture or board not supported.
#error Architecture or board not supported.
^
In file included from .piolibdeps/SD_ID161/utility/Sd2Card.h:26:0,
from .piolibdeps/SD_ID161/utility/SdFat.h:29,
from .piolibdeps/SD_ID161/utility/SdFile.cpp:20:
.piolibdeps/SD_ID161/utility/Sd2PinMap.h:371:2: error: #error Architecture or board not supported.
#error Architecture or board not supported.
^
In file included from .piolibdeps/SD_ID161/utility/SdFat.h:29:0,
from .piolibdeps/SD_ID161/SD.h:25,
from .piolibdeps/SD_ID161/File.cpp:15:
.piolibdeps/SD_ID161/utility/Sd2Card.h:65:37: error: ‘SS_PIN’ was not declared in this scope
uint8_t const SD_CHIP_SELECT_PIN = SS_PIN;
^
.piolibdeps/SD_ID161/utility/Sd2Card.h:68:31: error: ‘MOSI_PIN’ was not declared in this scope
uint8_t const SPI_MOSI_PIN = MOSI_PIN;
^
.piolibdeps/SD_ID161/utility/Sd2Card.h:70:31: error: ‘MISO_PIN’ was not declared in this scope
uint8_t const SPI_MISO_PIN = MISO_PIN;
^
.piolibdeps/SD_ID161/utility/Sd2Card.h:72:30: error: ‘SCK_PIN’ was not declared in this scope
uint8_t const SPI_SCK_PIN = SCK_PIN;
^
In file included from .piolibdeps/SD_ID161/utility/Sd2Card.h:26:0,
from .piolibdeps/SD_ID161/utility/SdFat.h:29,
from .piolibdeps/SD_ID161/utility/SdVolume.cpp:20:
.piolibdeps/SD_ID161/utility/Sd2PinMap.h:371:2: error: #error Architecture or board not supported.
#error Architecture or board not supported.
^
In file included from .piolibdeps/SD_ID161/utility/SdFat.h:29:0,
from .piolibdeps/SD_ID161/utility/SdVolume.cpp:20:
.piolibdeps/SD_ID161/utility/Sd2Card.h:65:37: error: ‘SS_PIN’ was not declared in this scope
uint8_t const SD_CHIP_SELECT_PIN = SS_PIN;
^
.piolibdeps/SD_ID161/utility/Sd2Card.h:68:31: error: ‘MOSI_PIN’ was not declared in this scope
uint8_t const SPI_MOSI_PIN = MOSI_PIN;
^
.piolibdeps/SD_ID161/utility/Sd2Card.h:70:31: error: ‘MISO_PIN’ was not declared in this scope
uint8_t const SPI_MISO_PIN = MISO_PIN;
^
.piolibdeps/SD_ID161/utility/Sd2Card.h:72:30: error: ‘SCK_PIN’ was not declared in this scope
uint8_t const SPI_SCK_PIN = SCK_PIN;
^
In file included from .piolibdeps/SD_ID161/utility/SdFat.h:29:0,
from .piolibdeps/SD_ID161/SD.h:25,
from .piolibdeps/SD_ID161/SD.cpp:53:
.piolibdeps/SD_ID161/utility/Sd2Card.h:65:37: error: ‘SS_PIN’ was not declared in this scope
uint8_t const SD_CHIP_SELECT_PIN = SS_PIN;
^
.piolibdeps/SD_ID161/utility/Sd2Card.h:68:31: error: ‘MOSI_PIN’ was not declared in this scope
uint8_t const SPI_MOSI_PIN = MOSI_PIN;
^
.piolibdeps/SD_ID161/utility/Sd2Card.h:70:31: error: ‘MISO_PIN’ was not declared in this scope
uint8_t const SPI_MISO_PIN = MISO_PIN;
^
.piolibdeps/SD_ID161/utility/Sd2Card.h:72:30: error: ‘SCK_PIN’ was not declared in this scope
uint8_t const SPI_SCK_PIN = SCK_PIN;
^
In file included from .piolibdeps/SD_ID161/utility/Sd2Card.h:26:0,
from .piolibdeps/SD_ID161/utility/Sd2Card.cpp:26:
.piolibdeps/SD_ID161/utility/Sd2PinMap.h:371:2: error: #error Architecture or board not supported.
#error Architecture or board not supported.
^
In file included from .piolibdeps/SD_ID161/utility/SdFat.h:29:0,
from .piolibdeps/SD_ID161/utility/SdFile.cpp:20:
.piolibdeps/SD_ID161/utility/Sd2Card.h:65:37: error: ‘SS_PIN’ was not declared in this scope
uint8_t const SD_CHIP_SELECT_PIN = SS_PIN;
^
.piolibdeps/SD_ID161/utility/Sd2Card.h:68:31: error: ‘MOSI_PIN’ was not declared in this scope
uint8_t const SPI_MOSI_PIN = MOSI_PIN;
^
.piolibdeps/SD_ID161/utility/Sd2Card.h:70:31: error: ‘MISO_PIN’ was not declared in this scope
uint8_t const SPI_MISO_PIN = MISO_PIN;
^
.piolibdeps/SD_ID161/utility/Sd2Card.h:72:30: error: ‘SCK_PIN’ was not declared in this scope
uint8_t const SPI_SCK_PIN = SCK_PIN;
^
In file included from .piolibdeps/SD_ID161/utility/Sd2Card.cpp:26:0:
.piolibdeps/SD_ID161/utility/Sd2Card.h:65:37: error: ‘SS_PIN’ was not declared in this scope
uint8_t const SD_CHIP_SELECT_PIN = SS_PIN;
^
.piolibdeps/SD_ID161/utility/Sd2Card.h:68:31: error: ‘MOSI_PIN’ was not declared in this scope
Compiling .pioenvs/m5stack-core-esp32/lib368/FS/FS.cpp.o
uint8_t const SPI_MOSI_PIN = MOSI_PIN;
^
.piolibdeps/SD_ID161/utility/Sd2Card.h:70:31: error: ‘MISO_PIN’ was not declared in this scope
uint8_t const SPI_MISO_PIN = MISO_PIN;
^
.piolibdeps/SD_ID161/utility/Sd2Card.h:72:30: error: ‘SCK_PIN’ was not declared in this scope
uint8_t const SPI_SCK_PIN = SCK_PIN;
^
.piolibdeps/SD_ID161/utility/Sd2Card.cpp: In member function ‘uint8_t Sd2Card::init(uint8_t, uint8_t, int8_t, int8_t, int8_t)’:
.piolibdeps/SD_ID161/utility/Sd2Card.cpp:302:17: error: cannot convert ‘volatile uint32_t* {aka volatile unsigned int*}’ to ‘volatile uint8_t* {aka volatile unsigned char*}’ in assignment
clkport = portOutputRegister(digitalPinToPort(clockPin_));
^
.piolibdeps/SD_ID161/utility/Sd2Card.cpp:304:17: error: cannot convert ‘volatile uint32_t* {aka volatile unsigned int*}’ to ‘volatile uint8_t* {aka volatile unsigned char*}’ in assignment
mosiport = portOutputRegister(digitalPinToPort(mosiPin_));
^
.piolibdeps/SD_ID161/utility/Sd2Card.cpp:306:17: error: cannot convert ‘volatile uint32_t* {aka volatile unsigned int*}’ to ‘volatile uint8_t* {aka volatile unsigned char*}’ in assignment
misoport = portInputRegister(digitalPinToPort(misoPin_));
^
.piolibdeps/SD_ID161/utility/Sd2Card.cpp: In member function ‘uint8_t Sd2Card::readData(uint32_t, uint16_t, uint16_t, uint8_t*)’:
.piolibdeps/SD_ID161/utility/Sd2Card.cpp:438:12: warning: unused variable ‘n’ [-Wunused-variable]
uint16_t n;
^
*** [.pioenvs/m5stack-core-esp32/lib8c3/SD_ID161/File.cpp.o] Error 1
*** [.pioenvs/m5stack-core-esp32/lib8c3/SD_ID161/utility/SdVolume.cpp.o] Error 1
*** [.pioenvs/m5stack-core-esp32/lib8c3/SD_ID161/SD.cpp.o] Error 1
*** [.pioenvs/m5stack-core-esp32/lib8c3/SD_ID161/utility/Sd2Card.cpp.o] Error 1
.piolibdeps/SD_ID161/utility/SdFile.cpp: In static member function ‘static uint8_t SdFile::make83Name(const char*, uint8_t*)’:
.piolibdeps/SD_ID161/utility/SdFile.cpp:261:15: warning: unused variable ‘b’ [-Wunused-variable]
uint8_t b;
^
*** [.pioenvs/m5stack-core-esp32/lib8c3/SD_ID161/utility/SdFile.cpp.o] Error 1
In file included from .piolibdeps/SD_ID161/utility/SdFat.h:29:0,
from .piolibdeps/SD_ID161/SD.h:25,
from .piolibdeps/M5Stack_ID1851/src/m5stack.h:92,
from src/main.cpp:2:
.piolibdeps/SD_ID161/utility/Sd2Card.h:65:37: error: ‘SS_PIN’ was not declared in this scope
uint8_t const SD_CHIP_SELECT_PIN = SS_PIN;
^
.piolibdeps/SD_ID161/utility/Sd2Card.h:68:31: error: ‘MOSI_PIN’ was not declared in this scope
uint8_t const SPI_MOSI_PIN = MOSI_PIN;
^
.piolibdeps/SD_ID161/utility/Sd2Card.h:70:31: error: ‘MISO_PIN’ was not declared in this scope
uint8_t const SPI_MISO_PIN = MISO_PIN;
^
.piolibdeps/SD_ID161/utility/Sd2Card.h:72:30: error: ‘SCK_PIN’ was not declared in this scope
uint8_t const SPI_SCK_PIN = SCK_PIN;
^
In file included from .piolibdeps/M5Stack_ID1851/src/m5stack.h:92:0,
from src/main.cpp:2:
.piolibdeps/SD_ID161/SD.h:31:7: error: redefinition of ‘class fs::File’
class File : public Stream {
^
In file included from .piolibdeps/M5Stack_ID1851/src/m5stack.h:91:0,
from src/main.cpp:2:
/Users/juan/.platformio/packages/framework-arduinoespressif32/libraries/FS/src/FS.h:47:7: error: previous definition of ‘class fs::File’
class File : public Stream
^
*** [.pioenvs/m5stack-core-esp32/src/main.cpp.o] Error 1
==================================================================== [ERROR] Took 1.88 seconds ====================================================================
The terminal process terminated with exit code: 1

Terminal will be reused by tasks, press any key to close it.

See GitHub - m5stack/M5Stack-platformio: M5Stack PlatformIO Project Examples

I did, keep having error…, I don’t understand, why run ok in Arduino IDE, but have a lot of issues in platform
io??

You added the SD and FS libraries, which pulls some other library which causes a compile error. The project compiles fine with just M5Stack in lib_deps, tested myself.

can u share ur platformio.ini ?

Exactly the same as in M5Stack-platformio/platformio.ini at master · m5stack/M5Stack-platformio · GitHub

im using the default platformio.ini for that example, keep having errors,

im using macOS, can that be a problem?

No, MacOS is no problem. I don’t understand what project files you have now. If you have the main.cpp you shown above plus the platformio.ini I linked, this compiles fine.

just trying with myapp, the default main, with default platformio.ini, having errors like:

Compiling .pioenvs/m5stack-core-esp32/src/main.cpp.o
In file included from /Users/juan/.platformio/lib/SD_ID868/src/utility/Sd2Card.h:26:0,
from /Users/juan/.platformio/lib/SD_ID868/src/utility/SdFat.h:29,
from /Users/juan/.platformio/lib/SD_ID868/src/SD.h:20,
from .piolibdeps/M5Stack_ID1851/src/M5Stack.h:92,
from src/main.cpp:1:
/Users/juan/.platformio/lib/SD_ID868/src/utility/Sd2PinMap.h:510:2: error: #error Architecture or board not supported.

SOLVED.

thanks guys, I deleted the lib folder, after that, compile it without any error,

I have the same problem but after removing lib folder in the project errors are still active.

My platformio.ini:

[env:m5stack-core-esp32]
platform = espressif32
board = m5stack-core-esp32
framework = arduino
upload_speed = 921600
targets = upload
; lib_extra_dirs = ~/Documents/Arduino/libraries/
lib_deps = M5Stack

In main.cpp:

#include <M5Stack.h>

// the setup routine runs once when M5Stack starts up

void setup(){

    // Initialize the M5Stack object

    M5.begin();

    // LCD display

    M5.Lcd.print("Hello world!");

 }

// the loop routine runs over and over again forever

void loop() {
   M5.update();
}

Results:

Executing task in folder M5Stack: C:\Users\bfajd.platformio\penv\Scripts\platformio.exe run <

Processing m5stack-core-esp32 (framework: arduino; platform: espressif32; board: m5stack-core- 
esp32)
------------------------------------------------------------------------------------------------------------------------------------- 
------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/m5stack-core-esp32.html
PLATFORM: Espressif 32 > M5Stack Core ESP32
HARDWARE: ESP32 240MHz 320KB RAM (4MB Flash)
DEBUG: CURRENT(esp-prog) EXTERNAL(esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm- 
usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF MODES: FINDER(chain) COMPATIBILITY(soft)
Collected 37 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <M5Stack> 0.2.6
|   |-- <Wire> 1.0.1
|   |-- <SPI> 1.0
|   |-- <SPIFFS> 1.0
|   |   |-- <FS> 1.0
|   |-- <FS> 1.0
|   |-- <SD>
|   |   |-- <SPI> 1.0
Compiling .pioenvs\m5stack-core-esp32\src\main.cpp.o
Generating partitions .pioenvs\m5stack-core-esp32\partitions.bin
Compiling .pioenvs\m5stack-core-esp32\libd1b\Wire\Wire.cpp.o
Compiling .pioenvs\m5stack-core-esp32\lib345\SPI\SPI.cpp.o
Compiling .pioenvs\m5stack-core-esp32\lib9f4\FS\FS.cpp.o
Compiling .pioenvs\m5stack-core-esp32\lib9f4\FS\vfs_api.cpp.o
Compiling .pioenvs\m5stack-core-esp32\libc07\SPIFFS\SPIFFS.cpp.o
In file included from .piolibdeps\SD_ID161/utility/Sd2Card.h:26:0,
from .piolibdeps\SD_ID161/utility/SdFat.h:29,
from .piolibdeps\SD_ID161/SD.h:25,
from .piolibdeps\M5Stack_ID1851\src/M5Stack.h:106,
from src\main.cpp:1:
.piolibdeps\SD_ID161/utility/Sd2PinMap.h:371:2: error: #error Architecture or board not supported.
#error Architecture or board not supported.
^
In file included from .piolibdeps\M5Stack_ID1851\src/M5Stack.h:106:0,
from src\main.cpp:1:
.piolibdeps\SD_ID161/SD.h:28:0: warning: "FILE_READ" redefined
#define FILE_READ O_READ
^
In file included from .piolibdeps\M5Stack_ID1851\src/M5Stack.h:105:0,
from src\main.cpp:1:
C:\users\bfajd\.platformio\packages\framework-arduinoespressif32\libraries\FS\src/FS.h:30:0: note: 
this is the location of the previous definition
#define FILE_READ       "r"
^
In file included from .piolibdeps\M5Stack_ID1851\src/M5Stack.h:106:0,
from src\main.cpp:1:
.piolibdeps\SD_ID161/SD.h:29:0: warning: "FILE_WRITE" redefined
#define FILE_WRITE (O_READ | O_WRITE | O_CREAT)
^
In file included from .piolibdeps\M5Stack_ID1851\src/M5Stack.h:105:0,
from src\main.cpp:1:
C:\users\bfajd\.platformio\packages\framework-arduinoespressif32\libraries\FS\src/FS.h:31:0: note: 
this is the location of the previous definition
#define FILE_WRITE      "w"
^
Compiling .pioenvs\m5stack-core-esp32\lib6b6\SD_ID161\File.cpp.o
Archiving .pioenvs\m5stack-core-esp32\lib345\libSPI.a
Compiling .pioenvs\m5stack-core-esp32\lib6b6\SD_ID161\SD.cpp.o
Compiling .pioenvs\m5stack-core-esp32\lib6b6\SD_ID161\utility\Sd2Card.cpp.o
In file included from .piolibdeps\SD_ID161/utility/SdFat.h:29:0,
fArom .piolibdeps\SD_ID161/SD.h:25,rchiving .pioenvs\m5stack-core-esp32\libd1b\libWire.a

from .piolibdeps\M5Stack_ID1851\src/M5Stack.h:106,
from src\main.cpp:1:
.piolibdeps\SD_ID161/utility/Sd2Card.h:65:37: error: 'SS_PIN' was not declared in this scope
uint8_t const  SD_CHIP_SELECT_PIN = SS_PIN; 
^
.piolibdeps\SD_ID161/utility/Sd2Card.h:68:31: error: 'MOSI_PIN' was not declared in this scope
uint8_t const  SPI_MOSI_PIN = MOSI_PIN;
^
.piolibdeps\SD_ID161/utility/Sd2Card.h:70:31: error: 'MISO_PIN' was not declared in this scope
uint8_t const  SPI_MISO_PIN = MISO_PIN;
^
.piolibdeps\SD_ID161/utility/Sd2Card.h:72:30: error: 'SCK_PIN' was not declared in this scope
uint8_t const  SPI_SCK_PIN = SCK_PIN;
^
In file included from .piolibdeps\M5Stack_ID1851\src/M5Stack.h:106:0,
from src\main.cpp:1:
.piolibdeps\SD_ID161/SD.h:31:7: error: redefinition of 'class fs::File'
class File : public Stream {
^
In file included from .piolibdeps\M5Stack_ID1851\src/M5Stack.h:105:0,
from src\main.cpp:1:
       C:\users\bfajd\.platformio\packages\framework-arduinoespressif32\libraries\FS\src/FS.h:47:7: error: 
      previous definition of 'class fs::File'
      class File : public Stream
      ^
      In file included from .piolibdeps\SD_ID161/utility/Sd2Card.h:26:0,
      from .piolibdeps\SD_ID161/utility/SdFat.h:29,
      from .piolibdeps\SD_ID161/SD.h:25,
      from .piolibdeps\SD_ID161\File.cpp:15:
      .piolibdeps\SD_ID161/utility/Sd2PinMap.h:371:2: error: #error Architecture or board not supported.
      #error Architecture or board not supported.
      ^
      Compiling .pioenvs\m5stack-core-esp32\lib6b6\SD_ID161\utility\SdFile.cpp.o
      In file included from .piolibdeps\SD_ID161/utility/Sd2Card.h:26:0,
      from .piolibdeps\SD_ID161/utility/SdFat.h:29,
      from .piolibdeps\SD_ID161\SD.h:25,
      from .piolibdeps\SD_ID161\SD.cpp:53:
      .piolibdeps\SD_ID161/utility/Sd2PinMap.h:371:2: error: #error Architecture or board not supported.
      #error Architecture or board not supported.
      ^
      In file included from .piolibdeps\SD_ID161\utility\Sd2Card.h:26:0,
      from .piolibdeps\SD_ID161\utility\Sd2Card.cpp:26:
      .piolibdeps\SD_ID161\utility\Sd2PinMap.h:371:2: error: #error Architecture or board not supported.
      #error Architecture or board not supported.
      ^
      In file included from .piolibdeps\SD_ID161\utility\Sd2Card.h:26:0,
      from .piolibdeps\SD_ID161\utility\SdFat.h:29,
      from .piolibdeps\SD_ID161\utility\SdFile.cpp:20:
      .piolibdeps\SD_ID161\utility\Sd2PinMap.h:371:2: error: #error Architecture or board not supported.
      #error Architecture or board not supported.
      ^
      Compiling .pioenvs\m5stack-core-esp32\lib6b6\SD_ID161\utility\SdVolume.cpp.o
      In file included from .piolibdeps\SD_ID161/utility/SdFat.h:29:0,
      from .piolibdeps\SD_ID161/SD.h:25,
      from .piolibdeps\SD_ID161\File.cpp:15:
      .piolibdeps\SD_ID161/utility/Sd2Card.h:65:37: error: 'SS_PIN' was not declared in this scope
      uint8_t const  SD_CHIP_SELECT_PIN = SS_PIN;
      ^
      .piolibdeps\SD_ID161/utility/Sd2Card.h:68:31: error: 'MOSI_PIN' was not declared in this scope
      uint8_t const  SPI_MOSI_PIN = MOSI_PIN;
      ^
      .piolibdeps\SD_ID161/utility/Sd2Card.h:70:31: error: 'MISO_PIN' was not declared in this scope
      uint8_t const  SPI_MISO_PIN = MISO_PIN;
      ^
      .piolibdeps\SD_ID161/utility/Sd2Card.h:72:30: error: 'SCK_PIN' was not declared in this scope
      uint8_t const  SPI_SCK_PIN = SCK_PIN;
      ^
      In file included from .piolibdeps\SD_ID161\utility\Sd2Card.cpp:26:0:
      .piolibdeps\SD_ID161\utility\Sd2Card.h:65:37: error: 'SS_PIN' was not declared in this scope
      uint8_t const  SD_CHIP_SELECT_PIN = SS_PIN;
      ^
      .piolibdeps\SD_ID161\utility\Sd2Card.h:68:31: error: 'MOSI_PIN' was not declared in this scope
      uint8_t const  SPI_MOSI_PIN = MOSI_PIN;
      ^
      .piolibdeps\SD_ID161\utility\Sd2Card.h:70:31: error: 'MISO_PIN' was not declared in this scope
      uint8_t const  SPI_MISO_PIN = MISO_PIN;
      ^
      .piolibdeps\SD_ID161\utility\Sd2Card.h:72:30: error: 'SCK_PIN' was not declared in this scope
      uint8_t const  SPI_SCK_PIN = SCK_PIN;
      ^
      .piolibdeps\SD_ID161\utility\Sd2Card.cpp: In member function 'uint8_t Sd2Card::init(uint8_t, uint8_t, int8_t, int8_t, int8_t)':
      .piolibdeps\SD_ID161\utility\Sd2Card.cpp:302:17: error: cannot convert 'volatile uint32_t* {aka volatile unsigned int*}' to 'volatile uint8_t* {aka volatile unsigned char*}' in assignment
      clkport     = portOutputRegister(digitalPinToPort(clockPin_));
      ^
      .piolibdeps\SD_ID161\utility\Sd2Card.cpp:304:17: error: cannot convert 'volatile uint32_t* {aka volatile unsigned int*}' to 'volatile uint8_t* {aka volatile unsigned char*}' in assignment
      mosiport    = portOutputRegister(digitalPinToPort(mosiPin_));
      ^
      .piolibdeps\SD_ID161\utility\Sd2Card.cpp:306:17: error: cannot convert 'volatile uint32_t* {aka volatile unsigned int*}' to 'volatile uint8_t* {aka volatile unsigned char*}' in assignment
      misoport    = portInputRegister(digitalPinToPort(misoPin_));
      ^
      .piolibdeps\SD_ID161\utility\Sd2Card.cpp: In member function 'uint8_t Sd2Card::readData(uint32_t, uint16_t, uint16_t, uint8_t*)':
      .piolibdeps\SD_ID161\utility\Sd2Card.cpp:438:12: warning: unused variable 'n' [-Wunused-variable]
      uint16_t n;
      ^
      In file included from .piolibdeps\SD_ID161/utility/SdFat.h:29:0,
      from .piolibdeps\SD_ID161\SD.h:25,
      from .piolibdeps\SD_ID161\SD.cpp:53:
      .piolibdeps\SD_ID161/utility/Sd2Card.h:65:37: error: 'SS_PIN' was not declared in this scope
      uint8_t const  SD_CHIP_SELECT_PIN = SS_PIN;
      ^
      .piolibdeps\SD_ID161/utility/Sd2Card.h:68:31: error: 'MOSI_PIN' was not declared in this scope
      uint8_t const  SPI_MOSI_PIN = MOSI_PIN;
      ^
      .piolibdeps\SD_ID161/utility/Sd2Card.h:70:31: error: 'MISO_PIN' was not declared in this scope
      uint8_t const  SPI_MISO_PIN = MISO_PIN;
      ^
      .piolibdeps\SD_ID161/utility/Sd2Card.h:72:30: error: 'SCK_PIN' was not declared in this scope
      Aurchiving .pioenvs\m5stack-core-esp32\lib9f4\libFS.aint8_t const  SPI_SCK_PIN = SCK_PIN;

      ^
      *** [.pioenvs\m5stack-core-esp32\lib6b6\SD_ID161\utility\Sd2Card.cpp.o] Error 1
      *** [.pioenvs\m5stack-core-esp32\lib6b6\SD_ID161\File.cpp.o] Error 1
      In file included from .piolibdeps\SD_ID161\utility\Sd2Card.h:26:0,
      from .piolibdeps\SD_ID161\utility\SdFat.h:29,
      from .piolibdeps\SD_ID161\utility\SdVolume.cpp:20:
      .piolibdeps\SD_ID161\utility\Sd2PinMap.h:371:2: error: #error Architecture or board not supported.
      #error Architecture or board not supported.
      ^
      *** [.pioenvs\m5stack-core-esp32\lib6b6\SD_ID161\SD.cpp.o] Error 1
      In file included from .piolibdeps\SD_ID161\utility\SdFat.h:29:0,
      from .piolibdeps\SD_ID161\utility\SdVolume.cpp:20:
      .piolibdeps\SD_ID161\utility\Sd2Card.h:65:37: error: 'SS_PIN' was not declared in this scope
      uint8_t const  SD_CHIP_SELECT_PIN = SS_PIN;
      ^
      .piolibdeps\SD_ID161\utility\Sd2Card.h:68:31: error: 'MOSI_PIN' was not declared in this scope
      uint8_t const  SPI_MOSI_PIN = MOSI_PIN;
      ^
      .piolibdeps\SD_ID161\utility\Sd2Card.h:70:31: error: 'MISO_PIN' was not declared in this scope
      uint8_t const  SPI_MISO_PIN = MISO_PIN;
      ^
      .piolibdeps\SD_ID161\utility\Sd2Card.h:72:30: error: 'SCK_PIN' was not declared in this scope
      uint8_t const  SPI_SCK_PIN = SCK_PIN;
      ^
      *** [.pioenvs\m5stack-core-esp32\lib6b6\SD_ID161\utility\SdVolume.cpp.o] Error 1
      In file included from .piolibdeps\SD_ID161\utility\SdFat.h:29:0,
      from .piolibdeps\SD_ID161\utility\SdFile.cpp:20:
      .piolibdeps\SD_ID161\utility\Sd2Card.h:65:37: error: 'SS_PIN' was not declared in this scope
      uint8_t const  SD_CHIP_SELECT_PIN = SS_PIN;
      ^
      .piolibdeps\SD_ID161\utility\Sd2Card.h:68:31: error: 'MOSI_PIN' was not declared in this scope
      uint8_t const  SPI_MOSI_PIN = MOSI_PIN;
      ^
      .piolibdeps\SD_ID161\utility\Sd2Card.h:70:31: error: 'MISO_PIN' was not declared in this scope
      uint8_t const  SPI_MISO_PIN = MISO_PIN;
      ^
      .piolibdeps\SD_ID161\utility\Sd2Card.h:72:30: error: 'SCK_PIN' was not declared in this scope
      uint8_t const  SPI_SCK_PIN = SCK_PIN;
      ^
      *** [.pioenvs\m5stack-core-esp32\src\main.cpp.o] Error 1
      .piolibdeps\SD_ID161\utility\SdFile.cpp: In static member function 'static uint8_t 
      SdFile::make83Name(const char*, uint8_t*)':
      .piolibdeps\SD_ID161\utility\SdFile.cpp:261:15: warning: unused variable 'b' [-Wunused-variable]
      uint8_t b;
        ^
        *** [.pioenvs\m5stack-core-esp32\lib6b6\SD_ID161\utility\SdFile.cpp.o] Error 1
    
        The terminal process terminated with exit code: 1

        Terminal will be reused by tasks, press any key to close it.

I had the exact same issues and deleting lib folder wasn’t enough as well.
I had to replace every File variable with fs::File (define the namespace) because the M5Stack library includes SD.h and so two implementations of the File type arise.
Besides that, I also removed the .pio folder before building the project again.
After that, everything worked as expected.