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

Add support for NM180410 #1632

Merged
merged 1 commit into from
Oct 19, 2023
Merged
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 @@ -317,4 +317,5 @@ class BoardInfo(NamedTuple):
"9906": BoardInfo( "micro:bit v2", "nrf52833", "microbitv2.bin", ),
"C004": BoardInfo( "tinyK20", "k20d50m", "l1_k20d50m.bin", ),
"C006": BoardInfo( "VBLUno51", "nrf51", "l1_nrf51.bin", ),
"D000": BoardInfo( "NM180410", "ama3b1kk_kbr", "l1_ama3b1kk_kbr.bin", ),
}
45,505 changes: 45,505 additions & 0 deletions pyocd/debug/svd/data/apollo3.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 @@ -136,6 +136,7 @@
from . import target_STM32H7B0xx
from . import target_Air001
from . import target_Air32F103xx
from . import target_AMA3B1KK

## @brief Dictionary of all builtin targets.
#
Expand Down Expand Up @@ -316,4 +317,5 @@
'air32f103xp': target_Air32F103xx.Air32F103xP,
'air32f103xe': target_Air32F103xx.Air32F103xE,
'air32f103xg': target_Air32F103xx.Air32F103xG,
'ama3b1kk_kbr': target_AMA3B1KK.AMA3B1KK_KBR,
}
167 changes: 167 additions & 0 deletions pyocd/target/builtin/target_AMA3B1KK.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
# pyOCD debugger
# Copyright (c) 2023 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': [
0xE00ABE00, 0x062D780D, 0x24084068, 0xD3000040, 0x1E644058, 0x1C49D1FA, 0x2A001E52, 0x4770D1F2,
0x2040f04f, 0x61812147, 0x61412100, 0x46086181, 0x20004770, 0xe92d4770, 0x4e3341f0, 0x4f332500,
0x444e2406, 0x68734622, 0x46382100, 0x43054798, 0x2c401c64, 0x6832dbf6, 0x46382101, 0x43284790,
0x81f0e8bd, 0x0cc1b510, 0x2101d000, 0x444a4a26, 0xf3c06853, 0x48253245, 0x28004798, 0x2001d000,
0xe92dbd10, 0x460747f0, 0x07884616, 0x2001d000, 0x0491eb00, 0x8070f8df, 0x0006ea47, 0xa06cf8df,
0x44c80780, 0x2000d025, 0xf5b4e01f, 0xd2017f00, 0xe00100a5, 0x6500f44f, 0x20004915, 0xe0044449,
0x2b01f816, 0x2b01f801, 0x42a81c40, 0x4910d3f8, 0xc008f8d8, 0xf02708ab, 0x44490203, 0x47e04650,
0xd1042800, 0x0495eba4, 0x2c00442f, 0xe8bdd1dd, 0xf8d887f0, 0x46235008, 0x4631463a, 0x46ac4650,
0x47f0e8bd, 0x00004760, 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': 0x10000021,
'pc_unInit': 0x10000033,
'pc_program_page': 0x10000083,
'pc_erase_sector': 0x10000065,
'pc_eraseAll': 0x10000037,

'static_base' : 0x10000000 + 0x00000020 + 0x000000F4,
'begin_stack' : 0x10000400,
'begin_data' : 0x10000000 + 0x1000,
'page_size' : 0x2000,
'analyzer_supported' : False,
'analyzer_address' : 0x00000000,
'page_buffers' : [0x10001000, 0x10003000], # Enable double buffering
'min_program_length' : 0x2000,

# Flash information
'flash_start': 0xC000,
'flash_size': 0xF4000,
'sector_sizes': (
(0x0, 0x2000),
)
}

class AMA3B1KK_KBR(CoreSightTarget):

VENDOR = "Ambiq Micro"

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

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

CortexM_Core = AMA3BFamily

def __init__(self, link):
super().__init__(link, self.MEMORY_MAP)
self._svd_location = SVDFile.from_builtin("apollo3.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 Core found")
53 changes: 53 additions & 0 deletions pyocd/target/family/target_ama3b.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# pyOCD debugger
# Copyright (c) 2023 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 ...coresight.cortex_m import CortexM

LOG = logging.getLogger(__name__)

class AMA3BFamily(CortexM):
REG_MCU_CTRL_BOOTLOADER = 0x400201A0
REG_MCU_CTRL_SCRATCH0 = 0x400201B0

def set_reset_catch(self, reset_type=None):
# If Debugger Support is disabled by the SDBG bit in INFO0_SECURITY,
# The least significant bit of register REG_MCU_CTRL_SCRATCH0 must be
# set to indicate that a halt is requested by the debugger after
# primary boot.
#
# Refer to document A-SOCA3B-UGGA02EN for more details.

# Check the REG_MCU_CTRL_BOOTLOADER register to see if secure boot
# is enabled for:
# bit 31:30 warm reset
# bit 29:28 cold reset
# bit 27:26 secure boot feature enabled
secure_boot = False
reg_bootloader = self.read_memory(self.REG_MCU_CTRL_BOOTLOADER)
if (reg_bootloader & 0xFC000000):
secure_boot = True
LOG.debug("AMA3B Secure Boot: %x" % secure_boot)

if(secure_boot is True):
# Modify only the least significant bit and preserve the scratch
# register as it could be used by the application firmware.
reg_scratch0 = self.read_memory(self.REG_MCU_CTRL_SCRATCH0) | 0x01
self.write_memory(self.REG_MCU_CTRL_SCRATCH0, reg_scratch0)
else:
LOG.debug("normal_set_reset_catch")
super().set_reset_catch(reset_type)
Binary file added test/data/binaries/l1_ama3b1kk_kbr.bin
Binary file not shown.
Loading