November 23, 2024, 02:08:09 AM

STM32-E407 OpenOCD with ARM-USB-OCD

Started by Me, November 06, 2020, 11:04:20 PM

Previous topic - Next topic

Me

I'm trying to program a Olimex STM32-E407 with a ARM-USB-OCD. The power LED is bright and the ribbon cable is connected. The console notes "Polling target stm32f4x.cpu failed, trying to reexamine" and I do not get the desired debugger. I launch via pull down in ChibiStudio titled "OpenOCD no interface" then I choose the below config file. Are there any suggestions on how I can get this programming cable to allow debugging?

source [find interface/ftdi/olimex-arm-usb-ocd.cfg]

transport select jtag

# increase working area to 64KB
#set WORKAREASIZE 0x10000

source [find target/stm32f4x.cfg]

reset_config srst_only

Below is a copy of the console.

Open On-Chip Debugger 0.10.0+dev-01135-gdca1c6ca1-dirty (2020-03-17-11:50)
Licensed under GNU GPL v2
For bug reports, read
 http://openocd.org/doc/doxygen/bugs.html
srst_only separate srst_nogate srst_open_drain connect_deassert_srst

Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : clock speed 2000 kHz
Info : JTAG tap: stm32f4x.cpu tap/device found: 0x4ba00477 (mfg: 0x23b (ARM Ltd.), part: 0xba00, ver: 0x4)
Info : JTAG tap: stm32f4x.bs tap/device found: 0x06413041 (mfg: 0x020 (STMicroelectronics), part: 0x6413, ver: 0x0)
Info : stm32f4x.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : stm32f4x.cpu: external reset detected
Info : Listening on port 3333 for gdb connections
Error: Invalid ACK (0) in DAP response
Polling target stm32f4x.cpu failed, trying to reexamine
Error: Invalid ACK (0) in DAP response
Error: Invalid ACK (7) in DAP response
Error: Invalid ACK (7) in DAP response
Error: Invalid ACK (7) in DAP response
Error: Invalid ACK (7) in DAP response
Error: Invalid ACK (7) in DAP response
Error: Invalid ACK (7) in DAP response
Error: Invalid ACK (7) in DAP response
Error: Invalid ACK (7) in DAP response
Error: Invalid ACK (7) in DAP response
Error: Invalid ACK (7) in DAP response
Error: Invalid ACK (7) in DAP response
Error: Invalid ACK (7) in DAP response
Error: Invalid ACK (7) in DAP response

This is win10 pro 64 bit environment.

B0_1 jumpers are as below.

LubOlimex

The repeating message "Error: Invalid ACK (7) in DAP response" is not a good sign. Try with different reset settings. Test with

reset_config srst_only srst_pulls_trst


You might want to post in Chibi forums for more help with different configurations.
Technical support and documentation manager at Olimex

Me

With "reset_config srst_only srst_pulls_trst" as noted in this code snippet
# This is an STM32F4 board with a single STM32F407 chip.

source [find interface/ftdi/olimex-arm-usb-ocd.cfg]

transport select jtag

# increase working area to 64KB
set WORKAREASIZE 0x10000

source [find target/stm32f4x.cfg]

reset_config srst_only srst_pulls_trst

I get this.

