Skip to content

Commit e1356e9

Browse files
authored
Fix last hickup at first compile run after install
1 parent eca879b commit e1356e9

File tree

5 files changed

+60
-107
lines changed

5 files changed

+60
-107
lines changed

builder/frameworks/espidf.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
IDF_ENV_VERSION = "1.0.0"
7070
FRAMEWORK_DIR = platform.get_package_dir("framework-espidf")
7171
TOOLCHAIN_DIR = platform.get_package_dir(
72-
"tc-%s" % ("rv32" if mcu in ("esp32c2", "esp32c3", "esp32c6", "esp32h2") else ("xt-%s" % mcu))
72+
"toolchain-%s" % ("riscv32-esp" if mcu in ("esp32c2", "esp32c3", "esp32c6", "esp32h2") else ("xtensa-%s" % mcu))
7373
)
7474

7575

@@ -252,7 +252,7 @@ def populate_idf_env_vars(idf_env):
252252

253253
if mcu not in ("esp32c2", "esp32c3", "esp32c6", "esp32h2", "esp32p4"):
254254
additional_packages.append(
255-
os.path.join(platform.get_package_dir("tc-ulp"), "bin"),
255+
os.path.join(platform.get_package_dir("toolchain-esp32ulp"), "bin"),
256256
)
257257

258258
idf_env["PATH"] = os.pathsep.join(additional_packages + [idf_env["PATH"]])
@@ -1292,17 +1292,6 @@ def _get_installed_pip_packages(python_exe_path):
12921292
)
12931293
)
12941294

1295-
# # A special "esp-windows-curses" python package is required on Windows
1296-
# # for Menuconfig on IDF <5
1297-
# if not IDF5 and "esp-windows-curses" not in installed_packages:
1298-
# env.Execute(
1299-
# env.VerboseAction(
1300-
# '"%s" -m pip install "file://%s/tools/kconfig_new/esp-windows-curses"'
1301-
# % (python_exe_path, FRAMEWORK_DIR),
1302-
# "Installing windows-curses package",
1303-
# )
1304-
# )
1305-
13061295

13071296
def get_idf_venv_dir():
13081297
# The name of the IDF venv contains the IDF version to avoid possible conflicts and

builder/frameworks/ulp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ def prepare_ulp_env_vars(env):
3636
ulp_env.PrependENVPath("IDF_PATH", FRAMEWORK_DIR)
3737

3838
toolchain_path = platform.get_package_dir(
39-
"tc-xt-%s" % idf_variant
39+
"toolchain-xtensa-%s" % idf_variant
4040
)
4141

