Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions docs/target_support.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ In addition, because pyOCD dynamically inspects the target's debug infrastructur
debug functionality is enabled for any target that correctly implement the CoreSight architecture.


## Cortex-M42 identifier placeholders

Cortex-M42 support is prepared using the STAR-MC3 CPUID and CoreSight identifiers
as temporary placeholders. Replace the marked constants in `core_ids.py` and
`component_ids.py` when the Cortex-M42 identifiers are confirmed. Shared IDs
continue to display STAR-MC3 and select its existing component factories; they
cannot distinguish the two processors. This preparation does not add a device
memory map or flash algorithm.

## Target types

When pyOCD connects to a device, it needs to know what type of device (target) it is controlling.
Expand Down
16 changes: 15 additions & 1 deletion pyocd/coresight/component_ids.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# pyOCD debugger
# Copyright (c) 2015-2021 Arm Limited
# Copyright (c) 2015-2026 Arm Limited
# Copyright (c) 2021 Chris Reed
# Copyright (c) 2025 Arm Technology (China) Co. Ltd.
# SPDX-License-Identifier: Apache-2.0
Expand Down Expand Up @@ -45,6 +45,10 @@
# [6:0] ID
ARM_ID = 0x43b
ARM_CHINA_ID = 0xa75
# TODO: replace these Cortex-M42 placeholders with confirmed CoreSight IDs.
CORTEX_M42_DESIGNER = ARM_CHINA_ID
CORTEX_M42_PART = 0xd25 # STAR-MC3

FSL_ID = 0x00e
STM_ID = 0x020

Expand Down Expand Up @@ -273,3 +277,13 @@ class CmpInfo(NamedTuple):
(ARM_CHINA_ID, CORESIGHT_CLASS, 0xd25, 0x13, 0x4a13) : CmpInfo('ETM', 'Star-MC3', None ),
}


# Cortex-M42 reuses the STAR-MC3 components. Keep the original product names
# on ID collisions until the placeholder designer and part are confirmed.
CORTEX_M42_COMPONENT_MAP = {
(CORTEX_M42_DESIGNER, cls, CORTEX_M42_PART, devtype, archid): info._replace(product='Cortex-M42')
for (designer, cls, part, devtype, archid), info in COMPONENT_MAP.items()
if designer == ARM_CHINA_ID and part == 0xd25
}
for key, info in CORTEX_M42_COMPONENT_MAP.items():
COMPONENT_MAP.setdefault(key, info)
10 changes: 9 additions & 1 deletion pyocd/coresight/core_ids.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# pyOCD debugger
# Copyright (c) 2019-2020 Arm Limited
# Copyright (c) 2019-2026 Arm Limited
# Copyright (c) 2022 Chris Reed
# Copyright (c) 2025 Arm Technology (China) Co. Ltd.
# SPDX-License-Identifier: Apache-2.0
Expand Down Expand Up @@ -42,6 +42,11 @@
ARM_CortexM85 = 0xD23
ARM_China_StarMC1 = 0x132
ARM_China_StarMC3 = 0xD25

# TODO: replace these Cortex-M42 placeholders with confirmed CPUID values.
# Until then, use STAR-MC3 and preserve its name for the shared identifier.
CPUID_CORTEX_M42 = CPUID_ARM_CHINA
ARM_CortexM42 = ARM_China_StarMC3
# pylint: enable=invalid_name

## @brief User-friendly names for core types.
Expand All @@ -64,6 +69,9 @@
(CPUID_ARM_CHINA, ARM_China_StarMC3): "Star-MC3",
}

# Do not relabel STAR-MC3 while the Cortex-M42 identifiers are placeholders.
CORE_TYPE_NAME.setdefault((CPUID_CORTEX_M42, ARM_CortexM42), "Cortex-M42")

class CoreArchitecture(Enum):
"""@brief CPU architectures."""
ARMv6M = 1
Expand Down
21 changes: 20 additions & 1 deletion test/unit/test_rom_table.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# pyOCD debugger
# Copyright (c) 2019-2020,2026 Arm Limited
# Copyright (c) 2019-2026 Arm Limited
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -381,3 +381,22 @@ def test_c9_rom(self, c9_top_rom):
assert ahb.part == 0x9e3
assert ahb.archid == 0xa17


def test_cortex_m42_placeholder_ids_preserve_starmc3_detection():
from pyocd.coresight.core_ids import (
ARM_CortexM42, ARM_China_StarMC3, CPUID_CORTEX_M42, CPUID_ARM_CHINA, CORE_TYPE_NAME,
)
from pyocd.coresight.component_ids import (
ARM_CHINA_ID, CORTEX_M42_COMPONENT_MAP, CORTEX_M42_DESIGNER, CORTEX_M42_PART, COMPONENT_MAP,
)

assert (CPUID_CORTEX_M42, ARM_CortexM42) == (CPUID_ARM_CHINA, ARM_China_StarMC3)
assert CORE_TYPE_NAME[(CPUID_CORTEX_M42, ARM_CortexM42)] == 'Star-MC3'
assert (CORTEX_M42_DESIGNER, CORTEX_M42_PART) == (ARM_CHINA_ID, 0xd25)
assert len(CORTEX_M42_COMPONENT_MAP) == 9
for key, candidate in CORTEX_M42_COMPONENT_MAP.items():
existing = COMPONENT_MAP[key]
assert existing.product == 'Star-MC3'
assert candidate.product == 'Cortex-M42'
assert candidate.name == existing.name
assert candidate.factory == existing.factory