本文整理汇总了Python中cortex_m.CortexM类的典型用法代码示例。如果您正苦于以下问题:Python CortexM类的具体用法?Python CortexM怎么用?Python CortexM使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CortexM类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: resetStopOnReset
def resetStopOnReset(self, software_reset=False):
if self.ignoreReset:
return
# Set core up to run some code in RAM that is guaranteed to be valid
# since FLASH could be corrupted and that is what user is trying to fix.
self.writeMemory(0x10000000, 0x10087ff0) # Initial SP
self.writeMemory(0x10000004, 0x1000000d) # Reset Handler
self.writeMemory(0x10000008, 0x1000000d) # Hard Fault Handler
self.writeMemory(0x1000000c, 0xe7fee7fe) # Infinite loop
self.writeMemory(0x40043100, 0x10000000) # Shadow 0x0 to RAM
# Always use software reset for LPC4330 since the hardware version
# will reset the DAP.
CortexM.resetStopOnReset(self, True)
# Map shadow memory to SPIFI FLASH
self.writeMemory(0x40043100, 0x80000000)
# The LPC4330 flash init routine can be used to remount FLASH.
self.ignoreReset = True
self.flash.init()
self.ignoreReset = False
# Set SP and PC based on interrupt vector in SPIFI_FLASH
sp = self.readMemory(0x14000000)
pc = self.readMemory(0x14000004)
self.writeCoreRegisterRaw('sp', sp)
self.writeCoreRegisterRaw('pc', pc)
示例2: init
def init(self):
logging.debug('stm32l486 init')
CortexM.init(self)
self.writeMemory(DBGMCU_CR, DBGMCU_VAL)
self.writeMemory(DBGMCU_APB1_CR1, DBGMCU_APB1_VAL1)
self.writeMemory(DBGMCU_APB1_CR2, DBGMCU_APB1_VAL2)
self.writeMemory(DBGMCU_APB2_CR, DBGMCU_APB2_VAL)
示例3: init
def init(self):
CortexM.init(self, False)
# check for flash security
val = self.transport.readAP(MDM_IDR)
if val != 0x001c0020:
logging.error("KL25Z: bad flash ID")
val = self.transport.readAP(MDM_STATUS)
if (val & (1 << 2)):
logging.warning("KL25Z secure state: will try to unlock")
self.transport.assertReset(True)
while True:
self.transport.writeAP(MDM_CTRL, 1)
val = self.transport.readAP(MDM_STATUS)
logging.info(val)
if (val & 1):
break
while True:
self.transport.writeAP(MDM_CTRL, 0)
val = self.transport.readAP(MDM_CTRL)
if (val == 0):
break
logging.info("KL25Z not in secure state")
self.halt()
self.setupFPB()
示例4: init
def init(self):
logging.debug('stm32f051 init')
CortexM.init(self)
enclock = self.readMemory(RCC_APB2ENR_CR)
enclock |= RCC_APB2ENR_DBGMCU
self.writeMemory(RCC_APB2ENR_CR, enclock);
self.writeMemory(DBGMCU_APB1_CR, DBGMCU_APB1_VAL);
self.writeMemory(DBGMCU_APB2_CR, DBGMCU_APB2_VAL);
示例5: resetStopOnReset
def resetStopOnReset(self, software_reset = None, map_to_user = True):
CortexM.resetStopOnReset(self, software_reset)
# Remap to use flash and set SP and SP accordingly
if map_to_user:
self.writeMemory(0x40048000, 0x2, 32)
sp = self.readMemory(0x0)
pc = self.readMemory(0x4)
self.writeCoreRegisterRaw('sp', sp)
self.writeCoreRegisterRaw('pc', pc)
示例6: resetStopOnReset
def resetStopOnReset(self, software_reset=False, map_to_user=True):
CortexM.resetStopOnReset(self)
# Remap to use flash and set SP and SP accordingly
if map_to_user:
self.writeMemory(0x400FC040, 1)
sp = self.readMemory(0x0)
pc = self.readMemory(0x4)
self.writeCoreRegisterRaw("sp", sp)
self.writeCoreRegisterRaw("pc", pc)
示例7: resetn
def resetn(self):
"""
reset a core. After a call to this function, the core
is running
"""
#Regular reset will kick NRF out of DBG mode
logging.debug("target_nrf52.reset: enable reset pin")
self.writeMemory(RESET, RESET_ENABLE)
#reset
logging.debug("target_nrf52.reset: trigger nRST pin")
CortexM.reset(self)
示例8: init
def init(self):
CortexM.init(self, False, False)
# check for flash security
val = self.transport.readAP(MDM_IDR)
if val != self.mdm_idr:
logging.error("%s: bad MDM-AP IDR (is 0x%08x, expected 0x%08x)", self.part_number, val, self.mdm_idr)
if self.isLocked():
logging.warning("%s in secure state: will try to unlock via mass erase", self.part_number)
# keep the target in reset until is had been erased and halted
self.transport.assertReset(True)
if not self.massErase():
self.transport.assertReset(False)
logging.error("%s: mass erase failed", self.part_number)
raise Exception("unable to unlock device")
# Use the MDM to keep the target halted after reset has been released
self.transport.writeAP(MDM_CTRL, MDM_CTRL_DEBUG_REQUEST)
# Enable debug
self.writeMemory(DHCSR, DBGKEY | C_DEBUGEN)
self.transport.assertReset(False)
while self.transport.readAP(MDM_STATUS) & MDM_STATUS_CORE_HALTED != MDM_STATUS_CORE_HALTED:
logging.debug("Waiting for mdm halt (erase)")
sleep(0.01)
# release MDM halt once it has taken effect in the DHCSR
self.transport.writeAP(MDM_CTRL, 0)
else:
logging.info("%s not in secure state", self.part_number)
# Prevent the target from resetting if it has invalid code
self.transport.writeAP(MDM_CTRL, MDM_CTRL_DEBUG_REQUEST | MDM_CTRL_CORE_HOLD_RESET)
while self.transport.readAP(MDM_CTRL) & (MDM_CTRL_DEBUG_REQUEST | MDM_CTRL_CORE_HOLD_RESET) != (MDM_CTRL_DEBUG_REQUEST | MDM_CTRL_CORE_HOLD_RESET):
self.transport.writeAP(MDM_CTRL, MDM_CTRL_DEBUG_REQUEST | MDM_CTRL_CORE_HOLD_RESET)
# Enable debug
self.writeMemory(DHCSR, DBGKEY | C_DEBUGEN)
# Disable holding the core in reset, leave MDM halt on
self.transport.writeAP(MDM_CTRL, MDM_CTRL_DEBUG_REQUEST)
# Wait until the target is halted
while self.transport.readAP(MDM_STATUS) & MDM_STATUS_CORE_HALTED != MDM_STATUS_CORE_HALTED:
logging.debug("Waiting for mdm halt")
sleep(0.01)
# release MDM halt once it has taken effect in the DHCSR
self.transport.writeAP(MDM_CTRL, 0)
# sanity check that the target is still halted
if self.getState() == TARGET_RUNNING:
raise Exception("Target failed to stay halted during init sequence")
self.setupFPB()
self.setupDWT()
self.readCoreType()
self.checkForFPU()
示例9: init
def init(self):
CortexM.init(self, False)
# check for flash security
val = self.transport.readAP(MDM_IDR)
if val != self.mdm_idr:
logging.error("%s: bad MDM-AP IDR (is 0x%08x, expected 0x%08x)", self.part_number, val, self.mdm_idr)
self.checkSecurity()
self.halt()
self.setupFPB()
self.readCoreType()
self.checkForFPU()
示例10: __init__
def __init__(self, transport):
CortexM.__init__(self, transport)
self.auto_increment_page_size = 0x1000
示例11: init
def init(self):
CortexM.init(self, initial_setup=True, bus_accessible=False)
# check MDM-AP ID
val = self.dap.readAP(MDM_IDR)
if val != self.mdm_idr:
logging.error("%s: bad MDM-AP IDR (is 0x%08x, expected 0x%08x)", self.part_number, val, self.mdm_idr)
# check for flash security
isLocked = self.isLocked()
if isLocked:
if self.do_auto_unlock:
logging.warning("%s in secure state: will try to unlock via mass erase", self.part_number)
# keep the target in reset until is had been erased and halted
self.link.assert_reset(True)
if not self.massErase():
self.link.assert_reset(False)
logging.error("%s: mass erase failed", self.part_number)
raise Exception("unable to unlock device")
# Use the MDM to keep the target halted after reset has been released
self.dap.writeAP(MDM_CTRL, MDM_CTRL_DEBUG_REQUEST)
# Enable debug
self.writeMemory(CortexM.DHCSR, CortexM.DBGKEY | CortexM.C_DEBUGEN)
self.link.assert_reset(False)
while self.dap.readAP(MDM_STATUS) & MDM_STATUS_CORE_HALTED != MDM_STATUS_CORE_HALTED:
logging.debug("Waiting for mdm halt (erase)")
sleep(0.01)
# release MDM halt once it has taken effect in the DHCSR
self.dap.writeAP(MDM_CTRL, 0)
isLocked = False
else:
logging.warning("%s in secure state: not automatically unlocking", self.part_number)
else:
logging.info("%s not in secure state", self.part_number)
# Can't do anything more if the target is secure
if isLocked:
return
if self.halt_on_connect:
# Prevent the target from resetting if it has invalid code
self.dap.writeAP(MDM_CTRL, MDM_CTRL_DEBUG_REQUEST | MDM_CTRL_CORE_HOLD_RESET)
while self.dap.readAP(MDM_CTRL) & (MDM_CTRL_DEBUG_REQUEST | MDM_CTRL_CORE_HOLD_RESET) != (MDM_CTRL_DEBUG_REQUEST | MDM_CTRL_CORE_HOLD_RESET):
self.dap.writeAP(MDM_CTRL, MDM_CTRL_DEBUG_REQUEST | MDM_CTRL_CORE_HOLD_RESET)
# Enable debug
self.writeMemory(CortexM.DHCSR, CortexM.DBGKEY | CortexM.C_DEBUGEN)
# Disable holding the core in reset, leave MDM halt on
self.dap.writeAP(MDM_CTRL, MDM_CTRL_DEBUG_REQUEST)
# Wait until the target is halted
while self.dap.readAP(MDM_STATUS) & MDM_STATUS_CORE_HALTED != MDM_STATUS_CORE_HALTED:
logging.debug("Waiting for mdm halt")
sleep(0.01)
# release MDM halt once it has taken effect in the DHCSR
self.dap.writeAP(MDM_CTRL, 0)
# sanity check that the target is still halted
if self.getState() == Target.TARGET_RUNNING:
raise Exception("Target failed to stay halted during init sequence")
CortexM.init(self, initial_setup=False, bus_accessible=True)
示例12: reset
def reset(self, software_reset=False):
# Always use software reset for LPC4330 since the hardware version
# will reset the DAP.
CortexM.reset(self, True)
示例13: reset
def reset(self, software_reset=False):
CortexM.reset(self, False)
示例14: init
def init(self):
logging.debug('stm32f103rc init')
CortexM.init(self)
self.writeMemory(DBGMCU_CR, DBGMCU_VAL);
示例15: resetStopOnReset
def resetStopOnReset(self):
# halt processor
self.halt()
# not remap 0x0000-0x0020 to anything but the flash
self.writeMemory(0x400FC040, 1)
CortexM.resetStopOnReset(self)