├── .gitignore ├── .travis.yml ├── LICENSE ├── MANIFEST.in ├── PKG-INFO ├── README.md ├── pynrfjprog ├── API.py ├── APIError.py ├── Hex.py ├── HighLevel.py ├── JLink.py ├── LowLevel.py ├── MultiAPI.py ├── Parameters.py ├── QspiDefault.ini ├── RTTAsyncIO.py ├── __init__.py ├── config.toml ├── docs │ ├── __init__.py │ ├── highlevelnrfjprogdll.h │ ├── nrfdfu.h │ ├── nrfjprog_release_notes.txt │ └── nrfjprogdll.h ├── examples │ ├── __init__.py │ ├── hex_files │ │ ├── __init__.py │ │ ├── nrf51_dk_blinky.hex │ │ ├── nrf51_dk_rtt.hex │ │ ├── nrf52840_dk_blinky.hex │ │ ├── nrf52_dk_blinky.hex │ │ ├── nrf52_dk_rtt.hex │ │ ├── nrf53_dk_blinky.hex │ │ ├── nrf53_dk_rtt.hex │ │ ├── nrf9160_pca20035_firmware_upgrade_app_0.1.0.hex │ │ ├── nrf91_dk_blinky.hex │ │ └── nrf91_dk_rtt.hex │ ├── highlevel_memory_read_write.py │ ├── highlevel_program_hex.py │ ├── memory_read_write.py │ ├── nrf9160_pca20035_modem_upgrade_over_serial.py │ ├── program_hex.py │ ├── python_help.py │ ├── rtt_asyncio.py │ ├── rtt_callback.py │ └── rtt_synchronous.py ├── lib_arm64 │ ├── __init__.py │ ├── jlinkarm_nrf_worker_linux │ ├── libhighlevelnrfjprog.so │ ├── libnrfdfu.so │ └── libnrfjprogdll.so ├── lib_armhf │ ├── __init__.py │ ├── jlinkarm_nrf_worker_linux │ ├── libhighlevelnrfjprog.so │ ├── libnrfdfu.so │ └── libnrfjprogdll.so ├── lib_x64 │ ├── __init__.py │ ├── highlevelnrfjprog.dll │ ├── jlinkarm_nrf_worker.exe │ ├── jlinkarm_nrf_worker_linux │ ├── jlinkarm_nrf_worker_osx │ ├── libhighlevelnrfjprog.dylib │ ├── libhighlevelnrfjprog.so │ ├── libnrfdfu.dylib │ ├── libnrfdfu.so │ ├── libnrfjprogdll.dylib │ ├── libnrfjprogdll.so │ ├── nrfdfu.dll │ └── nrfjprog.dll └── lib_x86 │ └── __init__.py ├── pyproject.toml └── setup.cfg /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # Distribution / packaging 7 | .Python 8 | env/ 9 | build/ 10 | develop-eggs/ 11 | dist/ 12 | downloads/ 13 | eggs/ 14 | .eggs/ 15 | lib/ 16 | lib64/ 17 | parts/ 18 | sdist/ 19 | var/ 20 | *.egg-info/ 21 | .installed.cfg 22 | *.egg 23 | 24 | # PyInstaller 25 | # Usually these files are written by a python script from a template 26 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 27 | *.manifest 28 | *.spec 29 | 30 | # Installer logs 31 | pip-log.txt 32 | pip-delete-this-directory.txt 33 | 34 | # Unit test / coverage reports 35 | htmlcov/ 36 | .tox/ 37 | .coverage 38 | .coverage.* 39 | .cache 40 | nosetests.xml 41 | coverage.xml 42 | *,cover 43 | .hypothesis/ 44 | 45 | # Translations 46 | *.mo 47 | *.pot 48 | 49 | # Django stuff: 50 | *.log 51 | 52 | # Sphinx documentation 53 | docs/_build/ 54 | 55 | # PyBuilder 56 | target/ 57 | 58 | #Ipython Notebook 59 | .ipynb_checkpoints 60 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | python: 3 | - "2.7" 4 | - "3.4" 5 | - "3.5" 6 | - "3.5-dev" # 3.5 development branch 7 | - "nightly" # currently points to 3.6-dev 8 | # command to install dependencies 9 | install: 10 | - "pip install -r requirements.txt" 11 | - "python setup.py install" 12 | # command to run tests 13 | script: python tests/ci_tests.py 14 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2010 - 2024, Nordic Semiconductor ASA 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | 1. Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | 2. Redistributions in binary form, except as embedded into a Nordic 11 | Semiconductor ASA integrated circuit in a product or a software update for 12 | such product, must reproduce the above copyright notice, this list of 13 | conditions and the following disclaimer in the documentation and/or other 14 | materials provided with the distribution. 15 | 16 | 3. Neither the name of Nordic Semiconductor ASA nor the names of its 17 | contributors may be used to endorse or promote products derived from this 18 | software without specific prior written permission. 19 | 20 | 4. This software, with or without modification, must only be used with a 21 | Nordic Semiconductor ASA integrated circuit. 22 | 23 | 5. Any software provided in binary form under this license must not be reverse 24 | engineered, decompiled, modified and/or disassembled. 25 | 26 | THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS 27 | OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 28 | OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE 29 | DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE 30 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 31 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 32 | GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 35 | OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 36 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include MANIFEST.in 2 | include README.md 3 | include LICENSE 4 | include pynrfjprog/docs/*.h 5 | include pynrfjprog/docs/nrfjprog_release_notes*.txt 6 | include pynrfjprog/config.toml 7 | include pynrfjprog/QspiDefault.ini 8 | recursive-include pynrfjprog/lib_* *.dll 9 | recursive-include pynrfjprog/lib_* *.so* 10 | recursive-include pynrfjprog/lib_* *.dylib* 11 | recursive-include pynrfjprog/lib_* jlinkarm_nrf_worker* 12 | recursive-include pynrfjprog/examples/* * -------------------------------------------------------------------------------- /PKG-INFO: -------------------------------------------------------------------------------- 1 | Metadata-Version: 2.1 2 | Name: pynrfjprog 3 | Version: 10.24.2 4 | Summary: A simple Python interface for the nrfjprog functionality 5 | Author-email: Nordic Semiconductor ASA 6 | License: Copyright (c) 2010 - 2024, Nordic Semiconductor ASA 7 | All rights reserved. 8 | 9 | Redistribution and use in source and binary forms, with or without modification, 10 | are permitted provided that the following conditions are met: 11 | 12 | 1. Redistributions of source code must retain the above copyright notice, this 13 | list of conditions and the following disclaimer. 14 | 15 | 2. Redistributions in binary form, except as embedded into a Nordic 16 | Semiconductor ASA integrated circuit in a product or a software update for 17 | such product, must reproduce the above copyright notice, this list of 18 | conditions and the following disclaimer in the documentation and/or other 19 | materials provided with the distribution. 20 | 21 | 3. Neither the name of Nordic Semiconductor ASA nor the names of its 22 | contributors may be used to endorse or promote products derived from this 23 | software without specific prior written permission. 24 | 25 | 4. This software, with or without modification, must only be used with a 26 | Nordic Semiconductor ASA integrated circuit. 27 | 28 | 5. Any software provided in binary form under this license must not be reverse 29 | engineered, decompiled, modified and/or disassembled. 30 | 31 | THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS 32 | OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 33 | OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE 34 | DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE 35 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 36 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 37 | GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 38 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 39 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 40 | OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 41 | 42 | Project-URL: Homepage, https://www.nordicsemi.com/Products/Development-tools/nrf-pynrfjprog/ 43 | Project-URL: Bug Tracker, https://github.com/NordicSemiconductor/pynrfjprog/issues 44 | Keywords: nrfjprog,pynrfjprog 45 | Classifier: Development Status :: 5 - Production/Stable 46 | Classifier: Intended Audience :: Developers 47 | Classifier: Operating System :: MacOS 48 | Classifier: Operating System :: Microsoft :: Windows 49 | Classifier: Operating System :: POSIX :: Linux 50 | Classifier: Topic :: Software Development :: Build Tools 51 | Classifier: Topic :: Software Development :: Debuggers 52 | Classifier: Topic :: Software Development :: Embedded Systems 53 | Classifier: Programming Language :: Python :: 3.7 54 | Classifier: Programming Language :: Python :: 3.8 55 | Classifier: Programming Language :: Python :: 3.9 56 | Classifier: Programming Language :: Python :: 3.10 57 | Classifier: Programming Language :: Python :: 3.11 58 | Classifier: License :: Other/Proprietary License 59 | Requires-Python: >=3.7 60 | Description-Content-Type: text/markdown 61 | License-File: LICENSE 62 | Requires-Dist: future 63 | Requires-Dist: tomli-w 64 | 65 | [![PyPI](https://img.shields.io/static/v1?label=license&message=Nordic%205-Clause%20License&color=brightgreen)](https://github.com/NordicSemiconductor/pynrfjprog/blob/master/LICENSE) 66 | ![PyPI](https://img.shields.io/static/v1?label=platform&message=windows%20%7C%20linux%20%7C%20osx&color=lightgrey) 67 | ![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/) 68 | 69 | # pynrfjprog 70 | 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). 71 | 72 | ## Use-cases 73 | * 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...). 74 | * Automated testing: [Testing Production Programming tools on nRF5 using pynrfjprog](https://github.com/NordicSemiconductor/nrf52-production-programming/blob/master/tests/example_test_script.py). 75 | 76 | ## Dependencies 77 | * [SEGGER JLink DLL] (https://www.segger.com/jlink-software.html) 78 | * (Windows-only) [Microsoft Visual C++ Redistributable] (https://learn.microsoft.com/en-US/cpp/windows/latest-supported-vc-redist) 79 | 80 | ## Structure 81 | ```pynrfjprog 82 | pynrfjprog 83 | ├── pynrfjprog 84 | │ ├──__init__.py # Package marker to make pynrfjprog a module. Also defines the version number 85 | │ ├── API.py # (Deprecated; included only for backwards compatibility) Alias for LowLevel.py 86 | │ ├── APIError.py # Wrapper for the error return codes of the DLL 87 | │ ├── Hex.py # (Deprecated; included only for backwards compatibility) Hex parsing library 88 | │ ├── HighLevel.py # (Deprecated; included only for backwards compatibility) Wrapper for the nrfjprog highlevel DLL 89 | │ ├── JLink.py # (Deprecated; included only for backwards compatibility) Finds the JLinkARM DLL 90 | │ ├── LowLevel.py # Wrapper for the nrfjprog DLL, previously API.py 91 | │ ├── MultiAPI.py # Allow multiple devices (up to 128) to be programmed simultaneously with a LowLevel API 92 | │ ├── lib_armhf 93 | │ │ └── # armhf nrfjprog libraries 94 | │ ├── lib_x64 95 | │ │ └── # 64-bit nrfjprog libraries 96 | │ ├── lib_x86 97 | │ │ └── # 32-bit nrfjprog libraries 98 | │ ├── docs 99 | │ │ └── # Header files of the nrfjprog DLL to provide in-depth documentation of the functions that are wrapped 100 | │ └── examples 101 | │ └── # Example scripts to show off the different APIs 102 | ├── LICENSE 103 | ├── README.md 104 | ├── requirements.txt 105 | └── pyproject.toml 106 | ``` 107 | 108 | ## Getting started 109 | To install the latest release from PyPI: 110 | ``` 111 | python -m pip install pynrfjprog 112 | ``` 113 | To install from source: 114 | ``` 115 | python -m pip install path_to_unzipped_pynrfjprog 116 | ``` 117 | Open the Python interpreter and connect nRF device to PC: 118 | ``` 119 | from pynrfjprog import LowLevel 120 | 121 | with LowLevel.API('NRF52') as api: 122 | api.enum_emu_snr() 123 | api.connect_to_emu_without_snr() 124 | api.erase_all() 125 | api.write_u32(ADDRESS, DATA, IS_FLASH) 126 | api.disconnect_from_emu() 127 | ``` 128 | 129 | To work with multiple nRF devices at once: 130 | ``` 131 | import LowLevel 132 | 133 | api = LowLevel.API('NRF52') 134 | api.open() 135 | 136 | api2 = LowLevel.API('NRF52') 137 | api2.open() 138 | 139 | api3 = LowLevel.API('NRF52') 140 | api3.open() 141 | 142 | api.close() 143 | api2.close() 144 | api3.close() 145 | ``` 146 | 147 | To program firmware into the devices: 148 | ``` 149 | from pynrfjprog import LowLevel 150 | 151 | with LowLevel.API() as api: 152 | api.program_file() 153 | 154 | # Optional 155 | api.verify_file() 156 | ``` 157 | 158 | ## Contributing 159 | Contributing is encouraged along with the following coding standards. 160 | * [Google Python Style Guide](https://google.github.io/styleguide/pyguide.html) 161 | * http://www.clifford.at/style.html 162 | * [Semantic versioning](http://semver.org/) 163 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![PyPI](https://img.shields.io/static/v1?label=license&message=Nordic%205-Clause%20License&color=brightgreen)](https://github.com/NordicSemiconductor/pynrfjprog/blob/master/LICENSE) 2 | ![PyPI](https://img.shields.io/static/v1?label=platform&message=windows%20%7C%20linux%20%7C%20osx&color=lightgrey) 3 | ![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/) 4 | 5 | # pynrfjprog 6 | 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). 7 | 8 | ## Use-cases 9 | * 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...). 10 | * Automated testing: [Testing Production Programming tools on nRF5 using pynrfjprog](https://github.com/NordicSemiconductor/nrf52-production-programming/blob/master/tests/example_test_script.py). 11 | 12 | ## Dependencies 13 | * [SEGGER JLink DLL] (https://www.segger.com/jlink-software.html) 14 | * (Windows-only) [Microsoft Visual C++ Redistributable] (https://learn.microsoft.com/en-US/cpp/windows/latest-supported-vc-redist) 15 | 16 | ## Structure 17 | ```pynrfjprog 18 | pynrfjprog 19 | ├── pynrfjprog 20 | │ ├──__init__.py # Package marker to make pynrfjprog a module. Also defines the version number 21 | │ ├── API.py # (Deprecated; included only for backwards compatibility) Alias for LowLevel.py 22 | │ ├── APIError.py # Wrapper for the error return codes of the DLL 23 | │ ├── Hex.py # (Deprecated; included only for backwards compatibility) Hex parsing library 24 | │ ├── HighLevel.py # (Deprecated; included only for backwards compatibility) Wrapper for the nrfjprog highlevel DLL 25 | │ ├── JLink.py # (Deprecated; included only for backwards compatibility) Finds the JLinkARM DLL 26 | │ ├── LowLevel.py # Wrapper for the nrfjprog DLL, previously API.py 27 | │ ├── MultiAPI.py # Allow multiple devices (up to 128) to be programmed simultaneously with a LowLevel API 28 | │ ├── lib_armhf 29 | │ │ └── # armhf nrfjprog libraries 30 | │ ├── lib_x64 31 | │ │ └── # 64-bit nrfjprog libraries 32 | │ ├── lib_x86 33 | │ │ └── # 32-bit nrfjprog libraries 34 | │ ├── docs 35 | │ │ └── # Header files of the nrfjprog DLL to provide in-depth documentation of the functions that are wrapped 36 | │ └── examples 37 | │ └── # Example scripts to show off the different APIs 38 | ├── LICENSE 39 | ├── README.md 40 | ├── requirements.txt 41 | └── pyproject.toml 42 | ``` 43 | 44 | ## Getting started 45 | To install the latest release from PyPI: 46 | ``` 47 | python -m pip install pynrfjprog 48 | ``` 49 | To install from source: 50 | ``` 51 | python -m pip install path_to_unzipped_pynrfjprog 52 | ``` 53 | Open the Python interpreter and connect nRF device to PC: 54 | ``` 55 | from pynrfjprog import LowLevel 56 | 57 | with LowLevel.API('NRF52') as api: 58 | api.enum_emu_snr() 59 | api.connect_to_emu_without_snr() 60 | api.erase_all() 61 | api.write_u32(ADDRESS, DATA, IS_FLASH) 62 | api.disconnect_from_emu() 63 | ``` 64 | 65 | To work with multiple nRF devices at once: 66 | ``` 67 | import LowLevel 68 | 69 | api = LowLevel.API('NRF52') 70 | api.open() 71 | 72 | api2 = LowLevel.API('NRF52') 73 | api2.open() 74 | 75 | api3 = LowLevel.API('NRF52') 76 | api3.open() 77 | 78 | api.close() 79 | api2.close() 80 | api3.close() 81 | ``` 82 | 83 | To program firmware into the devices: 84 | ``` 85 | from pynrfjprog import LowLevel 86 | 87 | with LowLevel.API() as api: 88 | api.program_file() 89 | 90 | # Optional 91 | api.verify_file() 92 | ``` 93 | 94 | ## Contributing 95 | Contributing is encouraged along with the following coding standards. 96 | * [Google Python Style Guide](https://google.github.io/styleguide/pyguide.html) 97 | * http://www.clifford.at/style.html 98 | * [Semantic versioning](http://semver.org/) 99 | -------------------------------------------------------------------------------- /pynrfjprog/API.py: -------------------------------------------------------------------------------- 1 | import warnings 2 | 3 | try: 4 | from .LowLevel import API 5 | from .APIError import * 6 | from .Parameters import * 7 | from . import JLink 8 | except Exception: 9 | import LowLevel.API as API 10 | from APIError import * 11 | from Parameters import * 12 | import JLink 13 | 14 | warnings.warn("This module is deprecated; use LowLevel.py instead.", PendingDeprecationWarning) 15 | 16 | -------------------------------------------------------------------------------- /pynrfjprog/APIError.py: -------------------------------------------------------------------------------- 1 | import enum 2 | 3 | try: 4 | from . import Parameters 5 | except Exception: 6 | import Parameters 7 | 8 | 9 | @enum.unique 10 | class NrfjprogdllErr(enum.IntEnum): 11 | """ 12 | Wraps nrfjprogdll_err_t values from DllCommonDefinitions.h 13 | 14 | """ 15 | SUCCESS = 0 16 | 17 | OUT_OF_MEMORY = -1 18 | INVALID_OPERATION = -2 19 | INVALID_PARAMETER = -3 20 | INVALID_DEVICE_FOR_OPERATION = -4 21 | WRONG_FAMILY_FOR_DEVICE = -5 22 | UNKNOWN_DEVICE = -6 23 | INVALID_SESSION = -7 24 | 25 | EMULATOR_NOT_CONNECTED = -10 26 | CANNOT_CONNECT = -11 27 | LOW_VOLTAGE = -12 28 | NO_EMULATOR_CONNECTED = -13 29 | 30 | NVMC_ERROR = -20 31 | RECOVER_FAILED = -21 32 | 33 | 34 | NOT_AVAILABLE_BECAUSE_PROTECTION = -90 35 | NOT_AVAILABLE_BECAUSE_MPU_CONFIG = -91 36 | NOT_AVAILABLE_BECAUSE_COPROCESSOR_DISABLED = -92 37 | NOT_AVAILABLE_BECAUSE_TRUST_ZONE = -93 38 | NOT_AVAILABLE_BECAUSE_BPROT = -94 39 | 40 | JLINKARM_DLL_NOT_FOUND = -100 41 | JLINKARM_DLL_COULD_NOT_BE_OPENED = -101 42 | JLINKARM_DLL_ERROR = -102 43 | JLINKARM_DLL_TOO_OLD = -103 44 | JLINKARM_DLL_READ_ERROR = -104 45 | JLINKARM_DLL_TIME_OUT_ERROR = -105 46 | 47 | SERIAL_PORT_NOT_FOUND = -110 48 | SERIAL_PORT_PERMISSION_ERROR = -111 49 | SERIAL_PORT_WRITE_ERROR = -112 50 | SERIAL_PORT_READ_ERROR = -113 51 | SERIAL_PORT_RESOURCE_ERROR = -114 52 | SERIAL_PORT_NOT_OPEN_ERROR = -115 53 | 54 | NRFJPROG_SUB_DLL_NOT_FOUND = -150 55 | NRFJPROG_SUB_DLL_COULD_NOT_BE_OPENED = -151 56 | NRFJPROG_SUB_DLL_COULD_NOT_LOAD_FUNCTIONS = -152 57 | NRFJPROG_HOST_EXE_NOT_FOUND = -153 58 | 59 | VERIFY_ERROR = -160 60 | RAM_IS_OFF_ERROR = -161 61 | 62 | FILE_OPERATION_FAILED = -162 63 | FILE_PARSING_ERROR = -170 64 | FILE_UNKNOWN_FORMAT_ERROR = -171 65 | FILE_INVALID_ERROR = -172 66 | UNKNOWN_MEMORY_ERROR = -173 67 | CONFIG_TYPE_ERROR = -174 68 | CONFIG_SYNTAX_ERROR = -175 69 | CONFIG_PROPERTY_MISSING_ERROR = -176 70 | 71 | PYTHON_ALREADY_INSTANTIATED_ERROR = -200 72 | 73 | TIME_OUT = -220 74 | DFU_ERROR = -221 75 | 76 | INTERNAL_ERROR = -254 77 | NOT_IMPLEMENTED_ERROR = -255 78 | 79 | class APIError(Exception): 80 | """ 81 | pynrfjprog DLL exception class, inherits from the built-in Exception class. 82 | 83 | """ 84 | 85 | def __init__(self, err_code=None, err_msg="", log=None, error_data=None): 86 | """ 87 | Constructs a new object and sets the err_code. 88 | 89 | @param int err_code: The error code returned by the nrfjprog DLL. 90 | """ 91 | 92 | self.err_code = err_code 93 | self.err_msg = err_msg 94 | self.error_enum = NrfjprogdllErr(err_code) 95 | self.err_str = 'An error was reported by NRFJPROG DLL: {} {}. {}'.format(self.err_code, self.error_enum .name, err_msg).rstrip() 96 | 97 | if error_data: 98 | error_data = " \n" + ("\n\textra: ".join(error_data)) 99 | self.err_str += error_data 100 | 101 | Exception.__init__(self, self.err_str) 102 | 103 | if log is not None: 104 | log(self.err_str.encode('utf-8')) 105 | 106 | def __reduce__(self): 107 | return self.__class__, (self.err_code, self.err_msg, None, ) 108 | 109 | -------------------------------------------------------------------------------- /pynrfjprog/Hex.py: -------------------------------------------------------------------------------- 1 | """ 2 | Deprecated: This module will not be supported in the future and should not be used for new projects. 3 | We recommend using intelhex instead: https://pypi.python.org/pypi/IntelHex. 4 | """ 5 | 6 | from builtins import int 7 | import sys 8 | 9 | py2 = sys.version_info[0] == 2 10 | py3 = sys.version_info[0] == 3 11 | 12 | 13 | class Segment(object): 14 | """Memory segment for use with API.write() method.""" 15 | 16 | def __init__(self, addr, vals): 17 | self.address = addr 18 | self.data = vals 19 | self.length = len(vals) 20 | 21 | def append(self, vals): 22 | self.data.extend(vals) 23 | self.length += len(vals) 24 | 25 | 26 | class Hex(object): 27 | """Parsed hex file.""" 28 | 29 | def __init__(self, filename): 30 | 31 | self._segment_list = [] 32 | self._high_address = 0 33 | 34 | with open(filename, 'r', 1) as file: 35 | 36 | high_address_changed = False 37 | for line in file: 38 | 39 | record_data_length, record_address, record_type, record_data, record_checksum = self._intel_hex_recored_parse(line) 40 | if record_type == "extended_linear_address_record": 41 | self._high_address = record_data[0] * 0x1000000 + record_data[1] * 0x10000 42 | high_address_changed = True # Set this to true so that a new segment is added for the next line 43 | elif record_type == "extended_segment_address_record": 44 | self._high_address = ((record_data[0] << 8) | record_data[1]) * 16 45 | high_address_changed = True 46 | elif record_type == "data_record": 47 | # Check if segment_list is empty 48 | if (len(self._segment_list) == 0 or high_address_changed): 49 | self._segment_list.append(Segment(self._high_address + record_address, record_data)) 50 | high_address_changed = False # Set to false so next lines are check for appending 51 | else: 52 | # Check if data_record is the next address in current segment 53 | current_segment = self._segment_list[-1] 54 | record_full_address = self._high_address + record_address 55 | if ( ( current_segment.address + current_segment.length ) == record_full_address ) : 56 | # Append line to current segment 57 | current_segment.append(record_data) 58 | else: 59 | # Add new segment 60 | self._segment_list.append(Segment(self._high_address + record_address, record_data)) 61 | else: 62 | #implement more if desired or necessary 63 | pass 64 | 65 | def _intel_hex_recored_parse(self, line): 66 | 67 | record_data_length = int(line[1:3], 16) 68 | 69 | record_address = int(line[3:7], 16) 70 | 71 | if line[7:9] == '00': 72 | record_type = "data_record" 73 | elif line[7:9] == '02': 74 | record_type = "extended_segment_address_record" 75 | elif line[7:9] == '04': 76 | record_type = "extended_linear_address_record" 77 | else: 78 | # implement more if desired or necessary 79 | record_type = "other" 80 | 81 | record_data = [] 82 | for i in range(record_data_length): 83 | record_data.append(int(line[9+i*2:11+i*2], 16)) 84 | 85 | record_checksum = int(line[9+record_data_length*2:11+record_data_length*2], 16) 86 | 87 | return record_data_length, record_address, record_type, record_data, record_checksum 88 | 89 | 90 | def __iter__(self): 91 | self._iter_index = 0 92 | return self 93 | 94 | # Define __next__() method for iterables only if we are running under python 3. 95 | if py3: 96 | def __next__(self): 97 | 98 | if self._iter_index == len(self._segment_list): 99 | raise StopIteration 100 | 101 | self._iter_index = self._iter_index + 1 102 | return self._segment_list[self._iter_index - 1] 103 | 104 | # Define next() method for iterables only if we are running under python 2. 105 | if py2: 106 | def next(self): 107 | 108 | if self._iter_index == len(self._segment_list): 109 | raise StopIteration 110 | 111 | self._iter_index = self._iter_index + 1 112 | return self._segment_list[self._iter_index - 1] 113 | -------------------------------------------------------------------------------- /pynrfjprog/JLink.py: -------------------------------------------------------------------------------- 1 | """ 2 | This module provides some utility functions to locate a SEGGER JLINK dll. 3 | 4 | It is no longer used in LowLevel.API or MultiAPI.API, but maintained and tested in case it is still in use with third parties. 5 | The internal JLinkARM install search algorithm that is currently used internally in nRF shared libraries is exposed by 6 | the functions LowLevel.API.find_jlink(). 7 | 8 | These functions expect a standard OS installation and a default installation path for the SEGGER shared library. If these 9 | conditions are not met the absolute path of the SEGGER JLinkARM shared library must be provided when instantiating an 10 | API or MultiAPI object. 11 | """ 12 | 13 | try: 14 | from . import LowLevel 15 | except Exception: 16 | import LowLevel 17 | 18 | import warnings 19 | 20 | warnings.warn("JLink module will be deprecated in version 11, use LowLevel module instead.", PendingDeprecationWarning) 21 | 22 | 23 | def find_latest_dll(): 24 | return LowLevel.API().find_jlink_path() 25 | -------------------------------------------------------------------------------- /pynrfjprog/MultiAPI.py: -------------------------------------------------------------------------------- 1 | import warnings 2 | 3 | try: 4 | from . import LowLevel 5 | from .Parameters import * 6 | from . import APIError 7 | from . import JLink 8 | except Exception: 9 | import LowLevel 10 | from Parameters import * 11 | import APIError 12 | import JLink 13 | 14 | 15 | warnings.warn("MultiAPI module will be deprecated in version 11, use LowLevel module instead.", PendingDeprecationWarning) 16 | 17 | 18 | class MultiAPI(LowLevel.API): 19 | """ 20 | API class that allows multiple instantiations 21 | """ 22 | 23 | def __init__(self, device_family, jlink_arm_dll_path=None, log=False, log_str=None, log_file_path=None, api_lock_factory=None): 24 | self._terminated = False 25 | super(MultiAPI, self).__init__(device_family, jlink_arm_dll_path=jlink_arm_dll_path, log=log, log_str=log_str, log_file_path=log_file_path) 26 | 27 | def is_alive(self): 28 | """ Deprecated function, use is_open() instead. """ 29 | return not self._terminated 30 | 31 | def terminate(self): 32 | """ Deprecated function, use close() instead. """ 33 | self._terminated = True 34 | -------------------------------------------------------------------------------- /pynrfjprog/Parameters.py: -------------------------------------------------------------------------------- 1 | 2 | from __future__ import print_function 3 | 4 | import logging 5 | import time 6 | from builtins import int 7 | 8 | import enum 9 | import ctypes 10 | import codecs 11 | import sys 12 | import os 13 | import platform 14 | import ipaddress 15 | import datetime 16 | 17 | 18 | NRFJPROG_MAX_PATH = 260 19 | NRFJPROG_STRING_LENGTH = 256 20 | NRFJPROG_COM_PER_JLINK = 10 21 | NRFJPROG_INVALID_ADDRESS = 0xFFFFFFFF 22 | NRFJPROG_INVALID_RESET_PIN = 0xFFFFFFFF 23 | NRFJPROG_INVALID_EMU_SNR = 0xFFFFFFFF 24 | 25 | JLINKARM_SWD_MIN_SPEED_KHZ = 4 26 | JLINKARM_SWD_DEFAULT_SPEED_KHZ = 2000 27 | JLINKARM_SWD_MAX_SPEED_KHZ = 50000 28 | 29 | def find_lib_dir(): 30 | this_dir = os.path.dirname(__file__) 31 | 32 | os_name = sys.platform.lower() 33 | 34 | if platform.machine().startswith('arm') and not os_name.startswith('dar'): 35 | nrfjprog_dll_folder = 'lib_armhf' 36 | elif platform.machine().startswith('aarch') and not os_name.startswith('dar'): 37 | nrfjprog_dll_folder = 'lib_arm64' 38 | else: 39 | if sys.maxsize > 2**32: 40 | nrfjprog_dll_folder = 'lib_x64' 41 | else: 42 | nrfjprog_dll_folder = 'lib_x86' 43 | 44 | return os.path.abspath(os.path.join(this_dir, nrfjprog_dll_folder)) 45 | 46 | def decode_string(string): 47 | """This function ensures that string output from ctypes is normalized to the local string type.""" 48 | if sys.version_info[0] == 2 or isinstance(string, str): 49 | return string 50 | else: 51 | return string.decode('utf-8', errors='replace') 52 | 53 | 54 | ################################################################################### 55 | # # 56 | # Logger class # 57 | # # 58 | ################################################################################### 59 | 60 | 61 | class CallbackHandler(logging.Handler): 62 | def __init__(self, callback): 63 | super(CallbackHandler, self).__init__() 64 | self.callback = callback 65 | 66 | def emit(self, record): 67 | self.callback(record) 68 | 69 | 70 | class ErrorHandler(logging.Handler): 71 | def __init__(self): 72 | super(ErrorHandler, self).__init__() 73 | self.errors = list() 74 | self.setLevel(logging.ERROR) 75 | 76 | def emit(self, record): 77 | self.errors.append(record) 78 | 79 | 80 | class LoggerAdapter(logging.LoggerAdapter): 81 | def __init__(self, logger, id, log=None, log_str_cb=None, log_str=None, log_file_path=None, log_stringio=None): 82 | """ 83 | Setup API's debug output logging mechanism. 84 | 85 | """ 86 | super(LoggerAdapter, self).__init__(logger, {'id': id}) 87 | 88 | self.log_cb = None 89 | self.error_handler = ErrorHandler() 90 | self.logger.addHandler(self.error_handler) 91 | 92 | # Enable logging by default 93 | self.logger.disabled = False 94 | 95 | def log_filter(record): 96 | if self.extra['id'] is None: 97 | return False 98 | return self.extra['id'] == record.id 99 | 100 | handlers = [] 101 | 102 | if log_str_cb is not None: 103 | handlers.append(CallbackHandler(log_str_cb)) 104 | if log_stringio is not None: 105 | handlers.append(logging.StreamHandler(log_stringio)) 106 | if log_file_path is not None: 107 | handlers.append(logging.FileHandler(log_file_path)) 108 | 109 | if not log and not handlers: 110 | # No logging requested, disable log. 111 | self.logger.disabled = True 112 | 113 | if not self.logger.disabled: 114 | for handler in handlers: 115 | handler.setFormatter(logging.Formatter(logging.BASIC_FORMAT)) 116 | handler.addFilter(log_filter) 117 | self.logger.addHandler(handler) 118 | 119 | self.log_cb = ctypes.CFUNCTYPE(None, ctypes.c_char_p, ctypes.c_int, ctypes.c_char_p, ctypes.c_void_p)\ 120 | ( 121 | lambda logger_name, level, msg_str, instance: 122 | self.log_function(decode_string(logger_name).strip(), level, decode_string(msg_str).strip()) 123 | ) 124 | 125 | def set_id(self, id): 126 | self.extra['id'] = id 127 | 128 | def log_function(self, logger_name, level, msg_str): 129 | msg = f"[{logger_name}] {msg_str}" 130 | self.log(NrfjrpogdllLogLevel.get_level_from_value(level), msg) 131 | 132 | def process(self, msg, kwargs): 133 | msg, kwargs = super().process(msg, kwargs) 134 | if self.extra['id'] is not None: 135 | return '[%s] %s' % (self.extra['id'], msg), kwargs 136 | else: 137 | return msg, kwargs 138 | 139 | def get_errors(self): 140 | # Sleep 500 milliseconds so that any pending log messages can propagate to the logger. 141 | time.sleep(.5) 142 | formatter = logging.Formatter("%(message)s") 143 | return [formatter.format(record) for record in self.error_handler.errors] 144 | 145 | ################################################################################### 146 | # # 147 | # Low level data types # 148 | # # 149 | ################################################################################### 150 | 151 | # Helper functions for validating data types 152 | def is_pointer(value): 153 | return value is None or (isinstance(value, int) and ctypes.c_void_p(value).value == ctypes.size_t(value).value) 154 | 155 | def is_u32(value): 156 | return isinstance(value, int) and 0 <= value <= 0xFFFFFFFF 157 | 158 | 159 | def is_u16(value): 160 | return isinstance(value, int) and 0 <= value <= 0xFFFF 161 | 162 | 163 | def is_u8(value): 164 | return isinstance(value, int) and 0 <= value <= 0xFF 165 | 166 | 167 | def is_bool(value): 168 | return isinstance(value, bool) or 0 <= value <= 1 169 | 170 | 171 | def is_valid_buf(buf): 172 | if buf is None: 173 | return False 174 | for value in buf: 175 | if not is_u8(value): 176 | return False 177 | return len(buf) > 0 178 | 179 | 180 | def is_valid_encoding(encoding): 181 | try: 182 | codecs.lookup(encoding) 183 | except LookupError: 184 | return False 185 | else: 186 | return True 187 | 188 | 189 | def is_enum(param, enum_type): 190 | if isinstance(param, enum_type): 191 | return True 192 | if isinstance(param, int) and param in [member for name, member in enum_type.__members__.items()]: 193 | return True 194 | elif isinstance(param, str) and param in [name for name, member in enum_type.__members__.items()]: 195 | return True 196 | return False 197 | 198 | 199 | def is_right_class(instance, class_type): 200 | if instance is None: 201 | return False 202 | return isinstance(instance, class_type) 203 | 204 | 205 | def decode_enum(param, enum_type): 206 | if not is_enum(param, enum_type): 207 | return None 208 | 209 | if isinstance(param, int): 210 | return enum_type(param) 211 | elif isinstance(param, str): 212 | return enum_type[param] 213 | else: 214 | return param 215 | 216 | 217 | NRFJPROG_ENUM_INFO_IP_LEN = 16 218 | NRFJPROG_ENUM_INFO_IPV4_LEN = 4 219 | NRFJPROG_ENUM_INFO_MAC_LEN = 6 220 | NRFJPROG_ENUM_INFO_PROD_NAME_STR_LEN = 32 221 | NRFJPROG_ENUM_INFO_NICKNAME_STR_LEN = 32 222 | NRFJPROG_ENUM_INFO_FW_STR_LEN = 112 223 | 224 | 225 | @enum.unique 226 | class EMUConnection(enum.IntEnum): 227 | """ 228 | Wraps emu_connection_t values from DllCommonDefinitions.h 229 | 230 | """ 231 | USB = 1 232 | IP = 2 233 | 234 | 235 | class EMUConInfoStruct(ctypes.Structure): 236 | _fields_ = [("serial_number", ctypes.c_uint32), 237 | ("connection_type", ctypes.c_int), 238 | ("ip_addr", ctypes.c_uint8 * NRFJPROG_ENUM_INFO_IP_LEN), 239 | ("hardware_revision", ctypes.c_uint32), 240 | ("mac_addr", ctypes.c_uint8 * NRFJPROG_ENUM_INFO_MAC_LEN), 241 | ("product_name", ctypes.c_char * (NRFJPROG_ENUM_INFO_PROD_NAME_STR_LEN + 1)), 242 | ("nickname", ctypes.c_char * (NRFJPROG_ENUM_INFO_NICKNAME_STR_LEN + 1)), 243 | ("firmware_string", ctypes.c_char * (NRFJPROG_ENUM_INFO_FW_STR_LEN + 1)), 244 | ("num_ip_connections", ctypes.c_int8), 245 | ("_reserved", ctypes.c_uint32 * 8)] 246 | 247 | class EMUConInfo(object): 248 | """ 249 | Wraps emu_con_info_t struct from DllCommonDefinitions.h 250 | 251 | """ 252 | def __init__(self, emu_con_info): 253 | self.serial_number = emu_con_info.serial_number 254 | self.connection_type = EMUConnection(emu_con_info.connection_type) 255 | 256 | if self.connection_type == EMUConnection.IP: 257 | if self._is_ipv4(emu_con_info.ip_addr): 258 | self.ip_addr = ipaddress.ip_address('.'.join('{}'.format(x) for x in emu_con_info.ip_addr[:NRFJPROG_ENUM_INFO_IPV4_LEN])) 259 | else: 260 | self.ip_addr = ipaddress.ip_address(':'.join('{:02x}{:02x}'.format(x[0], x[1]) for x in zip(*[iter(emu_con_info.ip_addr)]*2))) 261 | self.hardware_revision = emu_con_info.hardware_revision 262 | self.mac_addr = ':'.join('{:02x}'.format(x) for x in emu_con_info.mac_addr) 263 | self.product_name = emu_con_info.product_name.decode("utf-8") 264 | self.nickname = emu_con_info.nickname.decode("utf-8") 265 | self.fw_string = emu_con_info.firmware_string.decode("utf-8") 266 | self.num_ip_connections = emu_con_info.num_ip_connections 267 | else: 268 | self.ip_addr = None 269 | self.hardware_revision = None 270 | self.mac_addr = None 271 | self.product_name = None 272 | self.nickname = None 273 | self.fw_string = None 274 | self.num_ip_connections = None 275 | 276 | @staticmethod 277 | def _is_ipv4(ipv4_bin_arr): 278 | # If all except first four bytes are 0, assume IPv4 279 | return sum(ipv4_bin_arr[NRFJPROG_ENUM_INFO_IPV4_LEN:]) == 0 280 | 281 | def __repr__(self): 282 | sep = "\n" 283 | result = f"Serial number: {self.serial_number}{sep}" + \ 284 | f"Connection type: {self.connection_type.name}" 285 | if self.connection_type == EMUConnection.IP: 286 | num_ip_connections_str = "N/A" if self.num_ip_connections < 0 else str(self.num_ip_connections) 287 | result += sep + \ 288 | f"IP address: {self.ip_addr}{sep}" + \ 289 | f"Hardware rev: {self.hardware_revision}{sep}" + \ 290 | f"MAC: {self.mac_addr}{sep}" + \ 291 | f"Product name: {self.product_name}{sep}" + \ 292 | f"Nickname: {self.nickname}{sep}" + \ 293 | f"Firmware: {self.fw_string}{sep}" + \ 294 | f"IP connections: {num_ip_connections_str}" 295 | return result 296 | 297 | 298 | @enum.unique 299 | class FileInputType(enum.IntEnum): 300 | """ 301 | Wraps file_input_type_t values from DllCommonDefinitions.h 302 | 303 | """ 304 | FILE_INPUT_PATH = 0, 305 | FILE_INPUT_BUFFER = 1 306 | 307 | 308 | @enum.unique 309 | class DeviceFamily(enum.IntEnum): 310 | """ 311 | Wraps device_family_t values from DllCommonDefinitions.h 312 | 313 | """ 314 | 315 | NRF51 = 0 316 | NRF52 = 1 317 | NRF53 = 53 318 | NRF54H = 544 319 | NRF54L = 541 320 | NRF91 = 91 321 | UNKNOWN = 99 322 | AUTO = 255 323 | 324 | 325 | class DeviceVersion(enum.IntEnum): 326 | """ 327 | Wraps device_version_t values from DllCommonDefinitions.h 328 | 329 | """ 330 | 331 | UNKNOWN = 0 332 | 333 | NRF51xxx_xxAA_REV1 = 1 334 | NRF51xxx_xxAA_REV2 = 2 335 | NRF51xxx_xxAA_REV3 = 3 336 | NRF51xxx_xxAB_REV3 = 4 337 | NRF51xxx_xxAC_REV3 = 5 338 | NRF51802_xxAA_REV3 = 6 339 | NRF51801_xxAB_REV3 = 17 340 | 341 | NRF52805_xxAA_REV1 = 0x05280500 342 | NRF52805_xxAA_REV2 = 0x05280501 343 | NRF52805_xxAA_FUTURE = 0x052805FF 344 | 345 | NRF52810_xxAA_REV1 = 13 346 | NRF52810_xxAA_REV2 = 0x05281001 347 | NRF52810_xxAA_REV3 = 0x05281002 348 | NRF52810_xxAA_FUTURE = 14 349 | 350 | NRF52811_xxAA_REV1 = 0x05281100 351 | NRF52811_xxAA_REV2 = 0x05281101 352 | NRF52811_xxAA_FUTURE = 0x052811FF 353 | 354 | NRF52820_xxAA_ENGB = 0x05282003 355 | NRF52820_xxAA_REV1 = 0x05282000 356 | NRF52820_xxAA_REV2 = 0x05282001 357 | NRF52820_xxAA_REV3 = 0x05282002 358 | NRF52820_xxAA_FUTURE = 0x052820FF 359 | 360 | NRF52832_xxAA_ENGA = 7 361 | NRF52832_xxAA_ENGB = 8 362 | NRF52832_xxAA_REV1 = 9 363 | NRF52832_xxAA_REV2 = 19 364 | NRF52832_xxAA_REV3 = 0x5283201 365 | NRF52832_xxAA_FUTURE = 11 366 | 367 | NRF52832_xxAB_REV1 = 15 368 | NRF52832_xxAB_REV2 = 20 369 | NRF52832_xxAB_REV3 = 0x5283211 370 | NRF52832_xxAB_FUTURE = 16 371 | 372 | NRF52833_xxAA_REV1 = 0x05283300 373 | NRF52833_xxAA_REV2 = 0x05283301 374 | NRF52833_xxAA_REV3 = 0x05283302 375 | NRF52833_xxAA_FUTURE = 0x052833FF 376 | 377 | 378 | NRF52840_xxAA_ENGA = 10 379 | NRF52840_xxAA_ENGB = 21 380 | NRF52840_xxAA_REV1 = 18 381 | NRF52840_xxAA_REV2 = 0x05284003 382 | NRF52840_xxAA_REV3 = 0x05284004 383 | NRF52840_xxAA_FUTURE = 12 384 | 385 | NRF5340_xxAA_ENGA = 0x05340000 386 | NRF5340_xxAA_ENGB = 0x05340001 387 | NRF5340_xxAA_ENGC = 0x05340002 388 | NRF5340_xxAA_REV1 = 0x05340003 389 | NRF5340_xxAA_ENGD = 0x05340003 390 | NRF5340_xxAA_FUTURE = 0x053400FF 391 | 392 | NRF54L15_xxAA_ENGA = 0x05414000 393 | NRF54L15_xxAA_FUTURE = 0x054140FF 394 | 395 | NRF54H20_xxAA_ENGA = 0x05442000 396 | NRF54H20_xxAA_FUTURE = 0x054420FF 397 | 398 | NRF9120_xxAA_REV3 = 0x09120002 399 | NRF9120_xxAA_FUTURE = 0x091200FF 400 | 401 | NRF9160_xxAA_REV1 = 0x09160000 402 | NRF9160_xxAA_REV2 = 0x09160001 403 | NRF9160_xxAA_FUTURE = 0x091600FF 404 | 405 | 406 | 407 | class DeviceName(enum.IntEnum): 408 | 409 | UNKNOWN_NAME = 0x0000000 410 | 411 | NRF51xxx = 0x05100000 412 | 413 | NRF51802 = 0x05180200 414 | NRF51801 = 0x05180100 415 | 416 | NRF52805 = 0x05280500 417 | NRF52810 = 0x05281000 418 | NRF52811 = 0x05281100 419 | NRF52820 = 0x05282000 420 | NRF52832 = 0x05283200 421 | NRF52833 = 0x05283300 422 | NRF52840 = 0x05284000 423 | 424 | NRF5340 = 0x05340000 425 | NRF9120 = 0x09120000 426 | 427 | NRF54L15 = 0x05411500 428 | 429 | NRF54H20 = 0x05442000 430 | 431 | NRF9160 = 0x09160000 432 | 433 | 434 | 435 | class DeviceMemory(enum.IntEnum): 436 | 437 | UNKNOWN_MEM = 0 438 | AA = 1 439 | AB = 2 440 | AC = 3 441 | 442 | 443 | class DeviceRevision(enum.IntEnum): 444 | 445 | UNKNOWN_REV = 0 446 | ENGA = 10 447 | ENGB = 11 448 | REV1 = 20 449 | REV2 = 21 450 | REV3 = 22 451 | FUTURE = 30 452 | 453 | @enum.unique 454 | class CoProcessor(enum.IntEnum): 455 | """ 456 | Wraps coprocessor_t values from DllCommonDefinitions.h 457 | """ 458 | CP_APPLICATION = 0 459 | CP_MODEM = 1 460 | CP_NETWORK = 2 461 | 462 | 463 | CP_PPR = 6 464 | CP_FLPR = 7 465 | 466 | 467 | 468 | @enum.unique 469 | class Architecture(enum.IntEnum): 470 | """ 471 | Wraps architecture_t values from DllCommonDefinitions.h 472 | """ 473 | ARM_CM0 = 0x00 474 | ARM_CM4 = 0x04 475 | ARM_CM33 = 0x33 476 | RISCV_VPR = 0x100 477 | 478 | 479 | @enum.unique 480 | class Region0Source(enum.IntEnum): 481 | """ 482 | Wraps region_0_source_t values from DllCommonDefinitions.h 483 | 484 | """ 485 | NO_REGION_0 = 0 486 | FACTORY = 1 487 | USER = 2 488 | 489 | 490 | @enum.unique 491 | class RamPower(enum.IntEnum): 492 | """ 493 | Wraps ram_power_status_t values from DllCommonDefinitions.h 494 | 495 | """ 496 | OFF = 0 497 | ON = 1 498 | 499 | 500 | @enum.unique 501 | class RTTChannelDirection(enum.IntEnum): 502 | """ 503 | Wraps rtt_direction_t values from DllCommonDefinitions.h 504 | 505 | """ 506 | UP_DIRECTION = 0 507 | DOWN_DIRECTION = 1 508 | 509 | 510 | @enum.unique 511 | class ReadbackProtection(enum.IntEnum): 512 | """ 513 | Wraps readback_protection_status_t values from DllCommonDefinitions.h 514 | Some modes are not available in all devices. 515 | 516 | """ 517 | NONE = 0 518 | REGION_0 = 1 519 | ALL = 2 520 | BOTH = 3 521 | SECURE = 4 522 | 523 | 524 | class CpuRegister(enum.IntEnum): 525 | """ 526 | Wraps cpu_registers_t values from DllCommonDefinitions.h 527 | 528 | """ 529 | R0 = 0 530 | R1 = 1 531 | R2 = 2 532 | R3 = 3 533 | R4 = 4 534 | R5 = 5 535 | R6 = 6 536 | R7 = 7 537 | R8 = 8 538 | R9 = 9 539 | R10 = 10 540 | R11 = 11 541 | R12 = 12 542 | R13 = 13 543 | SP = 13 544 | R14 = 14 545 | LR = 14 546 | R15 = 15 547 | PC = 15 548 | XPSR = 16 549 | MSP = 17 550 | PSP = 18 551 | RAZ = 19 552 | CFBP = 20 553 | APSR = 21 554 | EPSR = 22 555 | IPSR = 23 556 | MSP_NS = 24 557 | PSP_NS = 25 558 | MSP_S = 26 559 | PSP_S = 27 560 | MSPLIM_S = 28 561 | PSPLIM_S = 29 562 | MSPLIM_NS = 30 563 | PSPLIM_NS = 31 564 | CFBP_S = 32 565 | CFBP_NS = 33 566 | MSPLIM = 34 567 | PSPLIM = 35 568 | 569 | 570 | class RiscVCpuRegister(enum.IntEnum): 571 | """ 572 | Wraps riscv_cpu_registers_t values from DllCommonDefinitions.h 573 | 574 | """ 575 | # RISC-V CSR registers 576 | CSR_FIRST = 0, 577 | CSR_LAST = 0xFFF, 578 | 579 | # RISC-V CPU registers 580 | REG_ZERO = 0x1000, 581 | REG_RA = 0x1001 582 | REG_SP = 0x1002 583 | REG_GP = 0x1003 584 | REG_TP = 0x1004 585 | REG_T0 = 0x1005 586 | REG_T1 = 0x1006 587 | REG_T2 = 0x1007 588 | REG_S0 = 0x1008 589 | REG_FP = REG_S0, 590 | REG_S1 = 0x1009, 591 | REG_A0 = 0x100A, 592 | REG_A1 = 0x100B, 593 | REG_A2 = 0x100C, 594 | REG_A3 = 0x100D, 595 | REG_A4 = 0x100E, 596 | REG_A5 = 0x100F 597 | 598 | @enum.unique 599 | class NrfjrpogdllLogLevel(enum.IntEnum): 600 | """ 601 | Values for nrfjprogdll_log_level from DllCommonDefinitions.h 602 | """ 603 | critical = 60 604 | error = 50 605 | warning = 40 606 | info = 30 607 | debug = 20 608 | trace = 10 609 | none = 0 610 | 611 | @staticmethod 612 | def get_name_from_value(level): 613 | try: 614 | return NrfjrpogdllLogLevel(level).name 615 | except ValueError: 616 | return NrfjrpogdllLogLevel.info.name 617 | 618 | @staticmethod 619 | def get_level_from_value(level): 620 | if level == NrfjrpogdllLogLevel.critical: 621 | return logging.CRITICAL 622 | elif level == NrfjrpogdllLogLevel.error: 623 | return logging.ERROR 624 | elif level == NrfjrpogdllLogLevel.warning: 625 | return logging.WARNING 626 | elif level == NrfjrpogdllLogLevel.info: 627 | return logging.INFO 628 | elif level == NrfjrpogdllLogLevel.debug: 629 | return logging.DEBUG 630 | elif level == NrfjrpogdllLogLevel.trace: 631 | return logging.DEBUG 632 | elif level == NrfjrpogdllLogLevel.none: 633 | return logging.NOTSET 634 | else: 635 | return logging.NOTSET 636 | 637 | 638 | ################################################################################### 639 | # # 640 | # QSPI data types # 641 | # # 642 | ################################################################################### 643 | 644 | 645 | @enum.unique 646 | class QSPIEraseLen(enum.IntEnum): 647 | """ 648 | Wraps qspi_erase_len_t values from DllCommonDefinitions.h 649 | 650 | """ 651 | ERASE4KB = 0 652 | ERASE32KB = 3 653 | ERASE64KB = 1 654 | ERASEALL = 2 655 | 656 | 657 | @enum.unique 658 | class QSPIReadMode(enum.IntEnum): 659 | """ 660 | Wraps qspi_read_mode_t values from DllCommonDefinitions.h 661 | 662 | """ 663 | FASTREAD = 0 664 | READ2O = 1 665 | READ2IO = 2 666 | READ4O = 3 667 | READ4IO = 4 668 | 669 | 670 | @enum.unique 671 | class QSPIWriteMode(enum.IntEnum): 672 | """ 673 | Wraps qspi_write_mode_t values from DllCommonDefinitions.h 674 | 675 | """ 676 | PP = 0 677 | PP2O = 1 678 | PP4O = 2 679 | PP4IO = 3 680 | 681 | 682 | @enum.unique 683 | class QSPIAddressMode(enum.IntEnum): 684 | """ 685 | Wraps qspi_address_mode_t values from DllCommonDefinitions.h 686 | 687 | """ 688 | BIT24 = 0 689 | BIT32 = 1 690 | 691 | 692 | @enum.unique 693 | class QSPIFrequency(enum.IntEnum): 694 | """ 695 | Wraps qspi_frequency_t values from DllCommonDefinitions.h 696 | 697 | """ 698 | M2 = 15 699 | M4 = 7 700 | M8 = 3 701 | M16 = 1 702 | M32 = 0 703 | M64 = -1 704 | M96 = -2 705 | 706 | 707 | @enum.unique 708 | class QSPISpiMode(enum.IntEnum): 709 | """ 710 | Wraps qspi_spi_mode_t values from DllCommonDefinitions.h 711 | """ 712 | MODE0 = 0 713 | MODE3 = 1 714 | 715 | 716 | @enum.unique 717 | class QSPILevelIO(enum.IntEnum): 718 | """ 719 | Wraps qspi_custom_level_t values from DllCommonDefinitions.h 720 | """ 721 | LEVEL_HIGH = 1 722 | LEVEL_LOW = 0 723 | 724 | 725 | @enum.unique 726 | class QSPIPPSize(enum.IntEnum): 727 | """ 728 | Wraps qspi_custom_level_t values from DllCommonDefinitions.h 729 | """ 730 | PAGE256 = 0 731 | PAGE512 = 1 732 | 733 | 734 | class QSPIInitParams(ctypes.Structure): 735 | _fields_ = [("read_mode", ctypes.c_int), 736 | ("write_mode", ctypes.c_int), 737 | ("address_mode", ctypes.c_int), 738 | ("frequency", ctypes.c_int), 739 | ("spi_mode", ctypes.c_int), 740 | ("sck_delay", ctypes.c_uint32), 741 | ("custom_instruction_io2_level", ctypes.c_int), 742 | ("custom_instruction_io3_level", ctypes.c_int), 743 | ("CSN_pin", ctypes.c_uint32), 744 | ("CSN_port", ctypes.c_uint32), 745 | ("SCK_pin", ctypes.c_uint32), 746 | ("SCK_port", ctypes.c_uint32), 747 | ("DIO0_pin", ctypes.c_uint32), 748 | ("DIO0_port", ctypes.c_uint32), 749 | ("DIO1_pin", ctypes.c_uint32), 750 | ("DIO1_port", ctypes.c_uint32), 751 | ("DIO2_pin", ctypes.c_uint32), 752 | ("DIO2_port", ctypes.c_uint32), 753 | ("DIO3_pin", ctypes.c_uint32), 754 | ("DIO3_port", ctypes.c_uint32), 755 | ("WIP_index", ctypes.c_uint32), 756 | ("pp_size", ctypes.c_int)] 757 | 758 | def __init__(self, 759 | read_mode=QSPIReadMode.READ4IO, 760 | write_mode=QSPIWriteMode.PP4IO, 761 | address_mode=QSPIAddressMode.BIT24, 762 | frequency=QSPIFrequency.M16, 763 | spi_mode=QSPISpiMode.MODE0, 764 | sck_delay=0x80, 765 | custom_instruction_io2_level=QSPILevelIO.LEVEL_LOW, 766 | custom_instruction_io3_level=QSPILevelIO.LEVEL_HIGH, 767 | CSN_pin=17, 768 | CSN_port=0, 769 | SCK_pin=19, 770 | SCK_port=0, 771 | DIO0_pin=20, 772 | DIO0_port=0, 773 | DIO1_pin=21, 774 | DIO1_port=0, 775 | DIO2_pin=22, 776 | DIO2_port=0, 777 | DIO3_pin=23, 778 | DIO3_port=0, 779 | WIP_index=0, 780 | pp_size=QSPIPPSize.PAGE256): 781 | 782 | ctypes.Structure.__init__(self) 783 | self.read_mode = read_mode 784 | self.write_mode = write_mode 785 | self.address_mode = address_mode 786 | self.frequency = frequency 787 | self.spi_mode = spi_mode 788 | self.sck_delay = sck_delay 789 | self.custom_instruction_io2_level = custom_instruction_io2_level 790 | self.custom_instruction_io3_level = custom_instruction_io3_level 791 | self.CSN_pin = CSN_pin 792 | self.CSN_port = CSN_port 793 | self.SCK_pin = SCK_pin 794 | self.SCK_port = SCK_port 795 | self.DIO0_pin = DIO0_pin 796 | self.DIO0_port = DIO0_port 797 | self.DIO1_pin = DIO1_pin 798 | self.DIO1_port = DIO1_port 799 | self.DIO2_pin = DIO2_pin 800 | self.DIO2_port = DIO2_port 801 | self.DIO3_pin = DIO3_pin 802 | self.DIO3_port = DIO3_port 803 | self.WIP_index = WIP_index 804 | self.pp_size = pp_size 805 | 806 | 807 | class ComPortInfoStruct(ctypes.Structure): 808 | _fields_ =[("path", ctypes.c_char * NRFJPROG_MAX_PATH), 809 | ("vcom", ctypes.c_uint32), 810 | ("serial_number", ctypes.c_uint32)] 811 | 812 | 813 | class ComPortInfo(object): 814 | 815 | def __init__(self, probe_info): 816 | """Info about a COM port.""" 817 | self.path = decode_string(probe_info.path) 818 | self.vcom = probe_info.vcom 819 | self.serial_number = probe_info.serial_number 820 | 821 | def __repr__(self): 822 | return "ComPortInfoStruct({}, {}, {})".format(self.path, self.vcom, self.serial_number) 823 | 824 | 825 | @enum.unique 826 | class MemoryType(enum.IntEnum): 827 | """ 828 | Wraps memory_type_t values from DllCommonDefinitions.h 829 | """ 830 | CODE = 0 831 | DATA_RAM = 1 832 | CODE_RAM = 2 833 | FICR = 3 834 | UICR = 4 835 | XIP = 5 836 | 837 | 838 | @enum.unique 839 | class MemoryAccess(enum.IntFlag): 840 | """ 841 | Wraps memory_access_t values from DllCommonDefinitions.h. Note that values are bit masks. 842 | """ 843 | MEM_ACCESS_EXECUTE = 1, 844 | MEM_ACCESS_WRITE = 2, 845 | MEM_ACCESS_READ = 4, 846 | MEM_ACCESS_ERASE = 8, 847 | MEM_ACCESS_SECURE = 16, 848 | 849 | 850 | class MemoryDescriptionStruct(ctypes.Structure): 851 | """ 852 | Wraps memory_description_t values from DllCommonDefinitions.h 853 | """ 854 | _fields_ = [("start", ctypes.c_uint32), 855 | ("size", ctypes.c_uint32), 856 | ("num_pages", ctypes.c_uint32), 857 | ("type", ctypes.c_int), 858 | ("access_flags", ctypes.c_int), 859 | ("has_trustzone_alias", ctypes.c_bool), 860 | ("is_runtime_configurable", ctypes.c_bool), 861 | ("_id", ctypes.c_uint32), 862 | ("label", (ctypes.c_char * 33)), 863 | ("_reserved", (ctypes.c_uint32 * 8))] 864 | 865 | 866 | class PageRepetitionsStruct(ctypes.Structure): 867 | """ 868 | Wraps page_repetitions_t values from DllCommonDefinitions.h 869 | """ 870 | _fields_ = [("size", ctypes.c_uint32), 871 | ("num_repeats", ctypes.c_uint32)] 872 | 873 | 874 | class MemoryDescription(object): 875 | """ 876 | Description of a device memory. 877 | 878 | Returned by function API.read_memory_descriptors in LowLevel.py. 879 | """ 880 | def __init__(self, memory_description_struct): 881 | self._cstruct = memory_description_struct 882 | 883 | self.start = self._cstruct.start 884 | self.size = self._cstruct.size 885 | self.num_pages = self._cstruct.num_pages 886 | self.type = MemoryType(self._cstruct.type) 887 | self.access_flags = self._cstruct.access_flags 888 | self.has_trustzone_alias = self._cstruct.has_trustzone_alias 889 | self.is_runtime_configurable = self._cstruct.is_runtime_configurable 890 | self._id = self._cstruct._id 891 | self.label = decode_string(self._cstruct.label) 892 | 893 | self.page_repetitions = None 894 | 895 | def executable(self): 896 | return (self.access_flags & MemoryAccess.MEM_ACCESS_EXECUTE.value) > 0 897 | 898 | def writable(self): 899 | return (self.access_flags & MemoryAccess.MEM_ACCESS_WRITE.value) > 0 900 | 901 | def readable(self): 902 | return (self.access_flags & MemoryAccess.MEM_ACCESS_READ.value) > 0 903 | 904 | def erasable(self): 905 | return (self.access_flags & MemoryAccess.MEM_ACCESS_ERASE.value) > 0 906 | 907 | def read_page_sizes(self, lowlevel_api): 908 | """ 909 | A short hand function for updating the page sizes from a LowLevel API instance. 910 | 911 | @param LowLevel.API lowlevel_api: An API instance that has been opened and connected to a debug probe. 912 | @return PageRepetitions: A list of page repetitions describing the page sizes of the memory. 913 | """ 914 | self.page_repetitions = lowlevel_api.read_page_sizes(self) 915 | return self.page_repetitions 916 | 917 | 918 | class PageRepetitions(object): 919 | """ 920 | Page repetitions describe a homogenous block of memory. For memories with varying page size, such as the RAM of a nRF52840, 921 | a list of page repetitions can be used to describe the order and size of each page. 922 | 923 | Returned by function API.read_page_sizes in LowLevel.py. 924 | """ 925 | def __init__(self, page_repetitions_struct): 926 | self.size = page_repetitions_struct.size 927 | self.num_repeats = page_repetitions_struct.num_repeats 928 | 929 | 930 | ################################################################################### 931 | # # 932 | # High level data types # 933 | # # 934 | ################################################################################### 935 | 936 | 937 | @enum.unique 938 | class EraseAction(enum.IntEnum): 939 | """ 940 | Available erase processes during programming. 941 | 942 | """ 943 | ERASE_NONE = 0 944 | ERASE_ALL = 1 945 | ERASE_SECTOR = 2 946 | ERASE_SECTOR_AND_UICR = 3 947 | ERASE_CTRL_AP = 5 948 | 949 | 950 | @enum.unique 951 | class ResetAction(enum.IntEnum): 952 | """ 953 | Available reset modes. 954 | 955 | """ 956 | RESET_NONE = 0 957 | RESET_SYSTEM = 1 958 | RESET_DEBUG = 2 959 | RESET_PIN = 3 960 | RESET_HARD = 4 961 | 962 | 963 | @enum.unique 964 | class VerifyAction(enum.IntEnum): 965 | """ 966 | Available verify processes during programming. 967 | 968 | """ 969 | VERIFY_NONE = 0 970 | VERIFY_READ = 1 971 | VERIFY_HASH = 2 972 | 973 | 974 | class ProgramOptions(ctypes.Structure): 975 | _fields_ = [("verify", ctypes.c_int), 976 | ("erase_action", ctypes.c_int), 977 | ("qspi_erase_action", ctypes.c_int), 978 | ("reset", ctypes.c_int)] 979 | 980 | def __init__(self, verify=VerifyAction.VERIFY_NONE, erase_action=EraseAction.ERASE_ALL, qspi_erase_action=EraseAction.ERASE_NONE, reset=ResetAction.RESET_SYSTEM): 981 | ctypes.Structure.__init__(self) 982 | self.verify = verify 983 | self.erase_action = erase_action 984 | self.qspi_erase_action = qspi_erase_action 985 | self.reset = reset 986 | 987 | def __repr__(self): 988 | return "ProgramOptions({}, {}, {}, {})".format( 989 | self.verify, 990 | self.erase_action, 991 | self.qspi_erase_action, 992 | self.reset 993 | ) 994 | 995 | 996 | class ReadOptions(ctypes.Structure): 997 | _fields_ = [("readram", ctypes.c_bool), 998 | ("readcode", ctypes.c_bool), 999 | ("readuicr", ctypes.c_bool), 1000 | ("readficr", ctypes.c_bool), 1001 | ("readqspi", ctypes.c_bool), 1002 | ("reserved", ctypes.c_bool * 3)] 1003 | 1004 | def __init__(self, readram=False, readcode=False, readuicr=False, readficr=False, readqspi=False): 1005 | ctypes.Structure.__init__(self) 1006 | self.readram = readram 1007 | self.readcode = readcode 1008 | self.readuicr = readuicr 1009 | self.readficr = readficr 1010 | self.readqspi = readqspi 1011 | 1012 | def __repr__(self): 1013 | return "ReadOptions({}, {}, {}, {}, {})".format( 1014 | self.readram, 1015 | self.readcode, 1016 | self.readuicr, 1017 | self.readficr, 1018 | self.readqspi 1019 | ) 1020 | 1021 | 1022 | class DeviceInfoStruct(ctypes.Structure): 1023 | _fields_ = [ 1024 | ("device_family", ctypes.c_int), 1025 | ("device_type", ctypes.c_int), 1026 | 1027 | ("code_address", ctypes.c_uint32), 1028 | ("code_page_size", ctypes.c_uint32), 1029 | ("code_size", ctypes.c_uint32), 1030 | 1031 | ("uicr_address", ctypes.c_uint32), 1032 | ("info_page_size", ctypes.c_uint32), 1033 | 1034 | ("code_ram_present", ctypes.c_bool), 1035 | ("code_ram_address", ctypes.c_uint32), 1036 | ("data_ram_address", ctypes.c_uint32), 1037 | ("ram_size", ctypes.c_uint32), 1038 | 1039 | ("qspi_present", ctypes.c_bool), 1040 | ("xip_address", ctypes.c_uint32), 1041 | ("xip_size", ctypes.c_uint32), 1042 | 1043 | ("pin_reset_pin", ctypes.c_uint32)] 1044 | 1045 | 1046 | class DeviceInfo(object): 1047 | def __init__(self, device_info, dll_ret_code=None): 1048 | """Info about an nRF device.""" 1049 | self.device_type = DeviceVersion(device_info.device_type) 1050 | self.device_family = DeviceFamily(device_info.device_family) 1051 | self.code_address = device_info.code_address 1052 | self.code_page_size = device_info.code_page_size 1053 | self.code_size = device_info.code_size 1054 | self.uicr_address = device_info.uicr_address 1055 | self.info_page_size = device_info.info_page_size 1056 | self.code_ram_present = device_info.code_ram_present 1057 | self.code_ram_address = device_info.code_ram_address 1058 | self.data_ram_address = device_info.data_ram_address 1059 | self.ram_size = device_info.ram_size 1060 | self.qspi_present = device_info.qspi_present 1061 | self.xip_address = device_info.xip_address 1062 | self.xip_size = device_info.xip_size 1063 | self.pin_reset_pin = device_info.pin_reset_pin 1064 | 1065 | # Return code from HighLevel DLL when this struct was read. 1066 | self.dll_ret_code = dll_ret_code 1067 | 1068 | 1069 | class ProbeInfoStruct(ctypes.Structure): 1070 | _fields_ = [ 1071 | ("serial_number", ctypes.c_uint32), 1072 | ("clockspeed_khz", ctypes.c_uint32), 1073 | ("firmware_string", ctypes.c_char * NRFJPROG_STRING_LENGTH), 1074 | ("num_com_ports", ctypes.c_uint32), 1075 | ("com_ports", ComPortInfoStruct * NRFJPROG_COM_PER_JLINK)] 1076 | 1077 | 1078 | class ProbeInfo(object): 1079 | def __init__(self, probe_info): 1080 | """Info about a debug probe.""" 1081 | self.serial_number = probe_info.serial_number 1082 | self.clockspeed_khz = probe_info.clockspeed_khz 1083 | 1084 | self.firmware_string = decode_string(probe_info.firmware_string) 1085 | 1086 | self.num_com_ports = probe_info.num_com_ports 1087 | self.com_ports = [ComPortInfo(comport) for comport in probe_info.com_ports[0:self.num_com_ports]] 1088 | 1089 | def __repr__(self): 1090 | return "ProbeInfo(ProbeInfoStruct({}, {}, {}, {}, [{}]))".format( 1091 | self.serial_number, 1092 | self.clockspeed_khz, 1093 | self.firmware_string, 1094 | self.num_com_ports, 1095 | ", ".join([repr(comport) for comport in self.com_ports]) 1096 | ) 1097 | 1098 | 1099 | class LibraryInfoStruct(ctypes.Structure): 1100 | _fields_ = [ 1101 | ("version_major", ctypes.c_uint32), 1102 | ("version_minor", ctypes.c_uint32), 1103 | ("version_revision", ctypes.c_char), 1104 | ("file_path", ctypes.c_char * NRFJPROG_MAX_PATH)] 1105 | 1106 | 1107 | class LibraryInfo(object): 1108 | def __init__(self, library_info): 1109 | """Info about an interface library, like JLinkARMDLL.""" 1110 | self.version_major = library_info.version_major 1111 | self.version_minor = library_info.version_minor 1112 | 1113 | self.version_revision = decode_string(library_info.version_revision) 1114 | self.file_path = decode_string(library_info.file_path) 1115 | 1116 | def __repr__(self): 1117 | return "LibraryInfo(LibraryInfoStruct({}, {}, {}, {}))".format( 1118 | self.version_major, 1119 | self.version_minor, 1120 | self.version_revision, 1121 | self.file_path 1122 | ) 1123 | 1124 | -------------------------------------------------------------------------------- /pynrfjprog/QspiDefault.ini: -------------------------------------------------------------------------------- 1 | ;---------------------------------------------- 2 | ; Deprecated, use config.toml format instead 3 | ;---------------------------------------------- 4 | 5 | ; nrfjprog QSPI configuration file. 6 | 7 | [DEFAULT_CONFIGURATION] 8 | ; Define the capacity of the flash memory device in bytes. Set to 0 if no external memory device is present in your board. 9 | MemSize = 0x800000 10 | 11 | ; Define the desired ReadMode. Valid options are FASTREAD, READ2O, READ2IO, READ4O and READ4IO 12 | ReadMode = READ4IO 13 | 14 | ; Define the desired WriteMode. Valid options are PP, PP2O, PP4O and PP4IO 15 | WriteMode = PP4IO 16 | 17 | ; Define the desired AddressMode. Valid options are BIT24 and BIT32 18 | AddressMode = BIT24 19 | 20 | ; Define the desired Frequency. Valid options are M2, M4, M8, M16 and M32 21 | Frequency = M16 22 | 23 | ; Define the desired SPI mode. Valid options are MODE0 and MODE3 24 | SpiMode = MODE0 25 | 26 | ; Define the desired SckDelay. Valid options are in the range 0 to 255 27 | SckDelay = 0x80 28 | 29 | ; Define SPI interface timing. Valid options are in the range of 0 to 7. 30 | ; This argument is only used for devices where the dll function NRFJPROG_qspi_set_rx_delay() is supported. 31 | RxDelay = 2 32 | 33 | ; Define the desired IO level for DIO2 and DIO3 during a custom instruction. Valid options are LEVEL_HIGH and LEVEL_LOW 34 | CustomInstructionIO2Level = LEVEL_LOW 35 | CustomInstructionIO3Level = LEVEL_HIGH 36 | 37 | ; Define the assigned pins for the QSPI peripheral. Valid options are those existing in your device 38 | ; For nRF53, QSPI pins are not configurable and these values are ignored. 39 | CSNPin = 17 40 | CSNPort = 0 41 | SCKPin = 19 42 | SCKPort = 0 43 | DIO0Pin = 20 44 | DIO0Port = 0 45 | DIO1Pin = 21 46 | DIO1Port = 0 47 | DIO2Pin = 22 48 | DIO2Port = 0 49 | DIO3Pin = 23 50 | DIO3Port = 0 51 | 52 | ; Define the Index of the Write In Progress (WIP) bit in the status register. Valid options are in the range of 0 to 7. 53 | WIPIndex = 0 54 | 55 | ; Define page size for commands. Valid sizes are PAGE256 and PAGE512. 56 | PPSize = PAGE256 57 | 58 | ; Custom instructions to send to the external memory after initialization. Format is instruction code plus data to send in between optional brakets. 59 | ; These instructions will be executed each time the qspi peripheral is initiated by nrfjprog. 60 | ; To improve execution speed on consecutive interations with QSPI, you can run nrfjprog once with custom initialization, and then comment out the lines below. 61 | ; Numbers can be given in decimal, hex (starting with either 0x or 0X) and binary (starting with either 0b or 0B) formats. 62 | ; The custom instructions will be executed in the order found. 63 | ; This example includes two commands, first a WREN (WRite ENable) and then a WRSR (WRite Satus Register) enabling the Quad Operation and the High Performance 64 | ; mode for the MX25R6435F memory present in the nRF52840 DK. 65 | InitializationCustomInstruction = 0x06 66 | InitializationCustomInstruction = 0x01, [0x40, 0, 0x2] 67 | 68 | ; If retention is enabled, device RAM contents will be read and buffered during QSPI driver initialization. 69 | ; The buffered data will be written back to the device when unitializing the driver, restoring the original device RAM state. 70 | ; Enabled: RetainRAM = 1, Disabled: RetainRAM = 0 71 | RetainRAM = 1 72 | 73 | -------------------------------------------------------------------------------- /pynrfjprog/RTTAsyncIO.py: -------------------------------------------------------------------------------- 1 | import asyncio 2 | import functools 3 | import logging 4 | import concurrent.futures 5 | from . import APIError, Parameters 6 | 7 | 8 | logger = logging.getLogger(__name__) 9 | 10 | 11 | def _ctypes_callback_wrapper(callback): 12 | """ 13 | Propagate exception to asyncio loop and avoid "Exception ignored on calling ctypes callback function" warning 14 | """ 15 | 16 | @functools.wraps(callback) 17 | def wrapper(self, *args, **kwargs): 18 | try: 19 | callback(self, *args, **kwargs) 20 | except Exception as e: 21 | if self._loop: 22 | self._loop.call_soon_threadsafe(self._fatal_error, e, "Exception in C callback") 23 | else: 24 | # Fallback if RTTTransport is already closed 25 | self.logger.exception(e) 26 | 27 | return wrapper 28 | 29 | 30 | class RTTTransport(asyncio.Transport): 31 | """ 32 | RTT bidirectional transport. 33 | 34 | A transport class abstracts a communication channel. 35 | A transport is not instantiated directly, `LowLevel.rtt_asyncio_create_connection()` or 36 | `LowLevel.rtt_asyncio_open_connection()`utility functions should be called instead. 37 | 38 | .. seealso:: asyncio.Transport functions documentation 39 | """ 40 | 41 | def __init__(self, protocol, loop, api, channel_index, encoding="utf-8"): 42 | self._api = api 43 | self._snr = self._api.read_connected_emu_snr() 44 | 45 | super().__init__(extra={"snr": self._snr, "channel_index": channel_index}) 46 | 47 | self._protocol = protocol 48 | self._loop = loop 49 | self._channel_index = channel_index 50 | self._closing = False 51 | self.encoding = encoding 52 | 53 | self._unflushed_num_bytes = 0 54 | """ 55 | For how many bytes write has not been confirmed yet. 56 | 57 | When write(data) is called, the data length is added. 58 | When write confirmation callback is received from the DLL, the data length is subtracted. 59 | """ 60 | 61 | self.logger = Parameters.LoggerAdapter( 62 | logger, {"id": self._api._logger.extra["id"], "channel_index": channel_index} 63 | ) 64 | 65 | def __repr__(self): 66 | return f"<{self.__class__.__name__}({self._protocol}, {self._loop}, {self._channel_index})>" 67 | 68 | def is_closing(self): 69 | return self._closing 70 | 71 | def close(self): 72 | """ 73 | Close the transport gracefully 74 | """ 75 | self._close() 76 | 77 | def abort(self): 78 | """ 79 | Close the transport gracefully. 80 | Due to the underlying RTT implementation, it's not possible to immediately close the RTT connection 81 | """ 82 | self._close() 83 | 84 | def write(self, data): 85 | """ 86 | Non-blocking write 87 | """ 88 | if not self._closing: 89 | try: 90 | self._api.rtt_async_write(self._channel_index, data, encoding=self.encoding) 91 | self._unflushed_num_bytes += len(data) 92 | except APIError.APIError as e: 93 | self._fatal_error(e, "rtt_async_write error") 94 | 95 | def can_write_eof(self): 96 | # RTT does not support EOF 97 | return False 98 | 99 | def pause_reading(self): 100 | raise NotImplementedError("Pause rtt_async_read (flow control) is not implemented") 101 | 102 | def set_write_buffer_limits(self, high=None, low=None): 103 | raise NotImplementedError("RTT write watermarks (flow control) are not implemented") 104 | 105 | def get_write_buffer_size(self): 106 | return self._unflushed_num_bytes 107 | 108 | def _fatal_error(self, exc, message): 109 | """ 110 | Propagate `exc` to the event loop and abort the transport 111 | """ 112 | self._loop.call_exception_handler( 113 | { 114 | "message": message, 115 | "exception": exc, 116 | "protocol": self._protocol, 117 | "transport": self, 118 | } 119 | ) 120 | self._close(exc) 121 | 122 | def _flushed(self): 123 | return self._unflushed_num_bytes == 0 124 | 125 | def _close(self, exc=None): 126 | """ 127 | Close the transport gracefully, nrfjprogdll makes sure the close is performed gracefully. 128 | """ 129 | self._closing = True 130 | try: 131 | if self._protocol is not None: 132 | self._protocol.connection_lost(exc) 133 | finally: 134 | 135 | def blocking_close(): 136 | try: 137 | self._api.rtt_async_callback_stop(self._channel_index) 138 | except APIError.APIError: 139 | self.logger.exception("rtt_async_callback_stop returned an api error") 140 | except Exception: 141 | self.logger.exception("rtt_async_callback_stop encountered an unknown error") 142 | self._api = None 143 | 144 | self._protocol = None 145 | self._loop = None 146 | self._unflushed_num_bytes = 0 147 | 148 | if self._api is not None: 149 | executor = concurrent.futures.ThreadPoolExecutor( 150 | max_workers=1, thread_name_prefix=self.__class__.__name__ 151 | ) 152 | _ = executor.submit(blocking_close) 153 | executor.shutdown(wait=False) 154 | 155 | @_ctypes_callback_wrapper 156 | def rtt_asyncio_read_callback(self, _channel_index, data, _callback_param): 157 | if data and not self._closing: 158 | self._loop.call_soon_threadsafe(self._protocol.data_received, data) 159 | 160 | @_ctypes_callback_wrapper 161 | def rtt_asyncio_write_callback(self, _channel_index, num_bytes_flushed, result, _callback_param): 162 | if result != APIError.NrfjprogdllErr.SUCCESS: 163 | # This will be handled by _ctypes_callback_wrapper 164 | raise APIError.APIError(result, "rtt write failed", error_data=[self._api, self._snr, self._channel_index]) 165 | 166 | self._unflushed_num_bytes -= num_bytes_flushed 167 | assert self._unflushed_num_bytes >= 0 168 | -------------------------------------------------------------------------------- /pynrfjprog/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Package marker file. 3 | 4 | """ 5 | 6 | __version__ = "10.24.2" 7 | 8 | from pathlib import Path 9 | 10 | import platform 11 | import stat 12 | import logging 13 | 14 | 15 | def set_worker_executable(on_load=False): 16 | os_name = platform.system().lower() 17 | 18 | if os_name == 'linux' or os_name == 'darwin': 19 | # On linux and MacOS we need to make sure the jlinkarm worker is executable. 20 | try: 21 | worker_bin_names = { 22 | 'linux': 'jlinkarm_nrf_worker_linux', 23 | 'darwin': 'jlinkarm_nrf_worker_osx' 24 | } 25 | 26 | worker_bin_name = worker_bin_names[os_name] 27 | 28 | for worker_binary in Path(__file__).parent.glob(f"lib_*/{worker_bin_name}"): 29 | mode = worker_binary.stat().st_mode 30 | expected = stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH 31 | 32 | if (mode & expected) != expected: 33 | logging.info(f"Marking {worker_binary} as executable") 34 | worker_binary.chmod(expected | mode) 35 | except Exception: 36 | if on_load: 37 | raise RuntimeError( 38 | "jlinkarm_nrf_worker is not executable, and could not be made executable. \ 39 | Try doing this manually with python -m pynrfjprog.set_worker_executable" 40 | ) 41 | 42 | set_worker_executable(True) 43 | -------------------------------------------------------------------------------- /pynrfjprog/config.toml: -------------------------------------------------------------------------------- 1 | # nrfjprog configuration. 2 | [log] 3 | # level - A spdlog log level enumerator name. Case insensitive. 4 | # pattern - A spdlog log formatting pattern. 5 | # file - Target log file, will be written to in append mode. If file is a directory, or it's missing a file extension, "/log.log" will be appended to the log file path. 6 | [log.dll] 7 | # nrfjprogdll logger configuration 8 | level = "TRACE" 9 | pattern = "%v" 10 | [log.file] 11 | # nrfjprog executable file log sink configuration 12 | file = "log.log" 13 | level = "TRACE" 14 | pattern = "[%Y-%b-%d %H:%M:%S] [%5l] %v" 15 | [log.terminal] 16 | # nrfjprog executable terminal log sink configuration 17 | level = "ERROR" 18 | pattern = "[%5l] %v" 19 | 20 | [rtt] 21 | # If true, NRFJPROG_rtt_stop invalidates the current RTT control block. 22 | # To restart RTT communication the target device must reinitialize the RTT control block before NRFJPROG_rtt_start is called. 23 | invalidate_control_block_on_stop = true 24 | 25 | # Set the period between rtt API calls in the async rtt worker threads. 26 | # Shorter periods may improve performance, but can overwhelm the J-Link debug probe. 27 | async_read_period_ms = 10 28 | async_write_period_ms = 10 29 | 30 | [jlink] 31 | # If true, J-Link debug probe fw will be silently updated on NRFJPROG_connect_to_emu_with*(). 32 | auto_update_fw=true 33 | 34 | # Controls for how long to attempt Debug Access Port (DAP) power down procedure before timing out. 35 | # nrfjprogdll will loop deassertion of the DAP CTRL/STAT CSYSPWRUPREQ and CDBGPWRUPREQ signals and check for acknowledgment. 36 | # See arm's description of the DAP CTRL/STAT register for more information. 37 | # Set to 0 to skip check for power down acknowledgment. 38 | dap_powerdown_timeout_ms = 1000 39 | 40 | [target] 41 | # Define the desired family of devices to use by default by nrfjprog.exe when -f or --family arguments are not used. 42 | # Family identifiers are case insensitive, no suffixes, for example NRF51, nRF52, Nrf53 are all valid. 43 | # If set to AUTO an automatic family detection will be performed. The autodetect family operation will take time, so it is advised to use correct family if known. 44 | family = "AUTO" 45 | 46 | # Define the desired clockspeed in kHz you want nrfjprog.exe use by default when -c or --clockspeed arguments are not used. 47 | clockspeed = 2000 48 | 49 | # ** Subject to change ** 50 | # Write MPC override rules when enabling coprocessor (only when secure domain AHB-AP is available). 51 | # The rules will allow read/write of device memories, and is needed when SDFW is not present. 52 | # MPC rule writing is relevant for nRF54H family. 53 | # Valid options are: 54 | # "AUTO" Best effort write rules. Will not disable any active rules. 55 | # "ALWAYS" Always write if possible. Already enabled/active rules can be overwritten. 56 | # "OFF" Do not write rules. 57 | write_mpc_rules = "AUTO" 58 | 59 | # Write mode specifically for MPC000. 60 | # Overrides settings from "write_mpc_rules". 61 | write_mpc000_rules = "ALWAYS" 62 | 63 | # Write mode specifically for MPC110 override index 11 64 | # Overrides settings from "write_mpc_rules". 65 | write_mpc110_override11 = "ALWAYS" 66 | 67 | # How long to wait for a local domain to be started after a system reset. 68 | # On nRF54H, a local domain must be restarted by the Secure Domain firmware after a system reset. 69 | # Set to a negative value for no timeout. 70 | localdomain_started_timeout_ms = 7000 71 | 72 | 73 | [approtect] 74 | # Configurations for devices with hardened ap-protection. 75 | 76 | # Should nrfjprog write UICR APPROTECT registers after erasing? 77 | # Certain devices perform this write in hardware, in this case this configuration does nothing. 78 | write_uicr_approtect = true 79 | # Should nrfjprog verify UICR APPROTECT registers? 80 | # On certain devices UICR->APPROTECT is written automatically to some reset value != 0xFFFFFFFFF 81 | # on erase. On these devices it's not possible to directly compare this NVM register to image file contents. 82 | verify_uicr_approtect = false 83 | # Should nrfjprog cli write an unlock image to NVM memory after --recover? 84 | # Certain devices require this image to stay unlocked. 85 | install_unlock_image = true 86 | 87 | # nrfjprog QSPI configuration. 88 | [qspi] 89 | # Define the capacity of the non-volatile memory device in bytes. Set to 0 if no external memory device is present in your board. 90 | mem_size = 0x800000 91 | 92 | # Define the desired ReadMode. Valid options are FASTREAD, READ2O, READ2IO, READ4O and READ4IO 93 | read_mode = "READ4IO" 94 | 95 | # Define the desired WriteMode. Valid options are PP, PP2O, PP4O and PP4IO 96 | write_mode = "PP4IO" 97 | 98 | # Define the desired AddressMode. Valid options are BIT24 and BIT32 99 | address_mode = "BIT24" 100 | 101 | # Define the desired Frequency. Valid options are M2, M4, M8, M16 and M32 102 | frequency = "M16" 103 | 104 | # Define the desired SPI mode. Valid options are MODE0 and MODE3 105 | spi_mode = "MODE0" 106 | 107 | 108 | # Define SPI interface timing. Valid options are in the range of 0 to 7. 109 | # This argument is only used for devices where the dll function NRFJPROG_qspi_set_rx_delay() is supported. 110 | rx_delay = 2 111 | 112 | # Define the Index of the Write In Progress (WIP) bit in the status register. Valid options are in the range of 0 to 7. 113 | wip_index = 0 114 | 115 | # Define page size for commands. Valid sizes are PAGE256 and PAGE512. 116 | page_program_size = "PAGE256" 117 | 118 | # If retention is enabled, device RAM contents will be read and buffered during QSPI driver initialization. 119 | # The buffered data will be written back to the device when unitializing the driver, restoring the original device RAM state. 120 | # Enabled: retain_ram = true, Disabled: retain_ram = false 121 | retain_ram = true 122 | 123 | # Define the assigned pins for the QSPI peripheral. Valid options are those existing in your device 124 | # For nRF53, QSPI pins are not configurable and these values are ignored. 125 | [qspi.sck] 126 | # Define the desired SckDelay. Valid options are in the range 0 to 255 127 | delay = 0x80 128 | pin = 19 129 | port = 0 130 | 131 | [qspi.csn] 132 | pin = 17 133 | port = 0 134 | [qspi.dio0] 135 | pin = 20 136 | port = 0 137 | [qspi.dio1] 138 | pin = 21 139 | port = 0 140 | [qspi.dio2] 141 | pin = 22 142 | port = 0 143 | [qspi.dio3] 144 | pin = 23 145 | port = 0 146 | 147 | [qspi.custom] 148 | # Define the desired IO level for DIO2 and DIO3 during a custom instruction. Valid options are LEVEL_HIGH and LEVEL_LOW 149 | io2_level = "LEVEL_LOW" 150 | io3_level = "LEVEL_HIGH" 151 | 152 | # Custom instructions to send to the external memory after initialization. Format is instruction code plus data to send in between optional brakets. 153 | # These instructions will be executed each time the qspi peripheral is initiated by nrfjprog. 154 | # To improve execution speed on consecutive interations with QSPI, you can run nrfjprog once with custom initialization, and then comment out the lines below. 155 | # Numbers can be given in decimal, hex (starting with either 0x or 0X) and binary (starting with either 0b or 0B) formats. 156 | # The custom instructions will be executed in the order found. 157 | # This example includes two commands, first a WREN (WRite ENable) and then a WRSR (WRite Satus Register) enabling the Quad Operation and the High Performance 158 | # mode for the MX25R6435F memory present in the nRF52840 DK. 159 | instructions = [ 160 | {command=0x06, data=[]}, 161 | {command=0x01, data=[0x40, 0, 0x2]} 162 | ] 163 | 164 | 165 | [system] 166 | # If true, the underlying jlinkarm_nrf_worker process will ignore SIGINT, SIGTERM, SIGABRT, SIGILL and SIGSEGV signals. 167 | # It is strongly recommended to keep this as false for nrfjprog exe. 168 | # This feature is mainly inteded for use with the pynrfjprog API, where you sometimes want to manually handle a ctrl-c event without the signal 169 | # propagating to the jlinkarm_nrf_worker process. 170 | worker_ignore_signals = false 171 | -------------------------------------------------------------------------------- /pynrfjprog/docs/__init__.py: -------------------------------------------------------------------------------- 1 | # Documentation. 2 | 3 | # Read the header files for the API description. 4 | 5 | -------------------------------------------------------------------------------- /pynrfjprog/docs/nrfdfu.h: -------------------------------------------------------------------------------- 1 | #ifndef NRFDFU_H 2 | #define NRFDFU_H 3 | 4 | #include "DllCommonDefinitions.h" 5 | 6 | #if defined(__cplusplus) 7 | extern "C" { 8 | #endif 9 | 10 | typedef enum 11 | { 12 | IPCEVENT_NONE, 13 | IPCEVENT_FAULT, 14 | IPCEVENT_COMMAND, 15 | IPCEVENT_DATA 16 | } nrfdfu_ipc_event_t; 17 | 18 | typedef struct 19 | { 20 | uint32_t id[10]; 21 | } ipc_dfu_id_t; 22 | 23 | /* Old definition kept for backwards compatibility. */ 24 | typedef nrfjprog_inst_t connection_handle_t; 25 | 26 | /** 27 | * @brief Deprecated, use nrfjprog.dll 28 | * 29 | * @retval NOT_IMPLEMENTED_ERROR 30 | */ 31 | NRFJPROG_API nrfjprogdll_err_t NRFDFU_connect_to_ipc_target(nrfjprog_inst_t * handle, 32 | const char * jlink_path_cstr, 33 | device_family_t family, 34 | coprocessor_t coprocessor, 35 | uint32_t snr, 36 | uint32_t swd_frequency, 37 | msg_callback_ex * callback, 38 | void * param, 39 | void * prog_cb); 40 | 41 | /** 42 | * @brief Initialize MCUBoot DFU connection. 43 | * 44 | * @details Initializes connection and starts the DFU session with the device. 45 | * 46 | * @post The initial settings for the DFU will be activated. 47 | * 48 | * @param handle Pointer to connection handle to initialize 49 | * @param serial_port Serial port to connect to. 50 | * @param baud_rate Baud rate of serial connection. 51 | * @param response_timeout Time in ms before serial port should time out while waiting for a response from target. 52 | * @param callback Pointer to logger callback function to use, or NULL. 53 | * @param param Parameter to pass to callback function. 54 | * @param prog_cb Deprecated, progress info is passed back on the info log level. 55 | * 56 | * @retval SUCCESS 57 | * @retval OUT_OF_MEMORY Memory could not be allocated for the operation. 58 | * @retval INVALID_PARAMETER The handle parameter is NULL. 59 | * @retval The serial_port parameter is already initialized. 60 | * @retval FILE_OPERATION_FAILED Failed to make temporary files. 61 | * @retval TIME_OUT The operation timed out. 62 | */ 63 | NRFJPROG_API nrfjprogdll_err_t NRFDFU_connect_to_mcuboot_target(nrfjprog_inst_t * handle, 64 | const char * serial_port, 65 | const uint32_t baud_rate, 66 | const uint32_t response_timeout, 67 | msg_callback_ex * callback, 68 | void * param, 69 | void * prog_cb); 70 | 71 | /** 72 | * @brief Initialize Modem UART DFU connection. 73 | * 74 | * @details Initializes connection and starts the DFU session with the device. 75 | * 76 | * @post The initial settings for the DFU will be activated. 77 | * 78 | * @param handle Pointer to connection handle to initialize 79 | * @param serial_port Serial port to connect to. 80 | * @param baud_rate Baud rate of serial connection. 81 | * @param response_timeout Time in ms before serial port should time out while waiting for a response from target. 82 | * @param callback Pointer to logger callback function to use, or NULL. 83 | * @param param Parameter to pass to callback function. 84 | * @param prog_cb Deprecated, progress info is passed back on the info log level. 85 | * 86 | * @retval SUCCESS 87 | * @retval OUT_OF_MEMORY Memory could not be allocated for the operation. 88 | * @retval INVALID_PARAMETER The handle parameter is NULL. 89 | * @retval The serial_port parameter is already initialized. 90 | * @retval SERIAL_PORT_RESOURCE_ERROR Unable to open serial port. 91 | * @retval TIME_OUT The operation timed out. 92 | */ 93 | NRFJPROG_API nrfjprogdll_err_t NRFDFU_connect_to_modemdfu_target(nrfjprog_inst_t * handle, 94 | const char * serial_port, 95 | const uint32_t baud_rate, 96 | const uint32_t response_timeout, 97 | msg_callback_ex * callback, 98 | void * param, 99 | void * prog_cb); 100 | 101 | /** 102 | * @brief Closes the connection to the underlying DLLs. 103 | * 104 | * @details Closes the connection to the underlying DLLs. 105 | * 106 | * @pre handle must point to a handle that was previously initialized with any function NRFDFU_connect_to_*_target(). 107 | * 108 | * @param handle An initialized connection handle 109 | * 110 | * @post The connection will be closed, and the handle invalidated. 111 | * 112 | * @retval SUCCESS 113 | * @retval INVALID_PARAMETER The handle parameter is NULL. 114 | */ 115 | NRFJPROG_API nrfjprogdll_err_t NRFDFU_close_connection(nrfjprog_inst_t * handle); 116 | 117 | /** 118 | * @brief Programs the provided zip file 119 | * 120 | * @details Initializes connection and starts the DFU session with the device. 121 | * 122 | * @pre handle must be initialized with any function NRFDFU_connect_to_*_target() before this function is run. 123 | * 124 | * @param handle An initialized connection handle 125 | * @param package_path Path to zip file containing a DFU package compatible with the current DFU connection. 126 | * 127 | * @retval SUCCESS 128 | * @retval INVALID_PARAMETER The handle parameter is NULL. 129 | * @retval The package_path parameter is NULL. 130 | * @retval The package_path points to a non existing file. 131 | * @retval The package_path points to a file without reading rights. 132 | * @retval FILE_OPERATION_FAILED Failed to make temporary files. 133 | */ 134 | NRFJPROG_API nrfjprogdll_err_t NRFDFU_program_package(nrfjprog_inst_t handle, const char * package_path); 135 | 136 | /** 137 | * @brief Programs using the list of files provided 138 | * 139 | * @details Programs the files provided as if they were part of a zip file passed to program_package 140 | * 141 | * @pre handle must be initialized with the function NRFDFU_connect_to_*_target() before this function is run. 142 | * 143 | * @param handle An initialized connection handle 144 | * @param paths List of zero-terminated C strings containing file paths 145 | * @param num_files The number of file paths in paths. 146 | * 147 | * @retval SUCCESS 148 | * @retval INVALID_PARAMETER The handle parameter is NULL. 149 | * @retval The paths points to a non existing file. 150 | * @retval The paths points to a file without reading rights. 151 | * @retval FILE_OPERATION_FAILED Failed to make temporary files. 152 | */ 153 | NRFJPROG_API nrfjprogdll_err_t NRFDFU_program_files(nrfjprog_inst_t handle, const char ** paths, uint32_t num_files); 154 | 155 | /** 156 | * @brief Verifies target firmware. 157 | * 158 | * @details Verifies the firmware on the target and checks if the firmware digest is correct. 159 | * 160 | * @pre handle must be initialized with any function NRFDFU_connect_to_*_target() before this function is run. 161 | * 162 | * @param handle An initialized connection handle 163 | * @param package_path Path to package of files to be verified. 164 | * 165 | * @retval SUCCESS 166 | * @retval INVALID_PARAMETER The handle parameter is NULL. 167 | * @retval The package_path parameter is NULL. 168 | * @retval The package_path points to a non existing file. 169 | * @retval The package_path points to a file without reading rights. 170 | * @retval FILE_OPERATION_FAILED Failed to make temporary files. 171 | */ 172 | NRFJPROG_API nrfjprogdll_err_t NRFDFU_verify_package(nrfjprog_inst_t handle, const char * package_path); 173 | 174 | /** 175 | * @brief Updates, and verifies target. 176 | * 177 | * @details Updates the target firmware with the hex file provided. Then verifies the update and checks if the firmware digest is correct. 178 | * 179 | * @pre handle must be initialized with any function NRFDFU_connect_to_*_target() before this function is run. 180 | * 181 | * @param handle An initialized connection handle 182 | * @param paths List of zero-terminated C strings containing file paths 183 | * @param num_files The number of file paths in paths. 184 | * 185 | * @retval SUCCESS 186 | * @retval INVALID_PARAMETER The handle parameter is NULL. 187 | * @retval The paths points to a non existing file. 188 | * @retval The paths points to a file without reading rights. 189 | * @retval FILE_OPERATION_FAILED Failed to make temporary files. 190 | */ 191 | NRFJPROG_API nrfjprogdll_err_t NRFDFU_verify_files(nrfjprog_inst_t handle, const char ** paths, uint32_t num_files); 192 | 193 | /** 194 | * @brief Read part of the target firmware to a buffer. 195 | * @details Reads length bytes from address into buffer. 196 | * 197 | * @pre handle must be initialized with the function NRFDFU_connect_to_ipc_target() before this function is run. 198 | * 199 | * @param handle An initialized connection handle 200 | * @param address The start address of the read. 201 | * @param buffer A path to where the output is written. 202 | * @param length length of reading opperation. 203 | * 204 | * @retval SUCCESS 205 | * @retval INVALID_PARAMETER The handle parameter is NULL. 206 | * @retval The address parameter is not page aligned. 207 | * @retval The length parameter is not larger than 0. 208 | * @retval The length parameter is not a multiple of 4. 209 | */ 210 | NRFJPROG_API nrfjprogdll_err_t NRFDFU_read(nrfjprog_inst_t handle, uint32_t address, uint8_t * buffer, uint32_t length); 211 | 212 | /** 213 | * @brief Deprecated 214 | * 215 | * @retval INVALID_OPERATION 216 | */ 217 | NRFJPROG_API nrfjprogdll_err_t NRFDFU_IPC_get_event_status(nrfjprog_inst_t handle, 218 | nrfdfu_ipc_event_t event, 219 | bool * status); 220 | 221 | /** 222 | * @brief Deprecated 223 | * 224 | * @retval INVALID_OPERATION 225 | */ 226 | NRFJPROG_API nrfjprogdll_err_t NRFDFU_IPC_acknowledge_event(nrfjprog_inst_t handle, nrfdfu_ipc_event_t event); 227 | 228 | /** 229 | * @brief Deprecated 230 | * 231 | * @retval INVALID_OPERATION 232 | */ 233 | NRFJPROG_API nrfjprogdll_err_t NRFDFU_IPC_read_id(nrfjprog_inst_t handle, ipc_dfu_id_t * id); 234 | 235 | /** 236 | * @brief Deprecated 237 | * 238 | * @retval INVALID_OPERATION 239 | */ 240 | NRFJPROG_API nrfjprogdll_err_t NRFDFU_IPC_read_digest(nrfjprog_inst_t handle, void * digest); 241 | 242 | #if defined(__cplusplus) 243 | } 244 | #endif 245 | 246 | #endif /* NRFDFU_H */ 247 | -------------------------------------------------------------------------------- /pynrfjprog/examples/__init__.py: -------------------------------------------------------------------------------- 1 | """ Examples for pynrfjprog. 2 | Each individual example can be used by importing examples as: 3 | from pynrfjprog import examples; then calling: 4 | examples.python_help.run() """ 5 | 6 | try: 7 | from . import python_help 8 | from . import program_hex 9 | from . import memory_read_write 10 | from . import highlevel_program_hex 11 | from . import highlevel_memory_read_write 12 | from . import nrf9160_pca20035_modem_upgrade_over_serial 13 | from . import rtt_asyncio 14 | from . import rtt_callback 15 | from . import rtt_synchronous 16 | 17 | 18 | from .hex_files import * 19 | 20 | except Exception: 21 | import python_help 22 | import program_hex 23 | import memory_read_write 24 | import highlevel_program_hex 25 | import highlevel_memory_read_write 26 | import nrf9160_pca20035_modem_upgrade_over_serial 27 | import rtt_asyncio 28 | import rtt_callback 29 | import rtt_synchronous 30 | 31 | 32 | from .hex_files import * 33 | -------------------------------------------------------------------------------- /pynrfjprog/examples/hex_files/__init__.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | 4 | def find_device_hex(device_family, device_version, suffix): 5 | """Find the appropriate hex file to program""" 6 | 7 | module_dir, _ = os.path.split(__file__) 8 | device_version_short = device_version.split("_")[0] 9 | hex_file_path = os.path.join(os.path.abspath(module_dir), device_version_short.lower() + suffix + ".hex") 10 | 11 | if os.path.exists(hex_file_path): 12 | return hex_file_path 13 | 14 | hex_file_path = os.path.join(os.path.abspath(module_dir), device_family.lower() + suffix + ".hex") 15 | 16 | if os.path.exists(hex_file_path): 17 | return hex_file_path 18 | 19 | raise FileNotFoundError( 20 | f"Could not find example binary for device {device_version.lower()}.\n\ 21 | This example may not support your device yet." 22 | ) 23 | 24 | 25 | def find_blinky_hex(device_family, device_version): 26 | """Find the blinky program for the specified device""" 27 | return find_device_hex(device_family, device_version, "_dk_blinky") 28 | 29 | 30 | def find_rtt_hex(device_family, device_version): 31 | """Find the RTT program for the specified device""" 32 | return find_device_hex(device_family, device_version, "_dk_rtt") 33 | 34 | 35 | def find_thingy91_modem_update_hex(): 36 | """Find the modem update fw for the thingy91""" 37 | module_dir, _ = os.path.split(__file__) 38 | return os.path.join(os.path.abspath(module_dir), "nrf9160_pca20035_firmware_upgrade_app_0.1.1.hex") 39 | -------------------------------------------------------------------------------- /pynrfjprog/examples/hex_files/nrf51_dk_blinky.hex: -------------------------------------------------------------------------------- 1 | :020000040000FA 2 | :1000000068100020650100007F01000081010000F0 3 | :1000100000000000000000000000000000000000E0 4 | :10002000000000000000000000000000830100004C 5 | :1000300000000000000000008501000087010000B2 6 | :100040008901000089010000890100008901000088 7 | :100050008901000000000000890100008901000002 8 | :100060008901000089010000890100008901000068 9 | :100070008901000089010000890100008901000058 10 | :100080008901000089010000890100008901000048 11 | :100090008901000089010000890100008901000038 12 | :1000A000890100008901000000000000000000003C 13 | :1000B0000000000000000000000000000000000040 14 | :1000C00000F002F800F03EF80CA030C80838241800 15 | :1000D0002D18A246671EAB4654465D46AC4201D180 16 | :1000E00000F030F87E460F3E0FCCB6460126334274 17 | :1000F00000D0FB1AA246AB46334318470403000066 18 | :1001000024030000103A02D378C878C1FAD8520705 19 | :1001100001D330C830C101D504680C6070470000BD 20 | :100120000023002400250026103A01D378C1FBD813 21 | :10013000520700D330C100D50B6070471FB51FBDFB 22 | :1001400010B510BD00F03BF81146FFF7F7FF00F0C7 23 | :1001500017F900F053F803B4FFF7F2FF03BC00F007 24 | :1001600059F8000003210C4802680A4302600B485A 25 | :1001700002680A4302600A4880470A480047FEE7CF 26 | :10018000FEE7FEE7FEE7FEE7FEE700000648074958 27 | :10019000074A084B70470000240500405405004002 28 | :1001A00025020000C1000000680000206810002047 29 | :1001B000680800206808002070477047704775463F 30 | :1001C00000F024F8AE46050069465346C008C0005A 31 | :1001D000854618B020B5FFF7D9FF60BC0027490855 32 | :1001E000B6460026C0C5C0C5C0C5C0C5C0C5C0C5CF 33 | :1001F000C0C5C0C5403D49008D46704710B5044696 34 | :10020000C046C0462046FFF7A6FF10BD0048704715 35 | :100210000400002001491820ABBEFEE726000200C2 36 | :100220007047000010B500F04BF8002805D01048CA 37 | :1002300010494860C8131049886100F025F800286B 38 | :1002400002D001200D49886000F070F800280ED01F 39 | :100250000B480068012807D00A480949086000BF18 40 | :10026000074800680128FBD1C0200549486110BD3E 41 | :10027000DFFF07C000050040006C004000060040A2 42 | :1002800000EC0640759300000C48008CC0B20128B9 43 | :1002900012D10A48808C0007000F00280CD10748B3 44 | :1002A000806AF0210840402806D10448C06A08400E 45 | :1002B000002801D1012070470020FCE7C00F00F0AA 46 | :1002C0001948008CC0B201282CD11748808C000737 47 | :1002D000000F002826D11448806AF0210840002829 48 | :1002E00006D11148C06A0840002801D1012070479A 49 | :1002F0000D48806AF0210840102806D10A48C06ADB 50 | :100300000840002801D10120F1E70748806AF02168 51 | :100310000840302806D10448C06A0840002801D1AE 52 | :100320000120E4E70020E2E7C00F00F01348008C52 53 | :10033000C0B201281FD11148808C0007000F00288F 54 | :1003400019D10E48806AF0210840A02806D10B4838 55 | :10035000C06A0840002801D1012070470748806A20 56 | :10036000F0210840D02806D10448C06A084000287F 57 | :1003700001D10120F1E70020EFE70000C00F00F0FD 58 | :10038000FF23F5330120400517498861400088614B 59 | :10039000400088614000886125E001204005124945 60 | :1003A000C860184600F022F8012040050E49886018 61 | :1003B0004000C860184600F019F8012080050A497D 62 | :1003C00088604000C860184600F010F80120C005A1 63 | :1003D000054988604000C860184600F007F8012011 64 | :1003E000000601498860D8E700050050002100E0C0 65 | :1003F000491C7D22D20042438A42F9D8704700004E 66 | :10040000200400000000002004000000040100009F 67 | :1004100024040000040000206410000020010000FB 68 | :040420000024F400C0 69 | :04000005000000C136 70 | :00000001FF 71 | -------------------------------------------------------------------------------- /pynrfjprog/examples/hex_files/nrf51_dk_rtt.hex: -------------------------------------------------------------------------------- 1 | :020000040000FA 2 | :1000000030250020C9050000E3050000E5050000DB 3 | :1000100000000000000000000000000000000000E0 4 | :10002000000000000000000000000000E7050000E4 5 | :100030000000000000000000E9050000EB050000E2 6 | :10004000ED050000ED050000ED050000ED050000E8 7 | :10005000ED05000000000000ED050000ED050000CA 8 | :10006000ED050000ED050000ED050000ED050000C8 9 | :10007000ED050000ED050000ED050000ED050000B8 10 | :10008000ED050000ED050000ED050000ED050000A8 11 | :10009000ED050000ED050000ED050000ED05000098 12 | :1000A000ED050000ED05000000000000000000006C 13 | :1000B0000000000000000000000000000000000040 14 | :1000C0000348854600F052FB00480047D500000079 15 | :1000D0003025002008B500F01DFA002001239B0206 16 | :1000E000224A23A10090012000F0E6F9002001231C 17 | :1000F0009B02224A22A10090022000F0DDF900209C 18 | :1001000001239B02214A22A10090012000F0A4F9C2 19 | :10011000002001239B02214A21A10090022000F02F 20 | :100120009BF9002001239B02204A21A1009003207B 21 | :1001300000F092F921A1002000F05FF915E0012400 22 | :1001400011E064222149204600F055F8204908605A 23 | :1001500008460068002805DD08461C49026820465C 24 | :1001600000F0AAF8641C032CEBD3E8E7CC000020D5 25 | :10017000446F776E4275666665723100CC0400206C 26 | :10018000446F776E4275666665723200CC08002057 27 | :10019000557042756666657231000000CC0C002017 28 | :1001A000557042756666657232000000CC10002002 29 | :1001B00055704275666665723300000048656C6C68 30 | :1001C0006F20576F726C642100000000CC14002077 31 | :1001D0000000002001460022002900D1704700BF26 32 | :1001E0000878002800D102E0521C491CF8E700BF43 33 | :1001F0001046F3E77047F7B582B006461746FFF79B 34 | :10020000F9FF18207043EE49401805691820704323 35 | :100210004018C0680090002001900098854224DDBD 36 | :100220001820704340188068441BBC4201DA204605 37 | :1002300000E03846044618207043E14A80184068C0 38 | :1002400041192246039800F07FFA019800190190A5 39 | :100250000398001903903F1B2D1918207043D849AB 40 | :1002600040188068A84200D100250098441BBC4279 41 | :1002700001DA204600E038460446002C11DD182043 42 | :100280007043CF4A8018406841192246039800F015 43 | :100290005BFA0198001901900398001903903F1B25 44 | :1002A0002D190198002804D018207043C449401823 45 | :1002B0000561019805B0F0BDF7B582B00446164659 46 | :1002C000FFF798FF18206043BD4960394018007D52 47 | :1002D0008007800F02281FD018206043401807694C 48 | :1002E000182060434018C068381A451E002D04DAF3 49 | :1002F00018206043401880684519AE420CDD182074 50 | :100300006043AF4960394018007D8007800F0028A6 51 | :1003100001D105B0F0BD2E46002E01D10020F8E736 52 | :100320000020019000BF18206043A54960394018A3 53 | :100330000769182060434018C068381A451E002D10 54 | :1003400004DA18206043401880684519182060437B 55 | :100350009B49603940188268182060434018C06883 56 | :10036000101AA84201DD28460AE01820604394498B 57 | :10037000603940188268182060434018C068101A1D 58 | :100380000546B54201DA284600E030460546182108 59 | :1003900061438B4A603A89184A6818216143884B47 60 | :1003A000603BC918C96850182A46039900F0CCF977 61 | :1003B000019840190190039840190390761B18206A 62 | :1003C00060437F4960394018C06842191820604373 63 | :1003D0004018C260182060434018C268182060436B 64 | :1003E00040188068824204D10022182060434018DF 65 | :1003F000C260002E97D101988BE770B505460C4678 66 | :100400002046FFF7E7FE0646324621462846FFF71C 67 | :1004100053FF70BD38B5012269460020FFF7EBFE9F 68 | :100420000446012C02D16846007838BD0020C04344 69 | :10043000FBE710B500BFFFF7EDFF0028FBDB10BDA9 70 | :1004400010B5FFF7D7FE5E480469C068A04201D02E 71 | :10045000012010BD0020FCE7F8B504460D46164605 72 | :100460001F46FFF7C7FE564878380069A04220D9DA 73 | :10047000002C15D018206043514960390D501820C8 74 | :10048000604340184660182060434018876000228F 75 | :100490001820604340180261182060434018C26071 76 | :1004A00018216143464A603A89180698486100203D 77 | :1004B000F8BD0020C043FBE7F8B504460D461646DC 78 | :1004C0001F46FFF797FE3E4878384069A0421ED984 79 | :1004D000002C14D01820604339490D501820604377 80 | :1004E000401846601820604340188760002218209A 81 | :1004F000604340180261182060434018C260182110 82 | :1005000061432F4A8918069848610020F8BD0020F1 83 | :10051000C043FBE710B5FFF76DFE10BD38B50446CC 84 | :10052000FF20694608700A2C03DA204630304870F4 85 | :1005300007E0102C04DA204637306946487000E0A6 86 | :1005400038BD20480470022269460020FFF7B4FE3F 87 | :1005500000BFF5E7F8B504460D46FF206946087070 88 | :100560000A2C03DA20463030487009E0102C04DAF7 89 | :10057000204637306946487002E00020C043F8BD8D 90 | :10058000022269460020FFF797FE29460020FFF768 91 | :1005900034FF06460A2C05DA0A48007830306946EE 92 | :1005A000487006E0102C04DA0648007837306946B7 93 | :1005B0004870022269460020FFF77EFE3046DEE7E3 94 | :1005C0007C000020C40000200321094802680A437F 95 | :1005D0000260084802680A430260074880470748EB 96 | :1005E0000047FEE7FEE7FEE7FEE7FEE7FEE7000066 97 | :1005F0002405004054050040D9060000C100000059 98 | :1006000048484949086070474848008CC0B20128F2 99 | :1006100012D14648808C0007000F00280CD14348B7 100 | :10062000806AF0210840A02806D14048C06A0840EE 101 | :10063000002801D1012070470020FCE73B48008CD6 102 | :10064000C0B2012812D13948808C0007000F002861 103 | :100650000CD13648806AF0210840402806D1334842 104 | :10066000C06A0840002801D1012070470020FCE743 105 | :100670002E48008CC0B201282CD12C48808C000759 106 | :10068000000F002826D12948806AF0210840002860 107 | :1006900006D12648C06A0840002801D101207047D1 108 | :1006A0002248806AF0210840102806D11F48C06AFD 109 | :1006B0000840002801D10120F1E71C48806AF021A0 110 | :1006C0000840302806D11948C06A0840002801D1E6 111 | :1006D0000120E4E70020E2E710B5FFF7C9FF00289A 112 | :1006E00005D0134813494860C81313498861FFF7C0 113 | :1006F000A5FF002802D0012010498860FFF784FF81 114 | :1007000000280ED00E480068012807D00D480C497B 115 | :10071000086000BF0A4800680128FBD1C0200849D2 116 | :10072000486110BD0024F400C8000020C00F00F094 117 | :10073000DFFF07C000050040006C004000060040DD 118 | :1007400000EC06407593000003460B439B0703D063 119 | :1007500009E008C9121F08C0042AFAD203E00B7886 120 | :100760000370401C491C521EF9D27047064C0125EB 121 | :10077000064E05E0E36807CC2B430C3C9847103449 122 | :10078000B442F7D3FFF7A0FCBC070000DC07000071 123 | :1007900002E008C8121F08C1002AFAD1704770474A 124 | :1007A000002001E001C1121F002AFBD170470000A8 125 | :1007B0005465726D696E616C00000000DC0700001A 126 | :1007C00000000020CC00000090070000A8080000F6 127 | :1007D000CC00002064240000A007000000000000FE 128 | :1007E0005345474745522052545400000000000032 129 | :1007F0000400000003000000B007000030150020D6 130 | :1008000000040000000000000000000000000000E4 131 | :1008100000000000000000000000000000000000D8 132 | :1008200000000000000000000000000000000000C8 133 | :1008300000000000000000000000000000000000B8 134 | :1008400000000000000000000000000000000000A8 135 | :100850000000000000000000B00700003019002078 136 | :100860000004000000000000000000000000000084 137 | :100870000000000000000000000000000000000078 138 | :100880000000000000000000000000000000000068 139 | :100890000000000000000000000000000000000058 140 | :0808A000000000000024F40038 141 | :04000005000000C136 142 | :00000001FF 143 | -------------------------------------------------------------------------------- /pynrfjprog/examples/hex_files/nrf52840_dk_blinky.hex: -------------------------------------------------------------------------------- 1 | :020000040000FA 2 | :1000000008200020150400001D0400001F0400004B 3 | :10001000210400002304000025040000000000006B 4 | :1000200000000000000000000000000027040000A5 5 | :1000300029040000000000002B0400002D04000033 6 | :100040002F0400002F0400002F0400002F040000E4 7 | :100050002F0400002F0400002F0400002F040000D4 8 | :100060002F0400002F0400002F0400002F040000C4 9 | :100070002F0400002F0400002F0400002F040000B4 10 | :100080002F0400002F0400002F0400002F040000A4 11 | :100090002F0400002F0400002F0400002F04000094 12 | :1000A0002F0400002F0400002F0400002F04000084 13 | :1000B0002F0400002F0400000000000000000000DA 14 | :1000C0002F0400002F0400002F0400002F04000064 15 | :1000D0002F0400002F0400002F0400002F04000054 16 | :1000E0002F0400002F0400002F0400002F04000044 17 | :1000F000000000002F0400000000000000000000CD 18 | :1001000000000000000000000000000000000000EF 19 | :1001100000000000000000000000000000000000DF 20 | :1001200000000000000000000000000000000000CF 21 | :1001300000000000000000000000000000000000BF 22 | :1001400000000000000000000000000000000000AF 23 | :10015000000000000000000000000000000000009F 24 | :10016000000000000000000000000000000000008F 25 | :10017000000000000000000000000000000000007F 26 | :10018000000000000000000000000000000000006F 27 | :10019000000000000000000000000000000000005F 28 | :1001A000000000000000000000000000000000004F 29 | :1001B000000000000000000000000000000000003F 30 | :1001C000000000000000000000000000000000002F 31 | :1001D000000000000000000000000000000000001F 32 | :1001E000000000000000000000000000000000000F 33 | :1001F00000000000000000000000000000000000FF 34 | :1002000000000000000000000000000000000000EE 35 | :1002100000000000000000000000000000000000DE 36 | :1002200000000000000000000000000000000000CE 37 | :1002300000000000000000000000000000000000BE 38 | :1002400000000000000000000000000000000000AE 39 | :10025000000000000000000000000000000000009E 40 | :10026000000000000000000000000000000000008E 41 | :10027000000000000000000000000000000000007E 42 | :10028000000000000000000000000000000000006E 43 | :10029000000000000000000000000000000000005E 44 | :1002A000000000000000000000000000000000004E 45 | :1002B000000000000000000000000000000000003E 46 | :1002C000000000000000000000000000000000002E 47 | :1002D000000000000000000000000000000000001E 48 | :1002E000000000000000000000000000000000000E 49 | :1002F00000000000000000000000000000000000FE 50 | :1003000000000000000000000000000000000000ED 51 | :1003100000000000000000000000000000000000DD 52 | :1003200000000000000000000000000000000000CD 53 | :1003300000000000000000000000000000000000BD 54 | :1003400000000000000000000000000000000000AD 55 | :10035000000000000000000000000000000000009D 56 | :10036000000000000000000000000000000000008D 57 | :10037000000000000000000000000000000000007D 58 | :10038000000000000000000000000000000000006D 59 | :10039000000000000000000000000000000000005D 60 | :1003A000000000000000000000000000000000004D 61 | :1003B000000000000000000000000000000000003D 62 | :1003C000000000000000000000000000000000002D 63 | :1003D000000000000000000000000000000000001D 64 | :1003E000000000000000000000000000000000000D 65 | :1003F00000000000000000000000000000000000FD 66 | :10040000DFF80CD000F018F8004800478D05000018 67 | :10041000082000200648804706480047FEE7FEE720 68 | :10042000FEE7FEE7FEE7FEE7FEE7FEE7FEE7FEE7A4 69 | :100430005D04000001040000064C074D06E0E06882 70 | :1004400040F0010394E8070098471034AC42F6D31B 71 | :10045000FFF7DAFFFC0500001C06000030B54FF086 72 | :1004600080500021D0F830210124082A02D1D0F890 73 | :10047000343113B1082A09D00BE04FF08042C2F8A2 74 | :100480000C11C2F810112E4A116005E0D0F8343179 75 | :1004900013B1082A04D006E02B4B2A4A1A6005E063 76 | :1004A000D0F8343113B1082A08D00EE090F8583251 77 | :1004B0002648026863F30302026002E0D0F83401C8 78 | :1004C00018B9234A4FF4407010602248026842F481 79 | :1004D00070020260BFF34F8FBFF36F8F4FF0102297 80 | :1004E000D2F80002002803DBD2F80402002822DA46 81 | :1004F000194B1C6019480468002CFCD01224C2F867 82 | :1005000000420568002DFCD0C2F804420268002AAF 83 | :10051000FCD0196001680029FCD0BFF34F8F0D4853 84 | :100520007C3801680E4A01F4E06111430160BFF3B9 85 | :100530004F8F00BFFDE70C490A48086030BD00003E 86 | :1005400038050040488103008C560040E40E00400E 87 | :100550004096024088ED00E004E5014000E40140DF 88 | :100560000400FA050090D0030000002002E008C853 89 | :10057000121F08C1002AFAD170477047002001E01D 90 | :1005800001C1121F002AFBD17047000008B50021ED 91 | :10059000164A012000FA01F313F4F03F02D0146868 92 | :1005A0001C431460491C2029F4D3104E104C103EFB 93 | :1005B000371D104D4FF0000907F1040C002233687D 94 | :1005C00014F8028000FA08F121EA0308C7F8008055 95 | :1005D0001940CCF800104946CDF80090491C009114 96 | :1005E000A942FBDB521C042AE9DBE7E714050050B3 97 | :1005F000F8050000C02709000D0E0F101C060000B2 98 | :1006000000000020040000006C050000200600002F 99 | :1006100004000020042000007C0500000090D003AE 100 | :0400000500000401F2 101 | :00000001FF 102 | -------------------------------------------------------------------------------- /pynrfjprog/examples/hex_files/nrf52_dk_blinky.hex: -------------------------------------------------------------------------------- 1 | :020000040000FA 2 | :1000000068400020A1040000A9040000AB04000027 3 | :10001000AD040000AF040000B104000000000000C7 4 | :10002000000000000000000000000000B304000019 5 | :100030000000000000000000B5040000B70400004C 6 | :10004000B9040000B9040000B9040000B9040000BC 7 | :10005000B9040000B9040000B9040000B9040000AC 8 | :10006000B9040000B9040000B9040000B90400009C 9 | :10007000B9040000B9040000B9040000B90400008C 10 | :10008000B9040000B9040000B9040000B90400007C 11 | :10009000B9040000B9040000B9040000B90400006C 12 | :1000A000B9040000B9040000B9040000B90400005C 13 | :1000B000B9040000B90400000000000000000000C6 14 | :1000C000B9040000B9040000B9040000B90400003C 15 | :1000D000B9040000B90400000000000000000000A6 16 | :1000E0000000000000000000000000000000000010 17 | :1000F0000000000000000000000000000000000000 18 | :1001000000000000000000000000000000000000EF 19 | :1001100000000000000000000000000000000000DF 20 | :1001200000000000000000000000000000000000CF 21 | :1001300000000000000000000000000000000000BF 22 | :1001400000000000000000000000000000000000AF 23 | :10015000000000000000000000000000000000009F 24 | :10016000000000000000000000000000000000008F 25 | :10017000000000000000000000000000000000007F 26 | :10018000000000000000000000000000000000006F 27 | :10019000000000000000000000000000000000005F 28 | :1001A000000000000000000000000000000000004F 29 | :1001B000000000000000000000000000000000003F 30 | :1001C000000000000000000000000000000000002F 31 | :1001D000000000000000000000000000000000001F 32 | :1001E000000000000000000000000000000000000F 33 | :1001F00000000000000000000000000000000000FF 34 | :1002000000000000000000000000000000000000EE 35 | :1002100000000000000000000000000000000000DE 36 | :1002200000000000000000000000000000000000CE 37 | :1002300000000000000000000000000000000000BE 38 | :1002400000000000000000000000000000000000AE 39 | :10025000000000000000000000000000000000009E 40 | :10026000000000000000000000000000000000008E 41 | :10027000000000000000000000000000000000007E 42 | :10028000000000000000000000000000000000006E 43 | :10029000000000000000000000000000000000005E 44 | :1002A000000000000000000000000000000000004E 45 | :1002B000000000000000000000000000000000003E 46 | :1002C000000000000000000000000000000000002E 47 | :1002D000000000000000000000000000000000001E 48 | :1002E000000000000000000000000000000000000E 49 | :1002F00000000000000000000000000000000000FE 50 | :1003000000000000000000000000000000000000ED 51 | :1003100000000000000000000000000000000000DD 52 | :1003200000000000000000000000000000000000CD 53 | :1003300000000000000000000000000000000000BD 54 | :1003400000000000000000000000000000000000AD 55 | :10035000000000000000000000000000000000009D 56 | :10036000000000000000000000000000000000008D 57 | :10037000000000000000000000000000000000007D 58 | :10038000000000000000000000000000000000006D 59 | :10039000000000000000000000000000000000005D 60 | :1003A000000000000000000000000000000000004D 61 | :1003B000000000000000000000000000000000003D 62 | :1003C000000000000000000000000000000000002D 63 | :1003D000000000000000000000000000000000001D 64 | :1003E000000000000000000000000000000000000D 65 | :1003F00000000000000000000000000000000000FD 66 | :1004000000F002F800F03CF80AA090E8000C8244EA 67 | :100410008344AAF10107DA4501D100F031F8AFF2C7 68 | :10042000090EBAE80F0013F0010F18BFFB1A43F0D2 69 | :10043000010318477405000094050000103A24BF1A 70 | :1004400078C878C1FAD8520724BF30C830C144BF39 71 | :1004500004680C607047000000230024002500267B 72 | :10046000103A28BF78C1FBD8520728BF30C148BF17 73 | :100470000B6070471FB500F092FA1FBD10B510BD9C 74 | :1004800000F031F81146FFF7F5FF00F03FFA00F0F9 75 | :100490004FF803B4FFF7F2FF03BC00F057F8000079 76 | :1004A0000948804709480047FEE7FEE7FEE7FEE708 77 | :1004B000FEE7FEE7FEE7FEE7FEE700000448054929 78 | :1004C000054A064B704700006D050000010400005E 79 | :1004D000680000206840002068200020682000207C 80 | :1004E000704770477047754600F02CF8AE4605001F 81 | :1004F0006946534620F00700854618B020B5FFF73F 82 | :10050000DDFFBDE820404FF000064FF000074FF040 83 | :1005100000084FF0000B21F00701AC46ACE8C00921 84 | :10052000ACE8C009ACE8C009ACE8C0098D4670472A 85 | :1005300010B50446AFF300802046BDE81040FFF739 86 | :10054000A8BF00000048704704000020014918209F 87 | :10055000ABBEFEE7260002007047000001480249DA 88 | :10056000086070470090D0030000002010B500F034 89 | :10057000FBF828B172480068C0F342307149086046 90 | :1005800000F02EF928B17048006820F080706E49A4 91 | :10059000086000F043F948B100206C4908604FF052 92 | :1005A0008041C1F810016749091F086000F072F925 93 | :1005B00018B1032063496431086000F089F900280C 94 | :1005C00055D063480068634908606148001D0068B1 95 | :1005D000091D08605E4808300068091D08605C4815 96 | :1005E0000C300068091D0860594810300068091D6A 97 | :1005F0000860574814300068091D086054481830D6 98 | :10060000006854492031086051481C300068091DB9 99 | :1006100008604F4820300068091D08604C482430AD 100 | :100620000068091D08604A4828300068091D0860F4 101 | :1006300047482C300068091D086045483030006884 102 | :10064000444940310860424834300068091D086060 103 | :100650003F4838300068091D08603D483C3000685C 104 | :10066000091D08603A4840300068091D0860364896 105 | :100670007438006840F4700033497439086000BF72 106 | :1006800000BF00BFBFF34F8F00BF00BF00BF00BF60 107 | :1006900000BF00BFBFF36F8F00BF00BF00BF2E4879 108 | :1006A000006800F0004030B92B48001D006800F0E1 109 | :1006B0000040002840D001202849086000BF284899 110 | :1006C00000680028FBD015202349086000BF24489B 111 | :1006D00000680028FBD015211F48001D016000BFE5 112 | :1006E0001F4800680028FBD000201C49086000BF9C 113 | :1006F0001B4800680028FBD000BF00BF00BF00BF40 114 | :1007000000BFBFF34F8F00BF00BF00BF0E48F038DF 115 | :10071000006800F4E06013490843001D0A49F039FD 116 | :10072000086000BF00BF00BFBFF34F8F00BF00BF16 117 | :1007300000BF00BF00BFFDE7FFF710FF10BD0000C6 118 | :10074000440200103C050040FCED00E00C010040BC 119 | :100750000404001020C500400012001004E5014010 120 | :1007600000E401400000FA051C480078062832D158 121 | :100770001A48001D007800F00F0060BB17480830D1 122 | :10078000007800F0F000302807D114480C300078D1 123 | :1007900000F0F00008B901207047104808300078D8 124 | :1007A00000F0F000402807D10C480C30007800F031 125 | :1007B000F00008B90120EFE708480830007800F0A1 126 | :1007C000F000502807D105480C30007800F0F00008 127 | :1007D00008B90120E0E70020DEE70000E00F00F0AC 128 | :1007E0000D480078062814D10B48001D007800F051 129 | :1007F0000F0070B908480830007800F0F000302889 130 | :1008000007D105480C30007800F0F00008B901204D 131 | :1008100070470020FCE70000E00F00F01C48007863 132 | :10082000062832D11A48001D007800F00F0060BB86 133 | :1008300017480830007800F0F000302807D114483D 134 | :100840000C30007800F0F00008B901207047104823 135 | :100850000830007800F0F000402807D10C480C3038 136 | :10086000007800F0F00008B90120EFE708480830F0 137 | :10087000007800F0F000502807D105480C300078CF 138 | :1008800000F0F00008B90120E0E70020DEE70000FA 139 | :10089000E00F00F00D480078062814D10B48001D29 140 | :1008A000007800F00F0070B908480830007800F0B8 141 | :1008B000F000302807D105480C30007800F0F00037 142 | :1008C00008B9012070470020FCE70000E00F00F0AD 143 | :1008D0000D480078062814D10B48001D007800F060 144 | :1008E0000F0070B908480830007800F0F000502878 145 | :1008F00007D105480C30007800F0F00008B901205D 146 | :1009000070470020FCE70000E00F00F04FF4FA739E 147 | :100910004FF400301B490860400008604000086048 148 | :10092000400008602DE04FF4003016490C39086093 149 | :10093000184600F029F84FF40030124910390860C9 150 | :100940004000091D0860184600F01EF84FF4802092 151 | :100950000C49103908604000091D0860184600F075 152 | :1009600013F84FF400200749103908604000091DB2 153 | :100970000860184600F008F84FF48010014910395B 154 | :100980000860D0E718050050002100E0491C00EB8A 155 | :100990004002C2EBC012B1EBC20FF7D370474FF069 156 | :1009A0004070E1EE100A7047C80900000000002006 157 | :1009B000040000003C040000CC09000004000020FA 158 | :0C09C00064400000580400000090D003C8 159 | :0400000500000401F2 160 | :00000001FF 161 | -------------------------------------------------------------------------------- /pynrfjprog/examples/hex_files/nrf52_dk_rtt.hex: -------------------------------------------------------------------------------- 1 | :020000040000FA 2 | :10000000303D0020AD090000B5090000B70900002F 3 | :10001000B9090000BB090000BD0900000000000094 4 | :10002000000000000000000000000000BF09000008 5 | :100030000000000000000000C1090000C30900002A 6 | :10004000C5090000C5090000C5090000C509000078 7 | :10005000C5090000C5090000C5090000C509000068 8 | :10006000C5090000C5090000C5090000C509000058 9 | :10007000C5090000C5090000C5090000C509000048 10 | :10008000C5090000C5090000C5090000C509000038 11 | :10009000C5090000C5090000C5090000C509000028 12 | :1000A000C5090000C5090000C5090000C509000018 13 | :1000B000C5090000C50900000000000000000000A4 14 | :1000C000C5090000C5090000C5090000C5090000F8 15 | :1000D000C5090000C5090000000000000000000084 16 | :1000E0000000000000000000000000000000000010 17 | :1000F0000000000000000000000000000000000000 18 | :1001000000000000000000000000000000000000EF 19 | :1001100000000000000000000000000000000000DF 20 | :1001200000000000000000000000000000000000CF 21 | :1001300000000000000000000000000000000000BF 22 | :1001400000000000000000000000000000000000AF 23 | :10015000000000000000000000000000000000009F 24 | :10016000000000000000000000000000000000008F 25 | :10017000000000000000000000000000000000007F 26 | :10018000000000000000000000000000000000006F 27 | :10019000000000000000000000000000000000005F 28 | :1001A000000000000000000000000000000000004F 29 | :1001B000000000000000000000000000000000003F 30 | :1001C000000000000000000000000000000000002F 31 | :1001D000000000000000000000000000000000001F 32 | :1001E000000000000000000000000000000000000F 33 | :1001F00000000000000000000000000000000000FF 34 | :1002000000000000000000000000000000000000EE 35 | :1002100000000000000000000000000000000000DE 36 | :1002200000000000000000000000000000000000CE 37 | :1002300000000000000000000000000000000000BE 38 | :1002400000000000000000000000000000000000AE 39 | :10025000000000000000000000000000000000009E 40 | :10026000000000000000000000000000000000008E 41 | :10027000000000000000000000000000000000007E 42 | :10028000000000000000000000000000000000006E 43 | :10029000000000000000000000000000000000005E 44 | :1002A000000000000000000000000000000000004E 45 | :1002B000000000000000000000000000000000003E 46 | :1002C000000000000000000000000000000000002E 47 | :1002D000000000000000000000000000000000001E 48 | :1002E000000000000000000000000000000000000E 49 | :1002F00000000000000000000000000000000000FE 50 | :1003000000000000000000000000000000000000ED 51 | :1003100000000000000000000000000000000000DD 52 | :1003200000000000000000000000000000000000CD 53 | :1003300000000000000000000000000000000000BD 54 | :1003400000000000000000000000000000000000AD 55 | :10035000000000000000000000000000000000009D 56 | :10036000000000000000000000000000000000008D 57 | :10037000000000000000000000000000000000007D 58 | :10038000000000000000000000000000000000006D 59 | :10039000000000000000000000000000000000005D 60 | :1003A000000000000000000000000000000000004D 61 | :1003B000000000000000000000000000000000003D 62 | :1003C000000000000000000000000000000000002D 63 | :1003D000000000000000000000000000000000001D 64 | :1003E000000000000000000000000000000000000D 65 | :1003F00000000000000000000000000000000000FD 66 | :10040000DFF80CD000F06CFC004800471504000039 67 | :10041000303D002008B500F064FA00204FF48063FE 68 | :10042000224A23A10090012000F021FA00204FF47D 69 | :100430008063224A22A10090022000F018FA0020D6 70 | :100440004FF48063214A22A10090012000F0D0F9EE 71 | :1004500000204FF48063214A21A10090022000F087 72 | :10046000C7F900204FF48063204A21A100900320A7 73 | :1004700000F0BEF921A1002000F088F915E0012468 74 | :1004800011E064222149204600F054F82049086018 75 | :1004900008460068002805DD08461C490268204619 76 | :1004A00000F0AAF8641C032CEBD3E8E7CC00002092 77 | :1004B000446F776E4275666665723100CC04002029 78 | :1004C000446F776E4275666665723200CC08002014 79 | :1004D000557042756666657231000000CC0C0020D4 80 | :1004E000557042756666657232000000CC100020BF 81 | :1004F00055704275666665723300000048656C6C25 82 | :100500006F20576F726C642100000000CC14002033 83 | :10051000000000200146002209B90020704700BFFA 84 | :10052000087800B902E0521C491CF9E700BF1046E8 85 | :10053000F4E770472DE9F047064688461746FFF76F 86 | :10054000F8FF06EB4601F84800EBC100056906EB31 87 | :100550004601F54800EBC100D0F80CA04FF00009AF 88 | :10056000554524DD06EB4601EF4800EBC1008068ED 89 | :10057000441BBC4201DA204600E03846044606EB44 90 | :100580004602E94800EBC200406841192246404655 91 | :1005900000F094FBA144A0443F1B254406EB460118 92 | :1005A000E14800EBC1008068A84200D10025AAEB19 93 | :1005B0000504BC4201DA204600E038460446002C1F 94 | :1005C0000EDD06EB4602D84800EBC2004068411938 95 | :1005D0002246404600F072FBA144A0443F1B254444 96 | :1005E000B9F1000F05D006EB4601CF4800EBC10082 97 | :1005F00005614846BDE8F0872DE9F0470446894685 98 | :100600001646FFF796FF04EB4401C748603800EB3D 99 | :10061000C100007D00F0030002282BD004EB440150 100 | :10062000C148603800EBC100D0F8108004EB4401F1 101 | :10063000BD48603800EBC100C068A8EB0000451E53 102 | :10064000002D07DA04EB4401B748603800EBC10025 103 | :1006500080680544AE420DDD04EB4401B2486038C9 104 | :1006600000EBC100007D00F0030010B90020BDE8E0 105 | :10067000F0872E460EB90020F9E7002700BF04EBF3 106 | :100680004401A948603800EBC100D0F8108004EBA9 107 | :100690004401A548603800EBC100C068A8EB000029 108 | :1006A000451E002D07DA04EB44019F48603800EB3B 109 | :1006B000C1008068054404EB44019B48603800EBAE 110 | :1006C000C10004EB440281689748603800EBC20027 111 | :1006D000C068081AA84201DD28460EE004EB440178 112 | :1006E0009148603800EBC10004EB440281688E48F9 113 | :1006F000603800EBC200C068081A0546B54201DA4E 114 | :10070000284600E03046054604EB4402864960393D 115 | :1007100001EBC20104EB44034A688349603901EBF1 116 | :10072000C301C96850182A46494600F0C7FA2F4449 117 | :10073000A944761B04EB44017B48603800EBC10000 118 | :10074000C068411904EB44027748603800EBC200EE 119 | :10075000C16004EB44017448603800EBC100C1681B 120 | :1007600004EB44027048603800EBC20080688142AC 121 | :1007700007D1002104EB44026B48603800EBC20053 122 | :10078000C160002E7FF47BAF384670E770B5054638 123 | :100790000C462046FFF7BEFE064632462146284656 124 | :1007A000FFF72AFF70BD38B5012269460020FFF728 125 | :1007B000C1FE0446012C02D19DF8000038BD4FF067 126 | :1007C000FF30FBE710B500BFFFF7EDFF0028FBDBB4 127 | :1007D00010BD10B5FFF7ADFE53487838D0F888400B 128 | :1007E000D0F88400A04201D0012010BD0020FCE719 129 | :1007F0002DE9F04104460D4616461F46DDF81880E7 130 | :10080000FFF797FE484878380069A0422CD904B316 131 | :1008100004EB44014448603840F8315004EB440193 132 | :1008200000EBC100466004EB44013F48603800EB38 133 | :10083000C1008760002104EB44023B48603800EBB4 134 | :10084000C200016104EB44023748603800EBC2008B 135 | :10085000C16004EB44013448603800EBC100C0F8CB 136 | :1008600014800020BDE8F0814FF0FF30FAE72DE959 137 | :10087000F04104460D4616461F46DDF81880FFF786 138 | :1008800058FE294878384069A04227D9E4B104EBE2 139 | :100890004401254840F8315004EB440100EBC1000D 140 | :1008A000466004EB4401204800EBC1008760002152 141 | :1008B00004EB44021C4800EBC200016104EB44025B 142 | :1008C000194800EBC200C16004EB4401164800EB7C 143 | :1008D000C100C0F814800020BDE8F0814FF0FF3067 144 | :1008E000FAE710B5FFF725FE10BD38B50446FF2026 145 | :1008F0008DF800000A2C05DA04F13000C0B28DF842 146 | :10090000010008E0102C05DA04F13700C0B28DF8C0 147 | :10091000010000E038BD054804700222694600204D 148 | :10092000FFF76AFE00BFF5E77C000020C40000204E 149 | :10093000F8B504460D46FF208DF800000A2C05DAB4 150 | :1009400004F13000C0B28DF801000AE0102C05DA85 151 | :1009500004F13700C0B28DF8010002E04FF0FF3023 152 | :10096000F8BD022269460020FFF746FE2946002016 153 | :10097000FFF70CFF06460A2C06DA0B4800783030E9 154 | :10098000C0B28DF8010007E0102C05DA06480078A7 155 | :100990003730C0B28DF80100022269460020FFF70F 156 | :1009A0002BFE3046DCE70000C400002006488047EC 157 | :1009B00006480047FEE7FEE7FEE7FEE7FEE7FEE744 158 | :1009C000FEE7FEE7FEE700005F0B00000104000009 159 | :1009D000B148B24908607047B1480078062814D180 160 | :1009E000AF48001D007800F00F0070B9AC48083027 161 | :1009F000007800F0F000502807D1A9480C300078AA 162 | :100A000000F0F00008B9012070470020FCE7A4487E 163 | :100A10000078062814D1A248001D007800F00F00CD 164 | :100A200070B99F480830007800F0F000302807D1F6 165 | :100A30009B480C30007800F0F00008B901207047A6 166 | :100A40000020FCE796480078062832D19448001D23 167 | :100A5000007800F00F0060BB91480830007800F08B 168 | :100A6000F000302807D18E480C30007800F0F000FC 169 | :100A700008B9012070478A480830007800F0F0007B 170 | :100A8000402807D186480C30007800F0F00008B903 171 | :100A90000120EFE782480830007800F0F00050288D 172 | :100AA00007D17F480C30007800F0F00008B9012031 173 | :100AB000E0E70020DEE77A480078062814D178487D 174 | :100AC000001D007800F00F0070B9754808300078FC 175 | :100AD00000F0F000302807D171480C30007800F0A9 176 | :100AE000F00008B9012070470020FCE76C4800784E 177 | :100AF000062832D16A48001D007800F00F0060BB64 178 | :100B000067480830007800F0F000302807D16448CA 179 | :100B10000C30007800F0F00008B901207047604800 180 | :100B20000830007800F0F000402807D15C480C3015 181 | :100B3000007800F0F00008B90120EFE758480830CD 182 | :100B4000007800F0F000502807D155480C300078AC 183 | :100B500000F0F00008B90120E0E70020DEE710B562 184 | :100B6000FFF7C4FF28B14F480068C0F342304E4938 185 | :100B70000860FFF7A0FF28B14C48006820F08070A3 186 | :100B80004A490860FFF75EFF48B100204849086005 187 | :100B90004FF08041C1F810014349091F0860FFF779 188 | :100BA00036FF18B10320404964310860FFF714FF95 189 | :100BB000002855D03F4800683F4908603D48001D67 190 | :100BC0000068091D08603B4808300068091D08607E 191 | :100BD00038480C300068091D08603648103000683D 192 | :100BE000091D0860334814300068091D0860314849 193 | :100BF000183000683049203108602E481C300068E9 194 | :100C0000091D08602B4820300068091D086029482C 195 | :100C100024300068091D0860264828300068091D36 196 | :100C2000086024482C300068091D086021483030D5 197 | :100C300000682149403108601E4834300068091DB1 198 | :100C400008601C4838300068091D086019483C30AD 199 | :100C50000068091D0860174840300068091D0860D9 200 | :100C600012487438006840F4700010497439086004 201 | :100C700000BF00BF00BFBFF34F8F00BF00BF00BF6A 202 | :100C800000BF00BF00BFBFF36F8F00BF00BF00BF3A 203 | :100C9000FFF79EFE10BD00000090D003C8000020AA 204 | :100CA000E00F00F0440200103C050040FCED00E0C5 205 | :100CB0000C0100400404001020C5004040EA01037C 206 | :100CC0009B0703D009E008C9121F08C0042AFAD202 207 | :100CD00003E011F8013B00F8013B521EF9D27047C6 208 | :100CE000064C074D06E0E06840F0010394E8070079 209 | :100CF00098471034AC42F6D3FFF786FB300D000066 210 | :100D0000500D000002E008C8121F08C1002AFAD1E5 211 | :100D100070477047002001E001C1121F002AFBD17B 212 | :100D2000704700005465726D696E616C00000000D0 213 | :100D3000500D000000000020CC000000040D000059 214 | :100D40001C0E0000CC000020643C0000140D0000CC 215 | :100D500000000000534547474552205254540000BC 216 | :100D6000000000000400000003000000240D00004B 217 | :100D7000301500200004000000000000000000000A 218 | :100D80000000000000000000000000000000000063 219 | :100D90000000000000000000000000000000000053 220 | :100DA0000000000000000000000000000000000043 221 | :100DB0000000000000000000000000000000000033 222 | :100DC000000000000000000000000000240D0000F2 223 | :100DD00030190020000400000000000000000000A6 224 | :100DE0000000000000000000000000000000000003 225 | :100DF00000000000000000000000000000000000F3 226 | :100E000000000000000000000000000000000000E2 227 | :0C0E100000000000000000000090D00373 228 | :0400000500000401F2 229 | :00000001FF 230 | -------------------------------------------------------------------------------- /pynrfjprog/examples/hex_files/nrf53_dk_blinky.hex: -------------------------------------------------------------------------------- 1 | :020000040000FA 2 | :1000000060200020A1040000A9040000AB0400004F 3 | :10001000AD040000AF040000B1040000B304000010 4 | :10002000000000000000000000000000B504000017 5 | :10003000B704000000000000B9040000BB04000089 6 | :10004000BD040000BD04000000000000BD0400006D 7 | :1000500000000000BD0400000000000000000000DF 8 | :10006000BD040000BD040000BD040000BD0400008C 9 | :10007000BD040000BD040000BD040000BD0400007C 10 | :10008000BD040000BD0400000000000000000000EE 11 | :1000900061050000BD040000000000000000000039 12 | :1000A000BD040000BD040000BD040000BD0400004C 13 | :1000B000BD040000BD040000BD040000BD0400003C 14 | :1000C000BD040000BD040000BD040000BD0400002C 15 | :1000D000BD04000000000000BD040000000000009E 16 | :1000E000BD04000000000000BD040000BD040000CD 17 | :1000F00000000000BD04000000000000BD0400007E 18 | :10010000000000000000000000000000BD0400002E 19 | :10011000BD04000000000000BD040000BD0400009C 20 | :1001200000000000BD04000000000000000000000E 21 | :1001300000000000000000000000000000000000BF 22 | :1001400000000000000000000000000000000000AF 23 | :10015000BD040000000000000000000000000000DE 24 | :10016000000000000000000000000000000000008F 25 | :10017000000000000000000000000000000000007F 26 | :10018000000000000000000000000000000000006F 27 | :10019000000000000000000000000000000000005F 28 | :1001A000000000000000000000000000000000004F 29 | :1001B000000000000000000000000000000000003F 30 | :1001C000000000000000000000000000000000002F 31 | :1001D000000000000000000000000000000000001F 32 | :1001E000000000000000000000000000000000000F 33 | :1001F00000000000000000000000000000000000FF 34 | :1002000000000000000000000000000000000000EE 35 | :1002100000000000000000000000000000000000DE 36 | :1002200000000000000000000000000000000000CE 37 | :1002300000000000000000000000000000000000BE 38 | :1002400000000000000000000000000000000000AE 39 | :10025000000000000000000000000000000000009E 40 | :10026000000000000000000000000000000000008E 41 | :10027000000000000000000000000000000000007E 42 | :10028000000000000000000000000000000000006E 43 | :10029000000000000000000000000000000000005E 44 | :1002A000000000000000000000000000000000004E 45 | :1002B000000000000000000000000000000000003E 46 | :1002C000000000000000000000000000000000002E 47 | :1002D000000000000000000000000000000000001E 48 | :1002E000000000000000000000000000000000000E 49 | :1002F00000000000000000000000000000000000FE 50 | :1003000000000000000000000000000000000000ED 51 | :1003100000000000000000000000000000000000DD 52 | :1003200000000000000000000000000000000000CD 53 | :1003300000000000000000000000000000000000BD 54 | :1003400000000000000000000000000000000000AD 55 | :10035000000000000000000000000000000000009D 56 | :10036000000000000000000000000000000000008D 57 | :10037000000000000000000000000000000000007D 58 | :10038000000000000000000000000000000000006D 59 | :10039000000000000000000000000000000000005D 60 | :1003A000000000000000000000000000000000004D 61 | :1003B000000000000000000000000000000000003D 62 | :1003C000000000000000000000000000000000002D 63 | :1003D000000000000000000000000000000000001D 64 | :1003E000000000000000000000000000000000000D 65 | :1003F00000000000000000000000000000000000FD 66 | :1004000000F002F800F03CF80AA090E8000C8244EA 67 | :100410008344AAF10107DA4501D100F031F8AFF2C7 68 | :10042000090EBAE80F0013F0010F18BFFB1A43F0D2 69 | :10043000010318473C0300006C030000103A24BF7E 70 | :1004400078C878C1FAD8520724BF30C830C144BF39 71 | :1004500004680C607047000000230024002500267B 72 | :10046000103A28BF78C1FBD8520728BF30C148BF17 73 | :100470000B6070471FB500F06DF91FBD10B510BDC2 74 | :1004800000F033F81146FFF7F5FF00F01DF900F01A 75 | :1004900051F803B4FFF7F2FF03BC00F059F8000075 76 | :1004A0000A4880470A480047FEE7FEE7FEE7FEE706 77 | :1004B000FEE7FEE7FEE7FEE7FEE7FEE7FEE70000F9 78 | :1004C00004480549054A064B7047000075050000C1 79 | :1004D00001040000100004206020002010200420EF 80 | :1004E00060000020704770477047754600F02CF898 81 | :1004F000AE4605006946534620F00700854618B011 82 | :1005000020B5FFF7DDFFBDE820404FF000064FF0BB 83 | :1005100000074FF000084FF0000BAC46ACE8C009F4 84 | :10052000ACE8C009ACE8C009ACE8C00921F007019B 85 | :100530008D46704710B50446AFF300802046BDE8F5 86 | :100540001040FFF7A6BF00000048704700000020E1 87 | :1005500001491820ABBEFEE72600020070470000EC 88 | :100560000348002101607A4801210170704700BFF3 89 | :1005700040410150B0B53A4DAA6C3A4942F00202EE 90 | :10058000AA64002201F5E8730BE053F83200013051 91 | :1005900009D001EBC200D0F8D40153F83240013247 92 | :1005A0002060FF2AF1D908682F4A072843D14B68F9 93 | :1005B000022B2AD12D4829230360032303630868F3 94 | :1005C000072838D14B68022B1FD12948294B0360DB 95 | :1005D00001201060086807282DD14B68022B14D128 96 | :1005E0002548002303600868072824D14B68022BA4 97 | :1005F0000BD1224BD3F8EC02C00705D000201860C5 98 | :1006000058600868072816D14B6823F001000228BB 99 | :100610000BD11A4BD3F8EC02C00706D06FF00100E3 100 | :10062000C3F8EC020868072805D14868022802BF11 101 | :100630000E48652101606868114940F440606860B7 102 | :10064000286840F470002860BFF34F8FBFF36F8FAE 103 | :1006500010680C4A00F0010021FA00F01060B0BDF3 104 | :1006600088ED00E03001FF00585500500C47005065 105 | :10067000309503504400EFBE4C25035014510050F8 106 | :100680000020A107000004200C480221C0F810152A 107 | :1006900001210160D0F8FC100029FBD00021C0F836 108 | :1006A000FC1007484FF48031016401602021C0F83C 109 | :1006B000041204484FF48011016070470850005044 110 | :1006C0000443015000E100E0154CFFF7DDFF4FF05F 111 | :1006D0008058204640F8108F124D4FF000594FF0CF 112 | :1006E00080474FF00046C0F80090076006604FF466 113 | :1006F0007A70C4F80480A8474FF47A70C4F8008078 114 | :10070000C4F80490A8474FF47A70C4F8009067606A 115 | :10071000A8474FF47A7027606660A8472046E5E74F 116 | :100720000825845029070000094A0849002313704E 117 | :10073000C1F8400501208860086000E030BF1078F3 118 | :100740000028FBD001204860704700BF00400150E6 119 | :1007500008000420F1EE100A4FF6FF71C0F2C0311C 120 | :1007600020EA010040F04070E1EE100A70470000FE 121 | :10077000A007000000000420080000003C04000066 122 | :10078000A0070000000000206020000058040000C6 123 | :10079000A8070000080004200820000058040000FA 124 | :0807A0000090D00300000000EE 125 | :0400000500000401F2 126 | :00000001FF 127 | -------------------------------------------------------------------------------- /pynrfjprog/examples/hex_files/nrf53_dk_rtt.hex: -------------------------------------------------------------------------------- 1 | :020000040000FA 2 | :10000000383D0020A10C0000A90C0000AB0C000042 3 | :10001000AD0C0000AF0C0000B10C0000B30C0000F0 4 | :10002000000000000000000000000000B50C00000F 5 | :10003000B70C000000000000B90C0000BB0C000071 6 | :10004000BD0C0000BD0C000000000000BD0C000055 7 | :1000500000000000BD0C00000000000000000000D7 8 | :10006000BD0C0000BD0C0000BD0C00000000000035 9 | :1000700000000000BD0C0000BD0C0000BD0C000025 10 | :10008000BD0C0000BD0C00000000000000000000DE 11 | :10009000BD0C0000BD0C00000000000000000000CE 12 | :1000A000BD0C0000BD0C0000BD0C0000BD0C00002C 13 | :1000B000BD0C0000BD0C0000BD0C0000BD0C00001C 14 | :1000C000BD0C0000BD0C0000BD0C0000BD0C00000C 15 | :1000D0000000000000000000BD0C00000000000057 16 | :1000E000BD0C000000000000BD0C0000BD0C0000B5 17 | :1000F00000000000BD0C000000000000BD0C00006E 18 | :100100000000000000000000BD0C00000000000026 19 | :100110000000000000000000BD0C0000BD0C00004D 20 | :1001200000000000BD0C0000000000000000000006 21 | :1001300000000000000000000000000000000000BF 22 | :1001400000000000000000000000000000000000AF 23 | :10015000BD0C0000000000000000000000000000D6 24 | :10016000000000000000000000000000000000008F 25 | :10017000000000000000000000000000000000007F 26 | :10018000000000000000000000000000000000006F 27 | :10019000000000000000000000000000000000005F 28 | :1001A000000000000000000000000000000000004F 29 | :1001B000000000000000000000000000000000003F 30 | :1001C000000000000000000000000000000000002F 31 | :1001D000000000000000000000000000000000001F 32 | :1001E000000000000000000000000000000000000F 33 | :1001F00000000000000000000000000000000000FF 34 | :1002000000000000000000000000000000000000EE 35 | :1002100000000000000000000000000000000000DE 36 | :1002200000000000000000000000000000000000CE 37 | :1002300000000000000000000000000000000000BE 38 | :1002400000000000000000000000000000000000AE 39 | :10025000000000000000000000000000000000009E 40 | :10026000000000000000000000000000000000008E 41 | :10027000000000000000000000000000000000007E 42 | :10028000000000000000000000000000000000006E 43 | :10029000000000000000000000000000000000005E 44 | :1002A000000000000000000000000000000000004E 45 | :1002B000000000000000000000000000000000003E 46 | :1002C000000000000000000000000000000000002E 47 | :1002D000000000000000000000000000000000001E 48 | :1002E000000000000000000000000000000000000E 49 | :1002F00000000000000000000000000000000000FE 50 | :1003000000000000000000000000000000000000ED 51 | :1003100000000000000000000000000000000000DD 52 | :1003200000000000000000000000000000000000CD 53 | :1003300000000000000000000000000000000000BD 54 | :1003400000000000000000000000000000000000AD 55 | :10035000000000000000000000000000000000009D 56 | :10036000000000000000000000000000000000008D 57 | :10037000000000000000000000000000000000007D 58 | :10038000000000000000000000000000000000006D 59 | :10039000000000000000000000000000000000005D 60 | :1003A000000000000000000000000000000000004D 61 | :1003B000000000000000000000000000000000003D 62 | :1003C000000000000000000000000000000000002D 63 | :1003D000000000000000000000000000000000001D 64 | :1003E000000000000000000000000000000000000D 65 | :1003F00000000000000000000000000000000000FD 66 | :10040000DFF80CD000F0C6FC0048004715040000DF 67 | :10041000383D002080B58EB000200D900B9000F08C 68 | :10042000A9FB6846DDF82CE0C0F800E040F6E35197 69 | :10043000C0F2000140F2C802C2F2000201204FF4F3 70 | :1004400080630A90099300F035FB69460B9A0A60B5 71 | :1004500040F6F951C0F2000140F2C842C2F2000277 72 | :10046000022308901846DDF824E00793734600F055 73 | :1004700021FB69460B9A0A6040F6EF51C0F2000179 74 | :1004800040F6C802C2F200020A9B06901846099B79 75 | :1004900000F0B2FA69460B9A0A6040F60561C0F2B4 76 | :1004A000000140F6C842C2F20002079B05901846C0 77 | :1004B000099B00F0A1FA69460B9A0A6040F60F61A9 78 | :1004C000C0F2000141F2C802C2F20002032304900C 79 | :1004D0001846099B00F090FA40F6D651C0F2000190 80 | :1004E0000B9A0390104600F00DFA0290FFE70120EE 81 | :1004F0000C90FFE70C98022824D8FFE70C9841F6EF 82 | :10050000D041C2F20001642200F01EF841F6CC4155 83 | :10051000C2F200010860086801280EDBFFE70C98B2 84 | :1005200041F6CC41C2F200010A6841F6D041C2F264 85 | :10053000000100F0CDF80190FFE7FFE70C980130D3 86 | :100540000C90D7E7D3E7000080B590B013468C46F7 87 | :1005500086460F900E910D920893CDF81CC0CDF8F1 88 | :1005600018E000F0B3F80F9840F20401C2F2000165 89 | :10057000783100EB400001EBC00000690A900F9851 90 | :1005800000EB400001EBC000C068099000200B9018 91 | :100590000A98099988424EDDFFE70F9800EB40006A 92 | :1005A00040F20401C2F2000101EBC000D0F880006B 93 | :1005B0000A99401A0C900C980D99884203DAFFE7CB 94 | :1005C0000C98059002E00D980590FFE705980C90B7 95 | :1005D0000E980F9940F20402C2F20002783201EB49 96 | :1005E000410102EBC10149680A9B19440C9B04922A 97 | :1005F0001A4600F0BCFB0C990B9A11440B910C9914 98 | :100600000E9A11440E910C990D9A511A0D910C9954 99 | :100610000A9A11440A910A990F9A02EB4202049B2A 100 | :1006200003EBC20292689142039003D1FFE70020DE 101 | :100630000A90FFE7FFE709980A99401A0C900C9876 102 | :100640000D99884203DAFFE70C98029002E00D98BA 103 | :100650000290FFE702980C900C98012822DBFFE73C 104 | :100660000E980F9901EB410140F20402C2F2000220 105 | :1006700002EBC101C96F0A9A11440C9A00F077FB92 106 | :100680000C990B9A11440B910C990E9A11440E91EE 107 | :100690000C990D9A511A0D910C990A9A11440A91CC 108 | :1006A0000190FFE70B9800280DD0FFE70A980F99FB 109 | :1006B00001EB410140F20402C2F2000202EBC1016F 110 | :1006C000C1F88800FFE70B9810B080BD704700BFED 111 | :1006D00080B58EB013468C4686460C900B910A92DC 112 | :1006E0000693CDF814C0CDF810E0FFF7EFFF0C989B 113 | :1006F00000EB400040F20401C2F2000101EBC00037 114 | :10070000C06A00F00300022845D0FFE70C9800EB18 115 | :10071000400040F20401C2F20001183101EBC000B8 116 | :100720000069079007980C9A02EB420201EBC201A4 117 | :10073000C968401A013809900998B0F1FF3F0EDCF2 118 | :10074000FFE70C9800EB400040F20401C2F2000108 119 | :1007500001EBC000006A099908440990FFE70A9874 120 | :100760000999884216DDFFE70C9800EB400040F243 121 | :100770000401C2F2000101EBC00090F82C008007D8 122 | :10078000002803D1FFE700200D90B7E009980A90F8 123 | :10079000FFE7FFE7FFE70A98002803D1FFE7002003 124 | :1007A0000D90ABE000200890FFE70C9800EB4000B4 125 | :1007B00040F20401C2F20001183101EBC0000069EF 126 | :1007C000079007980C9A02EB420201EBC201C9683C 127 | :1007D000401A013809900998B0F1FF3F0EDCFFE79D 128 | :1007E0000C9800EB400040F20401C2F2000101EB62 129 | :1007F000C000006A099908440990FFE709980C991C 130 | :1008000001EB410140F20402C2F2000202EBC1011D 131 | :100810000A6A496A511A884203DAFFE70998039085 132 | :100820000DE00C9800EB400040F20401C2F2000120 133 | :1008300001EBC000016A406A081A0390FFE70398C1 134 | :10084000099009980A99884203DAFFE7099802900B 135 | :1008500002E00A980290FFE7029809900C9840F293 136 | :100860000401C2F20001183100EB400001EBC000AE 137 | :100870004268C06810440B9A099B019111461A46C0 138 | :1008800000F075FA0999089A1144089109990B9A90 139 | :1008900011440B9109990A9A511A0A9109990C9AD3 140 | :1008A00002EB4202019B03EBC202D2F80CE071445E 141 | :1008B000D1600C9901EB410103EBC101C9680C9AAD 142 | :1008C00002EB420203EBC2029268914200900CD10B 143 | :1008D000FFE70C9800EB400040F20401C2F2000177 144 | :1008E00001EBC00000214162FFE7FFE70A98002802 145 | :1008F0007FF45BAFFFE708980D90FFE70D980EB00F 146 | :1009000080BD00BF80B586B00A46034605900491BD 147 | :1009100004980292019300F009F803900598049955 148 | :10092000039AFFF7D5FE06B080BD00BF84B0014634 149 | :1009300002900020019002980028009103D1FFE767 150 | :100940000020039014E0FFE702980078002801D10E 151 | :10095000FFE70AE00198013001900298013002900F 152 | :10096000FFE701200028EFD1FFE701980390FFE7A0 153 | :10097000039804B0704700BF80B584B000200DF12B 154 | :100980000B010122FFF7E0FD01900198012804D13D 155 | :10099000FFE79DF80B00039003E04FF0FF3003905A 156 | :1009A000FFE7039804B080BD80B582B0FFE7FFF792 157 | :1009B000E3FF0190FFE701980028F8DBFFE70198CB 158 | :1009C00002B080BD80B582B0FFF780FE40F2040E19 159 | :1009D000C2F2000EDEF8880000900098DEF884E095 160 | :1009E000704503D0FFE70120019002E00020019054 161 | :1009F000FFE7019802B080BD70B58AB0DDF838C05D 162 | :100A00009E4614460D4606460890079106920593A9 163 | :100A1000CDF810E0039402950196CDF800C0FFF7E1 164 | :100A200055FE089840F20401C2F2000109698842AB 165 | :100A300039D2FFE70898002827D0FFE707980899E0 166 | :100A400001EB410140F20402C2F20002183242F806 167 | :100A500031000698089901EB410102EBC1014860A1 168 | :100A60000598089901EB410102EBC10188600898E3 169 | :100A700000EB400002EBC00000210161089800EB90 170 | :100A8000400002EBC000C160FFE70E98089901EB3F 171 | :100A9000410140F20402C2F2000202EBC101C8624D 172 | :100AA0000020099003E04FF0FF300990FFE709981C 173 | :100AB0000AB070BD70B58AB0DDF838C09E461446E5 174 | :100AC0000D4606460890079106920593CDF810E072 175 | :100AD000039402950196CDF800C0FFF7F7FD089842 176 | :100AE00040F20401C2F20001496988423AD2FFE7AC 177 | :100AF0000898002827D0FFE70798089901EB4101E3 178 | :100B000040F20402C2F20002783242F83100069844 179 | :100B1000089901EB410102EBC10148600598089971 180 | :100B200001EB410102EBC1018860089800EB400035 181 | :100B300002EBC00000210161089800EB400002EBCD 182 | :100B4000C000C160FFE70E98089901EB410140F237 183 | :100B50000402C2F2000202EBC101C1F88C000020C5 184 | :100B6000099003E04FF0FF300990FFE709980AB0C1 185 | :100B700070BD00BF80B5FFF7A9FD80BD80B584B012 186 | :100B800001468DF80F00FF208DF80D009DF80F0035 187 | :100B90000928029106DCFFE79DF80F0030308DF840 188 | :100BA0000E000CE09DF80F000F2806DCFFE79DF813 189 | :100BB0000F0037308DF80E0000E00FE0FFE79DF8E2 190 | :100BC0000F0041F2C841C2F20001087000200DF18F 191 | :100BD0000D010222FFF77CFD0190FFE704B080BD0C 192 | :100BE00080B58AB00A4603468DF823000791FF209E 193 | :100BF0008DF81A009DF8230009280492039306DC5F 194 | :100C0000FFE79DF8230030308DF81B000FE09DF8C2 195 | :100C100023000F2806DCFFE79DF8230037308DF80E 196 | :100C20001B0003E04FF0FF30099035E0FFE70020A4 197 | :100C30000DF11A0102220290FFF74AFD0799029A6C 198 | :100C400001901046FFF75EFE05909DF823000928ED 199 | :100C500009DCFFE741F2C840C2F200000078303002 200 | :100C60008DF81B000EE09DF823000F2809DCFFE73C 201 | :100C700041F2C840C2F20000007837308DF81B0006 202 | :100C8000FFE7FFE700200DF11A010222FFF720FD28 203 | :100C9000059909910090FFE709980AB080BD00000E 204 | :100CA0000748804707480047FEE7FEE7FEE7FEE704 205 | :100CB000FEE7FEE7FEE7FEE7FEE7FEE7FEE70000F1 206 | :100CC000DD0C00000104000040F20000C2F2000050 207 | :100CD00042F20001C0F2A1710160704780B582B09C 208 | :100CE00000200190FFE701980021FF2800910DD816 209 | :100CF000FFE7019840F20031C0F2FF0151F83000E7 210 | :100D00000130002818BF01200090FFE70098C007BD 211 | :100D1000002814D0FFE7019840F20431C0F2FF012F 212 | :100D200051F83000019940F20032C0F2FF0252F84F 213 | :100D300031100860FFE7019801300190D3E74EF6CB 214 | :100D40008C50CEF20000016841F4406101604EF623 215 | :100D50008850CEF20000016841F470010160BFF3D9 216 | :100D60004F8FBFF36F8FFFF7AFFF02B080BD40EA38 217 | :100D700001039B0703D009E008C9121F08C0042A19 218 | :100D8000FAD203E011F8013B00F8013B521EF9D200 219 | :100D900070470000064C074D06E0E06840F0010394 220 | :100DA00094E8070098471034AC42F6D3FFF72CFBC9 221 | :100DB000240E0000440E000002E008C8121F08C103 222 | :100DC000002AFAD170477047002001E001C1121FCC 223 | :100DD000002AFBD1704748656C6C6F20576F726CAE 224 | :100DE000642100446F776E42756666657231005506 225 | :100DF000704275666665723100446F776E42756643 226 | :100E000066657232005570427566666572320055CD 227 | :100E10007042756666657233005465726D696E6105 228 | :100E20006C000000480E000000000020C800000018 229 | :100E3000B80D0000100F0000C8000020703C00003A 230 | :100E4000C80D0000000000000020A10753454747DF 231 | :100E500045522052545400000000000004000000DD 232 | :100E600003000000190E0000C91800200004000053 233 | :100E70000000000000000000000000000000000072 234 | :100E80000000000000000000000000000000000062 235 | :100E90000000000000000000000000000000000052 236 | :100EA0000000000000000000000000000000000042 237 | :100EB0000000000000000000000000000000000032 238 | :100EC00000000000190E0000C914002000040000FA 239 | :100ED0000000000000000000000000000000000012 240 | :100EE0000000000000000000000000000000000002 241 | :100EF00000000000000000000000000000000000F2 242 | :100F000000000000000000000000000000000000E1 243 | :0400000500000401F2 244 | :00000001FF 245 | -------------------------------------------------------------------------------- /pynrfjprog/examples/hex_files/nrf91_dk_blinky.hex: -------------------------------------------------------------------------------- 1 | :1000000000000420B1070000E1070000E307000042 2 | :10001000E5070000E7070000E9070000EB07000024 3 | :10002000000000000000000000000000ED070000DC 4 | :10003000EF07000000000000F1070000F3070000D8 5 | :10004000000000000000000000000000F5070000B4 6 | :1000500000000000F50700000000000000000000A4 7 | :10006000F5070000F5070000F5070000F5070000A0 8 | :1000700000000000F5070000F5070000F50700008C 9 | :10008000F5070000F5070000000000000000000078 10 | :10009000F5070000F5070000000000000000000068 11 | :1000A000F50700000000000000000000F507000058 12 | :1000B000F5070000F5070000F5070000F507000050 13 | :1000C000F5070000F5070000F5070000F507000040 14 | :1000D000F507000000000000F50700000000000028 15 | :1000E000F507000000000000F50700000000000018 16 | :1000F000F507000000000000000000000000000004 17 | :1001000000000000F50700000000000000000000F3 18 | :1001100000000000000000000000000000000000DF 19 | :1001200000000000F50700000000000000000000D3 20 | :1001300000000000000000000000000000000000BF 21 | :10014000F5070000000000000000000000000000B3 22 | :10015000000000000000000000000000000000009F 23 | :10016000000000000000000000000000000000008F 24 | :10017000000000000000000000000000000000007F 25 | :10018000000000000000000000000000000000006F 26 | :10019000000000000000000000000000000000005F 27 | :1001A000000000000000000000000000000000004F 28 | :1001B000000000000000000000000000000000003F 29 | :1001C000000000000000000000000000000000002F 30 | :1001D000000000000000000000000000000000001F 31 | :1001E000000000000000000000000000000000000F 32 | :1001F00000000000000000000000000000000000FF 33 | :1002000000000000000000000000000000000000EE 34 | :1002100000000000000000000000000000000000DE 35 | :1002200000000000000000000000000000000000CE 36 | :1002300000000000000000000000000000000000BE 37 | :1002400000000000000000000000000000000000AE 38 | :10025000000000000000000000000000000000009E 39 | :10026000000000000000000000000000000000008E 40 | :10027000000000000000000000000000000000007E 41 | :10028000000000000000000000000000000000006E 42 | :10029000000000000000000000000000000000005E 43 | :1002A000000000000000000000000000000000004E 44 | :1002B000000000000000000000000000000000003E 45 | :1002C000000000000000000000000000000000002E 46 | :1002D000000000000000000000000000000000001E 47 | :1002E000000000000000000000000000000000000E 48 | :1002F00000000000000000000000000000000000FE 49 | :1003000000000000000000000000000000000000ED 50 | :1003100000000000000000000000000000000000DD 51 | :1003200000000000000000000000000000000000CD 52 | :1003300000000000000000000000000000000000BD 53 | :1003400000000000000000000000000000000000AD 54 | :10035000000000000000000000000000000000009D 55 | :10036000000000000000000000000000000000008D 56 | :10037000000000000000000000000000000000007D 57 | :10038000000000000000000000000000000000006D 58 | :10039000000000000000000000000000000000005D 59 | :1003A000000000000000000000000000000000004D 60 | :1003B000000000000000000000000000000000003D 61 | :1003C000000000000000000000000000000000002D 62 | :1003D000000000000000000000000000000000001D 63 | :1003E000000000000000000000000000000000000D 64 | :1003F00000000000000000000000000000000000FD 65 | :10040000BFF34F8F054BDB6803F4E0620349044BF5 66 | :100410001343CB60BFF34F8F00BFFDE700ED00E05B 67 | :100420000400FA05024B034A1A6000BF704700BF80 68 | :10043000000000200090D00300B583B0002301939A 69 | :100440000023019311E04FF47F024FF47F01019BE1 70 | :10045000603351F833301946019B6033DB0013449D 71 | :100460005B680B60019B01330193019BFF2B08D854 72 | :100470004FF47F02019B603352F83330B3F1FF3FFA 73 | :10048000E1D100F09FF80346002B04D100F08EF874 74 | :100490000346002B3FD000BF3F4BD3F80034012B65 75 | :1004A000FAD13D4B0122C3F8042500BF3A4BD3F8E3 76 | :1004B0000034012BFAD100F085F80346002B0BD055 77 | :1004C000364BDB69354A23F00103D36100BF324B61 78 | :1004D000D3F80034012BFAD100F068F80346002B62 79 | :1004E0000DD02E4B1B6A23F0FF032C4A43F0200350 80 | :1004F000136200BF284BD3F80034012BFAD1264BEE 81 | :100500000022C3F8042500BF234BD3F80034012B8D 82 | :10051000FAD1FFF775FF00F063F80346002B09D00E 83 | :100520004FF050230022C3F814214FF05023002233 84 | :10053000C3F8182100F06DF80346002B06D0184BC5 85 | :1005400001221A60174B0122C3F8782500F072F8D7 86 | :100550000346002B06D0124B00221A60114B0122D9 87 | :10056000C3F87825104BD3F88C300F4A43F440631E 88 | :10057000C2F88C300C4BD3F888300B4A43F470032C 89 | :10058000C2F88830BFF34F8FBFF36F8FFFF74AFF7A 90 | :1005900000BF03B05DF804FB009003500080FF0033 91 | :1005A000384A00500040005000ED00E0044B1B6A48 92 | :1005B000B3F1FF3F01D1012300E00023184670474B 93 | :1005C0000080FF00054BDB6903F00103002B01D025 94 | :1005D000012300E000231846704700BF0080FF00A1 95 | :1005E0004FF47F03D3F83031092B0FD14FF47F0341 96 | :1005F000D3F83431012B01D1012308E04FF47F03FC 97 | :10060000D3F83431022B01D1012300E00023184636 98 | :1006100070474FF47F03D3F83031092B07D14FF4E3 99 | :100620007F03D3F83431012B01D1012300E00023F3 100 | :10063000184670474FF47F03D3F83031092B07D1A8 101 | :100640004FF47F03D3F83431022B01D1012300E0B2 102 | :100650000023184670470000354936480A1A02D070 103 | :10066000072291438D46344934480A1A06D007229E 104 | :10067000914381F30988022282F31488304831497A 105 | :10068000314A00F043F831483149324A00F03EF82F 106 | :1006900031483249324A00F039F832483249334A57 107 | :1006A00000F034F832483349334A00F02FF8334829 108 | :1006B0003349344A00F02AF833483449344A00F0C8 109 | :1006C00025F834483449002200F02BF833483449E7 110 | :1006D000002200F026F833483349091A082903DBC1 111 | :1006E00000220260043001601F482049884205D082 112 | :1006F0000268043003B4904703BCF7E70020864645 113 | :10070000EC4600200021294A9047FEE7884207D0A6 114 | :10071000521A05D0037801300B700131013AF9D13A 115 | :100720007047884202D002700130FAE7704700003B 116 | :100730000000042000FC032000000420000004202E 117 | :100740009C0800000000002004000020F8070000C2 118 | :10075000F80700009C0800009C0800000000002032 119 | :10076000000000209C0800009C0800009C0800007D 120 | :100770009C0800009C0800009C0800009C080000E9 121 | :100780009C0800009C080000A00800000400002055 122 | :1007900004000020040000200400002004000020C9 123 | :1007A00004000020040000200404002021080000B0 124 | :1007B0000648804706484FF00701884385460548AC 125 | :1007C0008047054805490160FFF746BFF70700006D 126 | :1007D000000004203904000008ED00E000000000E3 127 | :1007E000FEE7FEE7FEE7FEE7FEE7FEE7FEE7FEE7E1 128 | :0807F000FEE7FEE7FEE770479B 129 | :1007F80084B001900023039302E0039B0133039329 130 | :10080800019B4FF47A7202FB03F3039A9A42F4D3E2 131 | :1008180000BF04B07047000000B583B04FF4FA730E 132 | :1008280001931B4B04229A61194B08229A61184BB9 133 | :1008380010229A61164B20229A61154B4FF0FF3215 134 | :10084800DA600198FFF7D4FF114B4FF0FF329A603E 135 | :100858000198FFF7CDFF0E4B0822DA600198FFF7E9 136 | :10086800C7FF0B4B08229A60094B1022DA600198E7 137 | :10087800FFF7BEFF064B10229A60054B2022DA6074 138 | :100888000198FFF7B5FF024B20229A60D5E700BF19 139 | :040898000025845063 140 | :04089C000090D003F5 141 | :04000003000007B141 142 | :00000001FF 143 | -------------------------------------------------------------------------------- /pynrfjprog/examples/hex_files/nrf91_dk_rtt.hex: -------------------------------------------------------------------------------- 1 | :020000040000FA 2 | :10000000383D0020A10C0000A90C0000AB0C000042 3 | :10001000AD0C0000AF0C0000B10C0000B30C0000F0 4 | :10002000000000000000000000000000B50C00000F 5 | :10003000B70C000000000000B90C0000BB0C000071 6 | :10004000000000000000000000000000BD0C0000E7 7 | :1000500000000000BD0C00000000000000000000D7 8 | :10006000BD0C0000BD0C0000BD0C0000BD0C00006C 9 | :1000700000000000BD0C0000BD0C0000BD0C000025 10 | :10008000BD0C0000BD0C00000000000000000000DE 11 | :10009000BD0C0000BD0C00000000000000000000CE 12 | :1000A000BD0C00000000000000000000BD0C0000BE 13 | :1000B000BD0C0000BD0C0000BD0C0000BD0C00001C 14 | :1000C000BD0C0000BD0C0000BD0C0000BD0C00000C 15 | :1000D000BD0C000000000000BD0C0000000000008E 16 | :1000E000BD0C000000000000BD0C0000000000007E 17 | :1000F000BD0C000000000000000000000000000037 18 | :1001000000000000BD0C0000000000000000000026 19 | :1001100000000000000000000000000000000000DF 20 | :1001200000000000BD0C0000000000000000000006 21 | :1001300000000000000000000000000000000000BF 22 | :10014000BD0C0000000000000000000000000000E6 23 | :10015000000000000000000000000000000000009F 24 | :10016000000000000000000000000000000000008F 25 | :10017000000000000000000000000000000000007F 26 | :10018000000000000000000000000000000000006F 27 | :10019000000000000000000000000000000000005F 28 | :1001A000000000000000000000000000000000004F 29 | :1001B000000000000000000000000000000000003F 30 | :1001C000000000000000000000000000000000002F 31 | :1001D000000000000000000000000000000000001F 32 | :1001E000000000000000000000000000000000000F 33 | :1001F00000000000000000000000000000000000FF 34 | :1002000000000000000000000000000000000000EE 35 | :1002100000000000000000000000000000000000DE 36 | :1002200000000000000000000000000000000000CE 37 | :1002300000000000000000000000000000000000BE 38 | :1002400000000000000000000000000000000000AE 39 | :10025000000000000000000000000000000000009E 40 | :10026000000000000000000000000000000000008E 41 | :10027000000000000000000000000000000000007E 42 | :10028000000000000000000000000000000000006E 43 | :10029000000000000000000000000000000000005E 44 | :1002A000000000000000000000000000000000004E 45 | :1002B000000000000000000000000000000000003E 46 | :1002C000000000000000000000000000000000002E 47 | :1002D000000000000000000000000000000000001E 48 | :1002E000000000000000000000000000000000000E 49 | :1002F00000000000000000000000000000000000FE 50 | :1003000000000000000000000000000000000000ED 51 | :1003100000000000000000000000000000000000DD 52 | :1003200000000000000000000000000000000000CD 53 | :1003300000000000000000000000000000000000BD 54 | :1003400000000000000000000000000000000000AD 55 | :10035000000000000000000000000000000000009D 56 | :10036000000000000000000000000000000000008D 57 | :10037000000000000000000000000000000000007D 58 | :10038000000000000000000000000000000000006D 59 | :10039000000000000000000000000000000000005D 60 | :1003A000000000000000000000000000000000004D 61 | :1003B000000000000000000000000000000000003D 62 | :1003C000000000000000000000000000000000002D 63 | :1003D000000000000000000000000000000000001D 64 | :1003E000000000000000000000000000000000000D 65 | :1003F00000000000000000000000000000000000FD 66 | :10040000DFF80CD000F08CFC004800471504000019 67 | :10041000383D002080B58EB000200D900B9000F08C 68 | :10042000A9FB6846DDF82CE0C0F800E040F66F510B 69 | :10043000C0F2000140F2C802C2F2000201204FF4F3 70 | :1004400080630A90099300F035FB69460B9A0A60B5 71 | :1004500040F68551C0F2000140F2C842C2F20002EB 72 | :10046000022308901846DDF824E00793734600F055 73 | :1004700021FB69460B9A0A6040F67B51C0F20001ED 74 | :1004800040F6C802C2F200020A9B06901846099B79 75 | :1004900000F0B2FA69460B9A0A6040F69151C0F238 76 | :1004A000000140F6C842C2F20002079B05901846C0 77 | :1004B000099B00F0A1FA69460B9A0A6040F69B512D 78 | :1004C000C0F2000141F2C802C2F20002032304900C 79 | :1004D0001846099B00F090FA40F66251C0F2000104 80 | :1004E0000B9A0390104600F00DFA0290FFE70120EE 81 | :1004F0000C90FFE70C98022824D8FFE70C9841F6EF 82 | :10050000D041C2F20001642200F01EF841F6CC4155 83 | :10051000C2F200010860086801280EDBFFE70C98B2 84 | :1005200041F6CC41C2F200010A6841F6D041C2F264 85 | :10053000000100F0CDF80190FFE7FFE70C980130D3 86 | :100540000C90D7E7D3E7000080B590B013468C46F7 87 | :1005500086460F900E910D920893CDF81CC0CDF8F1 88 | :1005600018E000F0B3F80F9840F20401C2F2000165 89 | :10057000783100EB400001EBC00000690A900F9851 90 | :1005800000EB400001EBC000C068099000200B9018 91 | :100590000A98099988424EDDFFE70F9800EB40006A 92 | :1005A00040F20401C2F2000101EBC000D0F880006B 93 | :1005B0000A99401A0C900C980D99884203DAFFE7CB 94 | :1005C0000C98059002E00D980590FFE705980C90B7 95 | :1005D0000E980F9940F20402C2F20002783201EB49 96 | :1005E000410102EBC10149680A9B19440C9B04922A 97 | :1005F0001A4600F083FB0C990B9A11440B910C994D 98 | :100600000E9A11440E910C990D9A511A0D910C9954 99 | :100610000A9A11440A910A990F9A02EB4202049B2A 100 | :1006200003EBC20292689142039003D1FFE70020DE 101 | :100630000A90FFE7FFE709980A99401A0C900C9876 102 | :100640000D99884203DAFFE70C98029002E00D98BA 103 | :100650000290FFE702980C900C98012822DBFFE73C 104 | :100660000E980F9901EB410140F20402C2F2000220 105 | :1006700002EBC101C96F0A9A11440C9A00F03EFBCB 106 | :100680000C990B9A11440B910C990E9A11440E91EE 107 | :100690000C990D9A511A0D910C990A9A11440A91CC 108 | :1006A0000190FFE70B9800280DD0FFE70A980F99FB 109 | :1006B00001EB410140F20402C2F2000202EBC1016F 110 | :1006C000C1F88800FFE70B9810B080BD704700BFED 111 | :1006D00080B58EB013468C4686460C900B910A92DC 112 | :1006E0000693CDF814C0CDF810E0FFF7EFFF0C989B 113 | :1006F00000EB400040F20401C2F2000101EBC00037 114 | :10070000C06A00F00300022845D0FFE70C9800EB18 115 | :10071000400040F20401C2F20001183101EBC000B8 116 | :100720000069079007980C9A02EB420201EBC201A4 117 | :10073000C968401A013809900998B0F1FF3F0EDCF2 118 | :10074000FFE70C9800EB400040F20401C2F2000108 119 | :1007500001EBC000006A099908440990FFE70A9874 120 | :100760000999884216DDFFE70C9800EB400040F243 121 | :100770000401C2F2000101EBC00090F82C008007D8 122 | :10078000002803D1FFE700200D90B7E009980A90F8 123 | :10079000FFE7FFE7FFE70A98002803D1FFE7002003 124 | :1007A0000D90ABE000200890FFE70C9800EB4000B4 125 | :1007B00040F20401C2F20001183101EBC0000069EF 126 | :1007C000079007980C9A02EB420201EBC201C9683C 127 | :1007D000401A013809900998B0F1FF3F0EDCFFE79D 128 | :1007E0000C9800EB400040F20401C2F2000101EB62 129 | :1007F000C000006A099908440990FFE709980C991C 130 | :1008000001EB410140F20402C2F2000202EBC1011D 131 | :100810000A6A496A511A884203DAFFE70998039085 132 | :100820000DE00C9800EB400040F20401C2F2000120 133 | :1008300001EBC000016A406A081A0390FFE70398C1 134 | :10084000099009980A99884203DAFFE7099802900B 135 | :1008500002E00A980290FFE7029809900C9840F293 136 | :100860000401C2F20001183100EB400001EBC000AE 137 | :100870004268C06810440B9A099B019111461A46C0 138 | :1008800000F03CFA0999089A1144089109990B9AC9 139 | :1008900011440B9109990A9A511A0A9109990C9AD3 140 | :1008A00002EB4202019B03EBC202D2F80CE071445E 141 | :1008B000D1600C9901EB410103EBC101C9680C9AAD 142 | :1008C00002EB420203EBC2029268914200900CD10B 143 | :1008D000FFE70C9800EB400040F20401C2F2000177 144 | :1008E00001EBC00000214162FFE7FFE70A98002802 145 | :1008F0007FF45BAFFFE708980D90FFE70D980EB00F 146 | :1009000080BD00BF80B586B00A46034605900491BD 147 | :1009100004980292019300F009F803900598049955 148 | :10092000039AFFF7D5FE06B080BD00BF84B0014634 149 | :1009300002900020019002980028009103D1FFE767 150 | :100940000020039014E0FFE702980078002801D10E 151 | :10095000FFE70AE00198013001900298013002900F 152 | :10096000FFE701200028EFD1FFE701980390FFE7A0 153 | :10097000039804B0704700BF80B584B000200DF12B 154 | :100980000B010122FFF7E0FD01900198012804D13D 155 | :10099000FFE79DF80B00039003E04FF0FF3003905A 156 | :1009A000FFE7039804B080BD80B582B0FFE7FFF792 157 | :1009B000E3FF0190FFE701980028F8DBFFE70198CB 158 | :1009C00002B080BD80B582B0FFF780FE40F2040E19 159 | :1009D000C2F2000EDEF8880000900098DEF884E095 160 | :1009E000704503D0FFE70120019002E00020019054 161 | :1009F000FFE7019802B080BD70B58AB0DDF838C05D 162 | :100A00009E4614460D4606460890079106920593A9 163 | :100A1000CDF810E0039402950196CDF800C0FFF7E1 164 | :100A200055FE089840F20401C2F2000109698842AB 165 | :100A300039D2FFE70898002827D0FFE707980899E0 166 | :100A400001EB410140F20402C2F20002183242F806 167 | :100A500031000698089901EB410102EBC1014860A1 168 | :100A60000598089901EB410102EBC10188600898E3 169 | :100A700000EB400002EBC00000210161089800EB90 170 | :100A8000400002EBC000C160FFE70E98089901EB3F 171 | :100A9000410140F20402C2F2000202EBC101C8624D 172 | :100AA0000020099003E04FF0FF300990FFE709981C 173 | :100AB0000AB070BD70B58AB0DDF838C09E461446E5 174 | :100AC0000D4606460890079106920593CDF810E072 175 | :100AD000039402950196CDF800C0FFF7F7FD089842 176 | :100AE00040F20401C2F20001496988423AD2FFE7AC 177 | :100AF0000898002827D0FFE70798089901EB4101E3 178 | :100B000040F20402C2F20002783242F83100069844 179 | :100B1000089901EB410102EBC10148600598089971 180 | :100B200001EB410102EBC1018860089800EB400035 181 | :100B300002EBC00000210161089800EB400002EBCD 182 | :100B4000C000C160FFE70E98089901EB410140F237 183 | :100B50000402C2F2000202EBC101C1F88C000020C5 184 | :100B6000099003E04FF0FF300990FFE709980AB0C1 185 | :100B700070BD00BF80B5FFF7A9FD80BD80B584B012 186 | :100B800001468DF80F00FF208DF80D009DF80F0035 187 | :100B90000928029106DCFFE79DF80F0030308DF840 188 | :100BA0000E000CE09DF80F000F2806DCFFE79DF813 189 | :100BB0000F0037308DF80E0000E00FE0FFE79DF8E2 190 | :100BC0000F0041F2C841C2F20001087000200DF18F 191 | :100BD0000D010222FFF77CFD0190FFE704B080BD0C 192 | :100BE00080B58AB00A4603468DF823000791FF209E 193 | :100BF0008DF81A009DF8230009280492039306DC5F 194 | :100C0000FFE79DF8230030308DF81B000FE09DF8C2 195 | :100C100023000F2806DCFFE79DF8230037308DF80E 196 | :100C20001B0003E04FF0FF30099035E0FFE70020A4 197 | :100C30000DF11A0102220290FFF74AFD0799029A6C 198 | :100C400001901046FFF75EFE05909DF823000928ED 199 | :100C500009DCFFE741F2C840C2F200000078303002 200 | :100C60008DF81B000EE09DF823000F2809DCFFE73C 201 | :100C700041F2C840C2F20000007837308DF81B0006 202 | :100C8000FFE7FFE700200DF11A010222FFF720FD28 203 | :100C9000059909910090FFE709980AB080BD00000E 204 | :100CA0000748804707480047FEE7FEE7FEE7FEE704 205 | :100CB000FEE7FEE7FEE7FEE7FEE7FEE7FEE70000F1 206 | :100CC000DD0C00000104000040F20000C2F2000050 207 | :100CD00049F20001C0F2D0310160704780B54EF694 208 | :100CE0008850CEF20000016841F470010160BFF34A 209 | :100CF0004F8FBFF36F8FFFF7E7FF80BD40EA01031F 210 | :100D00009B0703D009E008C9121F08C0042AFAD2C1 211 | :100D100003E011F8013B00F8013B521EF9D2704785 212 | :100D2000064C074D06E0E06840F0010394E8070038 213 | :100D300098471034AC42F6D3FFF766FBB00D0000C5 214 | :100D4000D00D000002E008C8121F08C1002AFAD125 215 | :100D500070477047002001E001C1121F002AFBD13B 216 | :100D6000704748656C6C6F20576F726C642100444B 217 | :100D70006F776E42756666657231005570427566B2 218 | :100D80006665723100446F776E42756666657232D1 219 | :100D90000055704275666665723200557042756620 220 | :100DA00066657233005465726D696E616C00000097 221 | :100DB000D00D000000000020C8000000440D00001D 222 | :100DC000980E0000C8000020703C0000540D000088 223 | :100DD0000090D003534547474552205254540000D9 224 | :100DE000000000000400000003000000A50D00004A 225 | :100DF000C9180020000400000000000000000000EE 226 | :100E000000000000000000000000000000000000E2 227 | :100E100000000000000000000000000000000000D2 228 | :100E200000000000000000000000000000000000C2 229 | :100E300000000000000000000000000000000000B2 230 | :100E4000000000000000000000000000A50D0000F0 231 | :100E5000C914002000040000000000000000000091 232 | :100E60000000000000000000000000000000000082 233 | :100E70000000000000000000000000000000000072 234 | :100E80000000000000000000000000000000000062 235 | :080E900000000000000000005A 236 | :0400000500000401F2 237 | :00000001FF 238 | -------------------------------------------------------------------------------- /pynrfjprog/examples/highlevel_memory_read_write.py: -------------------------------------------------------------------------------- 1 | """ 2 | 3 | This file contains example code meant to be used in order to test the 4 | pynrfjprog High Level API. 5 | 6 | Sample program: memory_read_write.py 7 | 8 | Run from command line: 9 | python memory_read_write.py 10 | or if imported using "from pynrfjprog import examples" 11 | examples.memory_read_write.run(682000044) 12 | 13 | Program flow: 14 | 0. An API object is instantiated. 15 | 1. A probe object is instantiated. 16 | 2. Flash memory is erased. 17 | 3. 0xDEADBEEF is written to address 0x0. 18 | 4. 0xBAADF00D is written to address 0x10. 19 | 5. Memory 0x0 and 0x10 is read and printed to console. 20 | 6. The probe object is destroyed. 21 | 7. The API is closed. 22 | 23 | """ 24 | 25 | from __future__ import print_function 26 | import argparse 27 | 28 | # Import pynrfjprog API module 29 | try: 30 | from .. import HighLevel 31 | except ImportError: 32 | from pynrfjprog import HighLevel 33 | 34 | 35 | def run(snr): 36 | """ 37 | Run example script. 38 | 39 | @param int snr: Specify serial number of DK to run example on. 40 | """ 41 | print("# Memory read and write example using pynrfjprog started...") 42 | 43 | print("# Opening High Level API instance and initializing a probe handle.") 44 | # Initialize an API object. 45 | # Open the loaded DLL and connect to an emulator probe. 46 | with HighLevel.API() as api: 47 | # Initialize the probe connection. The device family is automatically detected, and the correct sub dll is loaded. 48 | with HighLevel.DebugProbe(api, snr) as probe: 49 | # Erase all the flash of the device. 50 | print("# Erasing all flash in the microcontroller.") 51 | # api.erase supports several erase actions, including sector erase, erase all, and qspi erase options. 52 | probe.erase(HighLevel.EraseAction.ERASE_ALL) 53 | 54 | # Write to addresses 0x0 and 0x10. NVMC is used automatically whenever a write to flash is requested. 55 | print("# Writing 0xDEADBEEF to memory address 0x0.") 56 | probe.write(0x0, 0xDEADBEEF) 57 | print("# Writing 0xBAADF00D to memory address 0x10.") 58 | probe.write(0x10, 0xBAADF00D) 59 | 60 | # Read from addresses 0x0 and 0x10 and print the result. 61 | print("# Reading memory address 0x0 and 0x10, and print to console") 62 | print("Address 0x0 contains: ", hex(probe.read(0x0))) 63 | print("Address 0x10 contains: ", hex(probe.read(0x10))) 64 | 65 | print("# Example done...") 66 | 67 | 68 | if __name__ == "__main__": 69 | parser = argparse.ArgumentParser() 70 | parser.add_argument("-s", "--serial", type=int, help="Serial number to test.") 71 | args = parser.parse_args() 72 | 73 | run(args.serial) 74 | -------------------------------------------------------------------------------- /pynrfjprog/examples/highlevel_program_hex.py: -------------------------------------------------------------------------------- 1 | """ 2 | 3 | This file contains example code meant to be used in order to test the 4 | pynrfjprog API and Hex modules. If multiple devices are connected, a 5 | pop-up will appear for device selection. 6 | 7 | Sample program: program_hex.py 8 | Requires nRF Development Kit for visual confirmation (LEDs). 9 | 10 | Run from command line: 11 | python program_hex.py 12 | or if imported as "from pynrfjprog import examples" 13 | examples.program_hex.run() 14 | 15 | Program flow: 16 | 0. An API object is instantiated with AUTO family to read the device family. 17 | 1. An API object is instantiated with the read family. A connection to the debug probe is established. 18 | 2. Flash memory is erased. 19 | 3. A hex file is parsed and programmed into memory. 20 | 4. The device is reset and application is run. 21 | 22 | """ 23 | 24 | from __future__ import print_function 25 | import os 26 | import argparse 27 | 28 | # Import pynrfjprog API module and HEX parser module 29 | try: 30 | from .. import HighLevel 31 | except ImportError: 32 | from pynrfjprog import HighLevel 33 | 34 | from . import hex_files 35 | 36 | 37 | def run(snr): 38 | """ 39 | Run example script. 40 | 41 | @param int snr: Specify serial number of DK to run example on. 42 | """ 43 | print("# Hex file programming example using pynrfjprog started...") 44 | 45 | print("# Opening High Level API instance and initializing a probe handle.") 46 | # Initialize an API object. 47 | # Open the loaded DLL and connect to an emulator probe. 48 | with HighLevel.API() as api: 49 | # Initialize the probe connection. The device family is automatically detected, and the correct sub dll is loaded. 50 | with HighLevel.DebugProbe(api, snr) as probe: 51 | 52 | print("# Reading out device information.") 53 | # Read out device information to find out which hex file to program 54 | device_info = probe.get_device_info() 55 | hex_file_path = hex_files.find_blinky_hex(device_info.device_family.name, device_info.device_type.name) 56 | 57 | # Erase all the flash of the device. 58 | print("# Programming %s to device with ERASE_ALL and SYSTEM_RESET." % hex_file_path) 59 | 60 | # Make a program option struct to modify programming sequence. 61 | # If ommitted, the default programoptions struct specifies ERASE_ALL, SYSTEM_RESET, and VERIFY_NONE. 62 | program_options = HighLevel.ProgramOptions( 63 | erase_action=HighLevel.EraseAction.ERASE_ALL, 64 | reset=HighLevel.ResetAction.RESET_SYSTEM, 65 | verify=HighLevel.VerifyAction.VERIFY_READ, 66 | ) 67 | 68 | probe.program(hex_file_path, program_options=program_options) 69 | 70 | print("# Application running. Your board should be blinking.") 71 | 72 | print("# Example done...") 73 | 74 | 75 | if __name__ == "__main__": 76 | parser = argparse.ArgumentParser() 77 | parser.add_argument("-s", "--serial", type=int, help="Serial number to test.") 78 | args = parser.parse_args() 79 | 80 | run(args.serial) 81 | -------------------------------------------------------------------------------- /pynrfjprog/examples/memory_read_write.py: -------------------------------------------------------------------------------- 1 | """ 2 | 3 | This file contains example code meant to be used in order to test the 4 | pynrfjprog API. If multiple devices are connected, a pop-up will appear 5 | for device selection. 6 | 7 | Sample program: memory_read_write.py 8 | 9 | Run from command line: 10 | python memory_read_write.py 11 | or if imported using "from pynrfjprog import examples" 12 | examples.memory_read_write.run() 13 | 14 | Program flow: 15 | 0. An API object is instantiated with AUTO family to read the device family. 16 | 1. An API object is instantiated with the read family. A connection to the debug probe is established. 17 | 2. Flash memory is erased. 18 | 3. 0xDEADBEEF is written to address 0x0. 19 | 4. 0xBAADF00D is written to address 0x10. 20 | 5. Memory 0x0 and 0x10 is read and printed to console. 21 | 22 | """ 23 | 24 | from __future__ import print_function 25 | 26 | # Import pynrfjprog API module 27 | try: 28 | from .. import LowLevel 29 | except ImportError: 30 | from pynrfjprog import LowLevel 31 | 32 | 33 | def run(snr=None): 34 | """ 35 | Run example script. 36 | 37 | @param (optional) int snr: Specify serial number of DK to run example on. 38 | """ 39 | print("# Memory read and write example using pynrfjprog started...") 40 | 41 | print("# Opening API with device family AUTO, reading the device family.") 42 | 43 | # Use auto-detection of device family by using the default API initializer. 44 | with LowLevel.API() as api: 45 | if snr is not None: 46 | api.connect_to_emu_with_snr(snr) 47 | else: 48 | api.connect_to_emu_without_snr() 49 | 50 | # Erase all the flash of the device. 51 | print("# Erasing all flash in the microcontroller.") 52 | api.erase_all() 53 | 54 | # Write to addresses 0x0 and 0x10. 55 | print("# Writing 0xDEADBEEF to memory address 0x0, use NVMC") 56 | api.write_u32(0x0, 0xDEADBEEF, True) 57 | print("# Writing 0xBAADF00D to memory address 0x10, use NVMC") 58 | api.write_u32(0x10, 0xBAADF00D, True) 59 | 60 | # Read from addresses 0x0 and 0x10 and print the result. 61 | print("# Reading memory address 0x0 and 0x10, and print to console") 62 | print("Address 0x0 contains: ", hex(api.read_u32(0x0))) 63 | print("Address 0x10 contains: ", hex(api.read_u32(0x10))) 64 | 65 | # Close the loaded DLL to free resources. 66 | api.close() 67 | 68 | print("# Example done...") 69 | 70 | 71 | if __name__ == "__main__": 72 | run() 73 | -------------------------------------------------------------------------------- /pynrfjprog/examples/nrf9160_pca20035_modem_upgrade_over_serial.py: -------------------------------------------------------------------------------- 1 | """ 2 | 3 | This file contains an example of how to use pynrfjprog for doing a modem firmware upgrade on Thingy:91 4 | over a serial port. The Thingy:91 does not feature an on-board debugger and can't directly use the existing modem 5 | DFU tool (IPCDFUProbe). The upgrade is done in two steps. First, the nrf9160 is programmed with an application 6 | that accepts modem firmware data over UART. Next, the modem firmware is uploaded by communicating with 7 | the application. 8 | 9 | The Thingy:91 has an USB<->UART bridge that exposes two of nrf9160's UART pairs. MCUBoot (the bootloader) uses 10 | one of the UART pairs at 115200 baudrate, and is used to flash our application. The other pair is configured 11 | to 1Mbaud, and is used to upload the modem firmware. Note that the nrf52840 UART bridge might need a firmware 12 | upgrade for this example to function properly. The Thingy:91 board documentation has instructions for how 13 | to do this. 14 | 15 | There are three prerequisites for this example: 16 | 1) The nRF9160 device must be in serial recovery mode (ready for application flash) when starting 17 | the example. For Thingy:91, this is done by holding the reset button while toggling the power switch. 18 | 19 | 2) You must know the two serial ports used by the nRF9160 device. The "nRF Connect --> Programmer" desktop 20 | application might be of aid here. Keep in mind the enumeration of the serial ports on your computer does not 21 | necessarily correlate with UART enumeration, i.e. UART0 can show up as a higher serial port number than UART1. 22 | 23 | 3) The path to a zip file containing the modem firmware files must be provided. The zip folder can obtained from 24 | Nordic Semiconductors official websites. Note that your current version of the modem firmware might have downgrade 25 | protection, hence, a programming attempt can sometimes fail due to uploading outdated files. 26 | 27 | Sample program: nrf9160_pca20035_modem_upgrade_over_serial.py 28 | 29 | Run from command line: 30 | python nrf9160_pca20035_modem_upgrade_over_serial.py \ 31 | \ 32 | \ 33 | 34 | or if imported as "from pynrfjprog import examples" 35 | examples.nrf9160_pca20035_modem_upgrade_over_serial.run( 36 | , 37 | , 38 | ) 39 | 40 | Program flow: 41 | 0. Configure logging to see the output of HighLevel API operations. 42 | 1. Create a HighLevel API instance. 43 | 2. Program nRF9160 with 'nrf9160_pca20035_firmware_upgrade_app' using an MCUBootDFUProbe probe. 44 | This application will receive modem firmware data over serial communication and apply it to the device. 45 | 3. Upload the modem firmware pointed to by 'nrf9160_modem_firmware_zip_location' using a 46 | ModemUARTDFUProbe probe. 47 | 4. Print the time elapsed during modem firmware upload. 48 | 49 | """ 50 | 51 | from __future__ import print_function 52 | import sys 53 | import argparse 54 | import logging 55 | import time 56 | import os 57 | 58 | # Import pynrfjprog HighLevel API module 59 | try: 60 | from .. import HighLevel 61 | except ImportError: 62 | from pynrfjprog import HighLevel 63 | 64 | from . import hex_files 65 | 66 | 67 | def run(serial_device_name_uart0, serial_device_name_uart1, nrf9160_modem_firmware_zip_location): 68 | """ 69 | Run example script. 70 | 71 | @param string serial_device_name_uart0: Specify Thingy:91 UART0 serial port name. 72 | @param string serial_device_name_uart1: Specify Thingy:91 UART1 serial port name. 73 | @param string nrf9160_modem_firmware_zip_location: Specify the location of the modem firmware zip file 74 | """ 75 | # Verify that the firmware zip exists 76 | if not os.path.exists(nrf9160_modem_firmware_zip_location): 77 | raise FileNotFoundError( 78 | "Invalid path to modem firmware zip file provided. Skipping nrf9160 modem device firmware upgrade example." 79 | ) 80 | 81 | print("# nrf9160 modem firmware upgrade over serial port example started...") 82 | 83 | # Configure logging to see HighLevel API output 84 | logging.basicConfig(level=logging.INFO, format="%(message)s") 85 | 86 | hex_file_path = hex_files.find_thingy91_modem_update_hex() 87 | 88 | # Create our API instance 89 | with HighLevel.API() as api: 90 | # Program the nrf9160 device with the DFU server application using MCUBoot 91 | # This assumes the device is in serial recovery mode and is ready to be programmed 92 | print("Flashing nrf9160 modem DFU application") 93 | with HighLevel.MCUBootDFUProbe(api, serial_device_name_uart0) as mcuboot_probe: 94 | mcuboot_probe.program(hex_file_path) 95 | 96 | # Upload the modem firmware to the nrf9160 device 97 | start_time = time.time() 98 | with HighLevel.ModemUARTDFUProbe(api, serial_device_name_uart1) as modem_dfu_probe: 99 | modem_dfu_probe.program(nrf9160_modem_firmware_zip_location) 100 | modem_dfu_probe.verify(nrf9160_modem_firmware_zip_location) 101 | 102 | # Print upload time 103 | print("------------------------------------------------------------") 104 | print("The operation took {0:.2f} seconds ".format(time.time() - start_time)) 105 | 106 | print("# Example done...") 107 | 108 | 109 | if __name__ == "__main__": 110 | parser = argparse.ArgumentParser() 111 | parser.add_argument("uart0", default=None, help="Serial device name for Thingy:91 UART0 (mcuboot@115200 baud)") 112 | parser.add_argument("uart1", default=None, help="Serial device name for Thingy:91 UART1") 113 | parser.add_argument("firmware", default=None, help="Path to nrf9160 modem firmware zip folder") 114 | args = parser.parse_args() 115 | run(args.uart0, args.uart1, args.firmware) 116 | -------------------------------------------------------------------------------- /pynrfjprog/examples/program_hex.py: -------------------------------------------------------------------------------- 1 | """ 2 | 3 | This file contains example code meant to be used in order to test the 4 | pynrfjprog API and Hex modules. If multiple devices are connected, a 5 | pop-up will appear for device selection. 6 | 7 | Sample program: program_hex.py 8 | Requires an nRF Development Kit for visual confirmation (LEDs). 9 | 10 | Run from command line: 11 | python program_hex.py 12 | or if imported as "from pynrfjprog import examples" 13 | examples.program_hex.run() 14 | 15 | Program flow: 16 | 0. An API object is instantiated with AUTO family to read the device family. 17 | 1. An API object is instantiated with the read family. A connection to the debug probe is established. 18 | 2. Flash memory is erased. 19 | 3. A hex file is parsed and programmed into memory. 20 | 4. The device is reset and application is run. 21 | 22 | """ 23 | 24 | from __future__ import print_function 25 | import os 26 | 27 | # Import pynrfjprog API module and HEX parser module 28 | try: 29 | from .. import LowLevel, Hex 30 | except ImportError: 31 | from pynrfjprog import LowLevel, Hex 32 | 33 | from . import hex_files 34 | 35 | 36 | def run(snr=None): 37 | """ 38 | Run example script. 39 | 40 | @param (optional) int snr: Specify serial number of DK to run example on. 41 | """ 42 | print("# Hex file programming example using pynrfjprog started...") 43 | 44 | # We will detect the device family of your device. Initialize an API object with AUTO family. 45 | print("# Opening API with device family AUTO, reading the device family.") 46 | 47 | with LowLevel.API() as api: 48 | if snr is not None: 49 | api.connect_to_emu_with_snr(snr) 50 | else: 51 | api.connect_to_emu_without_snr() 52 | 53 | # Read the device's family. 54 | # This step is performed so this example can be run in all devices without customer input. 55 | device_family = api.read_device_family() 56 | device_version = api.read_device_version() 57 | 58 | hex_file_path = hex_files.find_blinky_hex(device_family, device_version) 59 | 60 | # Erase all the flash of the device. 61 | print("# Erase only flash sectors overlaping image.") 62 | api.erase_file(file_path=hex_file_path, chip_erase_mode=LowLevel.EraseAction.ERASE_SECTOR) 63 | 64 | print(f"# Programming {hex_file_path}") 65 | api.program_file(file_path=hex_file_path) 66 | 67 | # Reset the device and run. 68 | api.sys_reset() 69 | api.go() 70 | print("# Application running. Your board should be blinking.") 71 | 72 | # Close the loaded DLL to free resources. 73 | api.close() 74 | 75 | print("# Example done...") 76 | 77 | 78 | if __name__ == "__main__": 79 | run() 80 | -------------------------------------------------------------------------------- /pynrfjprog/examples/python_help.py: -------------------------------------------------------------------------------- 1 | """ 2 | 3 | This file contains example code meant to be used in order to test the 4 | pynrfjprog API. 5 | 6 | Sample program: python_help.py 7 | 8 | Run from command line: 9 | python python_help.py 10 | or if imported as "from pynrfjprog import examples" 11 | examples.python_help.run() 12 | 13 | Program flow: 14 | 0. Python help() is used to list the available API functions 15 | 16 | """ 17 | 18 | from __future__ import print_function 19 | 20 | # Import pynrfjprog API module 21 | try: 22 | from .. import LowLevel 23 | except ImportError: 24 | from pynrfjprog import LowLevel 25 | 26 | 27 | def run(): 28 | print("# Python help() example started...") 29 | 30 | # Use the python help() to list the available information regarding the API module 31 | help(LowLevel) 32 | 33 | print("# Example done...") 34 | 35 | 36 | if __name__ == "__main__": 37 | run() 38 | -------------------------------------------------------------------------------- /pynrfjprog/examples/rtt_asyncio.py: -------------------------------------------------------------------------------- 1 | """ 2 | 3 | This file contains example code meant to be used in order to showcase the 4 | pynrfjprog AsyncIO RTT functionality. 5 | 6 | Sample program: rtt_asyncio.py 7 | 8 | Run from command line: 9 | python rtt_asyncio.py 10 | or if imported using "from pynrfjprog import examples" 11 | asyncio.run(examples.rtt_asyncio.run(682000044)) 12 | 13 | Program flow: 14 | 0. An API object is instantiated with AUTO family to read the device family. 15 | 1. A connection to the debug probe is established. 16 | 2. The detected family is loaded using select_family() 17 | 3. An exapmle rtt application is programmed 18 | 4. An asyncio RTT channel is created 19 | 5. "Hello world!" is printed to channel 1 20 | 6. The echoed data is read from channel 1 and printed to terminal 21 | 22 | """ 23 | 24 | from __future__ import print_function 25 | import argparse 26 | import asyncio 27 | 28 | # Import pynrfjprog API module 29 | try: 30 | from .. import LowLevel 31 | except ImportError: 32 | from pynrfjprog import LowLevel 33 | 34 | from . import hex_files 35 | 36 | 37 | async def test_rtt(api, channel_index): 38 | while not api.rtt_is_control_block_found(): 39 | asyncio.sleep(0.5) 40 | 41 | # Test RTT echo functionality on channel 1 42 | reader, writer = await api.rtt_asyncio_open_connection(channel_index) 43 | 44 | print(f"# Send Hello World!") 45 | 46 | writer.write("Hello World!") 47 | 48 | data = await reader.read(n=100) 49 | print(f"# Received {data.decode()}") 50 | 51 | writer.close() 52 | 53 | await writer.wait_closed() 54 | 55 | 56 | def run(snr=None): 57 | """ 58 | Run example script. 59 | 60 | @param int snr: Specify serial number of DK to run example on. 61 | """ 62 | print("# AsyncIO RTT example using pynrfjprog started...") 63 | 64 | with LowLevel.API() as api: 65 | # Connect to and identify device 66 | if snr is None: 67 | api.connect_to_emu_without_snr() 68 | else: 69 | api.connect_to_emu_with_snr(snr) 70 | 71 | family = api.read_device_family() 72 | device_version = api.read_device_version() 73 | 74 | # Program and start RTT firmware 75 | hex_file_path = hex_files.find_rtt_hex(family, device_version) 76 | 77 | print(f"# Programming {hex_file_path}") 78 | 79 | api.erase_all() 80 | api.program_file(hex_file_path) 81 | 82 | api.sys_reset() 83 | api.go() 84 | 85 | api.rtt_start() 86 | 87 | asyncio.run(test_rtt(api, channel_index=1)) 88 | 89 | print("# Example done...") 90 | 91 | 92 | if __name__ == "__main__": 93 | parser = argparse.ArgumentParser() 94 | parser.add_argument("-s", "--serial", type=int, help="Serial number to test.") 95 | args = parser.parse_args() 96 | 97 | run(args.serial) 98 | -------------------------------------------------------------------------------- /pynrfjprog/examples/rtt_callback.py: -------------------------------------------------------------------------------- 1 | """ 2 | 3 | This file contains example code meant to be used in order to showcase the 4 | pynrfjprog callback-based asynchronous RTT functionality. 5 | 6 | Sample program: rtt_callback.py 7 | 8 | Run from command line: 9 | python rtt_callback.py 10 | or if imported using "from pynrfjprog import examples" 11 | examples.rtt_callback.run(682000044) 12 | 13 | Program flow: 14 | 0. An API object is instantiated with AUTO family to read the device family. 15 | 1. A connection to the debug probe is established. 16 | 2. The detected family is loaded using select_family() 17 | 3. An exapmle rtt application is programmed 18 | 4. RTT is started 19 | 5. "Hello world!" is printed to channel 1 20 | 6. The echoed data is read from channel 1 and printed to terminal 21 | 22 | """ 23 | 24 | from __future__ import print_function 25 | import argparse 26 | import threading 27 | import time 28 | 29 | # Import pynrfjprog API module 30 | try: 31 | from .. import LowLevel 32 | except ImportError: 33 | from pynrfjprog import LowLevel 34 | 35 | from . import hex_files 36 | 37 | read_event = threading.Event() 38 | 39 | 40 | def read_callback(channel_index, data, _): 41 | print(f"# Received {data.decode('utf-8')}") 42 | read_event.set() 43 | 44 | 45 | def run(snr=None): 46 | """ 47 | Run example script. 48 | 49 | @param int snr: Specify serial number of DK to run example on. 50 | """ 51 | print("# Callback-based asynchronous RTT example using pynrfjprog started...") 52 | 53 | with LowLevel.API() as api: 54 | # Connect to and identify device 55 | if snr is None: 56 | api.connect_to_emu_without_snr() 57 | else: 58 | api.connect_to_emu_with_snr(snr) 59 | 60 | family = api.read_device_family() 61 | device_version = api.read_device_version() 62 | 63 | # Program and start RTT firmware 64 | hex_file_path = hex_files.find_rtt_hex(family, device_version) 65 | 66 | print(f"# Programming {hex_file_path}") 67 | 68 | api.erase_all() 69 | api.program_file(hex_file_path) 70 | 71 | api.sys_reset() 72 | api.go() 73 | 74 | api.rtt_start() 75 | 76 | while not api.rtt_is_control_block_found(): 77 | time.sleep(0.5) 78 | 79 | api.rtt_async_callback_start(channel_index=1, max_read_data_len=100, read_callback_func=read_callback) 80 | 81 | print(f"# Send Hello World!") 82 | api.rtt_async_write(channel_index=1, msg="Hello World!") 83 | 84 | # Wait for read callback to happen 85 | read_event.wait(2) 86 | 87 | api.rtt_async_callback_stop(channel_index=1) 88 | 89 | print("# Example done...") 90 | 91 | 92 | if __name__ == "__main__": 93 | parser = argparse.ArgumentParser() 94 | parser.add_argument("-s", "--serial", type=int, help="Serial number to test.") 95 | args = parser.parse_args() 96 | 97 | run(args.serial) 98 | -------------------------------------------------------------------------------- /pynrfjprog/examples/rtt_synchronous.py: -------------------------------------------------------------------------------- 1 | """ 2 | 3 | This file contains example code meant to be used in order to showcase the 4 | pynrfjprog RTT functionality. 5 | 6 | Sample program: rtt_synchronous.py 7 | 8 | Run from command line: 9 | python rtt_synchronous.py 10 | or if imported using "from pynrfjprog import examples" 11 | examples.rtt_synchronous.run(682000044) 12 | 13 | Program flow: 14 | 0. An API object is instantiated with AUTO family to read the device family. 15 | 1. A connection to the debug probe is established. 16 | 2. The detected family is loaded using select_family() 17 | 3. An exapmle rtt application is programmed 18 | 4. RTT is started 19 | 5. "Hello world!" is printed to channel 1 20 | 6. The echoed data is read from channel 1 and printed to terminal 21 | 22 | """ 23 | 24 | from __future__ import print_function 25 | import argparse 26 | import time 27 | 28 | # Import pynrfjprog API module 29 | try: 30 | from .. import LowLevel 31 | except ImportError: 32 | from pynrfjprog import LowLevel 33 | 34 | from . import hex_files 35 | 36 | 37 | def run(snr=None): 38 | """ 39 | Run example script. 40 | 41 | @param int snr: Specify serial number of DK to run example on. 42 | """ 43 | print("# Synchronous RTT example using pynrfjprog started...") 44 | 45 | with LowLevel.API() as api: 46 | # Connect to and identify device 47 | if snr is None: 48 | api.connect_to_emu_without_snr() 49 | else: 50 | api.connect_to_emu_with_snr(snr) 51 | 52 | family = api.read_device_family() 53 | device_version = api.read_device_version() 54 | 55 | # Program and start RTT firmware 56 | hex_file_path = hex_files.find_rtt_hex(family, device_version) 57 | 58 | print(f"# Programming {hex_file_path}") 59 | 60 | api.erase_all() 61 | api.program_file(hex_file_path) 62 | 63 | api.sys_reset() 64 | api.go() 65 | 66 | api.rtt_start() 67 | 68 | while not api.rtt_is_control_block_found(): 69 | time.sleep(0.5) 70 | 71 | print(f"# Send Hello World!") 72 | 73 | api.rtt_write(channel_index=1, msg="Hello World!") 74 | time.sleep(0.1) # Wait for the message to be echoed back 75 | data = api.rtt_read(channel_index=1, length=100) 76 | 77 | print(f"# Received {data}") 78 | 79 | print("# Example done...") 80 | 81 | 82 | if __name__ == "__main__": 83 | parser = argparse.ArgumentParser() 84 | parser.add_argument("-s", "--serial", type=int, help="Serial number to test.") 85 | args = parser.parse_args() 86 | 87 | asyncio.run(run(args.serial)) 88 | -------------------------------------------------------------------------------- /pynrfjprog/lib_arm64/__init__.py: -------------------------------------------------------------------------------- 1 | #arm64 libraries -------------------------------------------------------------------------------- /pynrfjprog/lib_arm64/jlinkarm_nrf_worker_linux: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NordicSemiconductor/pynrfjprog/15b36b72da055ab631df205c4faba7591255176b/pynrfjprog/lib_arm64/jlinkarm_nrf_worker_linux -------------------------------------------------------------------------------- /pynrfjprog/lib_arm64/libhighlevelnrfjprog.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NordicSemiconductor/pynrfjprog/15b36b72da055ab631df205c4faba7591255176b/pynrfjprog/lib_arm64/libhighlevelnrfjprog.so -------------------------------------------------------------------------------- /pynrfjprog/lib_arm64/libnrfdfu.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NordicSemiconductor/pynrfjprog/15b36b72da055ab631df205c4faba7591255176b/pynrfjprog/lib_arm64/libnrfdfu.so -------------------------------------------------------------------------------- /pynrfjprog/lib_arm64/libnrfjprogdll.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NordicSemiconductor/pynrfjprog/15b36b72da055ab631df205c4faba7591255176b/pynrfjprog/lib_arm64/libnrfjprogdll.so -------------------------------------------------------------------------------- /pynrfjprog/lib_armhf/__init__.py: -------------------------------------------------------------------------------- 1 | # arm libraries 2 | -------------------------------------------------------------------------------- /pynrfjprog/lib_armhf/jlinkarm_nrf_worker_linux: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NordicSemiconductor/pynrfjprog/15b36b72da055ab631df205c4faba7591255176b/pynrfjprog/lib_armhf/jlinkarm_nrf_worker_linux -------------------------------------------------------------------------------- /pynrfjprog/lib_armhf/libhighlevelnrfjprog.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NordicSemiconductor/pynrfjprog/15b36b72da055ab631df205c4faba7591255176b/pynrfjprog/lib_armhf/libhighlevelnrfjprog.so -------------------------------------------------------------------------------- /pynrfjprog/lib_armhf/libnrfdfu.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NordicSemiconductor/pynrfjprog/15b36b72da055ab631df205c4faba7591255176b/pynrfjprog/lib_armhf/libnrfdfu.so -------------------------------------------------------------------------------- /pynrfjprog/lib_armhf/libnrfjprogdll.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NordicSemiconductor/pynrfjprog/15b36b72da055ab631df205c4faba7591255176b/pynrfjprog/lib_armhf/libnrfjprogdll.so -------------------------------------------------------------------------------- /pynrfjprog/lib_x64/__init__.py: -------------------------------------------------------------------------------- 1 | # 64 bit libraries 2 | 3 | -------------------------------------------------------------------------------- /pynrfjprog/lib_x64/highlevelnrfjprog.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NordicSemiconductor/pynrfjprog/15b36b72da055ab631df205c4faba7591255176b/pynrfjprog/lib_x64/highlevelnrfjprog.dll -------------------------------------------------------------------------------- /pynrfjprog/lib_x64/jlinkarm_nrf_worker.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NordicSemiconductor/pynrfjprog/15b36b72da055ab631df205c4faba7591255176b/pynrfjprog/lib_x64/jlinkarm_nrf_worker.exe -------------------------------------------------------------------------------- /pynrfjprog/lib_x64/jlinkarm_nrf_worker_linux: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NordicSemiconductor/pynrfjprog/15b36b72da055ab631df205c4faba7591255176b/pynrfjprog/lib_x64/jlinkarm_nrf_worker_linux -------------------------------------------------------------------------------- /pynrfjprog/lib_x64/jlinkarm_nrf_worker_osx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NordicSemiconductor/pynrfjprog/15b36b72da055ab631df205c4faba7591255176b/pynrfjprog/lib_x64/jlinkarm_nrf_worker_osx -------------------------------------------------------------------------------- /pynrfjprog/lib_x64/libhighlevelnrfjprog.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NordicSemiconductor/pynrfjprog/15b36b72da055ab631df205c4faba7591255176b/pynrfjprog/lib_x64/libhighlevelnrfjprog.dylib -------------------------------------------------------------------------------- /pynrfjprog/lib_x64/libhighlevelnrfjprog.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NordicSemiconductor/pynrfjprog/15b36b72da055ab631df205c4faba7591255176b/pynrfjprog/lib_x64/libhighlevelnrfjprog.so -------------------------------------------------------------------------------- /pynrfjprog/lib_x64/libnrfdfu.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NordicSemiconductor/pynrfjprog/15b36b72da055ab631df205c4faba7591255176b/pynrfjprog/lib_x64/libnrfdfu.dylib -------------------------------------------------------------------------------- /pynrfjprog/lib_x64/libnrfdfu.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NordicSemiconductor/pynrfjprog/15b36b72da055ab631df205c4faba7591255176b/pynrfjprog/lib_x64/libnrfdfu.so -------------------------------------------------------------------------------- /pynrfjprog/lib_x64/libnrfjprogdll.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NordicSemiconductor/pynrfjprog/15b36b72da055ab631df205c4faba7591255176b/pynrfjprog/lib_x64/libnrfjprogdll.dylib -------------------------------------------------------------------------------- /pynrfjprog/lib_x64/libnrfjprogdll.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NordicSemiconductor/pynrfjprog/15b36b72da055ab631df205c4faba7591255176b/pynrfjprog/lib_x64/libnrfjprogdll.so -------------------------------------------------------------------------------- /pynrfjprog/lib_x64/nrfdfu.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NordicSemiconductor/pynrfjprog/15b36b72da055ab631df205c4faba7591255176b/pynrfjprog/lib_x64/nrfdfu.dll -------------------------------------------------------------------------------- /pynrfjprog/lib_x64/nrfjprog.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NordicSemiconductor/pynrfjprog/15b36b72da055ab631df205c4faba7591255176b/pynrfjprog/lib_x64/nrfjprog.dll -------------------------------------------------------------------------------- /pynrfjprog/lib_x86/__init__.py: -------------------------------------------------------------------------------- 1 | # 32 bit libraries 2 | 3 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["setuptools>=61.0"] 3 | build-backend = "setuptools.build_meta" 4 | 5 | [project] 6 | name = "pynrfjprog" 7 | authors = [ 8 | { name="Nordic Semiconductor ASA", email = "sagtools@nordicsemi.no" } 9 | ] 10 | description = "A simple Python interface for the nrfjprog functionality" 11 | classifiers = [ 12 | "Development Status :: 5 - Production/Stable", 13 | "Intended Audience :: Developers", 14 | "Operating System :: MacOS", 15 | "Operating System :: Microsoft :: Windows", 16 | "Operating System :: POSIX :: Linux", 17 | "Topic :: Software Development :: Build Tools", 18 | "Topic :: Software Development :: Debuggers", 19 | "Topic :: Software Development :: Embedded Systems", 20 | "Programming Language :: Python :: 3.7", 21 | "Programming Language :: Python :: 3.8", 22 | "Programming Language :: Python :: 3.9", 23 | "Programming Language :: Python :: 3.10", 24 | "Programming Language :: Python :: 3.11", 25 | "License :: Other/Proprietary License" 26 | ] 27 | keywords = [ 28 | "nrfjprog", 29 | "pynrfjprog" 30 | ] 31 | dependencies = [ 32 | "future", 33 | "tomli-w" 34 | ] 35 | requires-python = ">=3.7" 36 | dynamic = ["version"] 37 | 38 | readme = "README.md" 39 | 40 | 41 | [project.license] 42 | file = "LICENSE" 43 | 44 | [project.urls] 45 | "Homepage" = "https://www.nordicsemi.com/Products/Development-tools/nrf-pynrfjprog/" 46 | "Bug Tracker" = "https://github.com/NordicSemiconductor/pynrfjprog/issues" 47 | 48 | [tool.setuptools] 49 | packages = {find = {}} 50 | include-package-data = true 51 | [tool.setuptools.dynamic] 52 | version = {attr = "pynrfjprog.__version__"} 53 | -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [egg_info] 2 | tag_build = 3 | tag_date = 0 4 | 5 | --------------------------------------------------------------------------------