Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 8 Replies) STM32 L4RE - Problems with OpenOCD (Read 4119 times)
Bambo
Member
***
Offline


Posts: 146
Location: Liverpool, UK
Joined: Jan 13th, 2020
STM32 L4RE - Problems with OpenOCD
Jan 16th, 2023 at 10:33am
Print Post  
Hi!

I have stumbled across an issue with the newest visual micro version, when i try to debug my program the openocd fails with the following debug logs.

Quote:
embedded:startup.tcl:26: Error: Can't find target/stm32l4.cfg
in procedure 'script' 
at file "embedded:startup.tcl", line 26


Quote:
Starting: "C:\ProgramData\vmicro\tools\openocd-0.11.0.20211209\bin/openocd.exe" -d2 -l ebug/SAIN.ino_DebugOpenOCD.log}" -s "C:\ProgramData\vmicro\tools\openocd-0.11.0.20211209/scripts/" -f "interface/stlink.cfg" -f "target/stm32l4.cfg" -c "init; reset halt"

Starting: arm-none-eabi-gcc\10.3.1-2.3/bin\arm-none-eabi-gdb.exe" --interpreter=mi

"C:\ProgramData\vmicro\tools\openocd-0.11.0.20211209\bin/openocd.exe" exited with code 1 (0x1).


How can i fix this?

Thank you,
- Richard
« Last Edit: Jan 31st, 2023 at 3:40pm by Simon@Visual Micro »  
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2145
Joined: Feb 13th, 2019
Re: Problems with OpenOCD
Reply #1 - Jan 16th, 2023 at 10:45am
Print Post  
Thanks for the report.

Could you enable the settings shown at the top of the page and attach the full build log so we can see your configuration?

We will be able to provide a workaround quickly...
  
Back to top
 
IP Logged
 
Bambo
Member
***
Offline


Posts: 146
Location: Liverpool, UK
Joined: Jan 13th, 2020
Re: Problems with OpenOCD
Reply #2 - Jan 16th, 2023 at 11:34am
Print Post  
Simon@Visual Micro wrote on Jan 16th, 2023 at 10:45am:
Thanks for the report.

Could you enable the settings shown at the top of the page and attach the full build log so we can see your configuration?

We will be able to provide a workaround quickly...


Thank you so much your quick reply, i have emailed the "Micro Build" output with the settings enabled to sales@visualmicro.com.
  
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2145
Joined: Feb 13th, 2019
Re: Problems with OpenOCD
Reply #3 - Jan 16th, 2023 at 11:56am
Print Post  
Thanks for the log.

If you add a local board.txt to your project (vMIcro > Add Code > Add Local Board.txt), and paste the below contents into the file:
Code
Select All
# STM32 Official Core: L4452RE Debug Workaround
cfg 



IF you then save the file and try debugging again it should find the correct *.cfg file.
  
Back to top
 
IP Logged
 
Bambo
Member
***
Offline


Posts: 146
Location: Liverpool, UK
Joined: Jan 13th, 2020
Re: Problems with OpenOCD
Reply #4 - Jan 16th, 2023 at 12:44pm
Print Post  
Hi,

I have tried the new local board.txt solution and now it starts up but unfortunately no breakpoints are working.

Here's the output from the debug...

Quote:
openocd: Open On-Chip Debugger 0.11.0+dev-gb1de116 (2021-12-09-11:34)
openocd: Licensed under GNU GPL v2
openocd: For bug reports, read
openocd:      http://openocd.org/doc/doxygen/bugs.html
openocd: debug_level: 2
openocd: 
=thread-group-added,id="i1"
GNU gdb (xPack GNU Arm Embedded GCC i386) 10.2.90.20210621-git
Copyright (C) 2021 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=i686-w64-mingw32 --target=arm-none-eabi".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
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".
=cmd-param-changed,param="pagination",value="off"
Note: automatically using hardware breakpoints for read-only addresses.
Reset_Handler () at m32l452xx.s:62
62        ldr   sp, =_estack    /* Set stack pointer */


edit:

I have tried putting the following into the local board.txt but i can't seem to get it working on my machine.

Code
Select All
# Just have OpenOCD Connect and not reset when Debug > Start Debugging is used
tools.stlinkv2.server.initCmd=-c "init" 

« Last Edit: Jan 19th, 2023 at 11:29am by Bambo »  
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2145
Joined: Feb 13th, 2019
Re: Problems with OpenOCD
Reply #5 - Jan 19th, 2023 at 3:01pm
Print Post  
Thanks for the update.

