openocd JTAG with the iMX 8M Mini EVK.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

openocd JTAG with the iMX 8M Mini EVK.

4,213 Views
wes_philbrook
Contributor I

I'm trying to get openocd JTAG running with the iMX 8M Mini EVK.

Couldn't find a proper JTAG cfg file so I made one from a imx 8Mq I found,

nxp_mcimx8m-evk.cfg File

#
# configuration file for NXP MC-IMX8M-EVK
#

# only JTAG supported
transport select jtag

# set a safe JTAG clock speed, can be overridden
adapter speed 1000

# default JTAG configuration has only SRST and no TRST
reset_config srst_only srst_push_pull

# delay after SRST goes inactive
adapter srst delay 70

# board has an i.MX8MQ with 4 Cortex-A53 cores
set CHIPNAME imx8mq
set CHIPCORES 4


#
# configuration file for NXP i.MX8M family of SoCs
#
if { [info exists CHIPNAME] } {
set _CHIPNAME $CHIPNAME
} else {
set _CHIPNAME imx8m
}

if { [info exists CHIPCORES] } {
set _cores $CHIPCORES
} else {
set _cores 1
}

# CoreSight Debug Access Port
if { [info exists DAP_TAPID] } {
set _DAP_TAPID $DAP_TAPID
} else {
set _DAP_TAPID 0x5ba00477
}

# the DAP tap
jtag newtap $_CHIPNAME cpu -irlen 4 -ircapture 0x01 -irmask 0x0f \
-expected-id $_DAP_TAPID

dap create $_CHIPNAME.dap -chain-position $_CHIPNAME.cpu

set _TARGETNAME $_CHIPNAME.a53
set _CTINAME $_CHIPNAME.cti

set DBGBASE {0x80410000 0x80510000 0x80610000 0x80710000}
set CTIBASE {0x80420000 0x80520000 0x80620000 0x80720000}

for { set _core 0 } { $_core < $_cores } { incr _core } {

cti create $_CTINAME.$_core -dap $_CHIPNAME.dap -ap-num 1 \
-ctibase [lindex $CTIBASE $_core]

set _command "target create $_TARGETNAME.$_core aarch64 -dap $_CHIPNAME.dap \
-dbgbase [lindex $DBGBASE $_core] -cti $_CTINAME.$_core"

if { $_core != 0 } {
# non-boot core examination may fail
set _command "$_command -defer-examine"
set _smp_command "$_smp_command $_TARGETNAME.$_core"
} else {
set _smp_command "target smp $_TARGETNAME.$_core"
}

eval $_command
}

eval $_smp_command

# declare the auxiliary Cortex-M4 core on AP #4
target create ${_CHIPNAME}.m4 cortex_m -dap ${_CHIPNAME}.dap -ap-num 4 \
-defer-examine

# AHB-AP for direct access to soc bus
target create ${_CHIPNAME}.ahb mem_ap -dap ${_CHIPNAME}.dap -ap-num 0

# default target is A53 core 0
targets $_TARGETNAME.0

I run openocd as follows:

sudo openocd -f interface/jlink.cfg -f board/nxp_mcimx8m-evk.cfg

And the result is 

Open On-Chip Debugger 0.10.0+dev-01200-gff9ee13-dirty (2020-04-23-10:26)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : J-Link V11 compiled Mar 19 2020 11:11:08
Info : Hardware version: 11.00
Info : VTarget = 1.806 V
Info : clock speed 1000 kHz
Info : JTAG tap: imx8mq.cpu tap/device found: 0x5ba00477 (mfg: 0x23b (ARM Ltd.), part: 0xba00, ver: 0x5)
Info : DAP transaction stalled (WAIT) - slowing down
Error: JTAG-DP STICKY ERROR
Error: imx8mq.a53.0: examination failed

Info : starting gdb server for imx8mq.a53.0 on 3333
Info : Listening on port 3333 for gdb connections
Info : starting gdb server for imx8mq.m4 on 3334
Info : Listening on port 3334 for gdb connections

Can anyone explain why I get Error: JTAG-DP STICKY ERROR;

Any response will be greatly appreciated.

Wes

Tags (1)
0 Kudos
5 Replies

3,876 Views
wes_philbrook
Contributor I

I've tried the only difference I found in the suggestion, which was to modify the openocd command line as follows

sudo openocd -c init -f interface/jlink.cfg -f board/nxp_mcimx8m-evk.cfg

This did not make a difference, I've run openocd in debug/verbose mode and have the following output

for where trouble arises

