Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for the NM180110 #1725

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions pyocd/board/board_ids.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,4 +318,5 @@ class BoardInfo(NamedTuple):
"C004": BoardInfo( "tinyK20", "k20d50m", "l1_k20d50m.bin", ),
"C006": BoardInfo( "VBLUno51", "nrf51", "l1_nrf51.bin", ),
"D000": BoardInfo( "NM180410", "ama3b1kk_kbr", "l1_ama3b1kk_kbr.bin", ),
"D001": BoardInfo( "NM180411", "ama3b2kk_kbr", "l1_ama3b2kk_kbr.bin", ),
}
51,620 changes: 51,620 additions & 0 deletions pyocd/debug/svd/data/apollo3p.svd

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions pyocd/target/builtin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
from . import target_Air001
from . import target_Air32F103xx
from . import target_AMA3B1KK
from . import target_AMA3B2KK

## @brief Dictionary of all builtin targets.
#
Expand Down Expand Up @@ -320,4 +321,5 @@
'air32f103xe': target_Air32F103xx.Air32F103xE,
'air32f103xg': target_Air32F103xx.Air32F103xG,
'ama3b1kk_kbr': target_AMA3B1KK.AMA3B1KK_KBR,
'ama3b2kk_kbr': target_AMA3B2KK.AMA3B2KK_KBR,
}
182 changes: 182 additions & 0 deletions pyocd/target/builtin/target_AMA3B2KK.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
# pyOCD debugger
# Copyright (c) 2024 Northern Mechatronics, Inc.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import logging

from ...core import exceptions
from ...core.memory_map import (FlashRegion, RamRegion, MemoryMap)
from ...coresight.coresight_target import CoreSightTarget
from ...debug.svd.loader import SVDFile
from ..family.target_ama3b import AMA3BFamily

LOG = logging.getLogger(__name__)

FLASH_ALGO = {
'load_address' : 0x10000000,

# Flash algorithm as a hex string
'instructions': [
0xe7fdbe00,
0x2040f04f, 0x61812147, 0x61412100, 0x46086181, 0x20004770, 0xb5704770, 0x4e374d36, 0x444d2406,
0x686b4622, 0x46302100, 0xb9404798, 0x2c401c64, 0x2401d3f6, 0x4621682a, 0x47904630, 0x2001b108,
0x1c64bd70, 0xd3f52c04, 0xbd702000, 0x0cc1b510, 0x3245f3c0, 0xd8082903, 0xd8062a3f, 0x44484825,
0x48256843, 0x28004798, 0x2001d000, 0xe92dbd10, 0x460747f0, 0x07884616, 0x2001d000, 0x0491eb00,
0x8070f8df, 0x0006ea47, 0xa06cf8df, 0x44c80780, 0xe023d11f, 0x7f00f5b4, 0x00a5d201, 0xf44fe001,
0x49166500, 0x44492000, 0xf816e004, 0xf8012b01, 0x1c402b01, 0xd3f842a8, 0xf8d84910, 0x08abc008,
0x0203f027, 0x46504449, 0xb98047e0, 0x0495eba4, 0x2c00442f, 0x2000d1de, 0x87f0e8bd, 0x5008f8d8,
0x463a4623, 0x46504631, 0x280047a8, 0x2001d0f4, 0x0000e7f2, 0x00000004, 0x12344321, 0x00000024,
0x00000000, 0x0800004d, 0x08000051, 0x08000055, 0x08000059, 0x0800005d, 0x08000061, 0x08000065,
0x08000069, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000
],

# Relative function addresses
'pc_init': 0x10000005,
'pc_unInit': 0x10000017,
'pc_program_page': 0x10000073,
'pc_erase_sector': 0x10000051,
'pc_eraseAll': 0x1000001b,

'static_base' : 0x10000000 + 0x00000004 + 0x00000100,
'begin_stack' : 0x10005930,
'end_stack' : 0x10004930,
'begin_data' : 0x10000000 + 0x1000,
'page_size' : 0x2000,
'analyzer_supported' : False,
'analyzer_address' : 0x00000000,
# Enable double buffering
'page_buffers' : [
0x10000930,
0x10002930
],
'min_program_length' : 0x2000,

# Relative region addresses and sizes
'ro_start': 0x4,
'ro_size': 0x100,
'rw_start': 0x104,
'rw_size': 0x24,
'zi_start': 0x128,
'zi_size': 0x800,

# Flash information
'flash_start': 0xc000,
'flash_size': 0x1f4000,
'sector_sizes': (
(0x0, 0x2000),
)

}

class AMA3B2KK_KBR(CoreSightTarget):

VENDOR = "Ambiq Micro"

MEMORY_MAP = MemoryMap(
FlashRegion(name='flash', start=0x0000C000, length=0x001F4000, access='rx',
page_size=0x2000,
sector_size=0x2000,
is_boot_memory=True,
algo=FLASH_ALGO),

RamRegion( name='sram', start=0x10000000, length=0x000C0000, access='rwx')
)

CortexM_Core = AMA3BFamily

def __init__(self, link):
super().__init__(link, self.MEMORY_MAP)
self._svd_location = SVDFile.from_builtin("apollo3p.svd")

def create_init_sequence(self):
seq = super().create_init_sequence()
seq.wrap_task('discovery',
lambda seq: seq.replace_task('create_cores', self.create_cores)
)
return seq

def create_cores(self):
try:
core = self.CortexM_Core(self.session, self.aps[0], self.memory_map, 0)
core.default_reset_type = self.ResetType.SW_SYSRESETREQ
self.aps[0].core = core
core.init()
self.add_core(core)
except exceptions.Error:
LOG.error("No Apollo3 Plus Core found")
27 changes: 27 additions & 0 deletions pyocd/target/family/target_ama3b.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@
# limitations under the License.

import logging
from time import sleep

from ...coresight.cortex_m import CortexM
from ...utility.timeout import Timeout
from ...core.target import Target

LOG = logging.getLogger(__name__)

Expand Down Expand Up @@ -51,3 +54,27 @@ def set_reset_catch(self, reset_type=None):
else:
LOG.debug("normal_set_reset_catch")
super().set_reset_catch(reset_type)

def reset_and_halt(self, reset_type=None):
# Save CortexM.DEMCR
demcr = self.read_memory(CortexM.DEMCR)

# Clear the reset vector catch and make sure DWT and ITM blocks are enabled.
self.write32(CortexM.DEMCR, (demcr & ~CortexM.DEMCR_VC_CORERESET) | CortexM.DEMCR_TRCENA)

super().reset_and_halt(reset_type)

# restore reset vector catch setting
self.write_memory(CortexM.DEMCR, demcr)

def reset(self, reset_type=None):
# Save CortexM.DEMCR
demcr = self.read_memory(CortexM.DEMCR)

# Clear the reset vector catch and make sure DWT and ITM blocks are enabled.
self.write32(CortexM.DEMCR, (demcr & ~CortexM.DEMCR_VC_CORERESET) | CortexM.DEMCR_TRCENA)

super().reset(reset_type)

# restore reset vector catch setting
self.write_memory(CortexM.DEMCR, demcr)
Binary file added test/data/binaries/l1_ama3b2kk_kbr.bin
Binary file not shown.
Loading