Can you confirm you only have 1 or 2 breakpoints set (ensure 1 is in loop() so it is always hit if available)?

Can you also try changing the vMicro > Debugger > Optmization to "No Project", and then perform a Build > Clean Solution before recompiling? (just in case the code with the breakpoint has been optimized out).

  
Back to top
 
IP Logged
 
Bambo
Member
***
Offline


Posts: 146
Location: Liverpool, UK
Joined: Jan 13th, 2020
Re: Problems with OpenOCD
Reply #6 - Jan 19th, 2023 at 4:11pm
Print Post  
Simon@Visual Micro wrote on Jan 19th, 2023 at 3:01pm:
Thanks for the update.

Can you confirm you only have 1 or 2 breakpoints set (ensure 1 is in loop() so it is always hit if available)?

Can you also try changing the vMicro > Debugger > Optmization to "No Project", and then perform a Build > Clean Solution before recompiling? (just in case the code with the breakpoint has been optimized out).



With those settings enabled the project doesn't complete linking anymore. I've sent the build logs to the email above.
  
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2145
Joined: Feb 13th, 2019
Re: Problems with OpenOCD
Reply #7 - Jan 19th, 2023 at 4:58pm
Print Post  
Thanks for the update.

Can you try the same setup but just with a simple Blink Sketch so it removes any potential other code from libraries etc?

If it still doesn't work can you send the build output after trying to attach the debugger (with vMicro > Upload > Verbose Enabled) so we can compare configurations?
  
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2145
Joined: Feb 13th, 2019
Re: Problems with OpenOCD
Reply #8 - Jan 19th, 2023 at 5:23pm
Print Post  
Additional:

If it still fails to compile leave the Optimization as "default".

Init Command
The Init Command you are trying to set does depend on how the debugging session is started, please see the attached file (STM32_DebugInitCommands.txt) for the two options which can be amended to change this.

Potential Fix Via Command Change
Can you also try the overrides in the attached file which ensure the Hardware Reset handler is used (STM32_L4RE_CommandChange.txt).
« Last Edit: Jan 19th, 2023 at 5:24pm by Simon@Visual Micro »  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
Bambo
Member
***
Offline


Posts: 146
Location: Liverpool, UK
Joined: Jan 13th, 2020
Re: Problems with OpenOCD
Reply #9 - Jan 24th, 2023 at 1:27pm
Print Post  
Hi, i've managed to get it compiling again. Sadly OpenOCD is still breaking when the debugger launches, here is my board.txt...
Code
Select All
# STM32 Official Core: L4452RE Debug Workaround
# cfg

# Additional Command added from board/st_nucleo_l4.cfg to use hardware reset
cfg
vs-cmd.Debug.AttachtoProcess.tools.stlinkv2.vmserver.initCmd=-c "reset_config srst_only srst_nogate" -c "init"

# Alternative to the above is to use the packaged board script (same resulting commands)
# NOTE this replaces the previous override for the openocd script property!
# tools.stlinkv2.vmserver.boardCmd=
# l4.cfg

# When using the vMicro > Debugger > Hardware Debugger STLink v2 (External) or STLink v2.1 (Onboard)
# Ensure Init command is set for Debug > Start
tools.stlinkv2.server.initCmd=-c "init"
# Ensure Init command is set for Debug > Attach to Process
vs-cmd.Debug.AttachtoProcess.tools.stlinkv2.vmserver.initCmd=-c "init" 



And i have sent to the email at the top the build and uploading logs.

Thanks!
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Problems with OpenOCD
Reply #10 - Jan 25th, 2023 at 1:15pm
Print Post  
Thanks, someone will respond early next week.
  
Back to top
WWW  
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2145
Joined: Feb 13th, 2019
Re: Problems with OpenOCD
Reply #11 - Jan 31st, 2023 at 10:13am
Print Post  
Thanks for the detail.

Are the below lines present in your board.txt file? (the logs show it is resetting the board still on debug start which may be the culprit)

# When using the vMicro > Debugger > Hardware Debugger STLink v2 (External) or STLink v2.1 (Onboard)
# Ensure Init command is set for Debug > Start 
tools.stlinkv2.server.initCmd=-c "init"
# Ensure Init command is set for Debug > Attach to Process
vs-cmd.Debug.AttachtoProcess.tools.stlinkv2.vmserver.initCmd=-c "init"


Once they are present, if you upload the code, and then try Debug > Attach to Process after a few seconds, does this change the result?
  
