Skip to content

add Hybrid Compile #73

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 100 commits into from
Dec 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
173a93a
Rename examples.yml to examples.yml.off
Jason2866 Nov 10, 2024
02582bd
Update platform.py
Jason2866 Nov 10, 2024
366a4b4
Update main.py
Jason2866 Nov 10, 2024
d32b3aa
Update arduino.py
Jason2866 Nov 10, 2024
b82581b
Update arduino.py
Jason2866 Nov 10, 2024
4342893
Update espidf.py
Jason2866 Nov 10, 2024
808f2f8
fix lib path
Jason2866 Nov 10, 2024
f6830ec
Update esp32-solo1.json
Jason2866 Nov 10, 2024
816f19c
Update platformio.ini
Jason2866 Nov 10, 2024
bf4bd97
Create dummy
Jason2866 Nov 10, 2024
6691316
Add files via upload
Jason2866 Nov 10, 2024
2f8068a
Delete builder/build_lib/dummy
Jason2866 Nov 10, 2024
efb31e8
Rename examples.yml.off to examples.yml
Jason2866 Nov 10, 2024
3dfcbee
Update arduino.py
Jason2866 Nov 10, 2024
04d3e93
Update espidf.py
Jason2866 Nov 10, 2024
27e6cf4
Update espidf.py
Jason2866 Nov 10, 2024
757a9f8
Update espidf.py
Jason2866 Nov 10, 2024
c6a0369
symlink is not working
Jason2866 Nov 10, 2024
bca7f76
Update platformio.ini
Jason2866 Nov 10, 2024
56e38c3
Update platformio.ini
Jason2866 Nov 10, 2024
4bd2401
fix path
Jason2866 Nov 10, 2024
b3065ca
Update espidf.py
Jason2866 Nov 10, 2024
4c18aad
Update espidf.py
Jason2866 Nov 10, 2024
bcc5100
Update espidf.py
Jason2866 Nov 10, 2024
c758cad
Update espidf.py
Jason2866 Nov 10, 2024
720fbbb
Update espidf.py
Jason2866 Nov 10, 2024
3116595
Update espidf.py
Jason2866 Nov 10, 2024
a427675
Update espidf.py
Jason2866 Nov 10, 2024
ed75ecc
Update espidf.py
Jason2866 Nov 10, 2024
6d2e6fb
Update espidf.py
Jason2866 Nov 10, 2024
68b2cee
Update espidf.py
Jason2866 Nov 10, 2024
dc37c4a
Update espidf.py
Jason2866 Nov 10, 2024
2c2d643
Update platformio.ini
Jason2866 Nov 10, 2024
3db8ecf
Update espidf.py
Jason2866 Nov 10, 2024
224ea38
Update espidf.py
Jason2866 Nov 10, 2024
8594dd4
S3 on steriods
Jason2866 Nov 10, 2024
832a843
Create esp32s3_120_16_8-qio_opi.json
Jason2866 Nov 10, 2024
9b51485
Create esp32-p4.json
Jason2866 Nov 10, 2024
fa993b7
Update platformio.ini
Jason2866 Nov 10, 2024
83d1f6c
remove rainmaker
Jason2866 Nov 10, 2024
1d42983
use interim Arduino branch `idf-release/v5.3`
Jason2866 Nov 10, 2024
39e233f
Update Zigbee_On_Off_Light.ino
Jason2866 Nov 10, 2024
9f8d2e4
Update Zigbee_On_Off_Switch.ino
Jason2866 Nov 10, 2024
93960df
Update platformio.ini
Jason2866 Nov 10, 2024
cef857a
Update espidf.py
Jason2866 Nov 10, 2024
681ac5c
Update platformio.ini
Jason2866 Nov 10, 2024
5857759
Update platform.json
Jason2866 Nov 10, 2024
6d52b2b
Update platformio.ini
Jason2866 Nov 10, 2024
763ab75
Update platform.json
Jason2866 Nov 11, 2024
b939c52
Update platform.py
Jason2866 Nov 11, 2024
112d3c3
Update espidf.py
Jason2866 Nov 11, 2024
271c6d9
Update platformio.ini
Jason2866 Nov 11, 2024
b5c5c01
Update espidf.py
Jason2866 Nov 11, 2024
b82a529
Update platformio.ini
Jason2866 Nov 11, 2024
8af3d90
Update espidf.py
Jason2866 Nov 11, 2024
8fa8efe
copy c2 skeleton in Arduino libs dir
Jason2866 Nov 11, 2024
818b227
remove not needed import
Jason2866 Nov 11, 2024
472d387
Update arduino.py
Jason2866 Nov 11, 2024
8fbb13b
Update arduino.py
Jason2866 Nov 11, 2024
7d19500
Update arduino.py
Jason2866 Nov 11, 2024
820070d
Update arduino.py
Jason2866 Nov 11, 2024
fd36cb5
remove debug print
Jason2866 Nov 11, 2024
e50993c
Update sdkconfig.defaults
Jason2866 Nov 11, 2024
3bf62c0
Update platformio.ini
Jason2866 Nov 11, 2024
6ada863
Update platformio.ini
Jason2866 Nov 11, 2024
a5488a3
Disable C6 example
Jason2866 Nov 11, 2024
9f72c08
remove import
Jason2866 Nov 11, 2024
2725f9e
remove zigbee from sdkconfig default
Jason2866 Nov 11, 2024
dc4bd63
Update platformio.ini
Jason2866 Nov 13, 2024
9c4ad03
add debug path var
Jason2866 Nov 13, 2024
6ba8276
Update espidf.py
Jason2866 Nov 13, 2024
b0d7d92
Update espidf.py
Jason2866 Nov 13, 2024
12cc831
Fix path platforms dir
Jason2866 Nov 13, 2024
b68e709
remove debug print
Jason2866 Nov 13, 2024
9c41bd1
add `http(s)` and `file` as source for custom sdkconfig
Jason2866 Nov 14, 2024
120d7ed
Hybrid compile: fix solo1 if check
Jason2866 Nov 14, 2024
ff43b05
fix custom partiton table offset calculation
Jason2866 Nov 15, 2024
cc0698e
Create tasmota_platformio_override.ini
Jason2866 Nov 15, 2024
8a6c777
add Tasmota as example for Hybrid compile
Jason2866 Nov 15, 2024
1460e33
add tasmota32 hybrid compile example
Jason2866 Nov 15, 2024
cab77d5
Update tasmota_platformio_override.ini
Jason2866 Nov 15, 2024
e82ac53
Update tasmota_platformio_override.ini
Jason2866 Nov 15, 2024
5fb8ffd
Update tasmota_platformio_override.ini
Jason2866 Nov 15, 2024
62b6f90
change override order for custom sdkconfig settings
Jason2866 Nov 15, 2024
502bb4f
switch off Ethernet in IDF
Jason2866 Nov 15, 2024
ed237b2
Update examples.yml
Jason2866 Nov 15, 2024
6b67dee
switch off Tasmota example
Jason2866 Nov 15, 2024
821c188
Update tasmota_platformio_override.ini
Jason2866 Nov 15, 2024
0305320
add example tasmota again
Jason2866 Nov 15, 2024
1b6bb5a
base Tasmota32 variant
Jason2866 Nov 15, 2024
923f348
Update examples.yml
Jason2866 Nov 15, 2024
a28a7de
Update examples.yml
Jason2866 Nov 17, 2024
720c3f4
Update tasmota_platformio_override.ini
Jason2866 Nov 17, 2024
a1e5f2b
Update README.md
Jason2866 Nov 20, 2024
f2a618c
prep for new script "pioarduino-build.py"
Jason2866 Dec 10, 2024
a45b0a4
IDF 5.3.2 release / esptool v4.8.5
Jason2866 Dec 13, 2024
cc3800d
Update Zigbee_On_Off_Switch.ino
Jason2866 Dec 13, 2024
20c41bd
Update Zigbee_On_Off_Light.ino
Jason2866 Dec 13, 2024
62fe998
Create esp32-p4-evboard.json
Jason2866 Dec 14, 2024
c0de14d
Merge branch 'Arduino/IDF53' into Arduino/IDF53_work_hybrid
Jason2866 Dec 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions .github/workflows/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
- "examples/arduino-wifiscan"
- "examples/arduino-zigbee-light"
- "examples/arduino-zigbee-switch"
- "examples/tasmota"
- "examples/espidf-arduino-h2zero-BLE_scan"
- "examples/espidf-arduino-matter-light"
- "examples/espidf-arduino-blink"
Expand Down Expand Up @@ -49,15 +50,15 @@ jobs:
python -m pip install --upgrade pip
pip install wheel
pip install -U https://github.com/platformio/platformio/archive/develop.zip
pio pkg install --global --platform symlink://.
pio pkg install --global --platform file://.
if: "matrix.os == 'windows-2022'"
env:
PLATFORMIO_CORE_DIR: C:\plat
PLATFORMIO_PACKAGES_DIR: C:\plat\pack
PLATFORMIO_PLATFORMS_DIR: C:\plat\plat
- name: Build Windows examples
run: pio run -d ${{ matrix.example }}
if: "matrix.os == 'windows-2022'"
if: "matrix.example != 'examples/tasmota' && matrix.os == 'windows-2022'"
env:
PLATFORMIO_CORE_DIR: C:\plat
PLATFORMIO_PACKAGES_DIR: C:\plat\pack
Expand All @@ -67,8 +68,13 @@ jobs:
python -m pip install --upgrade pip
pip install wheel
pip install -U https://github.com/platformio/platformio/archive/develop.zip
pio pkg install --global --platform symlink://.
pio pkg install --global --platform file://.
if: "matrix.os != 'windows-2022'"
- name: git clone Tasmota and add to examples
run: |
git clone -b development --depth 1 https://github.com/arendst/Tasmota.git examples/tasmota
cp examples/tasmota_platformio_override.ini examples/tasmota/platformio_override.ini
if: "matrix.example == 'examples/tasmota' && matrix.os != 'windows-2022'"
- name: Build Ubuntu Mac examples
run: pio run -d ${{ matrix.example }}
if: "matrix.os != 'windows-2022'"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ based on devel branch Arduino 3.1.0 and IDF 5.3.1+

