@jbruggem Your first post shows that

you haven't configured Arduino to configure code for the M5Stack Core2 which uses a different core and pin config to a base esp32. The example you are using is not an M5Stack demo, Arduino is missing Libraries.

All these errors point back to not have the M5Stack Core2 board type selected.