Skip to content

Commit 88ad739

Browse files
committed
cbuild-run: add pack related commands to the command set
- filter imports needed for TYPE_CHECKING - register cbuild-run in commander
1 parent 7f5ee7c commit 88ad739

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

pyocd/commands/commander.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# pyOCD debugger
2-
# Copyright (c) 2015-2020 Arm Limited
2+
# Copyright (c) 2015-2020,2025 Arm Limited
33
# Copyright (c) 2021 Chris Reed
44
# SPDX-License-Identifier: Apache-2.0
55
#
@@ -210,6 +210,7 @@ def connect(self) -> bool:
210210
user_script=self.args.script,
211211
no_config=self.args.no_config,
212212
pack=self.args.pack,
213+
cbuild_run=self.args.cbuild_run,
213214
target_override=self.args.target_override,
214215
connect_mode=connect_mode,
215216
frequency=self.args.frequency,

pyocd/target/pack/cbuild_run.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17+
from __future__ import annotations
18+
1719
import logging
1820
import yaml
1921
import os
@@ -23,19 +25,16 @@
2325
from pathlib import Path
2426
from copy import deepcopy
2527
from dataclasses import dataclass
26-
from typing import (cast, Optional, Set, Dict, List, Tuple, IO, Any)
28+
from typing import (cast, Optional, Set, Dict, List, Tuple, IO, Any, TYPE_CHECKING)
2729
from .flash_algo import PackFlashAlgo
2830
from .reset_sequence_maps import (RESET_SEQUENCE_TO_TYPE_MAP, RESET_TYPE_TO_SEQUENCE_MAP)
2931
from .. import (normalise_target_type_name, TARGET)
30-
from ...coresight.cortex_m import CortexM
3132
from ...coresight.coresight_target import CoreSightTarget
3233
from ...coresight.ap import (APAddressBase, APv1Address, APv2Address)
3334
from ...core import exceptions
3435
from ...core.target import Target
3536
from ...core.session import Session
36-
from ...core.core_target import CoreTarget
3737
from ...core.memory_map import (MemoryMap, MemoryType, MEMORY_TYPE_CLASS_MAP)
38-
from ...utility.sequencer import CallSequence
3938
from ...probe.debug_probe import DebugProbe
4039
from ...debug.svd.loader import SVDFile
4140
from ...debug.sequences.scope import Scope
@@ -50,6 +49,12 @@
5049
DebugSequenceExecutionContext
5150
)
5251

52+
if TYPE_CHECKING:
53+
from ...coresight.cortex_m import CortexM
54+
from ...core.core_target import CoreTarget
55+
from ...utility.sequencer import CallSequence
56+
from ...commands.execution_context import CommandSet
57+
5358
LOG = logging.getLogger(__name__)
5459

5560
class CbuildRunError(exceptions.Error):
@@ -254,7 +259,7 @@ def is_reset_sequence_enabled(name: str) -> bool:
254259
@staticmethod
255260
def _cbuild_target_add_core(_self, core: CoreTarget) -> None:
256261
"""@brief Override to set node name of added core to its pname."""
257-
pname = _self._cbuild_device.processors_ap_map[cast(CortexM, core).ap.address].name
262+
pname = _self._cbuild_device.processors_ap_map[cast('CortexM', core).ap.address].name
258263
core.node_name = pname
259264
CoreSightTarget.add_core(_self, core)
260265

@@ -273,6 +278,10 @@ def _cbuild_target_get_gdbserver_port(self, pname: str) -> Optional[int]:
273278
def _cbuild_target_get_output(self) -> Dict[str, Optional[int]]:
274279
return self._cbuild_device.output
275280

281+
@staticmethod
282+
def _cbuild_target_add_target_command_groups(_self, command_set: CommandSet):
283+
"""@brief Add pack related commands to the command set."""
284+
command_set.add_command_group('pack-target')
276285

277286
class CbuildRun:
278287
"""@brief Parser for the .cbuild-run.yml file (CSolution Run and Debug Management)."""
@@ -611,7 +620,8 @@ def populate_target(self, target: Optional[str] = None) -> None:
611620
"configure_core_reset": CbuildRunTargetMethods._cbuild_target_configure_core_reset,
612621
"add_core": CbuildRunTargetMethods._cbuild_target_add_core,
613622
"get_gdbserver_port": CbuildRunTargetMethods._cbuild_target_get_gdbserver_port,
614-
"get_output": CbuildRunTargetMethods._cbuild_target_get_output
623+
"get_output": CbuildRunTargetMethods._cbuild_target_get_output,
624+
"add_target_command_groups": CbuildRunTargetMethods._cbuild_target_add_target_command_groups,
615625
})
616626
TARGET[target] = tgt
617627

0 commit comments

Comments
 (0)