```ini
[env:development]
platform = https://github.com/pioarduino/platform-espressif32.git#Arduino/IDF53
platform = https://github.com/pioarduino/platform-espressif32.git#Arduino/IDF53_work_hybrid
board = ...
...
```
Expand Down
10 changes: 6 additions & 4 deletions boards/esp32-solo1.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
{
"build": {
"arduino":{
"ldscript": "esp32_out.ld"
},
"core": "esp32",
"extra_flags": "-DARDUINO_ESP32_DEV -DARDUINO_USB_CDC_ON_BOOT=0 -DCORE32SOLO1",
"f_cpu": "80000000L",
"f_cpu": "160000000L",
"f_flash": "40000000L",
"flash_mode": "dio",
"mcu": "esp32",
Expand All @@ -32,6 +29,11 @@
"require_upload_port": true,
"speed": 460800
},
"espidf": {
"custom_sdkconfig": [
"CONFIG_FREERTOS_UNICORE=y"
]
},
"url": "https://en.wikipedia.org/wiki/ESP32",
"vendor": "Espressif"
}
50 changes: 50 additions & 0 deletions boards/esp32s3_120_16_8-qio_opi.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"build": {
"arduino": {
"memory_type": "qio_opi",
"partitions": "default_16MB.csv"
},
"core": "esp32",
"f_cpu": "240000000L",
"f_flash": "80000000L",
"f_boot": "120000000L",
"boot": "qio",
"flash_mode": "qio",
"extra_flags": [
"-DBOARD_HAS_PSRAM",
"-DARDUINO_USB_MODE=1",
"-DARDUINO_USB_CDC_ON_BOOT=1",
"-DARDUINO_RUNNING_CORE=1",
"-DARDUINO_EVENT_RUNNING_CORE=1"
],
"hwids": [
[
"0x303A",
"0x1001"
]
],
"mcu": "esp32s3",
"variant": "esp32s3"
},
"connectivity": [
"bluetooth",
"wifi"
],
"debug": {
"openocd_target": "esp32s3.cfg"
},
"frameworks": [
"arduino",
"espidf"
],
"name": "ESP32-S3 16MB QIO, 8MB OPI PSRAM",
"upload": {
"flash_size": "16MB",
"maximum_ram_size": 327680,
"maximum_size": 16777216,
"require_upload_port": true,
"speed": 460800
},
"url": "https://www.espressif.com/sites/default/files/documentation/esp32-s3-wroom-1_wroom-1u_datasheet_en.pdf",
"vendor": "espressif"
}
1 change: 1 addition & 0 deletions builder/build_lib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
idf_component_register(SRCS "sketch.cpp" "arduino-lib-builder-gcc.c" "arduino-lib-builder-cpp.cpp" "arduino-lib-builder-as.S" INCLUDE_DIRS ".")
Empty file.
Empty file.
Empty file.
12 changes: 12 additions & 0 deletions builder/build_lib/idf_component.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
dependencies:
# Required IDF version
idf: ">=5.1"
espressif/cmake_utilities:
version: "0.*"
espressif/fb_gfx:
version: "master"
path: components/fb_gfx
git: https://github.com/espressif/esp32-arduino-lib-builder.git
require: public
rules:
- if: "target in [esp32, esp32s2, esp32s3, esp32p4]"
10 changes: 10 additions & 0 deletions builder/build_lib/sketch.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include "Arduino.h"

