tinyocd 1.0.0__tar.gz → 1.1.0__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.
@@ -1,31 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tinyocd
3
- Version: 1.0.0
3
+ Version: 1.1.0
4
4
  Summary: Programming Tool for STM32, PY32 and SAMD Microcontrollers via CMSIS-DAP, ST-Link or J-Link
5
5
  Author-email: Stefan Wagner <wagiminator@web.de>
6
6
  Maintainer-email: Stefan Wagner <wagiminator@web.de>
7
- License: MIT License
8
-
9
- Copyright (c) 2026 Stefan Wagner
10
-
11
- Permission is hereby granted, free of charge, to any person obtaining a copy
12
- of this software and associated documentation files (the "Software"), to deal
13
- in the Software without restriction, including without limitation the rights
14
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
- copies of the Software, and to permit persons to whom the Software is
16
- furnished to do so, subject to the following conditions:
17
-
18
- The above copyright notice and this permission notice shall be included in all
19
- copies or substantial portions of the Software.
20
-
21
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
- SOFTWARE.
28
-
29
7
  Project-URL: Homepage, https://wagiminator.github.io/
30
8
  Project-URL: Repository, https://github.com/wagiminator/MCU-Flash-Tools
31
9
  Project-URL: Issues, https://github.com/wagiminator/MCU-Flash-Tools/issues
@@ -38,12 +16,10 @@ Classifier: Intended Audience :: Developers
38
16
  Classifier: Topic :: Software Development :: Embedded Systems
39
17
  Requires-Python: >=3.8
40
18
  Description-Content-Type: text/markdown
41
- License-File: LICENSE
42
19
  Requires-Dist: pyusb
43
20
  Requires-Dist: libusb-package; platform_system == "Windows"
44
21
  Provides-Extra: hid
45
22
  Requires-Dist: hidapi; extra == "hid"
46
- Dynamic: license-file
47
23
 
48
24
  # Programming Tool for STM32, PY32 and SAMD Microcontrollers via CMSIS-DAP, ST-Link or J-Link
49
25
  ## Description
@@ -106,6 +82,8 @@ Example:
106
82
  tinyocd -f firmware.bin
107
83
  ```
108
84
 
85
+ Without action arguments, tinyocd shows the programmer, the chip, whether it is read protected and its option byte registers (user row on SAMD). Then the firmware is started.
86
+
109
87
  Notes:
110
88
  - The BIN file is written to the start of the flash memory (0x08000000 for STM32/PY32, 0x00000000 for SAMD).
111
89
  - If the chip cannot be halted (e.g. SWD pins disabled by the firmware), tinyOCD connects under reset. For this, NRST must be connected to the programmer.
@@ -59,6 +59,8 @@ Example:
59
59
  tinyocd -f firmware.bin
60
60
  ```
61
61
 
62
+ Without action arguments, tinyocd shows the programmer, the chip, whether it is read protected and its option byte registers (user row on SAMD). Then the firmware is started.
63
+
62
64
  Notes:
63
65
  - The BIN file is written to the start of the flash memory (0x08000000 for STM32/PY32, 0x00000000 for SAMD).
64
66
  - If the chip cannot be halted (e.g. SWD pins disabled by the firmware), tinyOCD connects under reset. For this, NRST must be connected to the programmer.
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "tinyocd"
7
- version = "1.0.0"
7
+ version = "1.1.0"
8
8
  description = "Programming Tool for STM32, PY32 and SAMD Microcontrollers via CMSIS-DAP, ST-Link or J-Link"
9
9
  keywords = ["SWD", "ARM", "Cortex-M", "STM32", "PY32", "PUYA", "SAMD", "ATSAMD21", "CMSIS-DAP", "DAPLink", "ST-Link", "J-Link", "microcontroller"]
10
10
  dependencies = ["pyusb", "libusb-package; platform_system == 'Windows'"]
@@ -2,7 +2,7 @@
2
2
  # ===================================================================================
3
3
  # Project: tinyOCD - Programming Tool for STM32, PY32 and SAMD Microcontrollers
4
4
  # via CMSIS-DAP (DAPLink), ST-Link or J-Link
5
- # Version: v1.0
5
+ # Version: v1.1
6
6
  # Year: 2026
7
7
  # Author: Stefan Wagner
8
8
  # Github: https://github.com/wagiminator
@@ -70,6 +70,8 @@
70
70
  # -R, --pinreset make NRST pin a reset pin
71
71
  # -f FLASH, --flash FLASH write BIN file to flash and verify
72
72
  # -t, --list list supported chips
73
+ # Without action arguments, the programmer, the chip and its option bytes
74
+ # (user row on SAMD) are shown.
73
75
  #
74
76
  # - Example:
75
77
  # python3 tinyocd.py -f firmware.bin
@@ -113,10 +115,8 @@ def _main():
113
115
  print_supported_chips()