Open On-Chip Debugger 0.10.0+dev-01135-gdca1c6ca1-dirty (2020-03-17-11:50)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
srst_only srst_pulls_trst srst_nogate srst_open_drain connect_deassert_srst

Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : clock speed 2000 kHz
Error: JTAG scan chain interrogation failed: all zeroes
Error: Check JTAG interface, timings, target power, etc.
Error: Trying to use configured scan chain anyway...
Error: stm32f4x.cpu: IR capture error; saw 0x00 not 0x01
Warn : Bypassing JTAG setup events due to errors
Error: Invalid ACK (0) in DAP response
Error: Invalid ACK (0) in DAP response
Error: Invalid ACK (0) in DAP response
Error: Invalid ACK (0) in DAP response
Error: Invalid ACK (0) in DAP response
Error: Invalid ACK (0) in DAP response
Error: Invalid ACK (0) in DAP response
Error: Invalid ACK (0) in DAP response
Error: Invalid ACK (0) in DAP response
Error: Invalid ACK (0) in DAP response
Error: Invalid ACK (0) in DAP response
Error: Invalid ACK (0) in DAP response
Error: Invalid ACK (0) in DAP response
Error: Invalid ACK (0) in DAP response
Error: Invalid ACK (0) in DAP response
Error: Invalid ACK (0) in DAP response
Error: Invalid ACK (0) in DAP response
Error: Invalid ACK (0) in DAP response
Error: Invalid ACK (0) in DAP response
Error: Invalid ACK (0) in DAP response
Error: Invalid ACK (0) in DAP response
Error: Invalid ACK (0) in DAP response
Error: Invalid ACK (0) in DAP response
Error: Invalid ACK (0) in DAP response
Error: Invalid ACK (0) in DAP response
Error: Invalid ACK (0) in DAP response
Error: Invalid ACK (0) in DAP response
Error: Invalid ACK (0) in DAP response
Error: Invalid ACK (0) in DAP response
Error: Invalid ACK (0) in DAP response
Error: Invalid ACK (0) in DAP response




I have cross posted to Chibi forums, So far 3 days and no replies. Chibi forum thread found here
http://www.chibios.com/forum/viewtopic.php?f=16&t=5689&sid=5556fe3b48011bbe898d4430d3eb549d

LubOlimex

It seems the result is now worse. What you had initially seemed to work fine until the debugger tried to access the board. Until this point everything is fine:

Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : clock speed 2000 kHz
Info : JTAG tap: stm32f4x.cpu tap/device found: 0x4ba00477 (mfg: 0x23b (ARM Ltd.), part: 0xba00, ver: 0x4)
Info : JTAG tap: stm32f4x.bs tap/device found: 0x06413041 (mfg: 0x020 (STMicroelectronics), part: 0x6413, ver: 0x0)
Info : stm32f4x.cpu: hardware has 6 breakpoints, 4 watchpoints

Maybe it is wrong port used for debugging? Try port setting port to both 4444 or 3333.

Maybe test with the basic setup - start OpenOCD server on one command prompt and on a second command prompt issue basic commands to start, stop, program the board.

I tried to run the environment but I am not familiar with it. Not sure what I have to do to reach the point where you receive the error.
Technical support and documentation manager at Olimex

Me

I get the same errors when I run the Olimex version of OCD as noted in the below manual.
https://www.olimex.com/Products/ARM/JTAG/_resources/ARM-USB-OCD_and_OCD_H_manual.pdf

