Anyone get the MagTag working with Platform IO?
Have you tried using the analogue of what is described in the Adafruit guide with PlatformIO tools? PlatformIO is well-capable of using the latest version of e.g. Arduino-ESP32 (docs) as well as changing board definitions to use a different variant folder etc.
So as a first try, you should create a new blank Espressif ESP32 Dev Module + Arduino project, then change the
[env:esp32dev] platform = espressif32 board = esp32dev framework = arduino platform_packages = toolchain-xtensa32@~2.80400.0 framework-arduinoespressif32@https://github.com/espressif/arduino-esp32.git board_build.mcu = esp32s2 board_build.variant = adafruit_magtag29_esp32s2
and e.g. a blink sketch.
See also related topic Update to the latest version v2.0.0 from GitHub.
Thanks, I’ll give that a try.
@blakefl Did you ever get this working?
While my build and upload works fine, sometimes, the MagTag seems to be doing … nothing. And sometimes, parts of the sketch seems fine, but other parts don’t work (for example, I just have an issue where drawing on the eInk works, but the serial port doesn’t - it doesn’t even show up as a device on my machine), while the same sketches work fine when copy-pasted into the Arduino IDE. Would be interesting to know what you did, it if works for you.
Looking at the board variant definition in espressif’s repo, I could find a lot of specifics, like the extra upload flag in
for example. Wondering what’s the best way to approach this.
If that is really the option that breaks this, this binary and address needs to be added in the
You can try and find this file locally (
C:\Users\<user>\.platformio\packages\framework-arduinoespressif32@src-***\tools\platformio-build-esp32s2.py) and add
("0x2d0000", join(FRAMEWORK_DIR, "variants", env.BoardConfig().get("build.variant"), "tinyuf2.bin")
to that array. Make sure to use the project task “Advanced → Verbose Upload” to verify the results in the final
That’s fair, there’s always the line between “doing what’s right”, and “doing experimental stuff because I’d really like to use PlatformIO instead of the Arduino editor because it makes me happier”.
Ultimately, I figured it out. The extra image wasn’t the issue - that only breaks booting into USB mode for drag-and-dropping firmwares, which I don’t use. I ended up comparing the verbose outputs for both tools compiling, and noticed differences in flags.
-DARDUINO_SERIAL_PORT=1 is probably the most significant, but just for the record, I’m sharing my
platformio.ini that works for me, just in case anyone else is looking:
[env:MagTag] platform = espressif32 platform_packages = toolchain-xtensa32s2 framework-arduinoespressif32@https://github.com/espressif/arduino-esp32.git#2.0.0-alpha1 framework = arduino board = esp32dev board_build.mcu = esp32s2 board_build.partitions = huge_app.csv build_unflags = -DARDUINO_ESP32_DEV -DARDUINO_VARIANT="esp32" build_flags = -DARDUINO_MAGTAG29_ESP32S2 -DARDUINO_SERIAL_PORT=1 -DARDUINO_VARIANT="adafruit_magtag29_esp32s2" -DBOARD_HAS_PSRAM monitor_speed = 115200
And with that, I’ll patiently wait until there is official support. Thanks for your help!
Ah, great that you got it working. Never seen the
ARDUINO_SERIAL_PORT=1 option before, that’s interesting.
Regarding the TinyUF2 bootloader flashing, I’ve opened an issue for that.
Thanks for filing that. I actually filed an issue about the
ARDUINO_SERIAL_PORT flag, ARDUINO_SERIAL_PORT=1 needed for (some) boards in v2.0.0 to get the Serial interface enabled · Issue #5258 · espressif/arduino-esp32 · GitHub, because looking at the sources, this is probably required in the future for (some?) boards to get USB Serial to work, at all.
Not sure if you want issues about not-yet-released versions, but closing an issue is usually a lot easier than not having an issue at all and debugging the same thing in a few months.