pypicoboot 1.4__tar.gz → 1.5__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.
- {pypicoboot-1.4 → pypicoboot-1.5}/PKG-INFO +1 -1
- {pypicoboot-1.4 → pypicoboot-1.5}/picoboot/_version.py +1 -1
- {pypicoboot-1.4 → pypicoboot-1.5}/picoboot/picoboot.py +19 -7
- {pypicoboot-1.4 → pypicoboot-1.5}/picoboot/utils.py +15 -1
- {pypicoboot-1.4 → pypicoboot-1.5}/pypicoboot.egg-info/PKG-INFO +1 -1
- {pypicoboot-1.4 → pypicoboot-1.5}/LICENSE +0 -0
- {pypicoboot-1.4 → pypicoboot-1.5}/README.md +0 -0
- {pypicoboot-1.4 → pypicoboot-1.5}/picoboot/__init__.py +0 -0
- {pypicoboot-1.4 → pypicoboot-1.5}/picoboot/core/__init__.py +0 -0
- {pypicoboot-1.4 → pypicoboot-1.5}/picoboot/core/enums.py +0 -0
- {pypicoboot-1.4 → pypicoboot-1.5}/picoboot/core/exceptions.py +0 -0
- {pypicoboot-1.4 → pypicoboot-1.5}/picoboot/core/log.py +0 -0
- {pypicoboot-1.4 → pypicoboot-1.5}/picoboot/picobootmonitor.py +0 -0
- {pypicoboot-1.4 → pypicoboot-1.5}/picoboot/tools/picotool.py +0 -0
- {pypicoboot-1.4 → pypicoboot-1.5}/pypicoboot.egg-info/SOURCES.txt +0 -0
- {pypicoboot-1.4 → pypicoboot-1.5}/pypicoboot.egg-info/dependency_links.txt +0 -0
- {pypicoboot-1.4 → pypicoboot-1.5}/pypicoboot.egg-info/requires.txt +0 -0
- {pypicoboot-1.4 → pypicoboot-1.5}/pypicoboot.egg-info/top_level.txt +0 -0
- {pypicoboot-1.4 → pypicoboot-1.5}/pyproject.toml +0 -0
- {pypicoboot-1.4 → pypicoboot-1.5}/setup.cfg +0 -0
- {pypicoboot-1.4 → pypicoboot-1.5}/setup.py +0 -0
- {pypicoboot-1.4 → pypicoboot-1.5}/tests/test_000_init.py +0 -0
|
@@ -23,7 +23,7 @@ import usb.core
|
|
|
23
23
|
import usb.util
|
|
24
24
|
import struct
|
|
25
25
|
import itertools
|
|
26
|
-
from .utils import uint_to_int
|
|
26
|
+
from .utils import uint_to_int, crc32_ieee
|
|
27
27
|
from .core.enums import NamedIntEnum
|
|
28
28
|
from .picobootmonitor import PicoBootMonitor, PicoBootMonitorObserver
|
|
29
29
|
from .core.log import get_logger
|
|
@@ -134,6 +134,7 @@ class Platform(NamedIntEnum):
|
|
|
134
134
|
|
|
135
135
|
class Addresses(NamedIntEnum):
|
|
136
136
|
BOOTROM_MAGIC = 0x00000010
|
|
137
|
+
PHYMARKER = 0x10100000
|
|
137
138
|
|
|
138
139
|
class PicoBoot:
|
|
139
140
|
|
|
@@ -277,19 +278,30 @@ class PicoBoot:
|
|
|
277
278
|
def has_device(self):
|
|
278
279
|
return self.dev is not None
|
|
279
280
|
|
|
280
|
-
@property
|
|
281
|
-
def serial_number(self) -> int:
|
|
282
|
-
s = usb.util.get_string(self.dev, self.dev.iSerialNumber)
|
|
283
|
-
return int(s, 16)
|
|
284
|
-
|
|
285
281
|
@property
|
|
286
282
|
def serial_number_str(self) -> str:
|
|
287
283
|
try:
|
|
288
|
-
s =
|
|
284
|
+
s = None
|
|
285
|
+
if self.platform == Platform.RP2040:
|
|
286
|
+
r = self.flash_read(Addresses.PHYMARKER, 24)
|
|
287
|
+
magic = struct.unpack_from("<Q", r, 0)[0]
|
|
288
|
+
if (magic == 0x5049434F4B455953): # "PICOKEYS"
|
|
289
|
+
crc32 = crc32_ieee(r[0:20])
|
|
290
|
+
if crc32 == struct.unpack_from("<I", r, 20)[0]:
|
|
291
|
+
s = hexlify(r[12:20]).decode().upper()
|
|
292
|
+
if not s:
|
|
293
|
+
s = usb.util.get_string(self.dev, self.dev.iSerialNumber)
|
|
289
294
|
except Exception:
|
|
290
295
|
s = "unknown"
|
|
291
296
|
return s
|
|
292
297
|
|
|
298
|
+
@property
|
|
299
|
+
def serial_number(self) -> int:
|
|
300
|
+
if self.dev is None:
|
|
301
|
+
raise PicoBootInvalidStateError("Device not connected")
|
|
302
|
+
s = self.serial_number_str
|
|
303
|
+
return int(s, 16)
|
|
304
|
+
|
|
293
305
|
def interface_reset(self) -> None:
|
|
294
306
|
logger.debug("Resetting interface...")
|
|
295
307
|
self.dev.ctrl_transfer(
|
|
@@ -22,4 +22,18 @@ def uint_to_int(value: int, bits: int = 8) -> int:
|
|
|
22
22
|
mask = (1 << bits) - 1
|
|
23
23
|
value &= mask # ensure value fits in `bits`
|
|
24
24
|
sign_bit = 1 << (bits - 1)
|
|
25
|
-
return value - (1 << bits) if (value & sign_bit) else value
|
|
25
|
+
return value - (1 << bits) if (value & sign_bit) else value
|
|
26
|
+
|
|
27
|
+
def crc32_ieee(data: bytes) -> int:
|
|
28
|
+
crc = 0xFFFFFFFF
|
|
29
|
+
|
|
30
|
+
for b in data:
|
|
31
|
+
crc ^= b
|
|
32
|
+
for _ in range(8):
|
|
33
|
+
if crc & 1:
|
|
34
|
+
crc = (crc >> 1) ^ 0xEDB88320
|
|
35
|
+
else:
|
|
36
|
+
crc >>= 1
|
|
37
|
+
|
|
38
|
+
return crc ^ 0xFFFFFFFF
|
|
39
|
+
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|