Here is a snippet when I run the OCD noted in that manual.
C:\Users\setup\Desktop\OpenOCD-OLIMEX-WINDOWS\openocd-0.9.0-rc1\bin-x64>openocd.exe -f ./stm32f4discovery_Olimex_Modified.cfg
Open On-Chip Debugger 0.9.0-rc1 (2015-04-24-22:09)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
adapter speed: 2000 kHz
adapter_nsrst_delay: 100
jtag_ntrst_delay: 100
none separate
cortex_m reset_config sysresetreq
srst_only srst_pulls_trst srst_nogate srst_open_drain connect_deassert_srst
Info : clock speed 2000 kHz
Info : JTAG tap: stm32f4x.cpu tap/device found: 0x4ba00477 (mfg: 0x23b, part: 0xba00, ver: 0x4)
Info : JTAG tap: stm32f4x.bs tap/device found: 0x06413041 (mfg: 0x020, part: 0x6413, ver: 0x0)
Info : stm32f4x.cpu: hardware has 6 breakpoints, 4 watchpoints
Warn : Invalid ACK 0 in JTAG-DP transaction
Polling target stm32f4x.cpu failed, trying to reexamine
Warn : Invalid ACK 0x7 in JTAG-DP transaction
Warn : Invalid ACK 0x7 in JTAG-DP transaction
Warn : Invalid ACK 0x7 in JTAG-DP transaction
Warn : Invalid ACK 0x7 in JTAG-DP transaction
Warn : Invalid ACK 0x7 in JTAG-DP transaction
Warn : Invalid ACK 0x7 in JTAG-DP transaction
Warn : Invalid ACK 0x7 in JTAG-DP transaction
Warn : Invalid ACK 0x7 in JTAG-DP transaction
Warn : Invalid ACK 0x7 in JTAG-DP transaction
Warn : Invalid ACK 0x7 in JTAG-DP transaction
Examination failed, GDB will be halted. Polling again in 100ms
Warn : Invalid ACK 0x7 in JTAG-DP transaction
Polling target stm32f4x.cpu failed, trying to reexamine
Warn : Invalid ACK 0x7 in JTAG-DP transaction
Warn : Invalid ACK 0x7 in JTAG-DP transaction
Warn : Invalid ACK 0x7 in JTAG-DP transaction
Warn : Invalid ACK 0x7 in JTAG-DP transaction
Warn : Invalid ACK 0x7 in JTAG-DP transaction
Warn : Invalid ACK 0x7 in JTAG-DP transaction
Warn : Invalid ACK 0x7 in JTAG-DP transaction
Warn : Invalid ACK 0x7 in JTAG-DP transaction
Warn : Invalid ACK 0x7 in JTAG-DP transaction
Warn : Invalid ACK 0x7 in JTAG-DP transaction
Examination failed, GDB will be halted. Polling again in 300ms
Warn : Invalid ACK 0 in JTAG-DP transaction
Polling target stm32f4x.cpu failed, trying to reexamine
Warn : Invalid ACK 0 in JTAG-DP transaction
Warn : Invalid ACK 0 in JTAG-DP transaction
Warn : Invalid ACK 0 in JTAG-DP transaction

This is the current contents of stm32f4discovery_Olimex_Modified.cfg
# This is an STM32F4 board with a single STM32F407 chip.

source [find interface/ftdi/olimex-arm-usb-ocd.cfg]

transport select jtag

# increase working area to 64KB
set WORKAREASIZE 0x10000

source [find target/stm32f4x.cfg]

reset_config srst_only srst_pulls_trst

Do you have the ARM-USB-OCD and a STM32-E407 to replicate this with? The manual is reasonably well detailed about how to set it up and where to get the various install files.

Me

Per your comments about reset, I decided to get the scope on reset. I do not see the reset line change when I OCD. If I press the reset button I see it toggle from high to low, but I do not see it when I run OCD. So I suspect the reset has failed. I have a new programming cable on order. We will see if that helps the situation.

Me

I found a cfg file found below which uses "reset_config trst_and_srst srst_pulls_trst" for the reset command. So I tried it.
https://www.noicedebugger.com/tour_arm/arm7_olimex_usb.cfg

I get this, which indicates my programmer can in fact operate the reset. The yellow is reset. Notice that it attempts a bunch of stuff via the blue, then yellow drops to 0V at the very end of the scope of the graphic. 


However I also get this.


How should I know what the reset should do? The what commands should I put in OCD to get reset to do what ever it should do?

LubOlimex

I think it is now looking much better, you are almost there! The error seems now related to the environment and probably the specific sequence of commands used for debugging that the environment sends to the ARM-USB-OCD. Probably the debug configuration needs to be adjusted. The offender seems to be "reset run" command. In our outdated Eclispe environment we used the following set of commands to program a board (not sure if they would work with latest OpenOCD but they would give an idea):

Initialize commands:

reset halt
wait_halt
sleep 100
poll
flash write_image erase main.bin 0x08000000
sleep 200
 
run commands:
 
soft_reset_halt
wait_halt
poll
thbreak main
continue
Technical support and documentation manager at Olimex

Me

Under the "debug configurations", on the "startup" tab I copied the Initialize commands: as well the run commands. I still get the below when I run it. 

Assertion failed: jtag_trst == 0, file src/jtag/core.c, line 343

I also use the terminals to send commands. See the below. OCD crashes when ever I run almost any command. I suspect the issues is that the ARM-USB-OCD cable is simply not working with OCD. See below video of the 2 terminals.
https://drive.google.com/file/d/11-tc7CSUq4pucuGTLntFOcyGtzEJlBtG/view?usp=sharing

Me

