sima-cli 0.0.36__py3-none-any.whl → 0.0.38__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -65,7 +65,7 @@ def _resolve_firmware_url(version_or_url: str, board: str, internal: bool = Fals
65
65
  image_file = 'release.tar.gz' if flavor == 'headless' else 'graphics.tar.gz'
66
66
  download_url = url.rstrip("/") + f"/soc-images/{board}/{version_or_url}/artifacts/{image_file}"
67
67
  elif swtype == 'elxr':
68
- image_file = 'elxr-palette-modalix-1.7.0-arm64.img.gz' # temporary, this should change.
68
+ image_file = f'{board}-tftp-boot.tar.gz'
69
69
  download_url = url.rstrip("/") + f"/soc-images/elxr/{board}/{version_or_url}/artifacts/palette/{image_file}"
70
70
 
71
71
  return download_url
@@ -203,6 +203,8 @@ def _extract_required_files(tar_path: str, board: str, update_type: str = 'stand
203
203
  f"{board}-som.dtb",
204
204
  f"{board}-dvt.dtb",
205
205
  f"{board}-hhhl_x16.dtb",
206
+ f"pcie-4rc-2rc-2rc.dtbo",
207
+ f"elxr-palette-{board}-arm64.cpio.gz",
206
208
  f"simaai-image-{_flavor}-{board}.wic.gz",
207
209
  f"simaai-image-{_flavor}-{board}.wic.bmap",
208
210
  f"simaai-image-{_flavor}-{board}.cpio.gz"
@@ -321,9 +323,26 @@ def _download_image(version_or_url: str, board: str, internal: bool = False, upd
321
323
  # Download the file
322
324
  click.echo(f"📦 Downloading from {image_url}")
323
325
  firmware_path = download_file_from_url(image_url, dest_path, internal=internal)
326
+ extracted_files = _extract_required_files(firmware_path, board, update_type, flavor)
327
+
328
+ # If internal, netboot and elxr, we need to download some additional files to prepare for eMMC flash.
329
+ if internal and update_type == "netboot" and swtype == "elxr":
330
+ base_url = os.path.dirname(image_url)
331
+ base_version = version_or_url.split('_')[0]
332
+ extra_files = [f"elxr-palette-{board}-{base_version}-arm64.img.gz"]
333
+
334
+ for fname in extra_files:
335
+ extra_url = f"{base_url}/{fname}"
336
+ try:
337
+ click.echo(f"📥 Downloading extra file: {fname} from {extra_url} saving into {dest_path}")
338
+ netboot_file_path = download_file_from_url(extra_url, dest_path, internal=internal)
339
+ extracted_files.extend(_extract_required_files(netboot_file_path, board, update_type, flavor))
340
+ click.echo(f"✅ Saved {fname} to {dest_path}")
341
+ except Exception as e:
342
+ click.echo(f"⚠️ Failed to download {fname}: {e}")
324
343
 
325
344
  click.echo(f"📦 Firmware downloaded to: {firmware_path}")
326
- return _extract_required_files(firmware_path, board, update_type, flavor)
345
+ return extracted_files
327
346
 
328
347
  except Exception as e:
329
348
  click.echo(f"❌ Host update failed: {e}")
@@ -471,7 +490,7 @@ def download_image(version_or_url: str, board: str, swtype: str, internal: bool
471
490
  Args:
472
491
  version_or_url (str): Either a version string (e.g., "1.6.0") or a direct URL or local file path to the image.
473
492
  board (str): The board type (e.g., "mlsoc", "modalix").
474
- swtype (str): The software type (default to 'davinci', possible values: `davinci`, `modalix`): not supported for now
493
+ swtype (str): The software type (default to 'yocto', possible values: `yocto`, `elxr`): not supported for now
475
494
  internal (bool): Whether to use internal download paths (e.g., Artifactory).
476
495
  update_type (str): Whether this is standard update or writing boot image.
477
496
  flavor (str): Flavor of the image, can be headless or full.
sima_cli/utils/env.py CHANGED
@@ -2,7 +2,8 @@ import os
2
2
  import subprocess
3
3
  import platform
4
4
  import shutil
5
- from typing import Tuple
5
+ import re
6
+ from typing import Tuple, Optional
6
7
 
7
8
  # Utility functions to determine the environment:
8
9
  # - Whether we are running on a SiMa board
@@ -33,6 +34,38 @@ def is_sima_board() -> bool:
33
34
 
34
35
  return False
35
36
 
37
+ def get_sima_build_version() -> Tuple[Optional[str], Optional[str]]:
38
+ """
39
+ Retrieve the current SiMa build version from /etc/build or /etc/buildinfo.
40
+
41
+ It searches for 'SIMA_BUILD_VERSION=' and extracts:
42
+ - core_version: the semantic version (e.g., '2.0.0')
43
+ - full_version: the complete build string (e.g., '2.0.0_develop_B1932')
44
+
45
+ Returns:
46
+ tuple: (core_version, full_version)
47
+ If not found, returns (None, None)
48
+ """
49
+ build_file_paths = ["/etc/build", "/etc/buildinfo"]
50
+ version_pattern = re.compile(r"SIMA_BUILD_VERSION\s*=\s*([\w\.\-\+]+)")
51
+
52
+ for path in build_file_paths:
53
+ if os.path.exists(path):
54
+ try:
55
+ with open(path, "r") as f:
56
+ for line in f:
57
+ match = version_pattern.search(line)
58
+ if match:
59
+ full_version = match.group(1)
60
+ # Extract only major.minor.patch portion
61
+ core_match = re.match(r"(\d+\.\d+\.\d+)", full_version)
62
+ core_version = core_match.group(1) if core_match else None
63
+ return core_version, full_version
64
+ except Exception:
65
+ continue
66
+
67
+ return None, None
68
+
36
69
  def is_pcie_host() -> bool:
37
70
  """
38
71
  Detect if running from a PCIe host (typically a Linux or macOS dev machine).
@@ -71,6 +104,31 @@ def get_sima_board_type() -> str:
71
104
 
72
105
  return ""
73
106
 
107
+ def is_devkit_running_elxr() -> bool:
108
+ """
109
+ Check if the system is a SiMa devkit and is running ELXR software.
110
+
111
+ Conditions:
112
+ - Must be identified as a SiMa board via is_sima_board()
113
+ - /etc/buildinfo exists and contains "elxr" (case-insensitive)
114
+
115
+ Returns:
116
+ bool: True if SiMa devkit with ELXR software, False otherwise.
117
+ """
118
+ if not is_sima_board():
119
+ return False
120
+
121
+ buildinfo_path = "/etc/buildinfo"
122
+ if not os.path.exists(buildinfo_path):
123
+ return False
124
+
125
+ try:
126
+ with open(buildinfo_path, "r") as f:
127
+ content = f.read().lower()
128
+ return "elxr" in content
129
+ except Exception:
130
+ return False
131
+
74
132
  def is_modalix_devkit() -> bool:
75
133
  """
76
134
  Determines whether the current system is a Modalix DevKit (SoM)
@@ -41,16 +41,19 @@ def update_package(package_name: str):
41
41
  def has_internet(timeout: float = 1.0) -> bool:
42
42
  """
43
43
  Quick check for internet connectivity by connecting to a known DNS server.
44
+ First tries Cloudflare (1.1.1.1), falls back to Google (8.8.8.8).
44
45
  Uses IP to avoid DNS lookup delays.
45
46
  """
46
- try:
47
- socket.setdefaulttimeout(timeout)
48
- sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
49
- sock.connect(("1.1.1.1", 53))
50
- sock.close()
51
- return True
52
- except OSError:
53
- return False
47
+ def try_connect(ip: str, port: int = 53) -> bool:
48
+ try:
49
+ with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
50
+ sock.settimeout(timeout)
51
+ sock.connect((ip, port))
52
+ return True
53
+ except OSError:
54
+ return False
55
+
56
+ return try_connect("1.1.1.1") or try_connect("8.8.8.8")
54
57
 
55
58
  def check_for_update(package_name: str, timeout: float = 2.0):
56
59
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sima-cli
3
- Version: 0.0.36
3
+ Version: 0.0.38
4
4
  Summary: CLI tool for SiMa Developer Portal to download models, firmware, and apps.
5
5
  Home-page: https://developer.sima.ai/
6
6
  Author: SiMa.ai
@@ -1,9 +1,9 @@
1
1
  sima_cli/__init__.py,sha256=Nb2jSg9-CX1XvSc1c21U9qQ3atINxphuNkNfmR-9P3o,332
2
2
  sima_cli/__main__.py,sha256=ehzD6AZ7zGytC2gLSvaJatxeD0jJdaEvNJvwYeGsWOg,69
3
- sima_cli/__version__.py,sha256=Bbhf5gpY7WnVH4M-cc4ByQEC0_SMh5CebOd37T5sqCA,49
4
- sima_cli/cli.py,sha256=qm8rtydcugVdd37Rd79weMdX78Y7SKWaUe4LGfX-1XY,17339
3
+ sima_cli/__version__.py,sha256=Vmt5txS5JnPSX3Xq_JSjKsimA5tK-R4xOPnyOu6NbeI,49
4
+ sima_cli/cli.py,sha256=jGufO70y0NGLsIfEhr1pQNdFoBdzMxTO1R7p386d4-8,19291
5
5
  sima_cli/app_zoo/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
- sima_cli/app_zoo/app.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ sima_cli/app_zoo/app.py,sha256=6u3iIqVZkuMK49kK0f3dVJCCf5-qC-xzLOS78-TkeN8,15738
7
7
  sima_cli/auth/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
8
  sima_cli/auth/basic_auth.py,sha256=UMEXCCnNQpjpp6RZxREs6iiKtYyaeqZBnTSR0wA8s6Q,8767
9
9
  sima_cli/auth/login.py,sha256=nE-dSHK_husXw1XJaEcOe3I1_bnwHkLgO_BqKuQODDM,3781
@@ -14,13 +14,13 @@ sima_cli/download/downloader.py,sha256=UQdrBWLQsPQygaoVaufOjbzWmRoNnk6pgLdnbnVi0
14
14
  sima_cli/install/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
15
  sima_cli/install/hostdriver.py,sha256=kAWDLebs60mbWIyTbUxmNrChcKW1uD5r7FtWNSUVUE4,5852
16
16
  sima_cli/install/metadata_info.py,sha256=wmMqwzGfXbuilkqaxRVrFOzOtTOiONkmPCyA2oDAQpA,2168
17
- sima_cli/install/metadata_installer.py,sha256=zIxs9nSX7EC1d6qxL2woZiMSQfFfIOzB2natyTvIPDI,27428
18
- sima_cli/install/metadata_validator.py,sha256=7954rp9vFRNnqmIMvCVTjq40kUIEbGXzfc8HmQmChe0,5221
17
+ sima_cli/install/metadata_installer.py,sha256=ZvR1bb8qie0e1v_UCpZOhtWPm83Bhi1oBQK69f8Ajhg,31462
18
+ sima_cli/install/metadata_validator.py,sha256=Xp51J68hMvpQeX-11kPLgz1YarQZ2m-95gGpfe3-D3Q,5644
19
19
  sima_cli/install/optiview.py,sha256=r4DYdQDTUbZVCR87hl5T21gsjZrhqpU8hWnYxKmUJ_k,4790
20
20
  sima_cli/install/palette.py,sha256=uRznoHa4Mv9ZXHp6AoqknfC3RxpYNKi9Ins756Cyifk,3930
21
21
  sima_cli/mla/meminfo.py,sha256=ndc8kQJmWGEIdvNh6iIhATGdrkqM2pbddr_eHxaPNfg,1466
22
22
  sima_cli/model_zoo/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
23
- sima_cli/model_zoo/model.py,sha256=q91Nrg62j1TqwPO8HiX4nlEFCCmzNEFcyFTBVMbJm8w,9836
23
+ sima_cli/model_zoo/model.py,sha256=WjkVd5ZNadWkBRaOpiBBvgFmrZ2CcEtV56vj3h63eH8,11613
24
24
  sima_cli/network/network.py,sha256=kXYI2oxgeIg7LoGt2VKF9JlK8DIfQT87A9-x-D6uHCA,7714
25
25
  sima_cli/sdk/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
26
26
  sima_cli/sdk/syscheck.py,sha256=h9zCULW67y4i2hqiGc-hc1ucBDShA5FAe9NxwBGq-fM,4575
@@ -33,20 +33,20 @@ sima_cli/update/bmaptool.py,sha256=KrhUGShBwY4Wzz50QiuMYAxxPgEy1nz5C68G-0a4qF4,4
33
33
  sima_cli/update/bootimg.py,sha256=OA_GyZwI8dbU3kaucKmoxAZbnnSnjXeOkU6yuDPji1k,13632
34
34
  sima_cli/update/cleanlog.py,sha256=-V6eDl3MdsvDmCfkKUJTqkXJ_WnLJE01uxS7z96b15g,909
35
35
  sima_cli/update/local.py,sha256=z3oRk6JH-zbCdoS3JpgeW_ZB4kolG7nPhLC55A2yssk,5597
36
- sima_cli/update/netboot.py,sha256=hsJQLq4HVwFFkaWjA54VZdkMGDhO0RmylciS78qAfrM,19663
36
+ sima_cli/update/netboot.py,sha256=V0QiqyHzAdrucJ87Q3Xlm2EBvkpjpu4RwPRWw9NXRcs,20334
37
37
  sima_cli/update/query.py,sha256=6RgvQfQT1_EtBGcibvVcz003dRKOq17NaGgL2mhaBbY,4891
38
38
  sima_cli/update/remote.py,sha256=wC4MSBQVxmibxtPBchAzFMhZYcRjxTiLlPSzVI0en4o,14690
39
- sima_cli/update/updater.py,sha256=NPd32OzM_356Nm1bEDDNh7faubW_VSOk12J4I6Yc2SQ,24580
39
+ sima_cli/update/updater.py,sha256=CYOXTV-8zIo92Lv2vyBzKtUyrtFBwkJiknttlS-UxF4,25648
40
40
  sima_cli/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
41
41
  sima_cli/utils/artifactory.py,sha256=6YyVpzVm8ATy7NEwT9nkWx-wptkXrvG7Wl_zDT6jmLs,2390
42
42
  sima_cli/utils/config.py,sha256=wE-cPQqY_gOqaP8t01xsRHD9tBUGk9MgBUm2GYYxI3E,1616
43
43
  sima_cli/utils/config_loader.py,sha256=7I5we1yiCai18j9R9jvhfUzAmT3OjAqVK35XSLuUw8c,2005
44
44
  sima_cli/utils/disk.py,sha256=66Kr631yhc_ny19up2aijfycWfD35AeLQOJgUsuH2hY,446
45
- sima_cli/utils/env.py,sha256=LtV8S1kCkOpi-7Gj4rhidQRN13x_NDKy4W_LxujheeI,8400
45
+ sima_cli/utils/env.py,sha256=0qY1-PJiI1G3uDVv774aimPXhHQBtY56FqXSMeMQTps,10401
46
46
  sima_cli/utils/net.py,sha256=WVntA4CqipkNrrkA4tBVRadJft_pMcGYh4Re5xk3rqo,971
47
47
  sima_cli/utils/network.py,sha256=UvqxbqbWUczGFyO-t1SybG7Q-x9kjUVRNIn_D6APzy8,1252
48
- sima_cli/utils/pkg_update_check.py,sha256=IAV_NAOsBDL_lYNYMRYfdZWuVq-rJ_zzHjJJZ7UQaoc,3274
49
- sima_cli-0.0.36.dist-info/licenses/LICENSE,sha256=a260OFuV4SsMZ6sQCkoYbtws_4o2deFtbnT9kg7Rfd4,1082
48
+ sima_cli/utils/pkg_update_check.py,sha256=GD0XVS2_l2WpuzL81TKkEQIDHXXffJeF3LELefncHNM,3467
49
+ sima_cli-0.0.38.dist-info/licenses/LICENSE,sha256=a260OFuV4SsMZ6sQCkoYbtws_4o2deFtbnT9kg7Rfd4,1082
50
50
  tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
51
51
  tests/test_app_zoo.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
52
52
  tests/test_auth.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -55,8 +55,8 @@ tests/test_download.py,sha256=t87DwxlHs26_ws9rpcHGwr_OrcRPd3hz6Zmm0vRee2U,4465
55
55
  tests/test_firmware.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
56
56
  tests/test_model_zoo.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
57
57
  tests/test_utils.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
58
- sima_cli-0.0.36.dist-info/METADATA,sha256=nRB0ysTR2pmyDNlBC6Tx7gk1VPJ6o83ZulKr99RLJTo,3705
59
- sima_cli-0.0.36.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
60
- sima_cli-0.0.36.dist-info/entry_points.txt,sha256=xRYrDq1nCs6R8wEdB3c1kKuimxEjWJkHuCzArQPT0Xk,47
61
- sima_cli-0.0.36.dist-info/top_level.txt,sha256=FtrbAUdHNohtEPteOblArxQNwoX9_t8qJQd59fagDlc,15
62
- sima_cli-0.0.36.dist-info/RECORD,,
58
+ sima_cli-0.0.38.dist-info/METADATA,sha256=EMJTYog2SdzP3e1dSwkTvzIQ_glqF9tQs7zTZAaGrgc,3705
59
+ sima_cli-0.0.38.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
60
+ sima_cli-0.0.38.dist-info/entry_points.txt,sha256=xRYrDq1nCs6R8wEdB3c1kKuimxEjWJkHuCzArQPT0Xk,47
61
+ sima_cli-0.0.38.dist-info/top_level.txt,sha256=FtrbAUdHNohtEPteOblArxQNwoX9_t8qJQd59fagDlc,15
62
+ sima_cli-0.0.38.dist-info/RECORD,,