114
116
  sys.exit(0)
115
117
 
116
- # Check arguments
117
- if not any( (args.unlock, args.lock, args.erase, args.bootpin, args.pingpio, args.pinreset, args.flash) ):
118
- print('No arguments - no action!')
119
- sys.exit(0)
118
+ # Check arguments (without action arguments the chip info is shown)
119
+ showinfo = not any( (args.unlock, args.lock, args.erase, args.bootpin, args.pingpio, args.pinreset, args.flash) )
120
120
  if args.pingpio and args.pinreset:
121
121
  sys.stderr.write('ERROR: -G and -R cannot be used together!\n')
122
122
  sys.exit(1)
@@ -160,6 +160,17 @@ def _main():
160
160
  if ocd.locked:
161
161
  print('Chip is read protected (locked).')
162
162
 
163
+ # Show option bytes (no action arguments)
164
+ if showinfo:
165
+ if not ocd.locked:
166
+ print('Read protection: off')
167
+ options = ocd.option_bytes()
168
+ if options and all(value is None for name, value in options):
169
+ print('INFO: Option bytes cannot be read.')
170
+ else:
171
+ for name, value in options:
172
+ print('%-16s %s' % (name + ':', 'not readable' if value is None else '0x%08x' % value))
173
+
163
174
  # Check option support before doing anything
164
175
  if args.bootpin and not ocd.chip.has_bootpin:
165
176
  raise Exception('BOOT0 pin configuration is not supported on this chip')
@@ -1467,6 +1478,12 @@ class Target:
1467
1478
  self.chip.driver.nrst(gpio)
1468
1479
  self.reconnect_after_reset()
1469
1480
 
1481
+ # Option byte registers (user row on SAMD) as list of (name, value or None)
1482
+ def option_bytes(self):
1483
+ if self.chip.driver is None:
1484
+ return []
1485
+ return self.chip.driver.options()
1486
+
1470
1487
 
1471
1488
  # ===================================================================================
1472
1489
  # Flash Driver Base Class
@@ -1475,6 +1492,7 @@ class Target:
1475
1492
  class FlashDriver:
1476
1493
  unit = 4
1477
1494
  iwdg_freeze = None
1495
+ option_regs = () # (name, offset) of option registers
1478
1496
 
1479
1497
  def __init__(self, target):
1480
1498
  self.t = target
@@ -1503,6 +1521,9 @@ class FlashDriver:
1503
1521
  def nrst(self, gpio):
1504
1522
  raise Exception('NRST pin configuration is not supported on this chip')
1505
1523
 
1524
+ def options(self):
1525
+ return [(name, self.t.try_read32(self.base + offset)) for name, offset in self.option_regs]
1526
+
1506
1527
  def r(self, reg):
1507
1528
  return self.t.read32(self.base + reg)
1508
1529
 
@@ -1523,6 +1544,7 @@ class FlashDriver:
1523
1544
 
1524
1545
  class STM32F1Flash(FlashDriver):
1525
1546
  unit = 2
1547
+ option_regs = (('FLASH_OBR', 0x1C), ('FLASH_WRPR', 0x20))
1526
1548
 
1527
1549
  def __init__(self, target, part, devid, size):
1528
1550
  super().__init__(target)
@@ -1628,6 +1650,7 @@ class STM32F1Flash(FlashDriver):
1628
1650
 
1629
1651
  class STM32F4Flash(FlashDriver):
1630
1652
  unit = 2
1653
+ option_regs = (('FLASH_OPTCR', 0x14),)
1631
1654
 
1632
1655
  def __init__(self, target, part, devid, size):
1633
1656
  super().__init__(target)
@@ -1703,6 +1726,8 @@ class STM32F4Flash(FlashDriver):
1703
1726
  # ===================================================================================
1704
1727
 
1705
1728
  class STM32L0Flash(FlashDriver):
1729
+ option_regs = (('FLASH_OPTR', 0x1C),)
1730
+
1706
1731
  def __init__(self, target, part, devid, size):
1707
1732
  super().__init__(target)
1708
1733
  self.l1 = (part == 0xC23)
@@ -1794,6 +1819,7 @@ class STM32L4Flash(FlashDriver):
1794
1819
  self.busy = (1 << 16) | (1 << 18) | ((1 << 17) if devid == 0x467 else 0)
1795
1820
  self.KEYR, self.OPTKEYR, self.SR, self.CR, self.OPTR = \
1796
1821
  (0x08, 0x10, 0x20, 0x28, 0x40) if self.l5 else (0x08, 0x0C, 0x10, 0x14, 0x20)
1822
+ self.option_regs = (('FLASH_OPTR', self.OPTR),)
1797
1823
  if opts.get('tz') and (self.r(self.OPTR) & (1 << 31)):