I see the STM32-E407 schematic notes a TRST line but does not have a SRST line. I also see the push pull seems to be work with a variety of pull up or pull down resistor configurations. So I tried this config file.

# This is an STM32F4 board with a single STM32F407 chip.

source [find interface/ftdi/olimex-arm-usb-ocd.cfg]

transport select jtag

# increase working area to 64KB
set WORKAREASIZE 0x10000

source [find target/stm32f4x.cfg]

reset_config trst_only trst_push_pull

This is getting promising. The below is what I get when I run the above cfg file to get the connection then I start debugging. It stops in Vectors.S the line with _crt0_entry. I think this is pretty darn close to the start of code execution.

Open On-Chip Debugger 0.10.0+dev-01135-gdca1c6ca1-dirty (2020-03-17-11:50)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
trst_only separate trst_push_pull

Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : clock speed 2000 kHz
Info : JTAG tap: stm32f4x.cpu tap/device found: 0x4ba00477 (mfg: 0x23b (ARM Ltd.), part: 0xba00, ver: 0x4)
Info : JTAG tap: stm32f4x.bs tap/device found: 0x06413041 (mfg: 0x020 (STMicroelectronics), part: 0x6413, ver: 0x0)
Info : stm32f4x.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : Listening on port 3333 for gdb connections
Info : accepting 'gdb' connection on tcp/3333
Info : device id = 0x10076413
Info : flash size = 1024 kbytes
Info : flash size = 512 bytes
undefined debug reason 8 - target needs reset
Info : JTAG tap: stm32f4x.cpu tap/device found: 0x4ba00477 (mfg: 0x23b (ARM Ltd.), part: 0xba00, ver: 0x4)
Info : JTAG tap: stm32f4x.bs tap/device found: 0x06413041 (mfg: 0x020 (STMicroelectronics), part: 0x6413, ver: 0x0)
target halted due to debug-request, current mode: Handler HardFault
xPSR: 0x21000003 pc: 0x080002be msp: 0x20000400
Info : JTAG tap: stm32f4x.cpu tap/device found: 0x4ba00477 (mfg: 0x23b (ARM Ltd.), part: 0xba00, ver: 0x4)
Info : JTAG tap: stm32f4x.bs tap/device found: 0x06413041 (mfg: 0x020 (STMicroelectronics), part: 0x6413, ver: 0x0)
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x080002b8 msp: 0x20000400
Info : JTAG tap: stm32f4x.cpu tap/device found: 0x4ba00477 (mfg: 0x23b (ARM Ltd.), part: 0xba00, ver: 0x4)
Info : JTAG tap: stm32f4x.bs tap/device found: 0x06413041 (mfg: 0x020 (STMicroelectronics), part: 0x6413, ver: 0x0)
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x080002b8 msp: 0x20000400
Info : JTAG tap: stm32f4x.cpu tap/device found: 0x4ba00477 (mfg: 0x23b (ARM Ltd.), part: 0xba00, ver: 0x4)
Info : JTAG tap: stm32f4x.bs tap/device found: 0x06413041 (mfg: 0x020 (STMicroelectronics), part: 0x6413, ver: 0x0)
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x080002b8 msp: 0x20000400

I can step through a bunch of ASM code, then it it gets to my breakpoints at the beginning of the main loop. So that's promising steps. When I do this I get the below additional lines in the terminal. Is this error something to be concerned about?