void setup() {
Serial.begin(115200);
}

void loop() {
Serial.println("Hello World!");
delay(1000);
}
170 changes: 163 additions & 7 deletions builder/frameworks/arduino.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,179 @@
http://arduino.cc/en/Reference/HomePage
"""

import subprocess
import json
import semantic_version
import os
import shutil
from os.path import join

from SCons.Script import DefaultEnvironment, SConscript
from SCons.Script import COMMAND_LINE_TARGETS, DefaultEnvironment, SConscript
from platformio.package.version import pepver_to_semver
from platformio.project.config import ProjectConfig
from platformio.package.manager.tool import ToolPackageManager

env = DefaultEnvironment()
pm = ToolPackageManager()
platform = env.PioPlatform()
config = env.GetProjectConfig()
board = env.BoardConfig()
build_core = board.get("build.core", "").lower()
mcu = board.get("build.mcu", "esp32")
board_sdkconfig = board.get("espidf.custom_sdkconfig", "")
entry_custom_sdkconfig = "\n"
flag_custom_sdkconfig = False

if config.has_option("env:"+env["PIOENV"], "custom_sdkconfig"):
entry_custom_sdkconfig = env.GetProjectOption("custom_sdkconfig")
flag_custom_sdkconfig = True

if len(str(board_sdkconfig)) > 2:
flag_custom_sdkconfig = True

extra_flags = (''.join([element for element in board.get("build.extra_flags", "")])).replace("-D", " ")
framework_reinstall = False
flag_any_custom_sdkconfig = False

SConscript("_embed_files.py", exports="env")

if "espidf" not in env.subst("$PIOFRAMEWORK"):
if os.path.exists(join(DefaultEnvironment().PioPlatform().get_package_dir(
flag_any_custom_sdkconfig = os.path.exists(join(platform.get_package_dir("framework-arduinoespressif32-libs"),"sdkconfig"))

# Esp32-solo1 libs needs adopted settings
if flag_custom_sdkconfig == True and ("CORE32SOLO1" in extra_flags or "CONFIG_FREERTOS_UNICORE=y" in entry_custom_sdkconfig or "CONFIG_FREERTOS_UNICORE=y" in board_sdkconfig):
if len(str(env.GetProjectOption("build_unflags"))) == 2: # No valid env, needs init
env['BUILD_UNFLAGS'] = {}
build_unflags = " ".join(env['BUILD_UNFLAGS'])
build_unflags = build_unflags + " -mdisable-hardware-atomics -ustart_app_other_cores"
new_build_unflags = build_unflags.split()
env.Replace(
BUILD_UNFLAGS=new_build_unflags
)

def install_python_deps():
def _get_installed_pip_packages():
result = {}
packages = {}
pip_output = subprocess.check_output(
[
env.subst("$PYTHONEXE"),
"-m",
"pip",
"list",
"--format=json",
"--disable-pip-version-check",
]
)
try:
packages = json.loads(pip_output)
except:
print("Warning! Couldn't extract the list of installed Python packages.")
return {}
for p in packages:
result[p["name"]] = pepver_to_semver(p["version"])

return result

deps = {
"wheel": ">=0.35.1",
"PyYAML": ">=6.0.2",
"intelhex": ">=2.3.0"
}

installed_packages = _get_installed_pip_packages()
packages_to_install = []
for package, spec in deps.items():
if package not in installed_packages:
packages_to_install.append(package)
else:
version_spec = semantic_version.Spec(spec)
if not version_spec.match(installed_packages[package]):
packages_to_install.append(package)

if packages_to_install:
env.Execute(
env.VerboseAction(
(
'"$PYTHONEXE" -m pip install -U '
+ " ".join(
[
'"%s%s"' % (p, deps[p])
for p in packages_to_install
]
)
),
"Installing Arduino Python dependencies",
)
)
return

install_python_deps()

def get_MD5_hash(phrase):
import hashlib
return hashlib.md5((phrase).encode('utf-8')).hexdigest()[:16]


def matching_custom_sdkconfig():
# check if current env is matching to existing sdkconfig
cust_sdk_is_present = False
matching_sdkconfig = False
last_sdkconfig_path = join(env.subst("$PROJECT_DIR"),"sdkconfig.defaults")
if flag_any_custom_sdkconfig == False:
matching_sdkconfig = True
return matching_sdkconfig, cust_sdk_is_present
if os.path.exists(last_sdkconfig_path) == False:
return matching_sdkconfig, cust_sdk_is_present
if flag_custom_sdkconfig == False:
matching_sdkconfig = False
return matching_sdkconfig, cust_sdk_is_present
with open(last_sdkconfig_path) as src:
line = src.readline()
if line.startswith("# TASMOTA__"):
cust_sdk_is_present = True;
costum_options = entry_custom_sdkconfig
if (line.split("__")[1]).strip() == get_MD5_hash((costum_options).strip() + mcu):
matching_sdkconfig = True

return matching_sdkconfig, cust_sdk_is_present

def check_reinstall_frwrk():
framework_reinstall = False
cust_sdk_is_present = False
matching_sdkconfig = False
if flag_custom_sdkconfig == True:
matching_sdkconfig, cust_sdk_is_present = matching_custom_sdkconfig()
if flag_custom_sdkconfig == False and flag_any_custom_sdkconfig == True:
# case custom sdkconfig exists and a env without "custom_sdkconfig"
framework_reinstall = True
if flag_custom_sdkconfig == True and matching_sdkconfig == False:
# check if current custom sdkconfig is different from existing
framework_reinstall = True
return framework_reinstall

def call_compile_libs():
if mcu == "esp32c2":
ARDUINO_FRMWRK_C2_LIB_DIR = join(platform.get_package_dir("framework-arduinoespressif32-libs"),mcu)
ARDUINO_C2_DIR = join(platform.get_package_dir("framework-arduino-c2-skeleton-lib"),mcu)
shutil.copytree(ARDUINO_C2_DIR, ARDUINO_FRMWRK_C2_LIB_DIR, dirs_exist_ok=True)
print("*** Compile Arduino IDF libs for %s ***" % env["PIOENV"])
SConscript("espidf.py")

if check_reinstall_frwrk() == True:
print("*** Reinstall Arduino framework libs ***")
shutil.rmtree(platform.get_package_dir("framework-arduinoespressif32-libs"))
ARDUINO_FRMWRK_LIB_URL = str(platform.get_package_spec("framework-arduinoespressif32-libs")).split("uri=",1)[1][:-1]
pm.install(ARDUINO_FRMWRK_LIB_URL)
if flag_custom_sdkconfig == True:
call_compile_libs()
flag_custom_sdkconfig = False

if flag_custom_sdkconfig == True and flag_any_custom_sdkconfig == False:
call_compile_libs()

if "arduino" in env.subst("$PIOFRAMEWORK") and "espidf" not in env.subst("$PIOFRAMEWORK") and env.subst("$ARDUINO_LIB_COMPILE_FLAG") in ("Inactive", "True"):
if os.path.exists(join(platform.get_package_dir(
"framework-arduinoespressif32"), "tools", "platformio-build.py")):
PIO_BUILD = "platformio-build.py"
else:
PIO_BUILD = "pioarduino-build.py"
SConscript(
join(DefaultEnvironment().PioPlatform().get_package_dir(
"framework-arduinoespressif32"), "tools", PIO_BUILD))
SConscript(join(platform.get_package_dir("framework-arduinoespressif32"), "tools", PIO_BUILD))
Loading