Debug: 833 146 aarch64.c:2328 aarch64_examine_first(): cpuid = 0x410fd034
Debug: 834 146 aarch64.c:2329 aarch64_examine_first(): ttypr = 0x00001122
Debug: 835 147 aarch64.c:2330 aarch64_examine_first(): debug = 0x10305106
Info : 836 147 armv8_dpm.c:1486 armv8_dpm_setup(): imx8mq.a53.0: hardware has 6 breakpoints, 4 watchpoints
Debug: 837 147 armv8_dpm.c:481 dpmv8_bpwp_disable(): A: bpwp disable, cr 80410408
Debug: 856 148 armv8_dpm.c:481 dpmv8_bpwp_disable(): A: bpwp disable, cr 80410418
Debug: 875 149 armv8_dpm.c:481 dpmv8_bpwp_disable(): A: bpwp disable, cr 80410428
Debug: 894 150 armv8_dpm.c:481 dpmv8_bpwp_disable(): A: bpwp disable, cr 80410438
Info : 904 151 adi_v5_jtag.c:535 jtagdp_overrun_check(): DAP transaction stalled (WAIT) - slowing down
Debug: 4622 331 adi_v5_jtag.c:621 jtagdp_transaction_endcheck(): jtag-dp: CTRL/STAT 0xf0000023
Error: 4623 331 adi_v5_jtag.c:632 jtagdp_transaction_endcheck(): JTAG-DP STICKY ERROR
Debug: 4624 331 adi_v5_jtag.c:634 jtagdp_transaction_endcheck(): JTAG-DP STICKY OVERRUN

The control register address is formed from armv8->debug_base + CPUV8_DBG_BCR_BASE + 16* index

Debug base is 80410000 from following line in imx8m.cfg

set DBGBASE {0x80410000 0x80510000 0x80610000 0x80710000}
set CTIBASE {0x80420000 0x80520000 0x80620000 0x80720000}

Does any one know if these base addresses are correct for the imx8m Mini ?

the file is for the imx8mq

0 Kudos

3,876 Views
fatalfeel
Contributor V

If you are interested in config for Jtag

find kernel_imx_aarch64.tar.gz from Programming Guide: Jtag Openocd Eclipse debug 

!!!sometimes CPU will into suspend mode

then Error: Invalid ACK (7) in DAP response but its a very tiny effect you can skip it!!!

check all CONFIG_SUSPEND in Kconfig and source c files can fix!

0 Kudos

3,876 Views
fatalfeel
Contributor V

connect those pins~~~( TRST - TRSTn "Test access port reset"  I do not use it)
TDI            - TDI
TMS          - TMS
TCK          - TCK
TDO          - TDO
TSRST      - nSRST (System reset)
GND         - GND

//main.c trace
static void __init do_initcall_level(int level)
{
    int            fnunm = 0;
    initcall_t *fn;

    strcpy(initcall_command_line, saved_command_line);
    parse_args(initcall_level_names[level],
           initcall_command_line, __start___param,
           __stop___param - __start___param,
           level, level,
           NULL, &repair_env_string);

    if( level >= 6 )
    {
        for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++)
        {
            do_one_initcall(*fn);

            if( fnunm >= 655 )
            {
                printk(KERN_ERR "fnum = %d, func = %p\n", fnunm, fn);
                __udelay(5000000);
            }
            else if( fnunm >= 650 )
            {
                printk(KERN_ERR "fnum = %d, func = %p\n", fnunm, fn);
                __udelay(4000000);
            }
            else if( fnunm >= 630 )
            {
                printk(KERN_ERR "fnum = %d, func = %p\n", fnunm, fn);
                __udelay(3000000);
            }

            fnunm++;
        }
    }
    else
    {
        for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++)
            do_one_initcall(*fn);
    }
}

///////////////////

when level 6 and fnunm is 637 happend

Info : DAP transaction stalled (WAIT)

637 is arm_idle_init in cpuidle-arm.c

call arm_enter_idle_state

then

call arm_cpuidle_suspend in kernel_imx/arch/arm64/kernel/cpuidle.c

its comment said arm_cpuidle_suspend() - function to enter a low-power idle state

////kernel_imx/arch/arm64/kernel/psci.c

const struct cpu_operations cpu_psci_ops = {
    .name        = "psci",
#ifdef CONFIG_CPU_IDLE
    .cpu_init_idle    = psci_cpu_init_idle,
    .cpu_suspend    = psci_cpu_suspend_enter,
#endif
    .cpu_init    = cpu_psci_cpu_init,
    .cpu_prepare    = cpu_psci_cpu_prepare,
    .cpu_boot    = cpu_psci_cpu_boot,
#ifdef CONFIG_HOTPLUG_CPU
    .cpu_disable    = cpu_psci_cpu_disable,
    .cpu_die    = cpu_psci_cpu_die,
    .cpu_kill    = cpu_psci_cpu_kill,
#endif
};

/////kernel_imx/arch/arm64/configs/android_defconfig

CONFIG_CPU_IDLE=y

change to

CONFIG_CPU_IDLE=n

also remove CPU_IDLE in all Kconfig

Here is my Jtag debug on imx8m demo

http://www.mediafire.com/view/gdqsm2vjskxkok8/key%20input.png 

may this will help you

0 Kudos

3,876 Views
fatalfeel
Contributor V

Stalled problem I trace to

static void __init do_initcall_level(int level)
{
    initcall_t *fn;

    strcpy(initcall_command_line, saved_command_line);
    parse_args(initcall_level_names[level],
           initcall_command_line, __start___param,
           __stop___param - __start___param,
           level, level,
           NULL, &repair_env_string);

    for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++)
        do_one_initcall(*fn);
}

When Level 6 will make jtag stalled but i dont know which driver make this problem

0 Kudos

3,876 Views
igorpadykov
NXP Employee
NXP Employee

Hi Wes

one can try suggestions on below link, also some details were sent via mail.

How to JTAG debug iMX8mq? 

Best regards
igor
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos