Getting J-Link working with i.MX6Q

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

  • Getting J-Link working with i.MX6Q

    I am having some trouble debugging a Freescale SabreSD board with i.MX6Q.

    I am running the GDB server on Linux using version V4.74. The e-mail for this release stated:

    - DLL: Reset support for Freescale i.MX6 added.

    I could not find a -device for i.MX6, even by dumping the list of devices with the command line tool. Therefore I resorted to:

    ./StartJLinkGDBServer.sh -device Cortex-A9

    If there is a -device option for this board, please tell me the option and perhaps nothing more needs to be done.

    If there is no other option than what I used, continue...

    I have the following in eclipse:

    set debug remote 1
    set remotetimeout 60
    monitor reset 1
    monitor sleep 1000
    monitor memU32 0x020bc000 = 0x30
    monitor memU32 0x020c4068 = 0xffffffff
    monitor memU32 0x020c406c = 0xffffffff
    monitor memU32 0x020c4070 = 0xffffffff
    ...

    Essentially, reset the processor and write to registers so that DDR works, clocks are setup, etc. These settings are known good and work with another "un-named" probe from another vendor. I am also debugging an image that works with the other vendor. In other words, all this works with another probe, just not my preferred J-Link probe.

    When gdb tries to reset, it can't halt. It proceeds and then seems to write the image, etc. But it can't read memory from registers, OCRAM, DDR, etc.

    I suspect the problem is the reset, due to the messages.

    A second natural question is, how to talk to the other 3 cores. I suspect I will have to use a script to do this. In the final solution, I would prefer to do this initialization in a script file anyway. I was unsuccessful at initializing with a script. It would be nice to have a script that can handle reset and initialization I can start with if you can provide one. The alternative would be to allow a script to override the functions and call the default ones within them so I can add the register initialization. If there is a way to call the originals, please let me know how to do that.

    I have attached the messages from J-Link so you can have a look.
    Files
    • segger.txt

      (20.9 kB, downloaded 1,722 times, last: )
  • Hi,

    If there is a -device option for this board, please tell me the option and perhaps nothing more needs to be done.

    Correct, GDBServer needs to know the device since the i.MX6 is extremely problematic when it comes to reset and requires a lot of special handling there.
    Please see below for more information.

    I could not find a -device for i.MX6, even by dumping the list of devices with the command line tool.

    Thanks for pointing this out. This is not intended... The devices should be listed. We will correct this.


    The call should look like this:

    C Source Code

    1. ./StartJLinkGDBServer.sh -device MCIMX6U8


    From there on, the reset issue should be solved.

    iMX6 devices known by the DLL/Library:
    MCIMX6D4
    MCIMX6D5
    MCIMX6D6
    MCIMX6D7
    MCIMX6Q4
    MCIMX6Q5
    MCIMX6Q6
    MCIMX6Q7
    MCIMX6S1
    MCIMX6S4
    MCIMX6S5
    MCIMX6S6
    MCIMX6S7
    MCIMX6S8
    MCIMX6U1
    MCIMX6U4
    MCIMX6U5
    MCIMX6U6
    MCIMX6U7
    MCIMX6U8


    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.
  • Works with small problem at restart

    Using -device MCIMX6U8 made all the difference. Thank you.

    There is one small problem. After my application runs, and halts at a breakpoint instruction in the _exit, I can't restart.

    What I did was stop (eclipse tool bar) reset the target (push button on board), as that is what allows a Sourcery Probe to debug a second time. I did the same and got these errors below. The eclipse stop generated the message "Closing remote socket". The when pressing eclipse debug, I get the errors. This happens whether I press the target pushbutton reset or not. I presume if I don't press the pushbutton, the target is halted, and if I do press it, the ROM starts to run the boot loader and eventually stops because there is no SD card.

    What is the proper way to end a debugging session and start it again?

    Note that if I kill the gdb server, then it seems to debug a second time properly. This suggests that JLink is not ending up in the write state to debug again.


    GDB closed TCP/IP connection
    Closing remote socket
    Waiting for GDB connection...Connected to 127.0.0.1
    Reading all registers
    ERROR: Can not read register 0 (R0) while CPU is running
    ERROR: Can not read register 1 (R1) while CPU is running
    ERROR: Can not read register 2 (R2) while CPU is running
    ERROR: Can not read register 3 (R3) while CPU is running
    ERROR: Can not read register 4 (R4) while CPU is running
    ERROR: Can not read register 5 (R5) while CPU is running
    ERROR: Can not read register 6 (R6) while CPU is running
    ERROR: Can not read register 7 (R7) while CPU is running
    ERROR: Can not read register 8 (CPSR) while CPU is running
    ./StartJLinkGDBServer.sh: line 7: 5341 Segmentation fault (core dumped) ./JLinkGDBServer "$@"
  • Hi,

    What is the proper way to end a debugging session and start it again?

    Close the session and restart it again, I think...

    Please note that just pushing the reset button will cause the debug probe to loose control of the CPU, since on the i.MX6 reset does not behave correctly, since it also resets the entire debug logic, causing all debug setup (including all hardware breakpoints and initialization during connect) to fail.

    By adding a "monitor reset" to your gdbinit sequence, you make sure that the target is reset prior to downloading.


    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.
  • How to see all cores of i.MX6Quad

    Hello

    We are using JLinkGDBServer (V4.74a) in Windows with Eclipse. Everything works fine but how can I see the other three cores?
    A second natural question is, how to talk to the other 3 cores. I
    suspect I will have to use a script to do this. In the final solution, I
    would prefer to do this initialization in a script file anyway. I was
    unsuccessful at initializing with a script. It would be nice to have a
    script that can handle reset and initialization I can start with if you
    can provide one. The alternative would be to allow a script to override
    the functions and call the default ones within them so I can add the
    register initialization. If there is a way to call the originals, please
    let me know how to do that.
    The debugger is a j-Trace CM 3.
    Thank you for your help,
    Reto
  • More info on reset

    I think there is a bit more going on. First, this application is running on four cores. The first core setups the other three and gets things running. When the app completes, it stops in the following code:

    __attribute__ ((naked)) void mybkpt(void)
    {
    asm volatile (
    #if DEBUG
    "bkpt #0 \n"
    #endif
    "bx lr \n"
    );
    }

    This code is part of the i.MX6 SDK. The debugger stops at the bkpt. If I press the green arrow to continue, JLink Server faults like this:


    ERROR: CPU is not halted
    ERROR: Can not read register 9 (R15 (PC)) while CPU is running
    ...Target halted (PC = 0x00000000)
    Reading all registers
    ERROR: Can not read register 0 (R0) while CPU is running
    ERROR: Can not read register 1 (R1) while CPU is running
    ERROR: Can not read register 2 (R2) while CPU is running
    ERROR: Can not read register 3 (R3) while CPU is running
    ERROR: Can not read register 4 (R4) while CPU is running
    ERROR: Can not read register 5 (R5) while CPU is running
    ERROR: Can not read register 6 (R6) while CPU is running
    ERROR: Can not read register 7 (R7) while CPU is running
    ERROR: Can not read register 8 (CPSR) while CPU is running
    ./StartJLinkGDBServer.sh: line 7: 6404 Segmentation fault (core dumped) ./JLinkGDBServer "$@"

    There are two issues here. First, the problem of reading registers. Second the core segmentation fault. Obviously, the segmentation fault is a bug in JLink Server. Once it dies, there is nothing you can do but start over.

    Related to the read errors from not being faulted...

    If I run my application, such that all four cores are running, and I hit the yellow pause in eclipse, only the first core halts. This sort of suggests that halting behavior is not well controlled wrt eclipse. Perhaps the other problem above leading to the fault is related. There may be a general halting problem on a multi core device.

    Could you give some description on how the halting works in general? How it relates to multiple cores? What approach to take when debugging multi-core applications?

    My assumption is things have to work a bit like this:

    Setup 4 debug configurations, one to download the app and run it, and 3 to attach
    Set each debug configuration to have a breakpoint at some well established place in code
    Setup a launch group
    Launch

    The natural questions would be:

    1) How to set a debug configuration for a core? Can this be done in the Initialization Commands? Can it be done in Script?
    2) How to get a relaunch without resetting the target (push button) and restarting JLink Server?
  • Hi,


    Setup 4 debug configurations, one to download the app and run it, and 3 to attach
    Set each debug configuration to have a breakpoint at some well established place in code
    Setup a launch group
    Launch


    More or less, this is what is necessary to do.
    You will need: 4 instances of the J-Link GDBServer (one for each debug session), each connecting to a different core.
    The first one is used as it is now and the three other ones need to be started with a J-Link script that configures them to connect to another core.
    So far so good.

    Current limitations:
    1) When performing a full reset (by resetting the debug session that controls the first core), the other three need to be closed first, otherwise the reset will will mess them up.
    2) Currently, this is only supported under Windows since under Linux, multiple processes accessing the same J-Link at the same time (as it would be the case here) is not supported right now.

    We plan to make the J-Link script files, necessary for setting up the sessions for the other 3 cores, available during next week.


    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.
  • J-Link Pro. Everything works fine with jlinkgdbserver. All secondary cores must be initialized (enabled) by core 0 at startup as described in TRM. Then just connect with each core by almost empty script with setting only CORESIGHT_CoreBaseAddr and different local ports. Setting it to the first core works as before without any script. Debug points works to all cores at the same time (all cores can be halted by common breakpoint address). Its really great, thanks to developers!

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

  • What I have got to work so far on Windows 8.1:
    - Install an ARM-centric gdb instance for Eclipse to use, basically a whole toolchain. For Windows, the folks at SysProgs have ports available #mce_temp_url#
    - Install the SEGGER J-Link for Windows. Four instances of the GDBServerCL.exe will be launched, one for each core.
    - Create four JLinkScript files to indicate where the address offsets are for each core
    MCIMX6-core-0.JLinkScript:

    // MCIMX6 Core Setup
    // Core0: 0x82150000;
    // Core1: 0x82152000;
    // Core2: 0x82154000;
    // Core3: 0x82156000;
    CORESIGHT_CoreBaseAddr = 0x82150000;
    DbgRegBaseAddr = 0x82150000;
    MCIMX6-core-1.JLinkScript:
    CORESIGHT_CoreBaseAddr = 0x82152000;
    DbgRegBaseAddr = 0x82152000;

    MCIMX6-core-2.JLinkScript:
    CORESIGHT_CoreBaseAddr = 0x82154000;
    DbgRegBaseAddr = 0x82154000;
    MCIMX6-core-3.JLinkScript:
    CORESIGHT_CoreBaseAddr = 0x82156000;
    DbgRegBaseAddr = 0x82156000;
    - Create a Window batch file to launch four instances simultaneously, each with different port settings
    JLinkGDBServer-MCIMX6.bat:
    start "JLinkGDBServerCL MCIMX6-core-0" "C:\Program Files (x86)\SEGGER\JLink_V490b\JLinkGDBServerCL.exe" -select USB=173000354 -device MCIMX6Q6 -if JTAG -speed auto -noreset -noir -scriptfile "C:\Projects\Road-iQVS\Developer\davidw\JLink\MCIMX6-core-0.JLinkScript" -port 2331 -swoport 2332 -telnetport 2333
    start "JLinkGDBServerCL MCIMX6-core-1" "C:\Program Files (x86)\SEGGER\JLink_V490b\JLinkGDBServerCL.exe" -select USB=173000354 -device MCIMX6Q6 -if JTAG -speed auto -noreset -noir -scriptfile "C:\Projects\Road-iQVS\Developer\davidw\JLink\MCIMX6-core-1.JLinkScript" -port 2334 -swoport 2335 -telnetport 2336
    start "JLinkGDBServerCL MCIMX6-core-2" "C:\Program Files (x86)\SEGGER\JLink_V490b\JLinkGDBServerCL.exe" -select USB=173000354 -device MCIMX6Q6 -if JTAG -speed auto -noreset -noir -scriptfile "C:\Projects\Road-iQVS\Developer\davidw\JLink\MCIMX6-core-2.JLinkScript" -port 2337 -swoport 2338 -telnetport 2339
    start "JLinkGDBServerCL MCIMX6-core-3" "C:\Program Files (x86)\SEGGER\JLink_V490b\JLinkGDBServerCL.exe" -select USB=173000354 -device MCIMX6Q6 -if JTAG -speed auto -noreset -noir -scriptfile "C:\Projects\Road-iQVS\Developer\davidw\JLink\MCIMX6-core-3.JLinkScript" -port 2340 -swoport 2341 -telnetport 2342
    - In Eclipse, add the C\C++ Development Tools repository - CDT - download.eclipse.org/tools/cdt/releases/kepler (NOTE: This URL for Kepler)
    - In Eclipse, install the CDT C/C++ Hardware Debugging Plug-in (and any thing else you would like)
    - In Eclipse, create four GDB Hardware Debugging gdb debug configurations, each pointed at respective ports of the GDBServerCL.exe instances.
    - In Eclipse create a Launch Group and add the four debug configurations to launch all four at once


    Fire off the *.bat, you should get four text windows with "Waiting for GDB Connection..." at the end of the trace. In Eclipse launch the Launch group and you should get four active gdb sessions, one for each core. There are issues like the four Eclipse instances do not seem to stay sync
    when starting and stopping the processor.
    I can get the processor to crash when halting fairly easily.
    I have not tried to load an executable directly, yet, but have been able to halt and restart the processor and see registers on a program loaded from an SD card.

    The post was edited 7 times, last by dBW ().

  • thank you very much, this was really helpful. i have tried on my enviroment, but did not get it working yet, but i will keep trying.

    in my case on run of the batch file, target is freezed, until i am connecting gdb clients. and seems like still only 1 core is working correctly, others are showing 0 PC on attach. i will try with gdb client you suggested.

    could you please tell me
    1) is the gdb server(s) run freezes target in your case?
    2) should those addresses (like 0x82150000 etc)
    be physical or virtual? or this is totally different jtag address bus and mmu is not involved here at all?
  • Has anyone been able to successfully do multicore debugging on imx6 using multiple JLinkGDBServers ? I have followed the method described in the above post and have made seperate JLink init scripts for each core by specifying its core address but still all of them connect to only the first core...
    Any help...

    Does segger plan to provide some readymade init scripts for multicore debugging on imx6 as mentioned in above posts ?

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

  • Hi,

    the J-Link Scripts posted above are not complete.

    The Script has to contain the function InitTarget(), which sets the CORESIGHT_CoreBaseAddr as well as the JTAG configuration.
    Additionally it should contain an empty ResetTarget(), since otherwise all cores would be reset.

    To be able to connect to Cores 1-3 they have to be enabled. This is normally done by the application running on Core 0, but can also be done in the J-Link Script.

    Attached are the Scripts for Core 1-3. For Core 0 there is no J-Link Script required.

    Regards
    Johannes
    Files
    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.