Cyclone V soc - problem with openocd

Hi,
I’ve encountered a problem with debugging bare-metal app on Terasic DE-10 Standard board.
I’m using Quartus Prime 20.1 Lite Edition, SoC EDS 20.1. I’m working with eclipse 2021-06, openocd 0.10.0 (installed with apt - it was not compiled on my host Ubuntu 18) and with gnu linaro toolchain 2019.12 version which comes with SoC EDS.
The problem is that I can’t debug app which runs from SDRAM while I don’t have any problem with launching it from on-chip RAM). GDB halts on entry point, but CPU resets when I run the app. I can observe this behavior when I power the board, I stop U-Boot just before it tries to perform autoboot command, and then I try to launch app via GDB. However, when I launch app from U-Boot console ( loading binary from SD card ) it works fine and then I can launch the app via GDB and debug it successfully. When I modify the app, then I have to repeat the procedure in order that I can debug it (run from U-Boot, then launch with openocd).
I am using Altera-SoCFPGA-HardwareLib-Timer-CV-GNU example and openocd configs shown below.

altera-usb-blaster2.cfg:

#
# Altera USB-Blaster II
#
interface usb_blaster
usb_blaster_vid_pid 0x09fb 0x6010 0x09fb 0x6810
usb_blaster_lowlevel_driver ublast2
usb_blaster_firmware /home/jakub/intelFPGA_lite/20.1/quartus/linux64/blaster_6810.hex

altera_sockit.cfg:

#
# Cyclone V SocKit board
# http://www.altera.com/b/arrow-sockit.html
#
# Software support page:
# http://www.rocketboards.org/

source [find interface/altera-usb-blaster2.cfg]
source [find target/altera_fpgasoc.cfg]

altera_fpgasoc.cfg:

#
# Altera cyclone V SoC family, 5Cxxx
#
if { [info exists CHIPNAME] } {
   set _CHIPNAME $CHIPNAME
} else {
   set _CHIPNAME fpgasoc
}
# Subsidiary TAP: fpga
if { [info exists FPGA_TAPID] } {
   set _FPGA_TAPID $FPGA_TAPID
} else {
   set _FPGA_TAPID 0x02d020dd
}
jtag newtap $_CHIPNAME.fpga tap -irlen 10 -ircapture 0x01 -irmask 0x3 -expected-id $_FPGA_TAPID

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

jtag newtap $_CHIPNAME dap -irlen 4 -ircapture 0x01 -irmask 0x0f \
        -expected-id $_DAP_TAPID
#
# Cortex-A9 target
#

# GDB target: Cortex-A9, using DAP, configuring only one core
# Base addresses of cores:
# core 0  -  0x80110000
# core 1  -  0x80112000

# Slow speed to be sure it will work
adapter_khz 1000
set _TARGETNAME1 $_CHIPNAME.cpu.0
set _TARGETNAME2 $_CHIPNAME.cpu.1

# A9 core 0
target create $_TARGETNAME1 cortex_a -chain-position $_CHIPNAME.dap \
        -coreid 0 -dbgbase 0x80110000

$_TARGETNAME1 configure -event reset-start { adapter_khz 1000 }
$_TARGETNAME1 configure -event reset-assert-post "cycv_dbginit $_TARGETNAME1"
$_TARGETNAME1 configure -event gdb-attach { halt }

# A9 core 1
# target create $_TARGETNAME2 cortex_a -chain-position $_CHIPNAME.dap \
#        -coreid 1 -dbgbase 0x80112000

# $_TARGETNAME2 configure -event reset-start { adapter_khz 1000 }
# $_TARGETNAME2 configure -event reset-assert-post "cycv_dbginit $_TARGETNAME2"
# $_TARGETNAME2 configure -event gdb-attach { halt }

proc cycv_dbginit {target} {
        # General Cortex-A8/A9 debug initialisation
        cortex_a dbginit
}

