OpenShock-AutoFlasher 0.2.1__tar.gz → 0.2.2__tar.gz
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.
- {openshock_autoflasher-0.2.1 → openshock_autoflasher-0.2.2/OpenShock_AutoFlasher.egg-info}/PKG-INFO +8 -1
- {openshock_autoflasher-0.2.1/OpenShock_AutoFlasher.egg-info → openshock_autoflasher-0.2.2}/PKG-INFO +8 -1
- {openshock_autoflasher-0.2.1 → openshock_autoflasher-0.2.2}/README.md +7 -0
- {openshock_autoflasher-0.2.1 → openshock_autoflasher-0.2.2}/openshock_autoflasher/cli.py +8 -1
- {openshock_autoflasher-0.2.1 → openshock_autoflasher-0.2.2}/openshock_autoflasher/constants.py +16 -0
- {openshock_autoflasher-0.2.1 → openshock_autoflasher-0.2.2}/openshock_autoflasher/flasher.py +23 -7
- {openshock_autoflasher-0.2.1 → openshock_autoflasher-0.2.2}/pyproject.toml +1 -1
- {openshock_autoflasher-0.2.1 → openshock_autoflasher-0.2.2}/tests/test_cli.py +12 -0
- {openshock_autoflasher-0.2.1 → openshock_autoflasher-0.2.2}/tests/test_constants.py +2 -0
- {openshock_autoflasher-0.2.1 → openshock_autoflasher-0.2.2}/tests/test_flasher.py +55 -0
- {openshock_autoflasher-0.2.1 → openshock_autoflasher-0.2.2}/LICENSE +0 -0
- {openshock_autoflasher-0.2.1 → openshock_autoflasher-0.2.2}/MANIFEST.in +0 -0
- {openshock_autoflasher-0.2.1 → openshock_autoflasher-0.2.2}/OpenShock_AutoFlasher.egg-info/SOURCES.txt +0 -0
- {openshock_autoflasher-0.2.1 → openshock_autoflasher-0.2.2}/OpenShock_AutoFlasher.egg-info/dependency_links.txt +0 -0
- {openshock_autoflasher-0.2.1 → openshock_autoflasher-0.2.2}/OpenShock_AutoFlasher.egg-info/entry_points.txt +0 -0
- {openshock_autoflasher-0.2.1 → openshock_autoflasher-0.2.2}/OpenShock_AutoFlasher.egg-info/requires.txt +0 -0
- {openshock_autoflasher-0.2.1 → openshock_autoflasher-0.2.2}/OpenShock_AutoFlasher.egg-info/top_level.txt +0 -0
- {openshock_autoflasher-0.2.1 → openshock_autoflasher-0.2.2}/openshock_autoflasher/__init__.py +0 -0
- {openshock_autoflasher-0.2.1 → openshock_autoflasher-0.2.2}/openshock_autoflasher/__main__.py +0 -0
- {openshock_autoflasher-0.2.1 → openshock_autoflasher-0.2.2}/openshock_autoflasher/py.typed +0 -0
- {openshock_autoflasher-0.2.1 → openshock_autoflasher-0.2.2}/openshock_autoflasher/styles.py +0 -0
- {openshock_autoflasher-0.2.1 → openshock_autoflasher-0.2.2}/requirements-dev.txt +0 -0
- {openshock_autoflasher-0.2.1 → openshock_autoflasher-0.2.2}/requirements.txt +0 -0
- {openshock_autoflasher-0.2.1 → openshock_autoflasher-0.2.2}/setup.cfg +0 -0
- {openshock_autoflasher-0.2.1 → openshock_autoflasher-0.2.2}/tests/__init__.py +0 -0
- {openshock_autoflasher-0.2.1 → openshock_autoflasher-0.2.2}/tests/test_styles.py +0 -0
{openshock_autoflasher-0.2.1 → openshock_autoflasher-0.2.2/OpenShock_AutoFlasher.egg-info}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: OpenShock-AutoFlasher
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: Automatically flash OpenShock firmware to ESP32 devices
|
|
5
5
|
Author: NanashiTheNameless
|
|
6
6
|
Author-email: NanashiTheNameless <NanashiTheNameless@NamelessNanashi.dev>
|
|
@@ -144,6 +144,7 @@ OPSH-AutoFlash -C develop --help # Shows boards for develop channel
|
|
|
144
144
|
| `--channel` | `-C` | Firmware channel: `stable`, `beta`, or `develop` | `stable` |
|
|
145
145
|
| `--version` | `-V` | Use specific firmware version (overrides channel) | - |
|
|
146
146
|
| `--board` | `-B` | Board type (required) | - |
|
|
147
|
+
| `--chip` | - | Target chip for esptool | `auto` |
|
|
147
148
|
| `--erase` | `-E` | Erase flash before flashing | `false` |
|
|
148
149
|
| `--no-auto` | `-N` | Disable auto-flash (just detect devices) | `false` |
|
|
149
150
|
| `--post-flash` | `-P` | Serial command to send after flashing (can use multiple times) | - |
|
|
@@ -170,6 +171,12 @@ OPSH-AutoFlash --version 1.5.0 --board Wemos-D1-Mini-ESP32
|
|
|
170
171
|
OPSH-AutoFlash --channel beta --board Wemos-D1-Mini-ESP32 --erase
|
|
171
172
|
```
|
|
172
173
|
|
|
174
|
+
**Flash with an explicit esptool chip:**
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
OPSH-AutoFlash --board Seeed-Xiao-ESP32C3 --chip esp32c3 --erase
|
|
178
|
+
```
|
|
179
|
+
|
|
173
180
|
**Flash and send post-flash commands to device:**
|
|
174
181
|
|
|
175
182
|
```bash
|
{openshock_autoflasher-0.2.1/OpenShock_AutoFlasher.egg-info → openshock_autoflasher-0.2.2}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: OpenShock-AutoFlasher
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: Automatically flash OpenShock firmware to ESP32 devices
|
|
5
5
|
Author: NanashiTheNameless
|
|
6
6
|
Author-email: NanashiTheNameless <NanashiTheNameless@NamelessNanashi.dev>
|
|
@@ -144,6 +144,7 @@ OPSH-AutoFlash -C develop --help # Shows boards for develop channel
|
|
|
144
144
|
| `--channel` | `-C` | Firmware channel: `stable`, `beta`, or `develop` | `stable` |
|
|
145
145
|
| `--version` | `-V` | Use specific firmware version (overrides channel) | - |
|
|
146
146
|
| `--board` | `-B` | Board type (required) | - |
|
|
147
|
+
| `--chip` | - | Target chip for esptool | `auto` |
|
|
147
148
|
| `--erase` | `-E` | Erase flash before flashing | `false` |
|
|
148
149
|
| `--no-auto` | `-N` | Disable auto-flash (just detect devices) | `false` |
|
|
149
150
|
| `--post-flash` | `-P` | Serial command to send after flashing (can use multiple times) | - |
|
|
@@ -170,6 +171,12 @@ OPSH-AutoFlash --version 1.5.0 --board Wemos-D1-Mini-ESP32
|
|
|
170
171
|
OPSH-AutoFlash --channel beta --board Wemos-D1-Mini-ESP32 --erase
|
|
171
172
|
```
|
|
172
173
|
|
|
174
|
+
**Flash with an explicit esptool chip:**
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
OPSH-AutoFlash --board Seeed-Xiao-ESP32C3 --chip esp32c3 --erase
|
|
178
|
+
```
|
|
179
|
+
|
|
173
180
|
**Flash and send post-flash commands to device:**
|
|
174
181
|
|
|
175
182
|
```bash
|
|
@@ -92,6 +92,7 @@ OPSH-AutoFlash -C develop --help # Shows boards for develop channel
|
|
|
92
92
|
| `--channel` | `-C` | Firmware channel: `stable`, `beta`, or `develop` | `stable` |
|
|
93
93
|
| `--version` | `-V` | Use specific firmware version (overrides channel) | - |
|
|
94
94
|
| `--board` | `-B` | Board type (required) | - |
|
|
95
|
+
| `--chip` | - | Target chip for esptool | `auto` |
|
|
95
96
|
| `--erase` | `-E` | Erase flash before flashing | `false` |
|
|
96
97
|
| `--no-auto` | `-N` | Disable auto-flash (just detect devices) | `false` |
|
|
97
98
|
| `--post-flash` | `-P` | Serial command to send after flashing (can use multiple times) | - |
|
|
@@ -118,6 +119,12 @@ OPSH-AutoFlash --version 1.5.0 --board Wemos-D1-Mini-ESP32
|
|
|
118
119
|
OPSH-AutoFlash --channel beta --board Wemos-D1-Mini-ESP32 --erase
|
|
119
120
|
```
|
|
120
121
|
|
|
122
|
+
**Flash with an explicit esptool chip:**
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
OPSH-AutoFlash --board Seeed-Xiao-ESP32C3 --chip esp32c3 --erase
|
|
126
|
+
```
|
|
127
|
+
|
|
121
128
|
**Flash and send post-flash commands to device:**
|
|
122
129
|
|
|
123
130
|
```bash
|
|
@@ -10,7 +10,7 @@ from typing import List
|
|
|
10
10
|
import requests
|
|
11
11
|
from rich.style import Style
|
|
12
12
|
|
|
13
|
-
from .constants import BASE_URL
|
|
13
|
+
from .constants import BASE_URL, SUPPORTED_CHIPS
|
|
14
14
|
from .styles import console
|
|
15
15
|
from .flasher import AutoFlasher
|
|
16
16
|
|
|
@@ -64,6 +64,12 @@ def create_argument_parser(channel: str = "stable") -> argparse.ArgumentParser:
|
|
|
64
64
|
help="Use specific firmware version (overrides channel selection)",
|
|
65
65
|
)
|
|
66
66
|
parser.add_argument("--board", "-B", required=True, help="Board type (required)")
|
|
67
|
+
parser.add_argument(
|
|
68
|
+
"--chip",
|
|
69
|
+
choices=("auto", *SUPPORTED_CHIPS),
|
|
70
|
+
default="auto",
|
|
71
|
+
help="Target chip for esptool (default: auto)",
|
|
72
|
+
)
|
|
67
73
|
parser.add_argument(
|
|
68
74
|
"--erase",
|
|
69
75
|
"-E",
|
|
@@ -146,6 +152,7 @@ def main() -> None:
|
|
|
146
152
|
post_flash_delay=args.post_flash_delay,
|
|
147
153
|
alert=args.alert,
|
|
148
154
|
version=args.version,
|
|
155
|
+
chip=args.chip,
|
|
149
156
|
)
|
|
150
157
|
|
|
151
158
|
flasher.run()
|
{openshock_autoflasher-0.2.1 → openshock_autoflasher-0.2.2}/openshock_autoflasher/constants.py
RENAMED
|
@@ -11,6 +11,22 @@ BAUD_RATE: str = "460800"
|
|
|
11
11
|
FLASH_MODE: str = "dio"
|
|
12
12
|
FLASH_FREQ: str = "80m"
|
|
13
13
|
FLASH_ADDRESS: str = "0x0000"
|
|
14
|
+
SUPPORTED_CHIPS: tuple[str, ...] = (
|
|
15
|
+
"esp32",
|
|
16
|
+
"esp32s2",
|
|
17
|
+
"esp32s3",
|
|
18
|
+
"esp32c3",
|
|
19
|
+
"esp32c2",
|
|
20
|
+
"esp32c6",
|
|
21
|
+
"esp32c61",
|
|
22
|
+
"esp32c5",
|
|
23
|
+
"esp32e22",
|
|
24
|
+
"esp32h2",
|
|
25
|
+
"esp32h21",
|
|
26
|
+
"esp32p4",
|
|
27
|
+
"esp32h4",
|
|
28
|
+
"esp32s31",
|
|
29
|
+
)
|
|
14
30
|
|
|
15
31
|
# Polling settings
|
|
16
32
|
INITIAL_POLL_INTERVAL: float = 0.5 # seconds
|
{openshock_autoflasher-0.2.1 → openshock_autoflasher-0.2.2}/openshock_autoflasher/flasher.py
RENAMED
|
@@ -24,6 +24,7 @@ from .constants import (
|
|
|
24
24
|
FLASH_MODE,
|
|
25
25
|
FLASH_FREQ,
|
|
26
26
|
FLASH_ADDRESS,
|
|
27
|
+
SUPPORTED_CHIPS,
|
|
27
28
|
INITIAL_POLL_INTERVAL,
|
|
28
29
|
MAX_POLL_INTERVAL,
|
|
29
30
|
POLL_BACKOFF_THRESHOLD,
|
|
@@ -32,6 +33,18 @@ from .constants import (
|
|
|
32
33
|
from .styles import StateColors, console
|
|
33
34
|
|
|
34
35
|
|
|
36
|
+
def normalize_chip(chip: Optional[str]) -> str:
|
|
37
|
+
"""Normalize and validate an optional esptool chip value."""
|
|
38
|
+
if chip is None:
|
|
39
|
+
return "auto"
|
|
40
|
+
|
|
41
|
+
normalized_chip = chip.lower()
|
|
42
|
+
if normalized_chip != "auto" and normalized_chip not in SUPPORTED_CHIPS:
|
|
43
|
+
supported = ", ".join(("auto", *SUPPORTED_CHIPS))
|
|
44
|
+
raise ValueError(f"Unsupported chip '{chip}'. Supported chips: {supported}")
|
|
45
|
+
return normalized_chip
|
|
46
|
+
|
|
47
|
+
|
|
35
48
|
class AutoFlasher:
|
|
36
49
|
"""Main auto-flashing controller for OpenShock devices"""
|
|
37
50
|
|
|
@@ -45,6 +58,7 @@ class AutoFlasher:
|
|
|
45
58
|
post_flash_delay: float = 0.0,
|
|
46
59
|
alert: bool = False,
|
|
47
60
|
version: Optional[str] = None,
|
|
61
|
+
chip: Optional[str] = None,
|
|
48
62
|
) -> None:
|
|
49
63
|
self.channel: str = channel
|
|
50
64
|
self.board: Optional[str] = board
|
|
@@ -54,6 +68,7 @@ class AutoFlasher:
|
|
|
54
68
|
self.post_flash_delay: float = post_flash_delay
|
|
55
69
|
self.alert: bool = alert
|
|
56
70
|
self.version: Optional[str] = version
|
|
71
|
+
self.chip: str = normalize_chip(chip)
|
|
57
72
|
self.base_url: str = BASE_URL
|
|
58
73
|
self.known_ports: Set[str] = set()
|
|
59
74
|
self.state: str = "waiting"
|
|
@@ -321,6 +336,7 @@ class AutoFlasher:
|
|
|
321
336
|
self.log(f"Starting flash process for {board}")
|
|
322
337
|
self.log(f"Port: {port}")
|
|
323
338
|
self.log(f"Version: {version}")
|
|
339
|
+
self.log(f"Chip: {self.chip}")
|
|
324
340
|
self.log("=" * 60)
|
|
325
341
|
|
|
326
342
|
# Download firmware
|
|
@@ -339,23 +355,23 @@ class AutoFlasher:
|
|
|
339
355
|
temp_file.close()
|
|
340
356
|
|
|
341
357
|
# Prepare esptool arguments
|
|
342
|
-
|
|
358
|
+
base_args = [
|
|
359
|
+
"--chip",
|
|
360
|
+
self.chip,
|
|
343
361
|
"--port",
|
|
344
362
|
port,
|
|
345
363
|
"--baud",
|
|
346
364
|
BAUD_RATE,
|
|
347
|
-
|
|
348
|
-
|
|
365
|
+
]
|
|
366
|
+
args = [
|
|
367
|
+
*base_args,
|
|
349
368
|
"write-flash",
|
|
350
369
|
]
|
|
351
370
|
|
|
352
371
|
if self.erase_flash:
|
|
353
372
|
self.log("Erasing flash...")
|
|
354
373
|
erase_args = [
|
|
355
|
-
|
|
356
|
-
port,
|
|
357
|
-
"--baud",
|
|
358
|
-
BAUD_RATE,
|
|
374
|
+
*base_args,
|
|
359
375
|
"erase-flash",
|
|
360
376
|
]
|
|
361
377
|
|
|
@@ -52,6 +52,7 @@ def test_create_argument_parser():
|
|
|
52
52
|
assert args.no_auto is False
|
|
53
53
|
assert args.post_flash is None
|
|
54
54
|
assert args.post_flash_delay == 0.0
|
|
55
|
+
assert args.chip == "auto"
|
|
55
56
|
|
|
56
57
|
|
|
57
58
|
def test_argument_parser_all_options():
|
|
@@ -102,6 +103,17 @@ def test_argument_parser_channel_choices():
|
|
|
102
103
|
parser.parse_args(["--channel", "invalid", "--board", "test"])
|
|
103
104
|
|
|
104
105
|
|
|
106
|
+
def test_argument_parser_chip_option():
|
|
107
|
+
"""Test parser with explicit esptool chip selection."""
|
|
108
|
+
parser = create_argument_parser()
|
|
109
|
+
|
|
110
|
+
args = parser.parse_args(["--board", "test-board", "--chip", "esp32c3"])
|
|
111
|
+
assert args.chip == "esp32c3"
|
|
112
|
+
|
|
113
|
+
with pytest.raises(SystemExit):
|
|
114
|
+
parser.parse_args(["--board", "test-board", "--chip", "invalid"])
|
|
115
|
+
|
|
116
|
+
|
|
105
117
|
def test_argument_parser_post_flash_single():
|
|
106
118
|
"""Test parser with single post-flash command"""
|
|
107
119
|
parser = create_argument_parser()
|
|
@@ -9,6 +9,7 @@ from openshock_autoflasher.constants import (
|
|
|
9
9
|
FLASH_MODE,
|
|
10
10
|
FLASH_FREQ,
|
|
11
11
|
FLASH_ADDRESS,
|
|
12
|
+
SUPPORTED_CHIPS,
|
|
12
13
|
INITIAL_POLL_INTERVAL,
|
|
13
14
|
MAX_POLL_INTERVAL,
|
|
14
15
|
POLL_BACKOFF_THRESHOLD,
|
|
@@ -24,6 +25,7 @@ def test_constants_are_defined():
|
|
|
24
25
|
assert FLASH_MODE in ["qio", "qout", "dio", "dout"]
|
|
25
26
|
assert FLASH_FREQ.endswith("m")
|
|
26
27
|
assert FLASH_ADDRESS.startswith("0x")
|
|
28
|
+
assert "esp32" in SUPPORTED_CHIPS
|
|
27
29
|
|
|
28
30
|
|
|
29
31
|
def test_polling_intervals():
|
|
@@ -5,6 +5,7 @@ Tests for flasher module
|
|
|
5
5
|
import pytest
|
|
6
6
|
from unittest.mock import Mock, patch, MagicMock
|
|
7
7
|
|
|
8
|
+
from openshock_autoflasher.constants import BAUD_RATE
|
|
8
9
|
from openshock_autoflasher.flasher import AutoFlasher
|
|
9
10
|
|
|
10
11
|
|
|
@@ -337,6 +338,60 @@ def test_flasher_with_version_and_all_options():
|
|
|
337
338
|
assert flasher.alert is True
|
|
338
339
|
|
|
339
340
|
|
|
341
|
+
def test_flasher_defaults_chip_to_auto():
|
|
342
|
+
"""Test AutoFlasher defaults to esptool autodetection."""
|
|
343
|
+
flasher = AutoFlasher(channel="stable", board="test-board")
|
|
344
|
+
|
|
345
|
+
assert flasher.chip == "auto"
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
def test_flasher_with_explicit_chip():
|
|
349
|
+
"""Test AutoFlasher stores explicit chip overrides."""
|
|
350
|
+
flasher = AutoFlasher(channel="stable", board="test-board", chip="ESP32S3")
|
|
351
|
+
|
|
352
|
+
assert flasher.chip == "esp32s3"
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
def test_flasher_rejects_unsupported_chip():
|
|
356
|
+
"""Test unsupported esptool chip values fail early."""
|
|
357
|
+
with pytest.raises(ValueError, match="Unsupported chip"):
|
|
358
|
+
AutoFlasher(channel="stable", board="test-board", chip="invalid")
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
def test_flash_device_uses_default_auto_chip_for_erase_and_flash(flasher):
|
|
362
|
+
"""Test erase and write commands both receive the default auto chip."""
|
|
363
|
+
flasher.erase_flash = True
|
|
364
|
+
|
|
365
|
+
with (
|
|
366
|
+
patch.object(flasher, "download_firmware", return_value=b"firmware"),
|
|
367
|
+
patch.object(flasher, "_run_esptool") as mock_run_esptool,
|
|
368
|
+
):
|
|
369
|
+
flasher.flash_device("/dev/ttyUSB0", "1.0.0", "Seeed-Xiao-ESP32C3")
|
|
370
|
+
|
|
371
|
+
assert mock_run_esptool.call_count == 2
|
|
372
|
+
erase_args = mock_run_esptool.call_args_list[0][0][0]
|
|
373
|
+
write_args = mock_run_esptool.call_args_list[1][0][0]
|
|
374
|
+
|
|
375
|
+
assert erase_args == [
|
|
376
|
+
"--chip",
|
|
377
|
+
"auto",
|
|
378
|
+
"--port",
|
|
379
|
+
"/dev/ttyUSB0",
|
|
380
|
+
"--baud",
|
|
381
|
+
BAUD_RATE,
|
|
382
|
+
"erase-flash",
|
|
383
|
+
]
|
|
384
|
+
assert write_args[:7] == [
|
|
385
|
+
"--chip",
|
|
386
|
+
"auto",
|
|
387
|
+
"--port",
|
|
388
|
+
"/dev/ttyUSB0",
|
|
389
|
+
"--baud",
|
|
390
|
+
BAUD_RATE,
|
|
391
|
+
"write-flash",
|
|
392
|
+
]
|
|
393
|
+
|
|
394
|
+
|
|
340
395
|
@patch("openshock_autoflasher.flasher.time.sleep")
|
|
341
396
|
@patch("openshock_autoflasher.flasher.esptool.main")
|
|
342
397
|
def test_run_esptool_retries_on_stopiteration(mock_esptool_main, mock_sleep, flasher):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{openshock_autoflasher-0.2.1 → openshock_autoflasher-0.2.2}/openshock_autoflasher/__init__.py
RENAMED
|
File without changes
|
{openshock_autoflasher-0.2.1 → openshock_autoflasher-0.2.2}/openshock_autoflasher/__main__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|