Skip to content

Python wrapper around the nrfjprog dynamic link library (DLL)

License

Notifications You must be signed in to change notification settings

LeHack/pynrfjprog

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status PyPI

pynrfjprog

Python wrapper around the nrfjprog dynamic link library (DLL). Use of this API allows developers to program/debug nRF5 devices from the interpreter, write simple scripts for a more efficient development work flow, or write automated test frameworks. It can also be used to create applications in Python (i.e. command-line tools).

Use-cases

Dependencies

"""
Detailed below is how our software is stacked. Each layer depends on the layer below.
"""
pynrfjprog  # Imports and wraps the nrfjprog DLL in Python.
nrfjprogdll # A DLL that wraps SEGGER's JLink API for nRF5 devices.
JLinkARMDLL # A DLL provided by SEGGER that works with SEGGER debuggers. Performs all low level operations with target device.
  • J-Link Software and Documentation Pack will install the JLink libraries pynrfjprog depends on in the correct installation directory.
  • The nrfjprog libraries are installed with pynrfjprog and are included in pynrfjprog/OPERATING_SYSTEM/.

Structure

pynrfjprog\
  # LICENSE, README.md, setup.py and requirements.txt (used to install this module).
  pynrfjprog\
    __init__.py # Package marker to make pynrfjprog a module. Also defines the version number.
    API.py # Wrapper around the nrfjprog DLL.
    MultiAPI.py # Allow multiple devices (up to 128) to be programmed simultaneously.
    JLink.py # Finds the JLinkARM DLL required by pynrfjprog.
    Hex.py # DEPRECATED. Use [intelhex](https://pypi.python.org/pypi/IntelHex) instead.
      win_dll\ # nrfjprog libraries.
      osx_dylib\
      linux_64bit_so\
      linux_32bit_so\
      docs\ # Header files of the nrfjprog DLL to provide in-depth documentation of the functions API.py wraps.

Getting started

To install latest release from PyPI:

pip install pynrfjprog

To install from source navigate to pynrfjprog:

python setup.py install

Open the Python interpreter and connect nRF5 device to PC:

from pynrfjprog import API

api = API.API('NRF52')
api.open()
api.enum_emu_snr()
api.connect_to_emu_without_snr()
api.erase_all()
api.write_u32(ADDRESS, DATA, IS_FLASH)
api.disconnect_from_emu()
api.close()

To work with multiple nRF5 devices at once:

import MultiAPI as API

api = API.API('NRF52')
api.open()

api2 = API.API('NRF52')
api2.open()

api3 = API.API('NRF51')
api3.open()

api.close()
api2.close()
api3.close()

Note: MultiAPI has the same interface as API, it just allows you to create multiple instances of API.

Contributing

Contributing is encouraged along with the following coding standards.

About

Python wrapper around the nrfjprog dynamic link library (DLL)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 81.2%
  • Python 18.8%