Back to top
 
IP Logged
 
Bambo
Member
***
Offline


Posts: 146
Location: Liverpool, UK
Joined: Jan 13th, 2020
Re: Problems with OpenOCD
Reply #12 - Jan 31st, 2023 at 11:07am
Print Post  
Simon@Visual Micro wrote on Jan 31st, 2023 at 10:13am:
Thanks for the detail.

Are the below lines present in your board.txt file? (the logs show it is resetting the board still on debug start which may be the culprit)

# When using the vMicro > Debugger > Hardware Debugger STLink v2 (External) or STLink v2.1 (Onboard)
# Ensure Init command is set for Debug > Start 
tools.stlinkv2.server.initCmd=-c "init"
# Ensure Init command is set for Debug > Attach to Process
vs-cmd.Debug.AttachtoProcess.tools.stlinkv2.vmserver.initCmd=-c "init"


Once they are present, if you upload the code, and then try Debug > Attach to Process after a few seconds, does this change the result?


Hi, my board.txt file contains these lines:

Quote:

menu.pnum.NUCLEO_L452RE.tools
.openocd.debug.build.openocdscript=target/stm32l4x.cfg

vs-cmd.Debug.AttachtoProcess.tools.stlinkv2.vmserver.initCmd=-c "reset_config srst_only srst_nogate" -c "init"

tools.stlinkv2.server.initCmd=-c "init"

vs-cmd.Debug.AttachtoProcess.tools.stlinkv2.vmserver.initCmd=-c "init"


The project compiles and uploads fine, but when i try to attach the debugger it pops up with a dialog "Initializing debuger... -break-insert -f main" and then halts (like before) and prints this to the debug:
Code
Select All
openocd: Open On-Chip Debugger 0.11.0+dev-gb1de116 (2021-12-09-11:34)
openocd: Licensed under GNU GPL v2
openocd: For bug reports, read
openocd: 	http://openocd.org/doc/doxygen/bugs.html
openocd: debug_level: 2
openocd:
=thread-group-added,id="i1"
GNU gdb (xPack GNU Arm Embedded GCC i386) 10.2.90.20210621-git
Copyright (C) 2021 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=i686-w64-mingw32 --target=arm-none-eabi".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
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".
=cmd-param-changed,param="pagination",value="off"
Note: automatically using hardware breakpoints for read-only addresses.
Reset_Handler () at m32l452xx.s:91
91	  str  r3, [r2]
 



I have sent the corresponding micro build output to the email address in the notification at the top of the page.

Thank you - R
« Last Edit: Jan 31st, 2023 at 11:55am by Bambo »  
Back to top
 
IP Logged
 
Bambo
Member
***
Offline


Posts: 146
Location: Liverpool, UK
Joined: Jan 13th, 2020
Re: STM32 L4RE - Problems with OpenOCD
Reply #13 - Feb 1st, 2023 at 8:40pm
Print Post  
Ok small progress, if i change the board.txt to this:

Code
Select All
# Additional Command added from board/st_nucleo_l4.cfg to use hardware reset
cfg

# When using the vMicro > Debugger > Hardware Debugger STLink v2 (External) or STLink v2.1 (Onboard)
# Ensure Init command is set for Debug > Start
tools.stlinkv2.server.initCmd=-c "reset_config srst_only srst_nogate" -c "init"
# Ensure Init command is set for Debug > Attach to Process
vs-cmd.Debug.AttachtoProcess.tools.stlinkv2.vmserver.initCmd=-c "reset_config srst_only srst_nogate" -c "init" 



Then attaching the debugger once its running and the Debug->Start method, still breaks at the Reset_Handler().

But if i use this:

Code
Select All
# Additional Command added from board/st_nucleo_l4.cfg to use hardware reset
cfg

# When using the vMicro > Debugger > Hardware Debugger STLink v2 (External) or STLink v2.1 (Onboard)
# Ensure Init command is set for Debug > Start
tools.stlinkv2.server.initCmd=-c "reset_config srst_only srst_nogate" -c "init"
# Ensure Init command is set for Debug > Attach to Process
#vs-cmd.Debug.AttachtoProcess.tools.stlinkv2.vmserver.initCmd=-c "reset_config srst_only srst_nogate" -c "init"
#vs-cmd.Debug.AttachtoProcess.tools.stlinkv2.vmserver.initCmd=-c "init" 



Then attaching the debugger breaks it at the current instruction.