4242
additional_packages = [
4343
toolchain_path,
4444
os.path.join(
45-
platform.get_package_dir("tc-ulp"),
45+
platform.get_package_dir("toolchain-esp32ulp"),
4646
"bin",
4747
),
4848
platform.get_package_dir("tool-ninja"),

builder/main.py

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -14,48 +14,23 @@
1414

1515
import re
1616
import sys
17-
import shutil
18-
import subprocess
19-
import os
20-
from os.path import isfile, isdir, join
17+
from os.path import isfile, join
2118

2219
from SCons.Script import (
2320
ARGUMENTS, COMMAND_LINE_TARGETS, AlwaysBuild, Builder, Default,
2421
DefaultEnvironment)
2522

2623
from platformio.util import get_serial_ports
27-
from platformio.proc import exec_command, where_is_program
2824

29-
pio_exe = where_is_program("platformio")
3025
env = DefaultEnvironment()
3126
platform = env.PioPlatform()
32-
board = env.BoardConfig()
33-
mcu = board.get("build.mcu", "esp32")
3427

3528
#
3629
# Helpers
3730
#
3831

39-
PLATFORM_PATH = env.GetProjectOption("platform")
40-
PLATFORM_CMD = (
41-
pio_exe,
42-
"pkg",
43-
"install",
44-
"--global",
45-
"--platform",
46-
PLATFORM_PATH,
47-
)
48-
49-
# install platform again to install missing packages, needed since no registry install
50-
if bool(platform.get_package_dir("tc-%s" % ("rv32" if mcu in ("esp32c2", "esp32c3", "esp32c6", "esp32h2") else ("xt-%s" % mcu)))) == False:
51-
result = exec_command(PLATFORM_CMD)
52-
if result["returncode"] != 0:
53-
sys.stderr.write(result["err"] + "\n")
54-
env.Exit(1)
55-
5632
FRAMEWORK_DIR = platform.get_package_dir("framework-arduinoespressif32")
5733

58-
5934
def BeforeUpload(target, source, env):
6035
upload_options = {}
6136
if "BOARD" in env:
@@ -277,15 +252,15 @@ def __fetch_fs_size(target, source, env):
277252
CXX="%s-elf-g++" % toolchain_arch,
278253
GDB=join(
279254
platform.get_package_dir(
280-
"tl-rv-gdb"
255+
"riscv32-esp-elf-gdb"
281256
if mcu in ("esp32c2", "esp32c3", "esp32c6")
282-
else "tl-xt-gdb"
257+
else "xtensa-esp-elf-gdb"
283258
)
284259
or "",
285260
"bin",
286261
"%s-elf-gdb" % toolchain_arch,
287262
),
288-
OBJCOPY=join(platform.get_package_dir("tool-esptool") or "", "esptool.py"),
263+
OBJCOPY=join(platform.get_package_dir("tool-esptoolpy") or "", "esptool.py"),
289264
RANLIB="%s-elf-gcc-ranlib" % toolchain_arch,
290265
SIZETOOL="%s-elf-size" % toolchain_arch,
291266

@@ -460,7 +435,7 @@ def __fetch_fs_size(target, source, env):
460435
elif upload_protocol == "esptool":
461436
env.Replace(
462437
UPLOADER=join(
463-
platform.get_package_dir("tool-esptool") or "", "esptool.py"),
438+
platform.get_package_dir("tool-esptoolpy") or "", "esptool.py"),
464439
UPLOADERFLAGS=[
465440
"--chip", mcu,
466441
"--port", '"$UPLOAD_PORT"',
@@ -553,7 +528,7 @@ def __fetch_fs_size(target, source, env):
553528
f.replace(
554529
"$PACKAGE_DIR",
555530
_to_unix_slashes(
556-
platform.get_package_dir("tl-openocd") or ""))
531+
platform.get_package_dir("tool-openocd") or ""))
557532
for f in openocd_args
558533
]
559534
env.Replace(

platform.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,49 +47,49 @@
4747
"owner": "pioarduino",
4848
"version": "https://github.com/pioarduino/esp-idf/releases/download/v5.1.4.240805/esp-idf-v5.1.4.zip"
4949
},
50-
"tc-xt-esp32": {
50+
"toolchain-xtensa-esp32": {
5151
"type": "toolchain",
5252
"optional": true,
5353
"owner": "",
5454
"version": ""
5555
},
56-
"tc-xt-esp32s2": {
56+
"toolchain-xtensa-esp32s2": {
5757
"type": "toolchain",
5858
"optional": true,
5959
"owner": "",
6060
"version": ""
6161
},
62-
"tc-xt-esp32s3": {
62+
"toolchain-xtensa-esp32s3": {
6363
"type": "toolchain",
6464
"optional": true,
6565
"owner": "",
6666
"version": ""
6767
},
68-
"tc-rv32": {
68+
"toolchain-riscv32-esp": {
6969
"type": "toolchain",
7070
"optional": true,
7171
"owner": "",
7272
"version": ""
7373
},
74-
"tc-ulp": {
74+
"toolchain-esp32ulp": {
7575
"type": "toolchain",
7676
"optional": true,
7777
"owner": "",
7878
"version": ""
7979
},
80-
"tl-xt-gdb": {
80+
"xtensa-esp-elf-gdb": {
8181
"type": "debugger",
8282
"optional": true,
8383
"owner": "",
8484
"version": ""
8585
},
86-
"tl-rv-gdb": {
86+
"riscv32-esp-elf-gdb": {
8787
"type": "debugger",
8888
"optional": true,
8989
"owner": "",
9090
"version": ""
9191
},
92-
"tool-esptool": {
92+
"tool-esptoolpy": {
9393
"type": "uploader",
9494
"optional": false,
9595
"owner": "pioarduino",
@@ -158,12 +158,12 @@
158158
"contrib-piohome": {
159159
"optional": true,
160160
"owner": "",
161-
"version": "https://github.com/pioarduino/registry/releases/download/0.0.1/contrib-piohome-3.4.4.tar.gz"
161+
"version": ""
162162
},
163163
"contrib-pioremote": {
164164
"optional": true,
165165
"owner": "",
166-
"version": "https://github.com/pioarduino/registry/releases/download/0.0.1/contrib-pioremote-1.0.1.tar.gz"
166+
"version": ""
167167
}
168168
}
169169
}

platform.py

Lines changed: 40 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,30 @@
2121
from platformio.public import PlatformBase, to_unix_path
2222
from platformio.proc import get_pythonexe_path
2323
from platformio.project.config import ProjectConfig
24+
from platformio.package.manager.tool import ToolPackageManager
2425

2526
python_exe = get_pythonexe_path()
27+
pm = ToolPackageManager()
2628

2729
IDF_TOOLS_PATH_DEFAULT = os.path.join(os.path.expanduser("~"), ".espressif")
2830
IDF_TOOLS = os.path.join(ProjectConfig.get_instance().get("platformio", "packages_dir"), "tl-install", "tools", "idf_tools.py")
29-
IDF_TOOLS_FLAG = ["install"]
30-
IDF_TOOLS_CMD = [python_exe, IDF_TOOLS] + IDF_TOOLS_FLAG
31+
IDF_TOOLS_CMD = (
32+
python_exe,
33+
IDF_TOOLS,
34+
"install",
35+
)
36+
37+
# IDF Install is needed only one time
38+
tl_flag = bool(os.path.exists(IDF_TOOLS))
39+
if (tl_flag and not bool(os.path.exists(join(IDF_TOOLS_PATH_DEFAULT, "tools")))):
40+
rc = subprocess.call(IDF_TOOLS_CMD)
41+
if rc != 0:
42+
sys.stderr.write("Error: Couldn't execute 'idf_tools.py install'\n")
43+
else:
44+
shutil.copytree(join(IDF_TOOLS_PATH_DEFAULT, "tools", "tool-packages"), join(IDF_TOOLS_PATH_DEFAULT, "tools"), symlinks=False, ignore=None, ignore_dangling_symlinks=False, dirs_exist_ok=True)
45+
for p in ("tool-mklittlefs", "tool-mkfatfs", "tool-mkspiffs", "tool-dfuutil", "tool-openocd", "tool-cmake", "tool-ninja", "tool-cppcheck", "tool-clangtidy", "tool-pvs-studio", "tc-xt-esp32", "tc-xt-esp32s2", "tc-xt-esp32s3", "tc-ulp", "tc-rv32", "tl-xt-gdb", "tl-rv-gdb", "contrib-piohome", "contrib-pioremote"):
46+
tl_path = "file://" + join(IDF_TOOLS_PATH_DEFAULT, "tools", p)
47+
pm.install(tl_path)
3148

3249
class Espressif32Platform(PlatformBase):
3350
def configure_default_packages(self, variables, targets):
@@ -37,48 +54,16 @@ def configure_default_packages(self, variables, targets):
3754
board_config = self.board_config(variables.get("board"))
3855
mcu = variables.get("board_build.mcu", board_config.get("build.mcu", "esp32"))
3956
frameworks = variables.get("pioframework", [])
40-
tl_flag = bool(os.path.exists(IDF_TOOLS))
41-
42-
# IDF Install is needed only one time
43-
if not os.path.exists(join(IDF_TOOLS_PATH_DEFAULT, "tools")) and tl_flag:
44-
rc = subprocess.call(IDF_TOOLS_CMD)
45-
if rc != 0:
46-
sys.stderr.write("Error: Couldn't execute 'idf_tools.py install'\n")
47-
else:
48-
shutil.copytree(join(IDF_TOOLS_PATH_DEFAULT, "tools", "tool-packages"), join(IDF_TOOLS_PATH_DEFAULT, "tools"), symlinks=False, ignore=None, ignore_dangling_symlinks=False, dirs_exist_ok=True)
49-
50-
if tl_flag:
51-
# install tool is not needed anymore
52-
self.packages["tl-install"]["optional"] = True
53-
# Install all tools and toolchains
54-
for p in self.packages:
55-
if p in ("tool-mklittlefs", "tool-mkfatfs", "tool-mkspiffs", "tool-dfuutil", "tool-openocd", "tool-cmake", "tool-ninja", "tool-cppcheck", "tool-clangtidy", "tool-pvs-studio", "contrib-piohome", "contrib-pioremote", "tc-ulp", "tc-rv32", "tl-xt-gdb", "tl-rv-gdb"):
56-
tl_path = "file://" + join(IDF_TOOLS_PATH_DEFAULT, "tools", p)
57-
self.packages[p]["optional"] = False
58-
self.packages[p]["version"] = tl_path
59-
# Enable common packages for IDF and mixed Arduino+IDF projects
60-
for p in self.packages:
61-
if p in ("tool-cmake", "tool-ninja", "tc-ulp"):
62-
self.packages[p]["optional"] = False if "espidf" in frameworks else True
63-
# Enabling of following tools is not needed, installing is enough
64-
for p in self.packages:
65-
if p in ("contrib-pioremote", "contrib-piohome"):
66-
try:
67-
pkg_dir = pm.get_package(p).path
68-
# When package is not found an execption happens -> install is forced
69-
# else the are removed from current env
70-
self.packages[p]["optional"] = True
71-
except:
72-
pass
73-
7457

7558
# Enable debug tool gdb only when build debug is enabled
76-
if variables.get("build_type") or "debug" in "".join(targets):
77-
self.packages["tl-rv-gdb"]["optional"] = False if mcu in ["esp32c2", "esp32c3", "esp32c6", "esp32h2"] else True
78-
self.packages["tl-xt-gdb"]["optional"] = False if not mcu in ["esp32c2", "esp32c3", "esp32c6", "esp32h2"] else True
59+
if (variables.get("build_type") or "debug" in "".join(targets)) and tl_flag:
60+
self.packages["riscv32-esp-elf-gdb"]["optional"] = False if mcu in ["esp32c2", "esp32c3", "esp32c6", "esp32h2"] else True
61+
self.packages["riscv32-esp-elf-gdb"]["version"] = "file://" + join(IDF_TOOLS_PATH_DEFAULT, "tools", "tl-rv-gdb")
62+
self.packages["xtensa-esp-elf-gdb"]["optional"] = False if not mcu in ["esp32c2", "esp32c3", "esp32c6", "esp32h2"] else True
63+
self.packages["xtensa-esp-elf-gdb"]["version"] = "file://" + join(IDF_TOOLS_PATH_DEFAULT, "tools", "tl-xt-gdb")
7964
else:
80-
self.packages["tl-rv-gdb"]["optional"] = True
81-
self.packages["tl-xt-gdb"]["optional"] = True
65+
self.packages["riscv32-esp-elf-gdb"]["optional"] = True
66+
self.packages["xtensa-esp-elf-gdb"]["optional"] = True
8267

8368
# Enable check tools only when "check_tool" is enabled
8469
for p in self.packages:
@@ -93,17 +78,18 @@ def configure_default_packages(self, variables, targets):
9378
filesystem = variables.get("board_build.filesystem", "littlefs")
9479
if filesystem == "littlefs":
9580
# Use mklittlefs v3.2.0 to generate FS
96-
tl_path = "file://" + join(IDF_TOOLS_PATH_DEFAULT, "tools", "tool-mklittlefs")
9781
self.packages["tool-mklittlefs"]["optional"] = False
98-
self.packages["tool-mklittlefs"]["version"] = tl_path
82+
self.packages["tool-mklittlefs"]["version"] = "file://" + join(IDF_TOOLS_PATH_DEFAULT, "tools", "tool-mklittlefs")
9983
del self.packages["tool-mkfatfs"]
10084
del self.packages["tool-mkspiffs"]
10185
elif filesystem == "fatfs":
10286
self.packages["tool-mkfatfs"]["optional"] = False
87+
self.packages["tool-mkfatfs"]["version"] = "file://" + join(IDF_TOOLS_PATH_DEFAULT, "tools", "tool-mkfatfs")
10388
del self.packages["tool-mklittlefs"]
10489
del self.packages["tool-mkspiffs"]
10590
elif filesystem == "spiffs":
10691
self.packages["tool-mkspiffs"]["optional"] = False
92+
self.packages["tool-mkspiffs"]["version"] = "file://" + join(IDF_TOOLS_PATH_DEFAULT, "tools", "tool-mkspiffs")
10793
del self.packages["tool-mkfatfs"]
10894
del self.packages["tool-mklittlefs"]
10995
else:
@@ -113,38 +99,41 @@ def configure_default_packages(self, variables, targets):
11399

114100
if variables.get("upload_protocol"):
115101
self.packages["tool-openocd"]["optional"] = False
102+
self.packages["tool-openocd"]["version"] = "file://" + join(IDF_TOOLS_PATH_DEFAULT, "tools", "tool-openocd")
116103
else:
117104
del self.packages["tool-openocd"]
118105

119106
if "downloadfs" in targets:
120107
filesystem = variables.get("board_build.filesystem", "littlefs")
121108
if filesystem == "littlefs":
122109
# Use mklittlefs v4.0.0 to unpack, older version is incompatible
123-
tl_path = "file://" + join(IDF_TOOLS_PATH_DEFAULT, "tools", "tool-mklittlefs400")
124110
self.packages["tool-mklittlefs"]["optional"] = False
125-
self.packages["tool-mklittlefs"]["version"] = tl_path
111+
self.packages["tool-mklittlefs"]["version"] = "file://" + join(IDF_TOOLS_PATH_DEFAULT, "tools", "tool-mklittlefs400")
126112

127113
# Currently only Arduino Nano ESP32 uses the dfuutil tool as uploader
128114
if variables.get("board") == "arduino_nano_esp32":
129115
self.packages["tool-dfuutil"]["optional"] = False
116+
self.packages["tool-dfuutil"]["version"] = "file://" + join(IDF_TOOLS_PATH_DEFAULT, "tools", "tool-dfuutil")
130117
else:
131118
del self.packages["tool-dfuutil"]
132119

133120
# Enable needed toolchains
134121
for available_mcu in ("esp32", "esp32s2", "esp32s3"):
135122
if available_mcu == mcu and tl_flag:
136123
tc_path = "file://" + join(IDF_TOOLS_PATH_DEFAULT, "tools", "tc-xt-%s" % mcu)
137-
self.packages["tc-xt-%s" % mcu]["optional"] = False
138-
self.packages["tc-xt-%s" % mcu]["version"] = tc_path
124+
self.packages["toolchain-xtensa-%s" % mcu]["optional"] = False
125+
self.packages["toolchain-xtensa-%s" % mcu]["version"] = tc_path
139126
if available_mcu == "esp32":
140-
del self.packages["tc-rv32"]
141-
# Enable ULP toolchains
127+
del self.packages["toolchain-riscv32-esp"]
128+
# Enable riscv and ULP toolchains
142129
if mcu in ("esp32s2", "esp32s3", "esp32c2", "esp32c3", "esp32c6", "esp32h2"):
143130
if mcu in ("esp32c2", "esp32c3", "esp32c6", "esp32h2"):
144-
del self.packages["tc-ulp"]
131+
del self.packages["toolchain-esp32ulp"]
145132
# RISC-V based toolchain for ESP32C3, ESP32C6 ESP32S2, ESP32S3 ULP
146133
if tl_flag:
147-
self.packages["tc-rv32"]["optional"] = False
134+
tc_path = "file://" + join(IDF_TOOLS_PATH_DEFAULT, "tools", "tc-rv32")
135+
self.packages["toolchain-riscv32-esp"]["optional"] = False
136+
self.packages["toolchain-riscv32-esp"]["version"] = tc_path
148137

149138
return super().configure_default_packages(variables, targets)
150139

0 commit comments

Comments
 (0)