Git Product home page Git Product logo

pydaplink's Introduction

pyDAPLink

pyDAPLink is an Open Source python 2.7 library for communicating with ARM Cortex-M microcontrollers through CMSIS-DAP over USB. Currently Linux, OSX, and Windows are supported.

For more information on CMSIS-DAP you can find the official standard:

Installation

To install the latest development version (master branch), you can do the following:

$ pip install --pre -U https://github.com/<user>/pyDAPLink/archive/master.zip
Note that you may run into permissions issues running these commands.
You have a few options here:
  1. Run with sudo -H to install pyDAPLink and dependencies globally
  2. Specify the --user option to install local to your user
  3. Run the command in a virtualenv local to a specific project working set.

You can also install from source by cloning the git repository and running

$ python setup.py install

Development Setup

PyDAPLink developers are recommended to setup a working environment using virtualenv. After cloning the code, you can setup a virtualenv and install the PyDAPLink dependencies for the current platform by doing the following:

$ virtualenv env
$ source env/bin/activate
$ pip install -r dev-requirements.txt

On Windows, the virtualenv would be activated by executing env\Scripts\activate.

Examples

For a more in depth example you can look into pyDAPLink's usage in pyOCD:
https://github.com/<user>/pyOCD

Hello World example program

from pyDAPLink import DAPLink
from pyDAPLink import AP_REG, DP_REG

# Some device specific definitions are needed
MBED_VID = 0x0d28
MBED_PID = 0x0204
CORTEXM_DHCSR = 0xE000EDF0
CORTEXM_DCRSR = 0xE000EDF4
CORTEXM_DCRDR = 0xE000EDF8
DBG_KEY = 0xA05F0000
DBG_ENABLE = 0x1
DBG_HALT = 0x2

# Find all connected devices
interfaces = DAPLink.getConnectedInterfaces(MBED_VID, MBED_PID)

for interface in interfaces:
    # Create a CMSIS-DAP connection
    dap = DAPLink(interface)
    dap.init()

    # Read ID code
    print 'ID: 0x%08x' % dap.readAP(AP_REG['IDR'])

    # Halt a Cortex-M
    dap.writeMem(CORTEXM_DHCSR, DBG_KEY | DBG_ENABLE | DBG_HALT)

    # Read a Cortex-M's PC
    dap.writeMem(CORTEXM_DCRSR, 15)
    print 'PC: 0x%08x' % dap.readMem(CORTEXM_DCRDR)

    dap.uninit()

pydaplink's People

Contributors

0xc0170 avatar c1728p9 avatar geky avatar ecnu3d avatar flit avatar bogdanm avatar adamgreen avatar emilmont avatar posborne avatar anpilog avatar wjzhang avatar xiongyihui avatar tkuyucu-nordicsemi avatar jeremybrodt avatar sg- avatar ynsta avatar kaizen8501 avatar stephenpaulger avatar oliviermartin avatar kevinmehall avatar janekm avatar chriswilliamson avatar donmorr avatar mindw avatar hugovincent avatar joeye-arm avatar kevin-gillespie avatar matthewelse avatar bremoran avatar blackstoneengineering avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.