Code
Select All
openocd: Open On-Chip Debugger 0.11.0+dev-gb1de116 (2021-12-09-11:34)
openocd: Licensed under GNU GPL v2
openocd: For bug reports, read
openocd: 	http://openocd.org/doc/doxygen/bugs.html
openocd: debug_level: 2
openocd:
=thread-group-added,id="i1"
GNU gdb (xPack GNU Arm Embedded GCC i386) 10.2.90.20210621-git
Copyright (C) 2021 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=i686-w64-mingw32 --target=arm-none-eabi".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
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".
=cmd-param-changed,param="pagination",value="off"
Note: automatically using hardware breakpoints for read-only addresses.
0x08001394 in RCC_SetFlashLatencyFromMSIRange (msirange=96) at 2\2.4.0\system/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc.c:1790
1790	  if(__HAL_RCC_PWR_IS_CLK_ENABLED()) 



 
  
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2145
Joined: Feb 13th, 2019
Re: STM32 L4RE - Problems with OpenOCD
Reply #14 - Feb 2nd, 2023 at 9:24am
Print Post  
Thanks for the brilliant detail and persistence with this!

We will review the resulting changes and commands and integrate this into Visual Micro, and update this thread when it is released.
  
Back to top
 
IP Logged
 
Bambo
Member
***
Offline


Posts: 146
Location: Liverpool, UK
Joined: Jan 13th, 2020
Re: STM32 L4RE - Problems with OpenOCD
Reply #15 - Feb 2nd, 2023 at 10:16am
Print Post  
Simon@Visual Micro wrote on Feb 2nd, 2023 at 9:24am:
Thanks for the brilliant detail and persistence with this!

We will review the resulting changes and commands and integrate this into Visual Micro, and update this thread when it is released.


No problem at all!
  
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2145
Joined: Feb 13th, 2019
Re: STM32 L4RE - Problems with OpenOCD
Reply #16 - Feb 2nd, 2023 at 3:58pm
Print Post  
Could you try commenting out these overrides and just adding in the attached one?

(This is the config for the full Nucleo L4 board, which does everything in those commands, but without having to specify them separately for the specific target chip)
« Last Edit: Feb 2nd, 2023 at 4:01pm by Simon@Visual Micro »  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
Bambo
Member
***
Offline


Posts: 146
Location: Liverpool, UK
Joined: Jan 13th, 2020
Re: STM32 L4RE - Problems with OpenOCD
Reply #17 - Feb 2nd, 2023 at 8:02pm
Print Post  
Simon@Visual Micro wrote on Feb 2nd, 2023 at 3:58pm:
Could you try commenting out these overrides and just adding in the attached one?

(This is the config for the full Nucleo L4 board, which does everything in those commands, but without having to specify them separately for the specific target chip)


Hi thank you, i have tried the new override and using debug->start which still hits the reset_handler(). However, when i use debug->attach to process it actually starts working!

If i press the PAUSE button when debug->attach to process, it breaks like this!

Edit:
I'm not sure if this is due to the debugger but the stm32 seems to be running very slowly  Shocked




« Last Edit: Feb 2nd, 2023 at 8:06pm by Bambo »  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2145
Joined: Feb 13th, 2019
Re: STM32 L4RE - Problems with OpenOCD
Reply #18 - Feb 3rd, 2023 at 2:23pm
Print Post  
Thanks for the update, we will look at why the config doesn't apply the same to both Debug > Start and Debug > Attach to Process.

Thanks for confirming the config file works instead of the options being specified manually, and we are reviewing the other STM32 configurations to ensure these are aligned as well where possible for the appropriate setups.

The pause looks correct to me, it simply stops on the current line of execution which can be anywhere in the Sketch/Library/Core code.

The execution speed with GDB is often slower as there is a constant conversation between OpenOCD, the debug probe and the MCU which does slow down execution.  You can increase the speed at which OpenOCD communicates with the probe, however this can lead to instability with debugging if set too high, depending on wire/trace lengths and noise.  The default set in the target\stm32l4x.cfg is 500Khz for safety.

If you edit the initCmd line to add in -c "adapter speed 1000" this would run at 1000Khz for example:
tools.stlinkv2.server.initCmd=-c "adapter speed 1000" -c "init"

Apparently from the CFG file and this changesets notes it can run up to 18*F_CPU for the onboard STLink probe.




  
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2145
Joined: Feb 13th, 2019
Re: STM32 L4RE - Problems with OpenOCD
Reply #19 - Feb 8th, 2023 at 2:03pm
Print Post  
Off-Topic replies have been moved to this Topic.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint