### Install PyLink using easy_install Source: https://github.com/square/pylink/blob/master/docs/installation.rst An alternative method for installing PyLink using the easy_install tool. ```bash easy_install pylink-square ``` -------------------------------- ### Install PyLink from Source Source: https://github.com/square/pylink/blob/master/docs/installation.rst Build and install the development version of PyLink from its source code repository. ```bash python setup.py install ``` -------------------------------- ### Install Development Requirements Source: https://github.com/square/pylink/blob/master/README.md Install development and testing requirements using pip. ```bash pip install -e ".[dev,test]" ``` -------------------------------- ### Serial Wire Viewer (SWV) Example Source: https://github.com/square/pylink/blob/master/docs/swd.rst An example demonstrating the use of the Serial Wire Viewer (SWV) for real-time trace data. This snippet requires the 'swv.py' example file to be present in the ../examples/ directory. ```python # This file is a literal include from ../examples/swv.py # It demonstrates the usage of SWV functionality. # The actual code content is not provided here but is expected to be in the referenced file. pass ``` -------------------------------- ### Install PyLink from a Release Branch Source: https://github.com/square/pylink/blob/master/docs/installation.rst Check out a specific release branch and then build and install PyLink from source for a stable version. ```bash git checkout release-major.minor python setup.py install ``` -------------------------------- ### Install J-Link Library on Mac (Copy) Source: https://github.com/square/pylink/blob/master/docs/installation.rst Manually copy the J-Link dynamic library to the system's default library directory on macOS. ```bash # Option A: Copy the library file to your libraries directory. cp libjlinkarm.dylib /usr/local/lib/ ``` -------------------------------- ### Install J-Link Library on Linux (Copy) Source: https://github.com/square/pylink/blob/master/docs/installation.rst Manually copy the J-Link shared object library to the system's default library directory on Linux. ```bash # Option A: Copy the library to your libraries directory. $ cp libjlinkarm.so /usr/local/lib/ ``` -------------------------------- ### Install PyLink using pip Source: https://github.com/square/pylink/blob/master/docs/installation.rst Use this command to install the PyLink package directly from the Python Package Index. ```bash pip install pylink-square ``` -------------------------------- ### Start SWO with JLink Source: https://github.com/square/pylink/blob/master/docs/swd.rst Initiates Serial Wire Output (SWO) tracing with a specified speed. Ensure your J-Link is set up and connected to the target device before calling this function. ```python speed = 9600 jlink.swo_start(swo_speed=speed) ``` -------------------------------- ### Configure J-Link Library Path on Linux Source: https://github.com/square/pylink/blob/master/docs/installation.rst Add the SEGGER J-Link installation directory to the LD_LIBRARY_PATH environment variable on Linux to help the system find the shared library. ```bash # Option B: Add SEGGER's J-Link library path to your libraries path. $ export LD_LIBRARY_PATH=/path/to/SEGGER/JLink:$LD_LIBRARY_PATH ``` -------------------------------- ### Configure J-Link Library Path on Mac Source: https://github.com/square/pylink/blob/master/docs/installation.rst Add the SEGGER J-Link installation directory to the DYLD_LIBRARY_PATH environment variable on macOS to help the system find the library. ```bash # Option B: Add SEGGER's J-Link directory to your dynamic libraries path. $ export DYLD_LIBRARY_PATH=/Applications/SEGGER/JLink:$DYLD_LIBRARY_PATH ``` -------------------------------- ### Run Tests Source: https://github.com/square/pylink/blob/master/README.md Execute unit tests using setup.py test or functional tests using setup.py bddtest. ```bash # Unit tests $ python setup.py test # Functional tests $ python setup.py bddtest ``` -------------------------------- ### Initialize and Connect to J-Link Source: https://github.com/square/pylink/blob/master/docs/index.rst Demonstrates the basic steps to import the PyLink library, create a JLink instance, open a connection to a specific J-Link by serial number, and retrieve the product name. ```python >>> import pylink >>> jlink = pylink.JLink() >>> jlink.open(serial_no=123456789) >>> jlink.product_name J-Trace Cortex-M ``` -------------------------------- ### Generate Documentation Source: https://github.com/square/pylink/blob/master/README.md Generate Sphinx documentation by navigating to the docs directory and running the make html command. ```bash $ cd docs $ make html ``` -------------------------------- ### PyLink CLI Help Source: https://github.com/square/pylink/blob/master/docs/cli.rst Display the help message for the PyLink CLI. This shows available commands and options. ```bash pylink --help ``` -------------------------------- ### Connect to J-Link Emulator Source: https://github.com/square/pylink/blob/master/docs/tutorial.rst Establishes a connection to a J-Link emulator using its serial number. Shows how to check connection status and retrieve product information. ```python >>> import pylink >>> jlink = pylink.JLink() >>> jlink.open(123456789) >>> jlink.product_name J-Trace Cortex-M >>> jlink.oem >>> jlink.opened() True >>> jlink.connected() True >>> jlink.target_connected() False ``` -------------------------------- ### Generate Coverage Report Source: https://github.com/square/pylink/blob/master/README.md Generate code coverage report and open the HTML index file. ```bash $ python setup.py coverage $ open htmlcov/index.html ``` -------------------------------- ### Configure J-Link on Linux Source: https://github.com/square/pylink/blob/master/README.md Copy the J-Link library to the system's library directory or add the SEGGER J-Link library path to the dynamic libraries path. ```bash # Option A: Copy the library to your libraries directory. $ cp libjlinkarm.so /usr/local/lib/ # Option B: Add SEGGER's J-Link library path to your libraries path. $ export LD_LIBRARY_PATH=/path/to/SEGGER/JLink:$LD_LIBRARY_PATH ``` -------------------------------- ### Enable SWO with JLink Source: https://github.com/square/pylink/blob/master/docs/swd.rst Enables Serial Wire Output (SWO) with specific CPU and SWO speeds, and a port mask. This is an alternative to swo_start() and requires the target device to be connected and J-Link initialized. ```python swo_speed = 9600 cpu_speed = 72000000 # 72 MHz port_mask = 0x01 jlink.swo_enable(cpu_speed, swo_speed, port_mask) ``` -------------------------------- ### Basic PyLink Usage Source: https://github.com/square/pylink/blob/master/README.md Connect to a J-Link device, connect to the target, and perform operations like flashing firmware and resetting the device. ```python import pylink if __name__ == '__main__': serial_no = '123456789' jlink = pylink.JLink() # Open a connection to your J-Link. jlink.open(serial_no) # Connect to the target device. jlink.connect('device', verbose=True) # Do whatever you want from here on in. jlink.flash(firmware, 0x0) jlink.reset() ``` -------------------------------- ### Configure J-Link on Mac Source: https://github.com/square/pylink/blob/master/README.md Copy the J-Link library to the system's library directory or add the SEGGER J-Link directory to the dynamic libraries path. ```bash # Option A: Copy the library to your libraries directory. $ cp libjlinkarm.dylib /usr/local/lib/ # Option B: Add SEGGER's J-Link directory to your dynamic libraries path. $ export DYLD_LIBRARY_PATH=/Applications/SEGGER/JLink:$DYLD_LIBRARY_PATH ``` -------------------------------- ### Flash File to Target Source: https://github.com/square/pylink/blob/master/docs/tutorial.rst Flashes a file from the specified path to the target device at a given address. Verifies the flash by reading back the data. ```python >>> jlink.flash_file('/path/to/file', address) 1337 >>> jlink.memory_read8(0, 1337) [ 0, 0, .... ] ``` -------------------------------- ### Flash Bytes to Target Source: https://github.com/square/pylink/blob/master/docs/tutorial.rst Flashes a list of bytes to the target device at a specified address. Verifies the flash by reading back the data. ```python >>> data = [1, 2, 3, 4] >>> jlink.flash(data, 0) 4 >>> jlink.memory_read8(0, 4) [1, 2, 3, 4] ``` -------------------------------- ### Connect to Target CPU Source: https://github.com/square/pylink/blob/master/docs/tutorial.rst Connects to a specific target CPU on the J-Link emulator. Retrieves core ID and device family information, and verifies target connection. ```python >>> jlink.connect('MKxxxxxxxxxx7') >>> jlink.core_id() 50331903 >>> jlink.device_family() 3 >>> jlink.target_connected() True ``` -------------------------------- ### Handle Unspecified Error in PyLink Source: https://github.com/square/pylink/blob/master/docs/troubleshooting.rst This traceback indicates a generic 'Unspecified error' from the J-Link SDK, often due to external factors. Review the specific operation (open, connect, erase, flash) for targeted solutions. ```python Traceback (most recent call last): File "pylink/decorators.py", line 38, in async_wrapper return func(*args, **kwargs) File "pylink/jlink.py", line 256, in open raise JLinkException(result) __main__.JLinkException: Unspecified error. ``` -------------------------------- ### Update J-Link Emulator Firmware Source: https://github.com/square/pylink/blob/master/docs/tutorial.rst Initiates the firmware update process for the connected J-Link emulator. Returns a status code indicating the result of the operation. ```python >>> jlink.update_firmware() 1 ``` -------------------------------- ### Unlock Kinetis Device Source: https://github.com/square/pylink/blob/master/docs/tutorial.rst Unlocks a Kinetis device using the provided J-Link object. This operation is currently only supported for Kinetis devices over SWD. ```python >>> pylink.unlock(jlink, 'Kinetis') True ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.