示例#1
0
 def init(self, frequency = 1000000):
     # connect to DAP, check for SWD or JTAG
     self.mode = dapConnect(self.interface)
     # set clock frequency
     dapSWJClock(self.interface, frequency)
     # configure transfer
     dapTransferConfigure(self.interface)
     if (self.mode == DAP_MODE_SWD):
         # configure swd protocol
         dapSWDConfigure(self.interface)
         # switch from jtag to swd
         JTAG2SWD(self.interface)
         # read ID code
         logging.info('IDCODE: 0x%X', self.readDP(DP_REG['IDCODE']))
         # clear errors
         dapWriteAbort(self.interface, 0x1e);
     elif (self.mode == DAP_MODE_JTAG):
         # configure jtag protocol
         dapJTAGConfigure(self.interface, 4)
         # Test logic reset, run test idle
         dapSWJSequence(self.interface, [0x1F])
         # read ID code
         logging.info('IDCODE: 0x%X', dapJTAGIDCode(self.interface))
         # clear errors
         self.writeDP(DP_REG['CTRL_STAT'], CTRLSTAT_STICKYERR | CTRLSTAT_STICKYCMP | CTRLSTAT_STICKYORUN)
     return
示例#2
0
 def init(self, frequency=1000000):
     # connect to DAP, check for SWD or JTAG
     self.mode = dapConnect(self.interface)
     # set clock frequency
     dapSWJClock(self.interface, frequency)
     # configure transfer
     dapTransferConfigure(self.interface)
     if (self.mode == DAP_MODE_SWD):
         # configure swd protocol
         dapSWDConfigure(self.interface)
         # switch from jtag to swd
         JTAG2SWD(self.interface)
         # read ID code
         logging.info('IDCODE: 0x%X', self.readDP(DP_REG['IDCODE']))
         # clear errors
         dapWriteAbort(self.interface, 0x1e)
     elif (self.mode == DAP_MODE_JTAG):
         # configure jtag protocol
         dapJTAGConfigure(self.interface, 4)
         # Test logic reset, run test idle
         dapSWJSequence(self.interface, [0x1F])
         # read ID code
         logging.info('IDCODE: 0x%X', dapJTAGIDCode(self.interface))
         # clear errors
         self.writeDP(
             DP_REG['CTRL_STAT'],
             CTRLSTAT_STICKYERR | CTRLSTAT_STICKYCMP | CTRLSTAT_STICKYORUN)
     return
示例#3
0
def JTAG2SWD(interface):
    data = [0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff]
    dapSWJSequence(interface, data)

    data = [0x9e, 0xe7]
    dapSWJSequence(interface, data)

    data = [0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff]
    dapSWJSequence(interface, data)

    data = [0x00]
    dapSWJSequence(interface, data)
示例#4
0
def JTAG2SWD(interface):
    data = [0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff]
    dapSWJSequence(interface, data)

    data = [0x9e, 0xe7]
    dapSWJSequence(interface, data)

    data = [0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff]
    dapSWJSequence(interface, data)

    data = [0x00]
    dapSWJSequence(interface, data)
示例#5
0
def JTAG2SWD(interface):
    data = [0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF]
    dapSWJSequence(interface, data)

    data = [0x9E, 0xE7]
    dapSWJSequence(interface, data)

    data = [0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF]
    dapSWJSequence(interface, data)

    data = [0x00]
    dapSWJSequence(interface, data)