Skip to content
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
# pioarduino (p)eople (i)nitiated (o)ptimized (arduino)

[![CI Examples](https://github.com/pioarduino/platform-espressif32/actions/workflows/examples.yml/badge.svg?branch=develop)](https://github.com/pioarduino/platform-espressif32/actions/workflows/examples.yml)
[![Build Status](https://github.com/pioarduino/platform-espressif32/actions/workflows/examples.yml/badge.svg)](https://github.com/pioarduino/platform-espressif32/actions)
[![Discord](https://img.shields.io/discord/1263397951829708871.svg?logo=discord&logoColor=white&color=5865F2&label=Discord)](https://discord.gg/Nutz9crnZr)
[![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/pioarduino/platform-espressif32)
[![GitHub Releases](https://img.shields.io/github/downloads/pioarduino/platform-espressif32/total?label=downloads)](https://github.com/pioarduino/platform-espressif32/releases/latest)

Espressif Systems is a privately held, fabless semiconductor company renowned for delivering cost-effective wireless communication microcontrollers. Their innovative solutions are widely adopted in mobile devices and Internet of Things (IoT) applications around the globe.

## General
* Issues with boards (wrong / missing). All issues caused from boards will not be fixed from the maintainer(s). A PR needs to be provided against branch `develop` to solve.
* No support for the Arduino Nora Nano board, issues needs to be solved by the community

## IDE Preparation
Prerequisites:
- Python >= 3.10 is required for pioarduino to function properly.

## Installation
- [Download and install Microsoft Visual Studio Code](https://code.visualstudio.com/). pioarduino IDE is on top of it.
- Open the extension manager.
- Search for the `pioarduino ide` extension.
Expand All @@ -25,7 +29,7 @@ Espressif Systems is a privately held, fabless semiconductor company renowned fo
The Wiki is AI generated and insane detailed and accurate.

### Stable Arduino
currently espressif Arduino 3.2.1 and IDF 5.4.2
currently espressif Arduino 3.3.0 and IDF 5.5.0

```ini
[env:stable]
Expand All @@ -49,13 +53,13 @@ Example configuration:

```ini
[env:esp32solo1]
platform = https://github.com/pioarduino/platform-espressif32.git#develop
platform = https://github.com/pioarduino/platform-espressif32/releases/download/stable/platform-espressif32.zip
framework = arduino
board = esp32-solo1
monitor_speed = 115200

[env:esp32-c2-devkitm-1]
platform = https://github.com/pioarduino/platform-espressif32.git#develop
platform = https://github.com/pioarduino/platform-espressif32/releases/download/stable/platform-espressif32.zip
framework = arduino
board = esp32-c2-devkitm-1
monitor_speed = 115200
Expand Down
2 changes: 1 addition & 1 deletion builder/frameworks/espidf.py
Original file line number Diff line number Diff line change
Expand Up @@ -1513,7 +1513,7 @@ def _get_installed_uv_packages(python_exe_path):
# https://github.com/platformio/platform-espressif32/issues/635
"cryptography": "~=44.0.0",
"pyparsing": ">=3.1.0,<4",
"idf-component-manager": "~=2.0.1",
"idf-component-manager": "~=2.2",
"esp-idf-kconfig": "~=2.5.0"
}

Expand Down
93 changes: 79 additions & 14 deletions builder/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@
from platformio.project.helpers import get_project_dir
from platformio.package.version import pepver_to_semver
from platformio.util import get_serial_ports
from platformio.compat import IS_WINDOWS

# Check Python version requirement
if sys.version_info < (3, 10):
sys.stderr.write(
f"Error: Python 3.10 or higher is required. "
f"Current version: {sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}\n"
f"Please update your Python installation.\n"
)
sys.exit(1)

# Python dependencies required for the build process
python_deps = {
Expand All @@ -56,6 +66,68 @@
# Framework directory path
FRAMEWORK_DIR = platform.get_package_dir("framework-arduinoespressif32")

platformio_dir = projectconfig.get("platformio", "core_dir")
penv_dir = os.path.join(platformio_dir, "penv")

pip_path = os.path.join(
penv_dir,
"Scripts" if IS_WINDOWS else "bin",
"pip" + (".exe" if IS_WINDOWS else ""),
)

def setup_pipenv_in_package():
"""
Checks if 'penv' folder exists in platformio dir and creates virtual environment if not.
"""
if not os.path.exists(penv_dir):
env.Execute(
env.VerboseAction(
'"$PYTHONEXE" -m venv --clear "%s"' % penv_dir,
"Creating a new virtual environment for Python dependencies",
)
)

assert os.path.isfile(
pip_path
), "Error: Failed to create a proper virtual environment. Missing the `pip` binary!"

penv_python = os.path.join(penv_dir, "Scripts", "python.exe") if IS_WINDOWS else os.path.join(penv_dir, "bin", "python")
env.Replace(PYTHONEXE=penv_python)
print(f"PYTHONEXE updated to penv environment: {penv_python}")

setup_pipenv_in_package()
# Update global PYTHON_EXE variable after potential pipenv setup
PYTHON_EXE = env.subst("$PYTHONEXE")
python_exe = PYTHON_EXE

# Ensure penv Python directory is in PATH for subprocess calls
python_dir = os.path.dirname(PYTHON_EXE)
current_path = os.environ.get("PATH", "")
if python_dir not in current_path:
os.environ["PATH"] = python_dir + os.pathsep + current_path

# Verify the Python executable exists
assert os.path.isfile(PYTHON_EXE), f"Python executable not found: {PYTHON_EXE}"

if os.path.isfile(python_exe):
# Update sys.path to include penv site-packages
if IS_WINDOWS:
penv_site_packages = os.path.join(penv_dir, "Lib", "site-packages")
else:
# Find the actual site-packages directory in the venv
penv_lib_dir = os.path.join(penv_dir, "lib")
if os.path.isdir(penv_lib_dir):
for python_dir in os.listdir(penv_lib_dir):
if python_dir.startswith("python"):
penv_site_packages = os.path.join(penv_lib_dir, python_dir, "site-packages")
break
else:
penv_site_packages = None
else:
penv_site_packages = None

if penv_site_packages and os.path.isdir(penv_site_packages) and penv_site_packages not in sys.path:
sys.path.insert(0, penv_site_packages)

def add_to_pythonpath(path):
"""
Expand All @@ -80,14 +152,10 @@ def add_to_pythonpath(path):
if normalized_path not in sys.path:
sys.path.insert(0, normalized_path)


def setup_python_paths():
"""
Setup Python paths based on the actual Python executable being used.
"""
if not PYTHON_EXE or not os.path.isfile(PYTHON_EXE):
return

"""
# Get the directory containing the Python executable
python_dir = os.path.dirname(PYTHON_EXE)
add_to_pythonpath(python_dir)
Expand All @@ -107,7 +175,6 @@ def setup_python_paths():
# Setup Python paths based on the actual Python executable
setup_python_paths()


def _get_executable_path(python_exe, executable_name):
"""
Get the path to an executable binary (esptool, uv, etc.) based on the Python executable path.
Expand All @@ -119,14 +186,11 @@ def _get_executable_path(python_exe, executable_name):
Returns:
str: Path to executable or fallback to executable name
"""
if not python_exe or not os.path.isfile(python_exe):
return executable_name # Fallback to command name

python_dir = os.path.dirname(python_exe)

if sys.platform == "win32":
scripts_dir = os.path.join(python_dir, "Scripts")
executable_path = os.path.join(scripts_dir, f"{executable_name}.exe")
if IS_WINDOWS:
executable_path = os.path.join(python_dir, f"{executable_name}.exe")
else:
# For Unix-like systems, executables are typically in the same directory as python
# or in a bin subdirectory
Expand Down Expand Up @@ -228,7 +292,7 @@ def install_python_deps():
uv_executable = _get_uv_executable_path(PYTHON_EXE)

# Add Scripts directory to PATH for Windows
if sys.platform == "win32":
if IS_WINDOWS:
python_dir = os.path.dirname(PYTHON_EXE)
scripts_dir = os.path.join(python_dir, "Scripts")
if os.path.isdir(scripts_dir):
Expand Down Expand Up @@ -366,8 +430,10 @@ def install_esptool():
return 'esptool' # Fallback


# Install Python dependencies and esptool
# Install Python dependencies
install_python_deps()

# Install esptool after dependencies
esptool_binary_path = install_esptool()


Expand Down Expand Up @@ -756,7 +822,6 @@ def switch_off_ldf():
if ' ' in esptool_binary_path
else esptool_binary_path
)

# Configure build tools and environment variables
env.Replace(
__get_board_boot_mode=_get_board_boot_mode,
Expand Down
15 changes: 8 additions & 7 deletions platform.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"type": "framework",
"optional": true,
"owner": "espressif",
"version": "https://github.com/espressif/arduino-esp32/archive/release/v3.3.x.zip"
"version": "https://github.com/espressif/arduino-esp32/archive/master.zip"
},
"framework-arduinoespressif32-libs": {
"type": "framework",
Expand All @@ -51,7 +51,7 @@
"type": "framework",
"optional": true,
"owner": "pioarduino",
"version": "https://github.com/pioarduino/esp-idf/releases/download/v5.5.0-rc1/esp-idf-v5.5.0-rc1.zip"
"version": "https://github.com/pioarduino/esp-idf/releases/download/v5.5.0/esp-idf-v5.5.0.zip"
},
"toolchain-xtensa-esp-elf": {
"type": "toolchain",
Expand Down Expand Up @@ -92,13 +92,14 @@
"type": "uploader",
"optional": true,
"owner": "pioarduino",
"package-version": "5.0.1",
"version": "https://github.com/pioarduino/registry/releases/download/0.0.1/esptoolpy-v5.0.1.zip"
"package-version": "5.0.2",
"version": "https://github.com/pioarduino/registry/releases/download/0.0.1/esptoolpy-v5.0.2.zip"
},
"tl-install": {
"tool-esp_install": {
"type": "tool",
"optional": false,
"owner": "pioarduino",
"package-version": "5.1.0",
"version": "https://github.com/pioarduino/esp_install/releases/download/v5.1.0/esp_install-v5.1.0.zip"
},
"contrib-piohome": {
Expand Down Expand Up @@ -188,8 +189,8 @@
"type": "tool",
"optional": true,
"owner": "pioarduino",
"package-version": "1.13.0",
"version": "https://github.com/pioarduino/registry/releases/download/0.0.1/ninja-1.13.0.zip"
"package-version": "1.13.1",
"version": "https://github.com/pioarduino/registry/releases/download/0.0.1/ninja-1.13.1.zip"
},
"tool-scons": {
"type": "tool",
Expand Down
Loading
Loading