1818import json
1919import re
2020import requests
21+ from os .path import isfile , join
2122
2223from platformio .public import PlatformBase , to_unix_path
24+ from platformio .project .config import ProjectConfig
2325
2426
2527IS_WINDOWS = sys .platform .startswith ("win" )
@@ -45,22 +47,24 @@ def configure_default_packages(self, variables, targets):
4547 if "arduino" in frameworks :
4648 self .packages ["framework-arduinoespressif32" ]["optional" ] = False
4749 self .packages ["framework-arduinoespressif32-libs" ]["optional" ] = False
48- try :
49- # use latest stable release Arduino core
50- ARDUINO_CORE_API_URL = "https://api.github.com/repos/espressif/Arduino-esp32/releases/latest"
51- api_data = requests .get (ARDUINO_CORE_API_URL , timeout = 2 ).json ()
52- zipball = api_data .get ("zipball_url" )
53- tag = api_data .get ("tag_name" )
54- if tag is not None :
55- # print("Latest release Arduino core URL:", zipball)
56- self .packages ["framework-arduinoespressif32" ]["version" ] = zipball
57- # use corresponding espressif Arduino libs to release
58- URL = "https://raw.githubusercontent.com/espressif/arduino-esp32/" + tag + "/package/package_esp32_index.template.json"
59- packjdata = requests .get (URL , timeout = 10 ).json ()
60- dyn_lib_url = packjdata ['packages' ][0 ]['tools' ][0 ]['systems' ][0 ]['url' ]
61- self .packages ["framework-arduinoespressif32-libs" ]["version" ] = dyn_lib_url
62- except :
63- pass
50+ ARDUINO_FRAMEWORK_DIR = os .path .join (ProjectConfig .get_instance ().get ("platformio" , "packages_dir" ), "framework-arduinoespressif32" )
51+ if not bool (os .path .exists (ARDUINO_FRAMEWORK_DIR )):
52+ try :
53+ # use latest stable release Arduino core
54+ ARDUINO_CORE_API_URL = "https://api.github.com/repos/espressif/Arduino-esp32/releases/latest"
55+ api_data = requests .get (ARDUINO_CORE_API_URL , timeout = 2 ).json ()
56+ zipball = api_data .get ("zipball_url" )
57+ tag = api_data .get ("tag_name" )
58+ if tag is not None :
59+ # print("Latest release Arduino core URL:", zipball)
60+ self .packages ["framework-arduinoespressif32" ]["version" ] = zipball
61+ # use corresponding espressif Arduino libs to release
62+ URL = "https://raw.githubusercontent.com/espressif/arduino-esp32/" + tag + "/package/package_esp32_index.template.json"
63+ packjdata = requests .get (URL , timeout = 10 ).json ()
64+ dyn_lib_url = packjdata ['packages' ][0 ]['tools' ][0 ]['systems' ][0 ]['url' ]
65+ self .packages ["framework-arduinoespressif32-libs" ]["version" ] = dyn_lib_url
66+ except :
67+ pass
6468
6569 if "buildfs" in targets :
6670 filesystem = variables .get ("board_build.filesystem" , "littlefs" )
@@ -132,10 +136,10 @@ def configure_default_packages(self, variables, targets):
132136 # and RISC-V targets.
133137 for gdb_package in ("tool-xtensa-esp-elf-gdb" , "tool-riscv32-esp-elf-gdb" ):
134138 self .packages [gdb_package ]["optional" ] = False
135- if IS_WINDOWS :
139+ # if IS_WINDOWS:
136140 # Note: On Windows GDB v12 is not able to
137141 # launch a GDB server in pipe mode while v11 works fine
138- self .packages [gdb_package ]["version" ] = "~11.2.0"
142+ # self.packages[gdb_package]["version"] = "~11.2.0"
139143
140144 # Common packages for IDF and mixed Arduino+IDF projects
141145 if "espidf" in frameworks :
0 commit comments