14
14
15
15
import fnmatch
16
16
import os
17
- import contextlib
18
17
import json
19
18
import requests
20
19
import socket
32
31
# Constants
33
32
RETRY_LIMIT = 3
34
33
SUBPROCESS_TIMEOUT = 300
35
- MKLITTLEFS_VERSION_320 = "3.2.0"
36
- MKLITTLEFS_VERSION_400 = "4.0.0"
37
34
DEFAULT_DEBUG_SPEED = "5000"
38
35
DEFAULT_APP_OFFSET = "0x10000"
39
36
ARDUINO_ESP32_PACKAGE_URL = "https://raw.githubusercontent.com/espressif/arduino-esp32/release/v3.3.x/package/package_esp32_index.template.json"
@@ -337,11 +334,11 @@ def _handle_existing_tool(
337
334
338
335
# Then remove the main tool directory (if it still exists)
339
336
safe_remove_directory (paths ['tool_path' ])
340
-
337
+
341
338
return self .install_tool (tool_name , retry_count + 1 )
342
339
343
340
def _configure_arduino_framework (self , frameworks : List [str ]) -> None :
344
- """Configure Arduino framework with dynamic library URL fetching. """
341
+ """Configure Arduino framework"""
345
342
if "arduino" not in frameworks :
346
343
return
347
344
@@ -442,6 +439,7 @@ def _install_common_idf_packages(self) -> None:
442
439
def _configure_check_tools (self , variables : Dict ) -> None :
443
440
"""Configure static analysis and check tools based on configuration."""
444
441
check_tools = variables .get ("check_tool" , [])
442
+ self .install_tool ("contrib-piohome" )
445
443
if not check_tools :
446
444
return
447
445
@@ -457,37 +455,38 @@ def _ensure_mklittlefs_version(self) -> None:
457
455
try :
458
456
with open (piopm_path , 'r' , encoding = 'utf-8' ) as f :
459
457
package_data = json .load (f )
460
- if package_data .get ('version' ) != MKLITTLEFS_VERSION_320 :
458
+ version = package_data .get ('version' , '' )
459
+ if not version .startswith ("3." ):
461
460
os .remove (piopm_path )
462
- logger .info ("Outdated mklittlefs version removed" )
461
+ logger .info (f"Incompatible mklittlefs version { version } removed (required: 3.x) " )
463
462
except (json .JSONDecodeError , KeyError ) as e :
464
463
logger .error (f"Error reading mklittlefs package data: { e } " )
465
464
466
465
def _setup_mklittlefs_for_download (self ) -> None :
467
- """Setup mklittlefs for download functionality with version 4.0.0 ."""
466
+ """Setup mklittlefs for download functionality with version 4.x ."""
468
467
mklittlefs_dir = os .path .join (self .packages_dir , "tool-mklittlefs" )
469
- mklittlefs400_dir = os .path .join (
470
- self .packages_dir , "tool-mklittlefs-4.0.0 "
468
+ mklittlefs4_dir = os .path .join (
469
+ self .packages_dir , "tool-mklittlefs4 "
471
470
)
472
471
473
- # Ensure mklittlefs 3.2.0 is installed
472
+ # Ensure mklittlefs 3.x is installed
474
473
if not os .path .exists (mklittlefs_dir ):
475
474
self .install_tool ("tool-mklittlefs" )
476
475
if os .path .exists (os .path .join (mklittlefs_dir , "tools.json" )):
477
476
self .install_tool ("tool-mklittlefs" )
478
477
479
- # Install mklittlefs 4.0.0
480
- if not os .path .exists (mklittlefs400_dir ):
481
- self .install_tool ("tool-mklittlefs-4.0.0 " )
482
- if os .path .exists (os .path .join (mklittlefs400_dir , "tools.json" )):
483
- self .install_tool ("tool-mklittlefs-4.0.0 " )
478
+ # Install mklittlefs 4.x
479
+ if not os .path .exists (mklittlefs4_dir ):
480
+ self .install_tool ("tool-mklittlefs4 " )
481
+ if os .path .exists (os .path .join (mklittlefs4_dir , "tools.json" )):
482
+ self .install_tool ("tool-mklittlefs4 " )
484
483
485
- # Copy mklittlefs 4.0.0 over 3.2.0
486
- if os .path .exists (mklittlefs400_dir ):
484
+ # Copy mklittlefs 4.x over 3.x
485
+ if os .path .exists (mklittlefs4_dir ):
487
486
package_src = os .path .join (mklittlefs_dir , "package.json" )
488
- package_dst = os .path .join (mklittlefs400_dir , "package.json" )
487
+ package_dst = os .path .join (mklittlefs4_dir , "package.json" )
489
488
safe_copy_file (package_src , package_dst )
490
- shutil .copytree (mklittlefs400_dir , mklittlefs_dir , dirs_exist_ok = True )
489
+ shutil .copytree (mklittlefs4_dir , mklittlefs_dir , dirs_exist_ok = True )
491
490
self .packages .pop ("tool-mkfatfs" , None )
492
491
493
492
def _handle_littlefs_tool (self , for_download : bool ) -> None :
@@ -542,6 +541,7 @@ def configure_default_packages(self, variables: Dict, targets: List[str]) -> Any
542
541
self ._configure_arduino_framework (frameworks )
543
542
self ._configure_espidf_framework (frameworks , variables , board_config , mcu )
544
543
self ._configure_mcu_toolchains (mcu , variables , targets )
544
+ self ._handle_littlefs_tool (for_download = False ) # Ensure mklittlefs is installed
545
545
546
546
if "espidf" in frameworks :
547
547
self ._install_common_idf_packages ()
0 commit comments