1798
1824
  raise Exception('TrustZone is enabled on this chip, not supported')
1799
1825
  fz = opts.get('fz')
@@ -1881,6 +1907,8 @@ class STM32L4Flash(FlashDriver):
1881
1907
  # ===================================================================================
1882
1908
 
1883
1909
  class STM32H7Flash(FlashDriver):
1910
+ option_regs = (('FLASH_OPTSR_CUR', 0x1C),)
1911
+
1884
1912
  def __init__(self, target, part, devid, size):
1885
1913
  super().__init__(target)
1886
1914
  self.base = 0x52002000
@@ -1967,6 +1995,7 @@ class STM32H7Flash(FlashDriver):
1967
1995
 
1968
1996
  class STM32H5Flash(FlashDriver):
1969
1997
  unit = 16
1998
+ option_regs = (('FLASH_OPTSR_CUR', 0x50),)
1970
1999
  iwdg_freeze = (0x44024008, 1 << 12)
1971
2000
 
1972
2001
  def __init__(self, target, part, devid, size):
@@ -2017,6 +2046,7 @@ PY32_VARIANTS = {
2017
2046
 
2018
2047
  class PY32Flash(FlashDriver):
2019
2048
  unit = 128
2049
+ option_regs = (('FLASH_OPTR', 0x20),)
2020
2050
 
2021
2051
  def __init__(self, target, variant):
2022
2052
  super().__init__(target)
@@ -2162,6 +2192,9 @@ class SAMDFlash(FlashDriver):
2162
2192
  if flags & 0x02:
2163
2193
  raise Exception('NVM controller error (STATUS 0x%04x)' % (self.r(0x18) & 0xFFFF))
2164
2194
 
2195
+ def options(self):
2196
+ return [('USER ROW word %d' % i, self.t.try_read32(0x00804000 + 4 * i)) for i in range(3 if self.d5x else 2)]
2197
+
2165
2198
  def _bootprot(self):
2166
2199
  user = self.t.read32(0x00804000)
2167
2200
  if self.d5x:
@@ -1,31 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tinyocd
3
- Version: 1.0.0
3
+ Version: 1.1.0
4
4
  Summary: Programming Tool for STM32, PY32 and SAMD Microcontrollers via CMSIS-DAP, ST-Link or J-Link
5
5
  Author-email: Stefan Wagner <wagiminator@web.de>
6
6
  Maintainer-email: Stefan Wagner <wagiminator@web.de>
7
- License: MIT License
8
-
9
- Copyright (c) 2026 Stefan Wagner
10
-
11
- Permission is hereby granted, free of charge, to any person obtaining a copy
12
- of this software and associated documentation files (the "Software"), to deal
13
- in the Software without restriction, including without limitation the rights
14
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
- copies of the Software, and to permit persons to whom the Software is
16
- furnished to do so, subject to the following conditions:
17
-
18
- The above copyright notice and this permission notice shall be included in all
19
- copies or substantial portions of the Software.
20
-
21
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
- SOFTWARE.
28
-
29
7
  Project-URL: Homepage, https://wagiminator.github.io/
30
8
  Project-URL: Repository, https://github.com/wagiminator/MCU-Flash-Tools
31
9
  Project-URL: Issues, https://github.com/wagiminator/MCU-Flash-Tools/issues
@@ -38,12 +16,10 @@ Classifier: Intended Audience :: Developers
38
16
  Classifier: Topic :: Software Development :: Embedded Systems
39
17
  Requires-Python: >=3.8
40
18
  Description-Content-Type: text/markdown
41
- License-File: LICENSE
42
19
  Requires-Dist: pyusb
43
20
  Requires-Dist: libusb-package; platform_system == "Windows"
44
21
  Provides-Extra: hid
45
22
  Requires-Dist: hidapi; extra == "hid"
46
- Dynamic: license-file
47
23
 
48
24
  # Programming Tool for STM32, PY32 and SAMD Microcontrollers via CMSIS-DAP, ST-Link or J-Link
49
25
  ## Description
@@ -106,6 +82,8 @@ Example:
106
82
  tinyocd -f firmware.bin
107
83
  ```
108
84
 
85
+ Without action arguments, tinyocd shows the programmer, the chip, whether it is read protected and its option byte registers (user row on SAMD). Then the firmware is started.
86
+
109
87
  Notes:
110
88
  - The BIN file is written to the start of the flash memory (0x08000000 for STM32/PY32, 0x00000000 for SAMD).
111
89
  - If the chip cannot be halted (e.g. SWD pins disabled by the firmware), tinyOCD connects under reset. For this, NRST must be connected to the programmer.
@@ -1,4 +1,3 @@
1
- LICENSE
2
1
  README.md
3
2
  pyproject.toml
4
3
  tinyocd/tinyocd.py
tinyocd-1.0.0/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Stefan Wagner
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
File without changes