1414# See the License for the specific language governing permissions and
1515# limitations under the License.
1616
17+ from __future__ import annotations
18+
1719import logging
1820import yaml
1921import os
2325from pathlib import Path
2426from copy import deepcopy
2527from 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 )
2729from .flash_algo import PackFlashAlgo
2830from .reset_sequence_maps import (RESET_SEQUENCE_TO_TYPE_MAP , RESET_TYPE_TO_SEQUENCE_MAP )
2931from .. import (normalise_target_type_name , TARGET )
30- from ...coresight .cortex_m import CortexM
3132from ...coresight .coresight_target import CoreSightTarget
3233from ...coresight .ap import (APAddressBase , APv1Address , APv2Address )
3334from ...core import exceptions
3435from ...core .target import Target
3536from ...core .session import Session
36- from ...core .core_target import CoreTarget
3737from ...core .memory_map import (MemoryMap , MemoryType , MEMORY_TYPE_CLASS_MAP )
38- from ...utility .sequencer import CallSequence
3938from ...probe .debug_probe import DebugProbe
4039from ...debug .svd .loader import SVDFile
4140from ...debug .sequences .scope import Scope
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+
5358LOG = logging .getLogger (__name__ )
5459
5560class 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
277286class 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