pynrfjprog


Namepynrfjprog JSON
Version 10.24.0 PyPI version JSON
download
home_page
SummaryA simple Python interface for the nrfjprog functionality
upload_time2024-01-30 12:17:46
maintainer
docs_urlNone
author
requires_python>=3.7
licenseCopyright (c) 2010 - 2024, Nordic Semiconductor ASA All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form, except as embedded into a Nordic Semiconductor ASA integrated circuit in a product or a software update for such product, must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of Nordic Semiconductor ASA nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 4. This software, with or without modification, must only be used with a Nordic Semiconductor ASA integrated circuit. 5. Any software provided in binary form under this license must not be reverse engineered, decompiled, modified and/or disassembled. THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
keywords nrfjprog pynrfjprog
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage No coveralls.
            [![PyPI](https://img.shields.io/static/v1?label=license&message=Nordic%205-Clause%20License&color=brightgreen)](https://github.com/NordicSemiconductor/pynrfjprog/blob/master/LICENSE)
![PyPI](https://img.shields.io/static/v1?label=platform&message=windows%20%7C%20linux%20%7C%20osx&color=lightgrey)
![PyPI](https://img.shields.io/static/v1?label=python&message=>=3.7&color=blue) [![PyPI](https://img.shields.io/pypi/v/pynrfjprog)](https://pypi.org/project/pynrfjprog/)

# pynrfjprog
Python wrapper around the nrfjprog dynamic link libraries (DLL). Use of this API allows developers to program/debug nRF SOC and SIP 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
*  Maximizing development efficiency: i.e. a script to perform various operations every time an application is built and run (could be hooked into a Makefile or automated build system etc...).
*  Automated testing: [Testing Production Programming tools on nRF5 using pynrfjprog](https://github.com/NordicSemiconductor/nrf52-production-programming/blob/master/tests/example_test_script.py).

## Dependencies
```python
"""
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](https://www.segger.com/jlink-software.html) 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
pynrfjprog
  ├── pynrfjprog
  │     ├──__init__.py    # Package marker to make pynrfjprog a module. Also defines the version number
  │     ├── API.py        # Legacy name of LowLevel.py. It's kept for backward support
  │     ├── APIError.py   # Wrapper for the error return codes of the DLL
  │     ├── Hex.py        # Hex parsing library
  │     ├── HighLevel.py  # Wrapper for the nrfjprog highlevel DLL
  │     ├── JLink.py      # Finds the JLinkARM DLL required by pynrfjprog
  │     ├── LowLevel.py   # Wrapper for the nrfjprog DLL, previously API.py
  │     ├── MultiAPI.py   # Allow multiple devices (up to 128) to be programmed simultaneously with a LowLevel API
  │     ├── lib_armhf
  │     │   └── # armhf nrfjprog libraries
  │     ├── lib_x64
  │     │   └── # 64-bit nrfjprog libraries
  │     ├── lib_x86
  │     │   └── # 32-bit nrfjprog libraries
  │     ├── docs
  │     │   └── # Header files of the nrfjprog DLL to provide in-depth documentation of the functions that are wrapped
  │     └── examples
  │         └── # Example scripts to show off the different APIs
  ├── LICENSE
  ├── README.md
  ├── requirements.txt
  └── pyproject.toml
  
  
    
```

## Getting started
To install the latest release from PyPI:
```
pip install pynrfjprog
```
To install from source:
```
python -m pip install path_to_unzipped_pynrfjprog
```
Open the Python interpreter and connect nRF device to PC:
```
from pynrfjprog import LowLevel

with LowLevel.API('NRF52') as api:
    api.enum_emu_snr()
    api.connect_to_emu_without_snr()
    api.erase_all()
    api.write_u32(ADDRESS, DATA, IS_FLASH)
    api.disconnect_from_emu()
```

To work with multiple nRF devices at once:
```
import LowLevel

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

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

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

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

To program hex files using the HighLevel API:
```
from pynrfjprog import HighLevel

with HighLevel.API() as api:
    snrs = api.get_connected_probes()

    # To program J-Link probe at snr <snr>:
    with HighLevel.DebugProbe(api, <snr>) as probe:
        probe.program(<hex_file>)

    # To program MCUBoot target at serial port <serial>:
    with HighLevel.MCUBootDFUProbe(api, <serial>) as probe:
        probe.program(<hex_file>)

    # To update LTE modem connected to J-Link probe at snr <snr>:
    with HighLevel.IPCDFUProbe(api, <snr>, HighLevel.CoProcessor.CP_MODEM) as probe:
        probe.program(<zip_file>, HighLevel.ProgramOptions(verify = HighLevel.VerifyAction.VERIFY_HASH))
```
Note: Only one HighLevel API can be instantiated and opened at a time. Several HighLevel probes can be opened from the same API at the same time.

## Contributing
Contributing is encouraged along with the following coding standards.
* [Google Python Style Guide](https://google.github.io/styleguide/pyguide.html)
* http://www.clifford.at/style.html
* [Semantic versioning](http://semver.org/)

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "pynrfjprog",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "nrfjprog,pynrfjprog",
    "author": "",
    "author_email": "Nordic Semiconductor ASA <sagtools@nordicsemi.no>",
    "download_url": "https://files.pythonhosted.org/packages/97/c0/88f210a47fec6cc6ed348c427dfb3ccc276be91dafd9ef100b2c4d8d68bd/pynrfjprog-10.24.0.tar.gz",
    "platform": null,
    "description": "[![PyPI](https://img.shields.io/static/v1?label=license&message=Nordic%205-Clause%20License&color=brightgreen)](https://github.com/NordicSemiconductor/pynrfjprog/blob/master/LICENSE)\n![PyPI](https://img.shields.io/static/v1?label=platform&message=windows%20%7C%20linux%20%7C%20osx&color=lightgrey)\n![PyPI](https://img.shields.io/static/v1?label=python&message=>=3.7&color=blue) [![PyPI](https://img.shields.io/pypi/v/pynrfjprog)](https://pypi.org/project/pynrfjprog/)\n\n# pynrfjprog\nPython wrapper around the nrfjprog dynamic link libraries (DLL). Use of this API allows developers to program/debug nRF SOC and SIP 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).\n\n## Use-cases\n*  Maximizing development efficiency: i.e. a script to perform various operations every time an application is built and run (could be hooked into a Makefile or automated build system etc...).\n*  Automated testing: [Testing Production Programming tools on nRF5 using pynrfjprog](https://github.com/NordicSemiconductor/nrf52-production-programming/blob/master/tests/example_test_script.py).\n\n## Dependencies\n```python\n\"\"\"\nDetailed below is how our software is stacked. Each layer depends on the layer below.\n\"\"\"\npynrfjprog  # Imports and wraps the nrfjprog DLL in Python.\nnrfjprogdll # A DLL that wraps SEGGER's JLink API for nRF5 devices.\nJLinkARMDLL # A DLL provided by SEGGER that works with SEGGER debuggers. Performs all low level operations with target device.\n```\n\n* [J-Link Software and Documentation Pack](https://www.segger.com/jlink-software.html) will install the JLink libraries pynrfjprog depends on in the correct installation directory.\n* The nrfjprog libraries are installed with pynrfjprog and are included in pynrfjprog/OPERATING_SYSTEM/.\n\n## Structure\n```pynrfjprog\npynrfjprog\n  \u251c\u2500\u2500 pynrfjprog\n  \u2502     \u251c\u2500\u2500__init__.py    # Package marker to make pynrfjprog a module. Also defines the version number\n  \u2502     \u251c\u2500\u2500 API.py        # Legacy name of LowLevel.py. It's kept for backward support\n  \u2502     \u251c\u2500\u2500 APIError.py   # Wrapper for the error return codes of the DLL\n  \u2502     \u251c\u2500\u2500 Hex.py        # Hex parsing library\n  \u2502     \u251c\u2500\u2500 HighLevel.py  # Wrapper for the nrfjprog highlevel DLL\n  \u2502     \u251c\u2500\u2500 JLink.py      # Finds the JLinkARM DLL required by pynrfjprog\n  \u2502     \u251c\u2500\u2500 LowLevel.py   # Wrapper for the nrfjprog DLL, previously API.py\n  \u2502     \u251c\u2500\u2500 MultiAPI.py   # Allow multiple devices (up to 128) to be programmed simultaneously with a LowLevel API\n  \u2502     \u251c\u2500\u2500 lib_armhf\n  \u2502     \u2502   \u2514\u2500\u2500 # armhf nrfjprog libraries\n  \u2502     \u251c\u2500\u2500 lib_x64\n  \u2502     \u2502   \u2514\u2500\u2500 # 64-bit nrfjprog libraries\n  \u2502     \u251c\u2500\u2500 lib_x86\n  \u2502     \u2502   \u2514\u2500\u2500 # 32-bit nrfjprog libraries\n  \u2502     \u251c\u2500\u2500 docs\n  \u2502     \u2502   \u2514\u2500\u2500 # Header files of the nrfjprog DLL to provide in-depth documentation of the functions that are wrapped\n  \u2502     \u2514\u2500\u2500 examples\n  \u2502         \u2514\u2500\u2500 # Example scripts to show off the different APIs\n  \u251c\u2500\u2500 LICENSE\n  \u251c\u2500\u2500 README.md\n  \u251c\u2500\u2500 requirements.txt\n  \u2514\u2500\u2500 pyproject.toml\n  \n  \n    \n```\n\n## Getting started\nTo install the latest release from PyPI:\n```\npip install pynrfjprog\n```\nTo install from source:\n```\npython -m pip install path_to_unzipped_pynrfjprog\n```\nOpen the Python interpreter and connect nRF device to PC:\n```\nfrom pynrfjprog import LowLevel\n\nwith LowLevel.API('NRF52') as api:\n    api.enum_emu_snr()\n    api.connect_to_emu_without_snr()\n    api.erase_all()\n    api.write_u32(ADDRESS, DATA, IS_FLASH)\n    api.disconnect_from_emu()\n```\n\nTo work with multiple nRF devices at once:\n```\nimport LowLevel\n\napi = LowLevel.API('NRF52')\napi.open()\n\napi2 = LowLevel.API('NRF52')\napi2.open()\n\napi3 = LowLevel.API('NRF51')\napi3.open()\n\napi.close()\napi2.close()\napi3.close()\n```\n\nTo program hex files using the HighLevel API:\n```\nfrom pynrfjprog import HighLevel\n\nwith HighLevel.API() as api:\n    snrs = api.get_connected_probes()\n\n    # To program J-Link probe at snr <snr>:\n    with HighLevel.DebugProbe(api, <snr>) as probe:\n        probe.program(<hex_file>)\n\n    # To program MCUBoot target at serial port <serial>:\n    with HighLevel.MCUBootDFUProbe(api, <serial>) as probe:\n        probe.program(<hex_file>)\n\n    # To update LTE modem connected to J-Link probe at snr <snr>:\n    with HighLevel.IPCDFUProbe(api, <snr>, HighLevel.CoProcessor.CP_MODEM) as probe:\n        probe.program(<zip_file>, HighLevel.ProgramOptions(verify = HighLevel.VerifyAction.VERIFY_HASH))\n```\nNote: Only one HighLevel API can be instantiated and opened at a time. Several HighLevel probes can be opened from the same API at the same time.\n\n## Contributing\nContributing is encouraged along with the following coding standards.\n* [Google Python Style Guide](https://google.github.io/styleguide/pyguide.html)\n* http://www.clifford.at/style.html\n* [Semantic versioning](http://semver.org/)\n",
    "bugtrack_url": null,
    "license": "Copyright (c) 2010 - 2024, Nordic Semiconductor ASA All rights reserved.  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.  2. Redistributions in binary form, except as embedded into a Nordic Semiconductor ASA integrated circuit in a product or a software update for such product, must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.  3. Neither the name of Nordic Semiconductor ASA nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.  4. This software, with or without modification, must only be used with a Nordic Semiconductor ASA integrated circuit.  5. Any software provided in binary form under this license must not be reverse engineered, decompiled, modified and/or disassembled.  THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ",
    "summary": "A simple Python interface for the nrfjprog functionality",
    "version": "10.24.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/NordicSemiconductor/pynrfjprog/issues",
        "Homepage": "https://www.nordicsemi.com/Products/Development-tools/nrf-pynrfjprog/"
    },
    "split_keywords": [
        "nrfjprog",
        "pynrfjprog"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "97c088f210a47fec6cc6ed348c427dfb3ccc276be91dafd9ef100b2c4d8d68bd",
                "md5": "0539b0ccb23614e6e630c6935c1d298d",
                "sha256": "9cd116aab565e6e90f9a46a6e7a16800cf07e7fe36d407cc53d99cfdcc56c7df"
            },
            "downloads": -1,
            "filename": "pynrfjprog-10.24.0.tar.gz",
            "has_sig": false,
            "md5_digest": "0539b0ccb23614e6e630c6935c1d298d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 46585190,
            "upload_time": "2024-01-30T12:17:46",
            "upload_time_iso_8601": "2024-01-30T12:17:46.053729Z",
            "url": "https://files.pythonhosted.org/packages/97/c0/88f210a47fec6cc6ed348c427dfb3ccc276be91dafd9ef100b2c4d8d68bd/pynrfjprog-10.24.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-30 12:17:46",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "NordicSemiconductor",
    "github_project": "pynrfjprog",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": false,
    "lcname": "pynrfjprog"
}
        
Elapsed time: 0.21261s