spsdk-lauterbach 0.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.
@@ -0,0 +1,31 @@
1
+
2
+
3
+ BSD 3-Clause "New" or "Revised" License
4
+
5
+ Copyright 2024 NXP
6
+
7
+ Redistribution and use in source and binary forms, with or without modification,
8
+ are permitted provided that the following conditions are met:
9
+
10
+ * Redistributions of source code must retain the above copyright notice, this
11
+ list of conditions and the following disclaimer.
12
+
13
+ * Redistributions in binary form must reproduce the above copyright notice, this
14
+ list of conditions and the following disclaimer in the documentation and/or
15
+ other materials provided with the distribution.
16
+
17
+ * Neither the name of the copyright holder nor the names of its
18
+ contributors may be used to endorse or promote products derived from this
19
+ software without specific prior written permission.
20
+
21
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
22
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24
+ IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
25
+ INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26
+ BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
28
+ OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
29
+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
30
+ OF THE POSSIBILITY OF SUCH DAMAGE.
31
+
@@ -0,0 +1,13 @@
1
+ include CONTRIBUTING.rst
2
+ include HISTORY.rst
3
+ include LICENSE
4
+ include README.rst
5
+ include SW_Content_Register_spsdk_lauterbach.txt
6
+ include requirements*
7
+
8
+ recursive-exclude * __pycache__
9
+ recursive-exclude * *.py[co]
10
+ recursive-exclude .github *
11
+ prune tests
12
+
13
+ recursive-include docs *.rst conf.py Makefile make.bat *.jpg *.png *.gif
@@ -0,0 +1,80 @@
1
+ Metadata-Version: 2.1
2
+ Name: spsdk-lauterbach
3
+ Version: 0.1.0
4
+ Summary: Lauterbach debug probe plugin for SPSDK
5
+ Author: NXP
6
+ Maintainer-email: Michal Starecek <michal.starecek@nxp.com>
7
+ License: BSD-3-Clause
8
+ Project-URL: Homepage, https://github.com/nxp-mcuxpresso/spsdk_plugins/tree/master/lauterbach
9
+ Project-URL: Issues, https://github.com/nxp-mcuxpresso/spsdk_plugins/issues
10
+ Keywords: NXP,SPSDK,Lauterbach
11
+ Classifier: Development Status :: 2 - Pre-Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: BSD License
14
+ Classifier: Natural Language :: English
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Requires-Python: >=3.9
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Requires-Dist: spsdk>=2.2.0
24
+ Requires-Dist: lauterbach-trace32-rcl
25
+
26
+
27
+ Lauterbach debug probe Plugin
28
+ =============================
29
+
30
+
31
+ * Free software: BSD-3-Clause
32
+
33
+
34
+ Features
35
+ --------
36
+
37
+ * Allow SPSDK to use Trace32 as an interface for Lauterbach debugger probes.
38
+
39
+
40
+ Installation
41
+ ------------
42
+
43
+ * Activate virtual env, where you have SPSDK
44
+ - if SPSDK is not installed, the latest one will be installed automatically from [PyPI](https://pypi.org/project/spsdk/)
45
+ * `pip install spsdk-lauterbach`
46
+ * Verify installation by running `nxpdebugmbox --help`
47
+ - you should see `lauterbach` amongst available interfaces (--interface)
48
+
49
+
50
+ Usage
51
+ -----
52
+
53
+ * Make sure to enable remote control to Trace32 in your config file
54
+ ```
55
+ <mandatory empty line>
56
+ ; Remote Control Access
57
+ RCL=NETTCP
58
+ PORT=20000
59
+ <mandatory empty line>
60
+ ```
61
+
62
+ * Make sure your startup script contains the following:
63
+ - (required) DEBUGPORTTYPE (SWD, JTAG, CJTAG)
64
+ - (required) CPU family (e.g.: CortexM33)
65
+ - (optional) exact CPU (e.g.: LPC55S69JBD64-CPU0)
66
+ - Exact CPU is not crucial for Debug Authentication (DA), it's for testing whether DA was successful
67
+ - Without specifying exact CPU, `nxpdebugmbox` will end `without AHB access`, thus unable to determine DA's status
68
+
69
+
70
+ * Start Trace32
71
+ * Run your startup script
72
+ * Run `nxpdebugmbox`
73
+ - you may specify `-i/--interface lauterbach`
74
+ - you may specify `-s/--serial-no <probe's serial number>`
75
+
76
+
77
+ Credits
78
+ -------
79
+
80
+ This package was created with [Cookiecutter](https://github.com/audreyr/cookiecutter) and the [audreyr/cookiecutter-pypackage](https://github.com/audreyr/cookiecutter-pypackage) project template.
@@ -0,0 +1,55 @@
1
+
2
+ Lauterbach debug probe Plugin
3
+ =============================
4
+
5
+
6
+ * Free software: BSD-3-Clause
7
+
8
+
9
+ Features
10
+ --------
11
+
12
+ * Allow SPSDK to use Trace32 as an interface for Lauterbach debugger probes.
13
+
14
+
15
+ Installation
16
+ ------------
17
+
18
+ * Activate virtual env, where you have SPSDK
19
+ - if SPSDK is not installed, the latest one will be installed automatically from [PyPI](https://pypi.org/project/spsdk/)
20
+ * `pip install spsdk-lauterbach`
21
+ * Verify installation by running `nxpdebugmbox --help`
22
+ - you should see `lauterbach` amongst available interfaces (--interface)
23
+
24
+
25
+ Usage
26
+ -----
27
+
28
+ * Make sure to enable remote control to Trace32 in your config file
29
+ ```
30
+ <mandatory empty line>
31
+ ; Remote Control Access
32
+ RCL=NETTCP
33
+ PORT=20000
34
+ <mandatory empty line>
35
+ ```
36
+
37
+ * Make sure your startup script contains the following:
38
+ - (required) DEBUGPORTTYPE (SWD, JTAG, CJTAG)
39
+ - (required) CPU family (e.g.: CortexM33)
40
+ - (optional) exact CPU (e.g.: LPC55S69JBD64-CPU0)
41
+ - Exact CPU is not crucial for Debug Authentication (DA), it's for testing whether DA was successful
42
+ - Without specifying exact CPU, `nxpdebugmbox` will end `without AHB access`, thus unable to determine DA's status
43
+
44
+
45
+ * Start Trace32
46
+ * Run your startup script
47
+ * Run `nxpdebugmbox`
48
+ - you may specify `-i/--interface lauterbach`
49
+ - you may specify `-s/--serial-no <probe's serial number>`
50
+
51
+
52
+ Credits
53
+ -------
54
+
55
+ This package was created with [Cookiecutter](https://github.com/audreyr/cookiecutter) and the [audreyr/cookiecutter-pypackage](https://github.com/audreyr/cookiecutter-pypackage) project template.
@@ -0,0 +1,10 @@
1
+ NXP Software Content Register
2
+
3
+ Package: spsdk-lauterbach
4
+ Version: 0.1.0
5
+ Outgoing License: BSD-3-Clause
6
+ License Files: LICENSE
7
+ Type of content: Source code
8
+ Description and comments: NXP Secure Provisioning SDK Team - Debug Probe plugin for Lauterbach probes
9
+ Origin: NXP (BSD-3-Clause)
10
+ URL: https://github.com/nxp-mcuxpresso/spsdk_plugins/tree/master/lauterbach
@@ -0,0 +1,208 @@
1
+ [project]
2
+ name = "spsdk-lauterbach"
3
+ description = "Lauterbach debug probe plugin for SPSDK"
4
+ dynamic = ["version"]
5
+
6
+ requires-python = ">= 3.9"
7
+ dependencies = ["spsdk>=2.2.0", "lauterbach-trace32-rcl"]
8
+ entry-points = { "spsdk.debug_probe" = { lauterbach = "spsdk_lauterbach.probe" } }
9
+
10
+ authors = [{ name = "NXP" }]
11
+ maintainers = [{ name = "Michal Starecek", email = "michal.starecek@nxp.com" }]
12
+ readme = { file = "README.md", content-type = "text/markdown" }
13
+ license = { text = "BSD-3-Clause" }
14
+
15
+ keywords = ["NXP", "SPSDK", "Lauterbach"]
16
+ classifiers = [
17
+ "Development Status :: 2 - Pre-Alpha",
18
+ "Intended Audience :: Developers",
19
+ "License :: OSI Approved :: BSD License",
20
+ "Natural Language :: English",
21
+ "Programming Language :: Python :: 3",
22
+ "Programming Language :: Python :: 3.9",
23
+ "Programming Language :: Python :: 3.10",
24
+ "Programming Language :: Python :: 3.11",
25
+ "Programming Language :: Python :: 3.12",
26
+ ]
27
+
28
+ [project.urls]
29
+ Homepage = "https://github.com/nxp-mcuxpresso/spsdk_plugins/tree/master/lauterbach"
30
+ Issues = "https://github.com/nxp-mcuxpresso/spsdk_plugins/issues"
31
+
32
+
33
+ [build-system]
34
+ requires = ["setuptools >= 61.0", "wheel"]
35
+ build-backend = "setuptools.build_meta"
36
+
37
+ [tool.setuptools]
38
+ packages = ["spsdk_lauterbach"]
39
+
40
+ [tool.setuptools.dynamic]
41
+ version = { attr = "spsdk_lauterbach.__version__" }
42
+
43
+ [tool.bumpversion]
44
+ current_version = "0.1.0"
45
+
46
+ [[tool.bumpversion.files]]
47
+ filename = "spsdk_lauterbach/__init__.py"
48
+ search = '__version__ = "{current_version}"'
49
+ replace = '__version__ = "{new_version}"'
50
+
51
+ [[tool.bumpversion.files]]
52
+ filename = "SW_Content_Register_spsdk_lauterbach.txt"
53
+ search = "{current_version}"
54
+ replace = "{new_version}"
55
+
56
+
57
+ [tool.pytest.ini_options]
58
+ testpaths = ["tests"]
59
+ junit_family = "xunit1"
60
+
61
+ [tool.coverage.report]
62
+ exclude_lines = ["pragma: no cover", "safe_main()", "sys.exit(main())"]
63
+
64
+ [tool.coverage.run]
65
+ relative_files = true
66
+
67
+ [tool.black]
68
+ line-length = 100
69
+ target-version = ["py39", "py310", "py311", "py312"]
70
+ include = '\.pyi?$'
71
+
72
+ [tool.isort]
73
+ multi_line_output = 3
74
+ include_trailing_comma = true
75
+ force_grid_wrap = 0
76
+ use_parentheses = true
77
+ ensure_newline_before_comments = true
78
+ line_length = 100
79
+
80
+ [tool.mypy]
81
+ disallow_untyped_defs = true
82
+ ignore_missing_imports = true
83
+ warn_unused_ignores = true
84
+
85
+ [tool.pydocstyle]
86
+ convention = "google"
87
+ add_ignore = "D105,D301"
88
+ match = '(?!test_|__version__).*\.py'
89
+
90
+ [tool.pylint]
91
+ format = { max-line-length = 120 }
92
+ "messages control" = { disable = ["logging-fstring-interpolation"] }
93
+
94
+
95
+ [tool.checker_depencecies.spdx]
96
+ "Apache-2.0" = [
97
+ "Apache 2.0",
98
+ "Apache-2.0 License",
99
+ "Apache Software License 2.0",
100
+ "Apache License, Version 2.0",
101
+ "Apache License 2.0",
102
+ "Apache Software License",
103
+ ]
104
+ "BSD-2-Clause" = ["BSD", "BSD 2-Clause License"]
105
+ "BSD-3-Clause" = [
106
+ "BSD",
107
+ "BSD License",
108
+ "BSD 3-Clause",
109
+ "BSD (3 clause)",
110
+ "BSD 3-Clause License",
111
+ "Modified BSD License",
112
+ ]
113
+ "MIT" = ["MIT License", "MIT license"]
114
+ "MPL-2.0" = ["MPL 2.0", "Mozilla Public License 2.0 (MPL 2.0)"]
115
+ "NLPL" = ["Public domain", "Public Domain"]
116
+ "PSF-2.0" = ["PSF", "PSFL", "Python Software Foundation License"]
117
+ "GPL-2.0-or-later" = []
118
+ "LGPL-2.0-only" = ["LGPL-2.0"]
119
+ "LGPL-2.1-or-later" = []
120
+ "LGPL-3.0-only" = ["LGPL-3.0"]
121
+ "ISC" = ["ISC license"]
122
+
123
+ [tool.nxp_codecheck]
124
+ git_parent_branch = "origin/master"
125
+ output_directory = "reports"
126
+ default_check_paths = ["spsdk_lauterbach"]
127
+
128
+ # *********************************** Checker list ***********************************
129
+ [[tool.nxp_codecheck.checkers]]
130
+ name = "PYTEST"
131
+ method = "check_pytest"
132
+ # check_paths = [] # The default check paths could be overrides by local settings
133
+ info_only = false
134
+ kwargs = { disable_xdist = false }
135
+
136
+ # [[tool.nxp_codecheck.checkers]]
137
+ # name = "GITCOV"
138
+ # method = "check_gitcov"
139
+ # # check_paths = [] # The default check paths could be overrides by local settings
140
+ # info_only = true
141
+ # dependencies = ["PYTEST"]
142
+ [[tool.nxp_codecheck.checkers]]
143
+ name = "PYLINT"
144
+ method = "check_pylint"
145
+ # check_paths = [] # The default check paths could be overrides by local settings
146
+ info_only = false
147
+ [[tool.nxp_codecheck.checkers]]
148
+ name = "MYPY"
149
+ method = "check_mypy"
150
+ # check_paths = [] # The default check paths could be overrides by local settings
151
+ info_only = false
152
+ [[tool.nxp_codecheck.checkers]]
153
+ name = "DEPENDENCIES"
154
+ method = "check_dependencies"
155
+ # check_paths = [] # The default check paths could be overrides by local settings
156
+ info_only = false
157
+ fixer = "fix_dependencies"
158
+ [[tool.nxp_codecheck.checkers]]
159
+ name = "PYDOCSTYLE"
160
+ method = "check_pydocstyle"
161
+ # check_paths = [] # The default check paths could be overrides by local settings
162
+ info_only = false
163
+ [[tool.nxp_codecheck.checkers]]
164
+ name = "RADON_C"
165
+ method = "check_radon"
166
+ # check_paths = [] # The default check paths could be overrides by local settings
167
+ info_only = true
168
+ kwargs = { min_rank = "C" }
169
+ [[tool.nxp_codecheck.checkers]]
170
+ name = "RADON_D"
171
+ method = "check_radon"
172
+ # check_paths = [] # The default check paths could be overrides by local settings
173
+ info_only = false
174
+ kwargs = { min_rank = "D" }
175
+ [[tool.nxp_codecheck.checkers]]
176
+ name = "BLACK"
177
+ method = "check_black"
178
+ # check_paths = [] # The default check paths could be overrides by local settings
179
+ info_only = false
180
+ dependencies = []
181
+ fixer = "fix_black"
182
+ [[tool.nxp_codecheck.checkers]]
183
+ name = "ISORT"
184
+ method = "check_isort"
185
+ # check_paths = [] # The default check paths could be overrides by local settings
186
+ info_only = false
187
+ dependencies = []
188
+ fixer = "fix_isort"
189
+ [[tool.nxp_codecheck.checkers]]
190
+ name = "COPYRIGHT"
191
+ method = "check_copyright_year"
192
+ # check_paths = [] # The default check paths could be overrides by local settings
193
+ info_only = false
194
+ dependencies = []
195
+ fixer = "fix_copyright_year"
196
+ [[tool.nxp_codecheck.checkers]]
197
+ name = "PY_HEADERS"
198
+ method = "check_py_file_headers"
199
+ # check_paths = [] # The default check paths could be overrides by local settings
200
+ info_only = false
201
+ dependencies = []
202
+ fixer = "fix_py_file_headers"
203
+ [[tool.nxp_codecheck.checkers]]
204
+ name = "CYCLIC"
205
+ method = "check_cyclic_imports"
206
+ # check_paths = [] # The default check paths could be overrides by local settings
207
+ info_only = false
208
+ dependencies = []
@@ -0,0 +1,10 @@
1
+ # package management
2
+ build
3
+ bump-my-version
4
+ twine
5
+
6
+ # testing
7
+ tox
8
+
9
+ # code quality
10
+ nxp-codecheck
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env python
2
+ # -*- coding: UTF-8 -*-
3
+ #
4
+ # Copyright 2024 NXP
5
+ #
6
+ # SPDX-License-Identifier: BSD-3-Clause
7
+ """Top-level package for Lauterbach debug probe plugin."""
8
+
9
+ __author__ = """NXP"""
10
+ __email__ = "michal.starecek@nxp.com"
11
+ __version__ = "0.1.0"
12
+
13
+ from .probe import DebugProbeLauterbach
14
+
15
+ __all__ = ["DebugProbeLauterbach"]
@@ -0,0 +1,281 @@
1
+ #!/usr/bin/env python
2
+ # -*- coding: UTF-8 -*-
3
+ #
4
+ # Copyright 2024 NXP
5
+ #
6
+ # SPDX-License-Identifier: BSD-3-Clause
7
+ """Main module for Lauterbach debug probe plugin."""
8
+
9
+ import functools
10
+ import logging
11
+ import time
12
+ from typing import Any, Callable, Dict, Optional, Tuple
13
+
14
+ from spsdk.debuggers.debug_probe import (
15
+ DebugProbeLocal,
16
+ DebugProbes,
17
+ ProbeDescription,
18
+ SPSDKDebugProbeError,
19
+ SPSDKDebugProbeNotOpenError,
20
+ SPSDKDebugProbeTransferError,
21
+ )
22
+ from spsdk.utils.spsdk_enum import SpsdkEnum
23
+
24
+ import lauterbach.trace32.rcl as t32
25
+
26
+ logger = logging.getLogger(__name__)
27
+
28
+
29
+ class T32Mode(SpsdkEnum):
30
+ """Enumeration of known T32 Modes (SYStem.Mode)."""
31
+
32
+ DOWN = (0, "Down")
33
+ STAND_BY = (1, "StandBy")
34
+ NO_DEBUG = (2, "NoDebug")
35
+ PREPARE = (4, "Prepare")
36
+ UP = (11, "Up")
37
+ UNKNOWN = (255, "UNKNOWN")
38
+
39
+
40
+ def ensure_mode(mode: Optional[T32Mode]) -> Callable:
41
+ """Decorator that checks if connection is open and sets T32 mode.
42
+
43
+ If `mode` is set to None, perform only check for open connection.
44
+ """
45
+
46
+ def decorator(func: Callable) -> Any:
47
+ @functools.wraps(func)
48
+ def wrapper(self: "DebugProbeLauterbach", *args: Any, **kwargs: Any) -> Any:
49
+ self.set_mode(mode=mode)
50
+ return func(self, *args, **kwargs)
51
+
52
+ return wrapper
53
+
54
+ return decorator
55
+
56
+
57
+ class DebugProbeLauterbach(DebugProbeLocal):
58
+ """SPSDK Debug Probe Lauterbach debug probe plugin class."""
59
+
60
+ NAME = "lauterbach"
61
+
62
+ def __init__(self, hardware_id: str, options: Optional[Dict] = None) -> None:
63
+ """The Debug Probe class initialization."""
64
+ super().__init__(hardware_id, options)
65
+ self.address, self.port = self.parse_options(options=options)
66
+ self.connection: Optional[t32.Debugger] = None
67
+ self.mode = T32Mode.UNKNOWN
68
+
69
+ @classmethod
70
+ def parse_options(cls, options: Optional[Dict] = None) -> Tuple[str, int]:
71
+ """Parse options passed to __init__ method.
72
+
73
+ :param options: Options passed to __init__ method, defaults to None
74
+ :return: T32 address and port (default localhost, 20_000)
75
+ """
76
+ if not options:
77
+ address = "localhost"
78
+ port = 20_000
79
+ else:
80
+ ip: str = options.get("ip", "localhost:20000")
81
+ parts = ip.split(":")
82
+ address = parts[0]
83
+ port = 20_000 if len(parts) == 1 else int(parts[1], 0)
84
+
85
+ return address, port
86
+
87
+ @classmethod
88
+ def get_connected_probes(
89
+ cls, hardware_id: Optional[str] = None, options: Optional[Dict] = None
90
+ ) -> DebugProbes:
91
+ """Functions returns the list of all connected probes in system.
92
+
93
+ There is option to look for just for one debug probe defined by its hardware ID.
94
+
95
+ :param hardware_id: None to list all probes, otherwise the the only probe with
96
+ matching hardware id is listed.
97
+ :param options: The options dictionary
98
+ :return: List of ProbeDescription
99
+ """
100
+ probes = DebugProbes()
101
+ address, port = cls.parse_options(options=options)
102
+ try:
103
+ connection = t32.connect(node=address, port=port, timeout=1.0)
104
+ serial = connection.fnc("LICENSE.SERIAL(0)")
105
+ if hardware_id and hardware_id != serial:
106
+ return probes
107
+ probes.append(
108
+ ProbeDescription(
109
+ interface="lauterbach",
110
+ hardware_id=serial,
111
+ description=f"Lauterbach probe at {address}:{port}",
112
+ probe=cls,
113
+ )
114
+ )
115
+ connection.disconnect()
116
+ except (ConnectionRefusedError, TimeoutError):
117
+ pass
118
+
119
+ return probes
120
+
121
+ @staticmethod
122
+ def get_options_help() -> Dict[str, str]:
123
+ """Get full list of options of debug probe.
124
+
125
+ :return: Dictionary with individual options. Key is parameter name and value the help text.
126
+ """
127
+ return {
128
+ "ip": "[HOST][:PORT] of the Lauterbach T32. Default HOST: localhost, default PORT: 20_000",
129
+ "note": "Your config.t32 file shall contain the following settings: RCL=NETTCP PORT=20000",
130
+ }
131
+
132
+ def open(self) -> None:
133
+ """Debug probe open.
134
+
135
+ General opening function for SPSDK library to support various DEBUG PROBES.
136
+ The function is used to initialize the connection to target and enable using debug probe
137
+ for DAT purposes.
138
+ """
139
+ self.connection = t32.connect(node=self.address, port=self.port)
140
+
141
+ def connect(self) -> None:
142
+ """Connect to target.
143
+
144
+ The PyLink connecting function for SPSDK library to support various DEBUG PROBES.
145
+ The function is used to initialize the connection to target
146
+
147
+ :raises SPSDKDebugProbeError: The PyLink cannot establish communication with target
148
+ """
149
+ self.set_mode(T32Mode.PREPARE)
150
+
151
+ def close(self) -> None:
152
+ """Debug probe close.
153
+
154
+ This is general closing function for SPSDK library to support various DEBUG PROBES.
155
+ """
156
+ if self.connection:
157
+ self.set_mode(T32Mode.DOWN)
158
+ self.connection.disconnect()
159
+ self.connection = None
160
+
161
+ def set_mode(self, mode: Optional[T32Mode]) -> None:
162
+ """Method to check if connection is open and sets Trace32 to desired mode.
163
+
164
+ If `mode` is set to None, perform only check for open connection.
165
+ """
166
+ if self.connection is None:
167
+ raise SPSDKDebugProbeNotOpenError()
168
+ if mode is None:
169
+ return
170
+ if self.mode == mode:
171
+ return
172
+ try:
173
+ self.connection.cmd(f"SYStem.Mode {mode.label}")
174
+ except t32.CommandError:
175
+ time.sleep(self.RESET_TIME)
176
+ try:
177
+ self.connection.cmd(f"SYStem.Mode {mode.label}")
178
+ except t32.CommandError as e:
179
+ raise SPSDKDebugProbeError(f"Unable to set mode: {mode.label}. Error: {e}") from e
180
+ self.mode = T32Mode.from_tag(self.connection.fnc("SYStem.Mode()"))
181
+ if self.mode != mode:
182
+ raise SPSDKDebugProbeError(f"Unable to set mode: {mode.label}")
183
+
184
+ def _get_cs_addr(self, access_port: bool, addr: int) -> int:
185
+ """Get CoreSight register address.
186
+
187
+ :param access_port: Get address for Access Port (set to false for Debug Port)
188
+ :param addr: Address of the Coresight register
189
+ :return: Full CoreSight register address
190
+ """
191
+ if access_port:
192
+ ap_num = (addr & self.APSEL) >> self.APSEL_SHIFT
193
+ return self._get_ap_addr(ap_num, addr)
194
+ return self._get_dp_addr(addr)
195
+
196
+ @staticmethod
197
+ def _get_dp_addr(reg_addr: int) -> int:
198
+ """Encode DP register byte address into T32 special format.
199
+
200
+ :param reg_addr: DP register address
201
+ :return: T32 DP address
202
+ """
203
+ addr = reg_addr & 0xFF
204
+ addr |= 0x4100_0000
205
+ return addr
206
+
207
+ @staticmethod
208
+ def _get_ap_addr(ap_number: int, reg_addr: int) -> int:
209
+ """Encode AP register byte address into T32 special format.
210
+
211
+ :param ap_number: AP index
212
+ :param reg_addr: AP register address
213
+ :return: T32 AP address
214
+ """
215
+ addr = reg_addr & 0xFF
216
+ addr |= (ap_number & 0xFF) << 8
217
+ addr |= 0x4000_0000
218
+ return addr
219
+
220
+ @ensure_mode(T32Mode.PREPARE)
221
+ def coresight_reg_read(self, access_port: bool = True, addr: int = 0) -> int:
222
+ """Read coresight register.
223
+
224
+ It reads coresight register function for SPSDK library to support various DEBUG PROBES.
225
+
226
+ :param access_port: if True, the Access Port (AP) register will be read(default), otherwise the Debug Port
227
+ :param addr: the register address
228
+ :return: The read value of addressed register (4 bytes)
229
+ """
230
+ logger.debug(f"CS READ: AP: {access_port}, ADDR: {addr:#x}")
231
+ try:
232
+ cs_addr = self._get_cs_addr(access_port=access_port, addr=addr)
233
+ cmd = f"DATA.LONG(EDBG:{cs_addr:#06x})"
234
+ data = self.connection.fnc(cmd) # type: ignore[union-attr] # None case is handled by "ensure_mode"
235
+ logger.debug(f"RESULT: {data:#x}")
236
+ return data
237
+ except t32.FunctionError as e:
238
+ raise SPSDKDebugProbeTransferError(str(e)) from e
239
+
240
+ @ensure_mode(T32Mode.PREPARE)
241
+ def coresight_reg_write(self, access_port: bool = True, addr: int = 0, data: int = 0) -> None:
242
+ """Write coresight register.
243
+
244
+ It writes coresight register function for SPSDK library to support various DEBUG PROBES.
245
+
246
+ :param access_port: if True, the Access Port (AP) register will be write(default), otherwise the Debug Port
247
+ :param addr: the register address
248
+ :param data: the data to be written into register
249
+ """
250
+ logger.debug(f"CS WRITE: AP: {access_port}, ADDR: {addr:#x}")
251
+ try:
252
+ cs_addr = self._get_cs_addr(access_port=access_port, addr=addr)
253
+ cmd = f"DATA.SET EDBG:{cs_addr:#06x} %Long {data:#x}"
254
+ try:
255
+ self.connection.cmd(cmd) # type: ignore[union-attr] # None case is handled by "ensure_mode"
256
+ except t32.CommandError as e:
257
+ if e.args[0] == "target reset detected":
258
+ time.sleep(0.5)
259
+ return
260
+ raise
261
+ except t32.CommandError as e:
262
+ raise SPSDKDebugProbeTransferError(str(e)) from e
263
+
264
+ @ensure_mode(None)
265
+ def assert_reset_line(self, assert_reset: bool = False) -> None:
266
+ """Control reset line at a target.
267
+
268
+ :param assert_reset: If True, the reset line is asserted(pulled down), if False the reset line is not affected.
269
+ """
270
+ if assert_reset:
271
+ self.connection.cmd("SYStem.RESetOut") # type: ignore[union-attr] # None case is handled by "ensure_mode"
272
+
273
+ @ensure_mode(None)
274
+ def clear_sticky_errors(self) -> None:
275
+ """Clear sticky errors of Debug port interface."""
276
+ self.set_mode(T32Mode.DOWN)
277
+ self.set_mode(T32Mode.PREPARE)
278
+
279
+ def __str__(self) -> str:
280
+ """Return information about the device."""
281
+ return f"lauterbach at {self.address}:{self.port}"
@@ -0,0 +1,80 @@
1
+ Metadata-Version: 2.1
2
+ Name: spsdk-lauterbach
3
+ Version: 0.1.0
4
+ Summary: Lauterbach debug probe plugin for SPSDK
5
+ Author: NXP
6
+ Maintainer-email: Michal Starecek <michal.starecek@nxp.com>
7
+ License: BSD-3-Clause
8
+ Project-URL: Homepage, https://github.com/nxp-mcuxpresso/spsdk_plugins/tree/master/lauterbach
9
+ Project-URL: Issues, https://github.com/nxp-mcuxpresso/spsdk_plugins/issues
10
+ Keywords: NXP,SPSDK,Lauterbach
11
+ Classifier: Development Status :: 2 - Pre-Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: BSD License
14
+ Classifier: Natural Language :: English
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Requires-Python: >=3.9
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Requires-Dist: spsdk>=2.2.0
24
+ Requires-Dist: lauterbach-trace32-rcl
25
+
26
+
27
+ Lauterbach debug probe Plugin
28
+ =============================
29
+
30
+
31
+ * Free software: BSD-3-Clause
32
+
33
+
34
+ Features
35
+ --------
36
+
37
+ * Allow SPSDK to use Trace32 as an interface for Lauterbach debugger probes.
38
+
39
+
40
+ Installation
41
+ ------------
42
+
43
+ * Activate virtual env, where you have SPSDK
44
+ - if SPSDK is not installed, the latest one will be installed automatically from [PyPI](https://pypi.org/project/spsdk/)
45
+ * `pip install spsdk-lauterbach`
46
+ * Verify installation by running `nxpdebugmbox --help`
47
+ - you should see `lauterbach` amongst available interfaces (--interface)
48
+
49
+
50
+ Usage
51
+ -----
52
+
53
+ * Make sure to enable remote control to Trace32 in your config file
54
+ ```
55
+ <mandatory empty line>
56
+ ; Remote Control Access
57
+ RCL=NETTCP
58
+ PORT=20000
59
+ <mandatory empty line>
60
+ ```
61
+
62
+ * Make sure your startup script contains the following:
63
+ - (required) DEBUGPORTTYPE (SWD, JTAG, CJTAG)
64
+ - (required) CPU family (e.g.: CortexM33)
65
+ - (optional) exact CPU (e.g.: LPC55S69JBD64-CPU0)
66
+ - Exact CPU is not crucial for Debug Authentication (DA), it's for testing whether DA was successful
67
+ - Without specifying exact CPU, `nxpdebugmbox` will end `without AHB access`, thus unable to determine DA's status
68
+
69
+
70
+ * Start Trace32
71
+ * Run your startup script
72
+ * Run `nxpdebugmbox`
73
+ - you may specify `-i/--interface lauterbach`
74
+ - you may specify `-s/--serial-no <probe's serial number>`
75
+
76
+
77
+ Credits
78
+ -------
79
+
80
+ This package was created with [Cookiecutter](https://github.com/audreyr/cookiecutter) and the [audreyr/cookiecutter-pypackage](https://github.com/audreyr/cookiecutter-pypackage) project template.
@@ -0,0 +1,14 @@
1
+ LICENSE
2
+ MANIFEST.in
3
+ README.md
4
+ SW_Content_Register_spsdk_lauterbach.txt
5
+ pyproject.toml
6
+ requirements_dev.txt
7
+ spsdk_lauterbach/__init__.py
8
+ spsdk_lauterbach/probe.py
9
+ spsdk_lauterbach.egg-info/PKG-INFO
10
+ spsdk_lauterbach.egg-info/SOURCES.txt
11
+ spsdk_lauterbach.egg-info/dependency_links.txt
12
+ spsdk_lauterbach.egg-info/entry_points.txt
13
+ spsdk_lauterbach.egg-info/requires.txt
14
+ spsdk_lauterbach.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [spsdk.debug_probe]
2
+ lauterbach = spsdk_lauterbach.probe
@@ -0,0 +1,2 @@
1
+ spsdk>=2.2.0
2
+ lauterbach-trace32-rcl
@@ -0,0 +1 @@
1
+ spsdk_lauterbach