iMX8M Cortex-M4 debug with FTDI and OpenOCD

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

iMX8M Cortex-M4 debug with FTDI and OpenOCD

5,147 Views
hfranco
Contributor II

Hi all! 

I have a board with iMX8M Mini where the JTAG from the Cortex-M4 is connected to a FTDI chip (FT4232HL) and I want to use OpenOCD to debug the M4. Here is the config file that I made:

 

# JTAG used trought FTDI chip
adapter driver ftdi

# Using JTAG
transport select jtag

# FTDI FT4232 IDs
ftdi_vid_pid 0x0403 0x6011

ftdi_channel 1

# Low value to start with
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.MX8MM with 4 Cortex-A53 cores
set CHIPNAME imx8mm
set CHIPCORES 4

# Source SOC Configuration
source [find target/imx8m.cfg]
init
${CHIPNAME}.m4 arp_examine allow-defer

 

I'm not used to OpenOCD, probably my code is wrong, but I can't see where my mistake is. Here is the output from OpenOCD:

 

Open On-Chip Debugger 0.11.0
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
Info : clock speed 1000 kHz
Error: JTAG scan chain interrogation failed: all ones
Error: Check JTAG interface, timings, target power, etc.
Error: Trying to use configured scan chain anyway...
Error: imx8mm.cpu: IR capture error; saw 0x0f not 0x01
Warn : Bypassing JTAG setup events due to errors
Error: Invalid ACK (7) in DAP response
Error: JTAG-DP STICKY ERROR

 

Does anyone know how to fix it?

Thank you!

Labels (1)
Tags (3)
0 Kudos
Reply
7 Replies

4,999 Views
hfranco
Contributor II

Hi @sinanakman,

I'm back to this problem and I made some progress. Here is my code:

adapter driver ftdi

ftdi vid_pid 0x0403 0x6011
ftdi channel 1

ftdi layout_init 0x00f8 0x000b

# only JTAG supported
transport select jtag

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

reset_config trst_only trst_open_drain

# board has an i.MX8MM with 4 Cortex-A53 cores
set CHIPNAME imx8mm
set CHIPCORES 4

# Source SOC Configuration
source [find target/imx8m.cfg]

targets imx8mm.m4

init

imx8mm.m4 arp_examine

 

Here is the output:

Open On-Chip Debugger 0.11.0+dev-00808-g9cd714cd1 (2022-08-19-13:38)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : Hardware thread awareness created
Info : clock speed 1000 kHz
Info : JTAG tap: imx8mm.cpu tap/device found: 0x5ba00477 (mfg: 0x23b (ARM Ltd), part: 0xba00, ver: 0x5)
Info : imx8mm.a53.0: hardware has 6 breakpoints, 4 watchpoints
Info : starting gdb server for imx8mm.a53.0 on 3333
Info : Listening on port 3333 for gdb connections
Info : starting gdb server for imx8mm.m4 on 3334
Info : Listening on port 3334 for gdb connections
Info : gdb port disabled
Info : [imx8mm.m4] Cortex-M4 r0p1 processor detected
Info : [imx8mm.m4] target has 6 breakpoints, 4 watchpoints
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : [imx8mm.m4] external reset detected
Info : accepting 'gdb' connection on tcp/3334
Error: timed out while waiting for target halted
Error executing event gdb-attach on target imx8mm.m4:

Info : New GDB Connection: 1, Target imx8mm.m4, state: reset
Warn : GDB connection 1 on target imx8mm.m4 not halted
Info : Halt timed out, wake up GDB.

I was able to set the cortex m4 as the target and reset it. But I can not halt it. As soon as I connected the GDB server, I get this error shown above.

Do you have any tips to solve this issue?

I'm using pins TCK, TDI, TDO, TMS, and TRST (active-low).

Thank you!

0 Kudos
Reply

4,987 Views
sinanakman
Senior Contributor III

Hi Hiago

Are you able to halt the core if you connect via telnet (instead of from your gdb client). I would recommend to get this working via telnet first then you can try gdb,

Also, initially you can set the number of cores to 1 until you get this working.

Regards

Sinan Akman

0 Kudos
Reply

5,097 Views
sinanakman
Senior Contributor III

Hi Hiago

I don't use openocd on this board but the fact that arp_examine is deferred probably means that m4 has to be started first by the a53 core then you can connect via gdb. I suggest that you start a telnet session via port 4444 and run the initial part of your firmware that would start both a53 and m4. On the telnet command line check the status of m4 first and make sure it is attached before you connect via gdb.

Hope this helps