I run debugger with “openocd -f board/altera_sockit.cfg”

Logs from console until halting on entry:

Open On-Chip Debugger 0.10.0
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
adapter speed: 1000 kHz
Warn : Adapter driver 'usb_blaster' did not declare which transports it allows; assuming legacy JTAG-only
Info : only one transport option; autoselect 'jtag'
cycv_dbginit
Started by GNU MCU Eclipse
Info : Altera USB-Blaster II found (Firm. rev. = 1.39)
Info : This adapter doesn't support configurable speed
Info : JTAG tap: fpgasoc.fpga.tap tap/device found: 0x02d020dd (mfg: 0x06e (Altera), part: 0x2d02, ver: 0x0)
Info : JTAG tap: fpgasoc.dap tap/device found: 0x4ba00477 (mfg: 0x23b (ARM Ltd.), part: 0xba00, ver: 0x4)
Info : DAP transaction stalled (WAIT) - slowing down
Info : DAP transaction stalled (WAIT) - slowing down
Info : DAP transaction stalled (WAIT) - slowing down
Info : fpgasoc.cpu.0: hardware has 6 breakpoints, 4 watchpoints
Info : accepting 'gdb' connection on tcp/3333
Info : fpgasoc.cpu.0 rev 0, partnum c09, arch f, variant 3, implementor 41
Info : fpgasoc.cpu.0 cluster 0 core 0 multi core
target halted in Thumb state due to debug-request, current mode: Supervisor
cpsr: 0x000001f3 pc: 0x3ff92798
MMU: enabled, D-Cache: enabled, I-Cache: enabled
Error: Translation from khz to jtag_speed not implemented
in procedure 'reset' 
in procedure 'ocd_bouncer' 
in procedure 'ocd_process_reset' 
in procedure 'ocd_process_reset_inner' called at file "embedded:startup.tcl", line 248
in procedure 'fpgasoc.cpu.0' called at file "embedded:startup.tcl", line 286
in procedure 'ocd_bouncer'

Info : JTAG tap: fpgasoc.fpga.tap tap/device found: 0x02d020dd (mfg: 0x06e (Altera), part: 0x2d02, ver: 0x0)
Info : JTAG tap: fpgasoc.dap tap/device found: 0x4ba00477 (mfg: 0x23b (ARM Ltd.), part: 0xba00, ver: 0x4)
Info : DAP transaction stalled (WAIT) - slowing down
Info : DAP transaction stalled (WAIT) - slowing down
Info : DAP transaction stalled (WAIT) - slowing down
Error: fpgasoc.cpu.0: how to reset?
in procedure 'reset' 
in procedure 'ocd_bouncer'


semihosting is enabled
Info : DAP transaction stalled (WAIT) - slowing down
Error: Translation from khz to jtag_speed not implemented
in procedure 'reset' 
in procedure 'ocd_bouncer' 
in procedure 'ocd_process_reset' 
in procedure 'ocd_process_reset_inner' called at file "embedded:startup.tcl", line 248
in procedure 'fpgasoc.cpu.0' called at file "embedded:startup.tcl", line 286
in procedure 'ocd_bouncer'

Info : JTAG tap: fpgasoc.fpga.tap tap/device found: 0x02d020dd (mfg: 0x06e (Altera), part: 0x2d02, ver: 0x0)
Info : JTAG tap: fpgasoc.dap tap/device found: 0x4ba00477 (mfg: 0x23b (ARM Ltd.), part: 0xba00, ver: 0x4)
Info : DAP transaction stalled (WAIT) - slowing down
Info : DAP transaction stalled (WAIT) - slowing down
Info : DAP transaction stalled (WAIT) - slowing down
Error: fpgasoc.cpu.0: how to reset?
in procedure 'reset' 
in procedure 'ocd_bouncer'


