[SOLVED] J-Link is low on memory

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

  • [SOLVED] J-Link is low on memory

    Hello,

    I am having some troubles with my J-Link BASE debugger. I am trying to use it as part of an automatic test suite, where I use the J-Link BASE to program a Nordic nRF52 board prior to running some tests. In this test suite, the J-Link BASE is used multiple times to re-program the board and get an SWO connection for debug logs.

    This typically works well the first few times, but after initiating and closing the connection a couple times, it stops working. Instead, I get this error with every attempt:

    Source Code

    1. ****** Error: The connected J-Link (S/N XXXXXXXX) is low on memory. Target connection cannot be established

    I can restore the J-Link by unplugging and replugging it. However, that is not much of a solution, since I need this to be automated.

    I have J-Link Software Pack 6.30e installed, with the debugger firmware updated. I'm using Windows 10. I have tried using both jlink.exe solely and arm-none-eabi-gdb + jlinkgdbservercl.exe in my scripts, and have the same problem.

    Do you have any idea of what causes this, and a way to avoid the problem? Or do you know some better way to restore the J-Link than replugging its USB cable?

    Best regards,
    Fabian

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

  • Hello Fabian,

    Thank you for your inquiry.
    Such an issue is not known to us.
    Could you give us more information about your exact testing setup?
    How are you interfacing with J-Link, are you using the J-Link commander for that or the J-Link SDK?
    Could you provide a J-Link log file of such a session?
    wiki.segger.com/Enable_J-Link_log_file

    It sounds like the J-Link connection is not closed properly and after a couple of runs the internal buffer is full.

    Best regards,
    Nino
    Please read the forum rules before posting: Forum Rules

    Keep in mind, this is not a support forum. Its main purpose is user to user interaction.
    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 contact us per e-mail.
    The following contact form can be used for this: Contact Us

  • Hello,

    I am using J-Link to download software and get debug logs as part of a test automation system in Robot Framework/Python. As such, I have a Python script which in turn starts J-Link and other applications. I have tried two approaches, both which give me the same error.

    For the first approach, Python starts J-Link Commander with the following command:

    Source Code

    1. jlink -device nRF52832_xxAA -If SWD -Speed 4000 -autoconnect 1 -commanderscript {commander_script_path}

    The commander script contains the following commands:

    Source Code

    1. h
    2. loadfile {binary_path}
    3. r
    4. go
    5. swoview {swo_freq}

    The command is started using Python's subprocess.Popen(), and the process is killed when the test suite is finished.

    For the other approach I use arm-none-eabi-gdb + J-Link GDB Server CL + Telnet. Here, I first start J-Link GDB Server CL with the following command:

    Source Code

    1. JLinkGDBServerCL -select USB -device {cpu_type} -if SWD -speed 1000 -ir -singlerun -vd -strict -nogui -timeout 0

    I then start arm-none-eabi-gdb with the following command:

    Source Code

    1. arm-none-eabi-gdb --eval-command='set $swo_cpu_speed = {swo_cpu_speed}' --eval-command='set $should_run = {should_run}' --command={gdb_commands_path} {binary_path}

    The GDB commands file contains this:

    Source Code

    1. set mem inaccessible-by-default off
    2. target remote localhost:2331
    3. monitor speed 1000
    4. monitor clrbp
    5. monitor reset
    6. monitor halt
    7. monitor regs
    8. flushreg
    9. monitor speed auto
    10. monitor flash breakpoints 1
    11. monitor semihosting enable
    12. monitor semihosting IOClient 1
    13. monitor SWO DisableTarget 0xFFFFFFFF
    14. eval "monitor SWO EnableTarget %u 0 0x1 0", $swo_cpu_speed
    15. load
    16. monitor clrbp
    17. monitor reset
    18. monitor halt
    19. monitor regs
    20. flushreg
    21. if $should_run
    22. continue
    23. else
    24. quit
    25. end
    Display All

    These processes are also started using Python's subprocess.Popen(). Finally, I start Telnet using Python's telnetlib. When the test suite is over, I kill the processes using process.kill().

    Perhaps the process killing in Python is not nice enough to close J-Link properly?

    Do you think there is a better way to do this? I have not really looked into the SDK. Is it easy to achieve what I want through Python using the SDK?

    I have run my script with the second approach adding a '-log' parameter to the GDB Server command. I'm attaching the log outputs: both from a successful attempt and from a subsequent failed attempt.

    (I omitted some lines from the successful attempt's log, since I guessed that they were actually the binary I'm downloading... Perhaps I'm overly paranoid, but I prefer to be on the safe side.)

    Thank you very much for taking your time to help me!

    Best regards,
    Fabian
    Files
  • Hello Fabian,

    Perhaps the process killing in Python is not nice enough to close J-Link properly?

    This sounds much like the scenario I described in my last post. All IDEs, Tools etc. that interface with J-Link need to issue J-Link a close command before terminating the main application. Otherwise the behaviour can be unpredictable.

    Do you think there is a better way to do this? I have not really looked into the SDK. Is it easy to achieve what I want through Python using the SDK?

    The SDK will offer you a documentation with all J-Link API functions and multiple example projects so you can create an application that fits your testing needs perfectly.
    All our software tools like Ozone, J-Link Commander, J-LinkGDBServer etc.etc. all use the SDK as base and can be recreated using the J-Link SDK.
    More information can be found here: segger.com/products/debug-prob…nk/technology/j-link-sdk/

    Best regards,
    Nino
    Please read the forum rules before posting: Forum Rules

    Keep in mind, this is not a support forum. Its main purpose is user to user interaction.
    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 contact us per e-mail.
    The following contact form can be used for this: Contact Us

  • Hello,

    Thank you very much for your help. I have now found a solution.

    I have realized that there is no easy way to gracefully terminate a subprocess in Python in Windows. It is possible, but it would require a bunch of extra wrapping code. If anyone is interested to learn more, check this link.

    Instead, I did as you recommended, and used the SDK. Well, I didn't use the SDK directly, but I found the excellent Python library pylink, which in turn uses the SDK. The pylink library allows me to easily close the J-Link connection in a graceful manner.

    Best regards,
    Fabian
  • Hello Fabian,

    Great to hear that you are up and running again.
    We will consider this thread as solved now.

    Best regards,
    Nino
    Please read the forum rules before posting: Forum Rules

    Keep in mind, this is not a support forum. Its main purpose is user to user interaction.
    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 contact us per e-mail.
    The following contact form can be used for this: Contact Us