[SOLVED] How to enable jlink support for custom flashloader to pylink python library?

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • [SOLVED] How to enable jlink support for custom flashloader to pylink python library?

    Hi,
    I would like to automate some things like flashing firmware, memory erase, uC reset and alike, for my microcontroller by using jlink.

    I have a custom bord with the following hardware configuration:
    • microcontroller: NXP IMXRT1176
    • external memory: Infineon Hyperflash S26HL512T with Hyperbus configuration
    Since there already is a python library that handles jlink, I would like to use it for my purposes.
    GitHub - square/pylink: Python Library for device debugging/programming via J-Link - github pylink library repository

    With my microcontroller, the type of memory and its configuration, it was stated that custom flash loader is required to allow jlink to perform operations on the memory that is connected to the microcontroller via Hyperbus interface.
    I have custom device configuration definition and jlink compatible .FLM flash loader file that I can use via jlink commander tool - write/read/erase work without any issue, I can also debug the code from non-volatile memory without any issues.

    The problem I have is that pylink can't find the device when I execute jlink.connect method. I assume it is due to the fact that my flashloader is external to what is normally included in the jlink software by default and for some reason built-in ARM DLL does not find the device configuration I added.
    See attached image for reference:

    Index is -1 which suggests it was not found.
    From the pylink python code I see that it fetches device configuration that is based on the index (that is probably where all the connection magic happens). Unfortunately for me, the index is not found as you can see on the image above.

    My guess is that the entire jlink architecture was made this way to be flexible and allow customization, hence the possibility to add and configure custom devices/targets with custom flash loader. Maybe I'm doing something wrong here, or pylink just does not support external flash loaders.
    Maybe it executes incorrect methods/functions from the DLL - hard to tell from my perspective.

    The questions:
    1. Do you know what is the procedure when it comes to custom flash loader and custom device configuration to be able to work with pylink library and jlink DLL?
    2. Is there a simple way to make it work in my case, and if so how?
    Please do let me know if you need any specific information to be able to help.

    Best regards,
    Michal
    Images
    • image.png

      4.91 kB, 434×46, viewed 372 times

    The post was edited 1 time, last by mimlo ().

  • Hello,

    I just checked, but I was unable to reproduce the issue.

    I used the example code specified in the README file of the Pylink project, as well as the DSK example code from our knowledge base:
    Adding a new device (Knowledge Base)

    Here is the Python source code I used:

    Python Source Code

    1. import pylink
    2. if __name__ == '__main__':
    3. jlink = pylink.JLink()
    4. # Open a connection to your J-Link.
    5. jlink.open()
    6. # Connect to the target device.
    7. jlink.connect('SEGGER_Device0', verbose=True)
    8. # Do whatever you want from here on in.
    9. jlink.reset()
    Display All

    When I executed this Python code, the J-Link DLL was able to detect the device and successfully connect to it.

    Could you please share the Python code you are using?

    Best regards,
    Simon
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • Hello @Simon

    It turned out that error was purely on my side. As stated in the Knowledge Base url you shared, for a new device to be readable by jlink, there is a requirement for the following folder's presence:


    C:\Users\<USER>\AppData\Roaming\SEGGER\JLinkDevices

    "In order to make the J-Link software aware of the new device, the previously created XML file need to be placed in the central JLinkDevices folder.
    If the folder does not exist, it may be created."

    After applying above, the issue was resolved.
    Thank you