Warn : negative acknowledgment, but no packet pending
Info : DAP transaction stalled (WAIT) - slowing down
===== ARM registers
(0) r0 (/32): 0x3BF65CE0 (dirty)
(1) r1 (/32): 0x00000014 (dirty)
(2) r2 (/32): 0x00000076
(3) r3 (/32): 0x3FF7E2C7
(4) r4 (/32): 0x00000000
(5) r5 (/32): 0x3FFEAA10
(6) r6 (/32): 0x3FFCA614
(7) r7 (/32): 0x3FFE0E4C
(8) r8 (/32): 0x00000000
(9) r9 (/32): 0x3BF64EE0
(10) r10 (/32): 0x00000001
(11) r11 (/32): 0x00000017
(12) r12 (/32): 0x3FFE4E50
(13) sp_usr (/32)
(14) lr_usr (/32)
(15) pc (/32): 0x00100060 (dirty)
(16) r8_fiq (/32)
(17) r9_fiq (/32)
(18) r10_fiq (/32)
(19) r11_fiq (/32)
(20) r12_fiq (/32)
(21) sp_fiq (/32)
(22) lr_fiq (/32)
(23) sp_irq (/32)
(24) lr_irq (/32)
(25) sp_svc (/32): 0x3BF5FEE8
(26) lr_svc (/32): 0x3FF7B07F
(27) sp_abt (/32)
(28) lr_abt (/32)
(29) sp_und (/32)
(30) lr_und (/32)
(31) cpsr (/32): 0x000001D3 (dirty)
(32) spsr_fiq (/32)
(33) spsr_irq (/32)
(34) spsr_svc (/32): 0x0C02AB02
(35) spsr_abt (/32)
(36) spsr_und (/32)
(37) sp (/32)
(38) lr (/32)
(39) sp_mon (/32)
(40) lr_mon (/32)
(41) spsr_mon (/32)

After running the debugger (cpu resets):

Error: Debug regions are unpowered, an unexpected reset might have happened
Error: JTAG-DP STICKY ERROR
Warn : target fpgasoc.cpu.0 is not halted
Polling target fpgasoc.cpu.0 failed, trying to reexamine
Info : DAP transaction stalled (WAIT) - slowing down
Info : DAP transaction stalled (WAIT) - slowing down
Info : DAP transaction stalled (WAIT) - slowing down
Info : fpgasoc.cpu.0: hardware has 6 breakpoints, 4 watchpoints
Error: Target not halted
Error: Target not halted
Error: Target not halted
Error: Target not halted
Error: Target not halted
Error: Target not halted
Error: Target not halted
Error: Target not halted
Error: Target not halted
Error: Target not halted
Error: Target not halted
Error: Target not halted
Error: Target not halted
Error: Target not halted
Error: Target not halted
Error: Target not halted
Error: Target not halted
Error: cortex_a_mmu: target not halted
Warn : target not halted
Error: cortex_a_mmu: target not halted
Warn : target not halted
Error: Invalid ACK (6) in DAP response
Polling target fpgasoc.cpu.0 failed, trying to reexamine
Info : DAP transaction stalled (WAIT) - slowing down
Info : DAP transaction stalled (WAIT) - slowing down
Info : DAP transaction stalled (WAIT) - slowing down
Info : fpgasoc.cpu.0: hardware has 6 breakpoints, 4 watchpoints
Error: Invalid ACK (6) in DAP response
Polling target fpgasoc.cpu.0 failed, trying to reexamine
Info : DAP transaction stalled (WAIT) - slowing down
Info : DAP transaction stalled (WAIT) - slowing down
Info : DAP transaction stalled (WAIT) - slowing down
Info : fpgasoc.cpu.0: hardware has 6 breakpoints, 4 watchpoints
Info : dropped 'gdb' connection

I hope someone can help me.

1 Like

I’ve probably found the solution/workaround, which is to disable cache from U-Boot console: icache off and dcache off, although it causes that CPU frequency slows down. If someone could explain in detail this behavior, I would be thankful.

1 Like