SWO support with Linux command line GDB server

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

  • SWO support with Linux command line GDB server

    Has anyone had success receiving SWO output from the Linux command line GDB server? e.g. via port 2332 as listed below? If so, are there any tricks to getting this going?

    ./JLinkGDBServer
    SEGGER J-Link GDB Server V4.50i

    JLinkARM.dll V4.50i (DLL compiled Jun 22 2012 19:00:36)

    The server has been started with the following settings:
    ---Server related settings---
    GDBInit file: none
    Listening port: 2331
    SWO thread listening port: 2332
    ...
  • Hi,

    Please note that running multiple processes which access the same J-Link in parallel is supported in the windows version only.

    Has anyone had success receiving SWO output from the Linux command line GDB server? e.g. via port 2332 as listed below? If so, are there any tricks to getting this going?

    Again: On port 2332 GDBServer will output raw(!) SWO data only, so no direct printable output. SWOViewer performs analysis of the SWO data and extracts the printf data from the raw stream.

    To get the same pre-analyzed output directly from GDBServer:
    1) Start GDBServer with the correct device being selected. (-device <DeviceName> command line option)
    2) Open TELNET connection on port 2333 (pre-analyzed, readable printf output)

    3) Add the following command to the .gdbinit file:

    C Source Code

    1. monitor SWO EnableTarget <CPUFreqHz> <SWOFreqHz> <PortMask> <Mode>


    If the correct device has been selected, J-Link determines <CPUFreqHz> and <SWOFreqHz> automatically, so the command would look like this:

    C Source Code

    1. //
    2. // Enable SWO with max. SWO frequency supported by CPU & J-Link and stimulus port 0 enabled
    3. //
    4. monitor SWO EnableTarget 0 0 1 0


    If no specific device has been selected, the CPU speed has to be explicitly passed to this function:

    C Source Code

    1. //
    2. // Enable SWO with max. SWO frequency supported by CPU & J-Link and stimulus port 0 enabled. CPU is assumed to be running at 16 MHz
    3. //
    4. monitor SWO EnableTarget 16000000 0 1 0


    Please note that the latest Linux Version (V4.74) should be used: segger.com/jlink-software.html

    Best regards
    Alex
    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.
  • SEGGER - Alex wrote:

    Please note that running multiple processes which access the same J-Link in parallel is supported in the windows version only.
    It's very disappointing, because it prevents our team to migrate on linux.
    In neighbouring topic you said
    > 90% of the users using Linux currently do not have the requirement to run multiple processes accessing the same J-Link at the same time
    I wonder why. Running GDB server and SWOViewer in parallel seems to be very typical scenario for most users. In my case, I even need to communicate with J-Link via custom application (developed with J-Link SDK).
  • Hi,

    I wonder why. Running GDB server and SWOViewer in parallel seems to be very typical scenario for most users. In my case, I even need to communicate with J-Link via custom application (developed with J-Link SDK).

    Because in most cases, what you need to do, can be done from a single application / process.
    GDBServer can already output printf data on the terminal port (2333) which is exactly the same as when using SWOViewer...
    Moreover, USB under Linux is a bit problematic regarding multiple processes accessing the same USB device at the same time. (We only had a quick look at this so far)

    Moreover, having multiple processes, talking to the same J-Link and connecting to the same target at the same time can always be problematic and is something like "asking for trouble".
    Because there *are* actions that, if performed on the target, can have a side effect on the first connection that may "confuse" the other session.
    Example:
    Connecting with two processes to the same Cortex-A8 device and both "halt" the CPU will cause only the first session to see the correct register contents, since reading all CPU registers modifies some of them (because they are used as temporary registers during debugging).
    So using multiple connections to the same J-Link + target CPU should only be done if absolutely necessary and most of the time it simply is not necessary.


    Best regards
    Alex
    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.
  • I understand. But I still hope you will manage this problem in some future. Solution would be make some high-level proxy (like already existing J-Link Remote Server) and share access via IPC (even with restrictions for some operations when more than one connections exists, or warnings about side effects). This solution would be very cross-platform and compatible with existing tools (just adds third j-link connection interface).