Sinan Akman

0 Kudos
Reply

5,110 Views
sinanakman
Senior Contributor III

Hi Hiago

Is this your custom board ? If it is a custom board please try your set up with iMX8M Mini reference board first to make sure your set up, cable etc are all fine. If it works with the reference board but not with your design we need to take a look schematics to make sure debug is enabled and ftdi is connected properly.

Also, does the board boot at all without debugging ?

Sinan Akman

5,104 Views
hfranco
Contributor II

Hi @sinanakman, thank you for the reply! 

 

It is a custom board, I'm using the FTDI FT4232HL just like the NXP EVK board with iMX8M.

I think the problem is my configuration because now I could start OpenOCD with this file:

adapter driver ftdi
ftdi_vid_pid 0x0403 0x6011
ftdi_channel 1

ftdi_layout_init 0x00f8 0x000b

ftdi_layout_signal RESET_B	-data 0x0010 -oe 0x0010
ftdi_layout_signal nSRST	-data 0x0020 -oe 0x0020
ftdi_layout_signal IO_nRST	-data 0x0040 -oe 0x0040
ftdi_layout_signal ONOFF_B	-data 0x0080 -oe 0x0080

transport select jtag

adapter speed 1000

# board has an i.MX8MM with 4 Cortex-A53 cores
set CHIPNAME imx8mm
set CHIPCORES 4

# Source SOC Configuration
source [find target/imx8m.cfg]
init
${CHIPNAME}.m4 arp_examine allow-defer

I think I'm close, now OpenOCD starts and gives me these messages:

Open On-Chip Debugger 0.11.0
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
Info : clock speed 1000 kHz
Info : JTAG tap: imx8mm.cpu tap/device found: 0x5ba00477 (mfg: 0x23b (ARM Ltd), part: 0xba00, ver: 0x5)
Info : imx8mm.a53.0: hardware has 6 breakpoints, 4 watchpoints
Info : starting gdb server for imx8mm.a53.0 on 3333
Info : Listening on port 3333 for gdb connections
Info : starting gdb server for imx8mm.m4 on 3334
Info : Listening on port 3334 for gdb connections
Info : Deferring arp_examine of imx8mm.m4
Info : Use arp_examine command to examine it manually!
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections

I have JTAG from cortex A on port 0 and cortex M on port 1 of the FTDI. I think the problem is with this line:

Info : Use arp_examine command to examine it manually!

Because when I try to connect with the GDB server, I get this error:

GNU gdb (GNU Toolchain for the Arm Architecture 11.2-2022.02 (arm-11.14)) 11.2.90.20220202-git
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "--host=x86_64-pc-linux-gnu --target=arm-none-eabi".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://bugs.linaro.org/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from hello_world.elf...
(gdb) target extended-remote localhost:3334
Remote debugging using localhost:3334
Remote connection closed
(gdb) 

And on OpenOCD, I get this error:

Open On-Chip Debugger 0.11.0
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
Info : clock speed 1000 kHz
Info : JTAG tap: imx8mm.cpu tap/device found: 0x5ba00477 (mfg: 0x23b (ARM Ltd), part: 0xba00, ver: 0x5)
Info : imx8mm.a53.0: hardware has 6 breakpoints, 4 watchpoints
Info : starting gdb server for imx8mm.a53.0 on 3333
Info : Listening on port 3333 for gdb connections
Info : starting gdb server for imx8mm.m4 on 3334
Info : Listening on port 3334 for gdb connections
Info : Deferring arp_examine of imx8mm.m4
Info : Use arp_examine command to examine it manually!
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : accepting 'gdb' connection on tcp/3334
Error: Target not examined yet
Error executing event gdb-attach on target imx8mm.m4:

Info : New GDB Connection: 1, Target imx8mm.m4, state: examine deferred
Error: Target imx8mm.m4 not examined yet, refuse gdb connection 1!
Error: attempted 'gdb' connection rejected

 Do you know how can I use this arp_examine to solve this issue?

Regards,
Hiago.

0 Kudos
Reply

5,116 Views
hfranco
Contributor II

Hi @sinanakman,

Thanks for your reply. I've changed the cable and the board is powered on.

I activated the debug_level, but the error occurs in the same step that I showed.

Best Regards,
Hiago.

0 Kudos
Reply

5,137 Views
sinanakman
Senior Contributor III

Hi Hfranco

 

It might help to increase debug_level to see more information but it looks like you may have a cabling issue or your board was not powered on at the time you tried to connect.

 

Hope this helps

Sinan Akman

0 Kudos
Reply