Use different version of Arduino framework on espressif platform

We are using ESP32 boards with espressif platform and Arduino framework
The arduino framework is maintained in GitHub - espressif/arduino-esp32: Arduino core for the ESP32 and we would like to use a specific branch from this repo to test certain upcoming improvements.

Is it possible to do this?

If this branch is after 1.0.6 (e.g. some 2.0.0 beta or 2.0.0), which I read when you say “upcoming improvements”, you can’t use it properly with PlatformIO yet because integration is missing. You can certainly attempt to use it per this (framework-arduinoespressif32) and ESP32-Arduino - platformio support for 2.0.0 version - #2 by maxgerhardt but it will likely not fully work.

Can’t we use this?

platform_packages =
    platformio/framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#wire-ng

Since this wire-ng branch does not exist in Branches · espressif/arduino-esp32 · GitHub I cannot confirm this. You might be needing an updated compiler and esptoolpy package, too.

My bad, the branch is called feature/wire_ng

No, not by itself. That branch is 6 commits ahead of master which is after 2.0.0, and thus falls in the “2.0.0 core is not yet supported by PlatformIO, this will likely not work” category per above. Also, by only redirecting the Arduino core package, you are still using the old compiler and old esptoolpy, which will give you an error during compilation.

What works for me is the following:

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
platform_packages =
   toolchain-xtensa32 @ file://C:\Users\Max\Downloads\xtensa-esp32-elf-gcc8_4_0-esp-2021r1-win32\xtensa-esp32-elf
   framework-arduinoespressif32@https://github.com/espressif/arduino-esp32.git#feature/wire_ng
   platformio/tool-esptoolpy @ ~1.30100
monitor_speed = 115200

whereas the path C:\Users\Max\Downloads\xtensa-esp32-elf-gcc8_4_0-esp-2021r1-win32\xtensa-esp32-elf must be changed to a folder created this way:

{
  "name": "toolchain-xtensa32",
  "version": "2.80400.210114",
  "description": "GCC Toolchain for Xtensa32 processor",
  "keywords": [
    "build tools",
    "compiler",
    "assembler",
    "linker",
    "preprocessor",
    "esp32"
  ],
  "license": "GPL-2.0-or-later",
  "repository": {
    "type": "git",
    "url": "https://github.com/espressif/crosstool-NG"
  },
  "system": [
    "windows_amd64"
  ]
}
  • If not using Windows, replace windows_amd64 with other identifiers, e.g., linux_x86_64 (Linux) or darwin_x86_64 (Mac)
  • Adapt the file:// path in the platformio.ini to where your xtensa-esp32-elf folder is
  • Compile and upload.

When I do this with the minimal code

#include <Arduino.h>

void setup() { Serial.begin(115200); }
void loop() { Serial.println("Test"); delay(1000); }

I get output on my ESP32 board.

Retrieving maximum program size .pio\build\esp32dev\firmware.elf
Checking size .pio\build\esp32dev\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   3.6% (used 11872 bytes from 327680 bytes)
Flash: [==        ]  17.9% (used 234061 bytes from 1310720 bytes)
Configuring upload protocol...
..
============================================================================= [SUCCESS] Took 16.30 seconds =============================================================================
--- Available filters and text transformations: colorize, debug, default, direct, esp32_exception_decoder, hexlify, log2file, nocontrol, printable, send_on_enter, time
--- More details at http://bit.ly/pio-monitor-filters
--- Miniterm on COM4  115200,8,N,1 ---
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
ets Jun  8 2016 00:22:57

rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:1100
ho 0 tail 12 room 4
load:0x40078000,len:12280
ho 0 tail 12 room 4
load:0x40080400,len:3076
entry 0x400805ec
Test

Sadly one can not use toolchain-xtensa32 @ ~2.80400.0 here to get the right compiler version because that seems to be one version behind (not gcc8_4_0-esp-2021r1).

No guarantes that this works fully and exactly the same as in the Arduino IDE though – as said, PlatformIO’s integration with 2.0.0+ cores is still pending.

1 Like

Thank you very much for your extensive answer!

The new toolchains are in the Platformio Registry no need for using homebrew ones.
The setup is

platform = https://github.com/platformio/platform-espressif32.git#feature/arduino-idf-master
platform_packages = framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#feature/wire_ng
platformio/tool-esptoolpy @ ~1.30100
1 Like