Error: JTAG-DP STICKY ERROR
Error: Failed to read memory at 0x2b003048
Error: JTAG-DP STICKY ERROR
Error: Failed to read memory at 0x2b003048
Error: JTAG-DP STICKY ERROR
Error: Failed to read memory at 0x2b003048
Error: JTAG-DP STICKY ERROR
Error: Failed to read memory at 0x2b003048
Error: JTAG-DP STICKY ERROR
Error: Failed to read memory at 0x2b003048
Error: JTAG-DP STICKY ERROR
Error: Failed to read memory at 0x2b003048
Error: JTAG-DP STICKY ERROR
Error: Failed to read memory at 0x2b003048
Error: JTAG-DP STICKY ERROR
Error: Failed to read memory at 0x2b003048
Error: JTAG-DP STICKY ERROR
Error: Failed to read memory at 0x2b003048
Error: JTAG-DP STICKY ERROR
Error: Failed to read memory at 0x2b003048
Error: JTAG-DP STICKY ERROR
Error: Failed to read memory at 0x2b003048
Error: JTAG-DP STICKY ERROR
Error: Failed to read memory at 0x2b003048
Error: JTAG-DP STICKY ERROR
Error: Failed to read memory at 0x2b003048
Error: JTAG-DP STICKY ERROR
Error: Failed to read memory at 0x2b003048
Error: JTAG-DP STICKY ERROR
Error: Failed to read memory at 0x2b003048
Error: JTAG-DP STICKY ERROR
Error: Failed to read memory at 0x2b003048
Error: JTAG-DP STICKY ERROR
Error: Failed to read memory at 0x2b003048
Error: JTAG-DP STICKY ERROR
Error: Failed to read memory at 0x2b003048
Error: JTAG-DP STICKY ERROR
Error: Failed to read memory at 0x2b003048
Error: JTAG-DP STICKY ERROR
Error: Failed to read memory at 0x2b003048
Error: JTAG-DP STICKY ERROR
Error: Failed to read memory at 0x2b003048
Error: JTAG-DP STICKY ERROR
Error: Failed to read memory at 0x2b003048
Error: JTAG-DP STICKY ERROR
Error: Failed to read memory at 0x2b003048
Error: JTAG-DP STICKY ERROR
Error: Failed to read memory at 0x2b003048
Error: JTAG-DP STICKY ERROR
Error: Failed to read memory at 0x2b003048
Error: JTAG-DP STICKY ERROR
Error: Failed to read memory at 0x2b003048
Error: JTAG-DP STICKY ERROR
Error: Failed to read memory at 0x2b003048
Error: JTAG-DP STICKY ERROR
Error: Failed to read memory at 0x2b003048
Error: JTAG-DP STICKY ERROR
Error: Failed to read memory at 0x2b003048
Error: JTAG-DP STICKY ERROR
Error: Failed to read memory at 0x2b003048
Error: JTAG-DP STICKY ERROR
Error: Failed to read memory at 0x2b003048
Error: JTAG-DP STICKY ERROR
Error: Failed to read memory at 0x2b003048
Error: JTAG-DP STICKY ERROR
Error: Failed to read memory at 0x2b003048
Error: JTAG-DP STICKY ERROR
Error: Failed to read memory at 0x2b003048
Error: JTAG-DP STICKY ERROR
Error: Failed to read memory at 0x2b003048
Error: JTAG-DP STICKY ERROR
Error: Failed to read memory at 0x2b003048
Error: JTAG-DP STICKY ERROR
Error: Failed to read memory at 0x2b003048
Error: JTAG-DP STICKY ERROR
Error: Failed to read memory at 0x2b003048
Error: JTAG-DP STICKY ERROR
Error: Failed to read memory at 0x2b003048
Error: JTAG-DP STICKY ERROR
Error: Failed to read memory at 0x2b003048
Error: JTAG-DP STICKY ERROR
Error: Failed to read memory at 0x2b003048
Error: JTAG-DP STICKY ERROR
Error: Failed to read memory at 0x2b003048

Me

Is this
Info : flash size = 1024 kbytes
Info : flash size = 512 bytes

And this a concern?

# increase working area to 64KB
set WORKAREASIZE 0x10000

Me

I've now used this setup for a bit, so it would seem I have the configuration parameters good enough for what I'm doing. I posted about how to get this working with ChibiOS in the below thread. If Olimex feels this .cfg file and it's parameters are correct, perhaps Olimex could relay this config file or similar to the official OCD. I release these config parameters under the IDC license. That's the I Don't Care License.
http://www.chibios.com/forum/viewtopic.php?f=16&t=5689&p=38932#p38932

LubOlimex

Great! Thanks for the update and the effort to compile the instructions so well! I don't know if OpenOCD would take notice and update the config, but I will make sure to keep your instructions for future reference and if another person has some difficulties. Thanks again!
Technical support and documentation manager at Olimex