M5stack Paper help, helloworld does not execute, default platform.ini seems broken. I have a working guess

I have an M5Stack Paper (“EPD”) device. WIth the arduino IDE, I can get helloworld working.
It’s not working with vscode/PIO.
I think there may be a configuration error with the suggested settings. I have the latest libraries

I am a new user, I know nothing. I don’t even know where to report the poor experience, I guessed here as a start.

To start a new project, I am choosing M5Stack Core ESP32.
I have these libraries installed via the PIO library manager

M5Stack v0.4.0
M5EPD v0.1.3
(I also have ArduinoJson installed)

I get this platform.ini


[env:m5stack-core-esp32]

platform = espressif32

board = m5stack-core-esp32

framework = arduino

the project builds, flashes and the device restarts, but the result is a blank screen. The same code work s in ArduinoIDE.

However, in this official-looking github repo GitHub - m5stack/M5Paper_FactoryTest
the platform.ini looks very different, including a different board. I don’t know what m5stack-fire is and I don’t recall seeing it in the getting started documentation.



[env:m5stack-fire]

platform = espressif32

board = m5stack-fire

framework = arduino

upload_speed = 2000000

monitor_speed = 115200

board_build.partitions = default_16MB.csv

build_flags =

-DCORE_DEBUG_LEVEL=4

-DBOARD_HAS_PSRAM

-mfix-esp32-psram-cache-issue

lib_deps =

m5stack/M5EPD

Even more weird, when I make a new project in PIO specifying board m5stack-fire, I get this:

[env:m5stack-core-esp32]

platform = espressif32

board = m5stack-filter

framework = arduino

build_flags =

lib_deps =

m5stack/M5EPD@^0.1.3

m5stack/M5Stack@^0.4.0

bblanchon/ArduinoJson@^6.19.4

on compilation, this leads to “Error: Unknown board ID ‘m5stack-filter’”

So at this point, I resort to guessing.

This worked:

[env:m5stack-core-esp32]

platform = espressif32

board = m5stack-fire

framework = arduino

build_flags =

lib_deps =

m5stack/M5EPD@^0.1.3

m5stack/M5Stack@^0.4.0

bblanchon/ArduinoJson@^6.19.4

This is because there is no m5stack-filter, there is m5stack-fire. (See all board files).

Let’s focus on this case. Same config + code + core versions + library versions should result in the same behavior. Can you show a screenshot of the Arduino IDE → Tools menu with which which it works? What’s the code you’re running on it? What version of the esp32 core does it show for you in Arduino IDE → Tools → Board → Board Manager → esp32?

This incorrect board comes from making a default project for the board I have. Do you know whose bug this is, so I can report it properly? My guess is M5Stack’s since I suppose it provides somewhere default configurations.

PlatformIO should only allow to create projects for boards in its platform. Can you make a few screenshots of how you create a project using the PlatformIO home → New Project dialog that leads to this invalid platformio.ini?

it says the board is ‘M5Stack-Paper’ which is not a board in PIO

I see, indeed. You’re using the board package as instructed from m5-docs, which is using the Arduino core https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/arduino/m5stack-2.0.3.zip. PlatformIO only supports the official Arduino-ESP32, which does not have the M5Stack-Paper (but other M5Stack boards), see here. Seems like the M5Stack people just fork the Arduino-ESP32 core, add their own boards, and don’t merge immediately back, leaving regular core users in the dark.

However, looking at the core download, it nicely has a package.json, so it can be used in PlatformIO, given the right board definition (already created in Create m5stack-paper.json by TomG736 · Pull Request #669 · platformio/platform-espressif32 · GitHub).

Could you try this example please? (Initial “Rebuilding Index” in VSCode might take long because it has to download the core from a slow chinese server…)

(referring to the second point of my initial post, with board =m5stack-filter): I can not reproduce the problem. When I make a new project specifying Fire as the board, I do not get the same platform.ini file I posted above.

thanks for your help. I will do this, but it requires me to build PlatformIO I guess and then integrate that with my install of vscode … I am new to all of this (even new to vscode) to it may take me a while to figure that out. … this is, I don’t know what to do with your github files

Nonono, if you say you already tried some things with PlatformIO I assume it’s installed in VSCode as an extension. That’s all the base installation you need. The PIO Home page has a “Open Project” button. You just need to download / clone the above Git repo (e.g., download + unzip https://github.com/maxgerhardt/pio-m5stack-paper-test/archive/refs/heads/main.zip) and use that Open Project dialog. After a bit of waiting for the index rebuild (bottom taskbar), you should be able to use build + upload just fine.

ok, I will try that … meanwhile I found this Custom Embedded Boards — PlatformIO v6.1 documentation but after adding the json file to the ~/.platformio/boards directory, nothing seems to have happened

My project already uses that in the local form, i.e. boards/ folder in the project folder. To avoid duplicate copies of m5stack-paper.json I’d recommend deleting it from the ~/.platformio/boards folder again. If the project works, you can add it there, but then it probably also needs a restart of VSCode to reload the board index.

Thanks, I opened the project after cloning your repository, and hello world works.

Should there be a way for me to add this board as an option for new projects? Not that it is any hardship cloning the project you made.

Great!

The problem is, the board definition file is only half the rent. The other half is making PlatformIO use M5Stack’s version of the Arduino core, achieved by the platform_packages line in the platformio.ini. So I wouldn’t actually recommend installing it as a global board, because this easily creates uncompilable projects if the original core is used. Further, when you put the board file in the project and upload that anywhere, it is now also usable and buildable on other computers that don’t have specially modified .platformio/ files.

ok. it didn’t work, anyway. Compilation fails:

#include “pins_arduino.h”
^~~~~~~~~~~~~~~~
compilation terminated.
*** [.pio/build/m5stack-paper/FrameworkArduino/FunctionalInterrupt.cpp.o] Error 1

PS One more question :slight_smile:

My initial workaround was to use

board = m5stack-fire

it works for ‘hello world’ but would this lead to later problems with more sophisticated projects?

Board board = .. selection influences a great number of things, that is, ESP32 type, flash size and the Arduino variant e.g. The m5stack_fire and and m5stack_paper variant folders each have their pins_arduino.h in them, and they might have different things (e.g., default pins for attached devices or SPI bus etc.) in them, leading to incompatibilities later.