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] 2  Send TopicPrint
Very Hot Topic (More than 25 Replies) Using the nucleo-64 SWD interface to debug another stm32? (Read 9338 times)
Bambo
Member
***
Offline


Posts: 146
Location: Liverpool, UK
Joined: Jan 13th, 2020
Using the nucleo-64 SWD interface to debug another stm32?
Feb 22nd, 2020 at 3:10pm
Print Post  
Hi,

Is it possible to use the nucleo-64 SWD pins as a hardware debugger, to debug a seperate stm32?

« Last Edit: Feb 22nd, 2020 at 3:16pm 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: Using the nucleo-64 SWD interface to debug another stm32?
Reply #1 - Feb 24th, 2020 at 10:11am
Print Post  
This should be possible as the STLink attached to the Nucleo is a separate board, though I have not tried this myself at present.  The below STLink Manual section shows how to wire up the SWD interface to an external board:

6.3.4 Using ST-LINK/V2-1 to program and debug an external STM32 application
STLink Documentation

An alternative may be to create a BMP with STLink Firmware from an STM32 Bluepill, as these can be re-flashed to be a debugger, then back again to be a normal board.
STM32 Blue Pill Custom Debugger creation
  
Back to top
 
IP Logged
 
Bambo
Member
***
Offline


Posts: 146
Location: Liverpool, UK
Joined: Jan 13th, 2020
Re: Using the nucleo-64 SWD interface to debug another stm32?
Reply #2 - Feb 24th, 2020 at 12:58pm
Print Post  
I see, the documentation says it is possible yes. But which options would be used in this configuration?

- edit -

I guess it would be the ST-Link v2 External correct?
« Last Edit: Feb 24th, 2020 at 12:59pm 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: Using the nucleo-64 SWD interface to debug another stm32?
Reply #3 - Feb 24th, 2020 at 1:19pm
Print Post  
It would still be the STLink v2.1 in this case, as it is still the same debugger, though we are using it differently.
(the USB identifiers are slightly different between this device and the external STLink, and are labelled only for their most common usage in the IDE).

You will also need to change to the right target board as well (I'm assuming it isn't another Nucleo-64 board), and I believe the jumpers also need removing on the STLink board to disconnect it from the on-board Nucleo (shown connected in the first image).
  
Back to top
 
IP Logged
 
Bambo
Member
***
Offline


Posts: 146
Location: Liverpool, UK
Joined: Jan 13th, 2020
Re: Using the nucleo-64 SWD interface to debug another stm32?
Reply #4 - Feb 24th, 2020 at 5:01pm
Print Post  
Simon@Visual Micro wrote on Feb 24th, 2020 at 1:19pm:
It would still be the STLink v2.1 in this case, as it is still the same debugger, though we are using it differently.
(the USB identifiers are slightly different between this device and the external STLink, and are labelled only for their most common usage in the IDE).

You will also need to change to the right target board as well (I'm assuming it isn't another Nucleo-64 board), and I believe the jumpers also need removing on the STLink board to disconnect it from the on-board Nucleo (shown connected in the first image).


Ok thanks Simon! i will experiment with it and see how far i get Smiley I will keep this thread updated

Only problem is i don't know which board to select since it's just a single STM32 L452RE without the nucleo board, i'll try a few different options and see what happens.
« Last Edit: Feb 24th, 2020 at 5:46pm by Bambo »  
Back to top
 
IP Logged
 
Bambo
Member
***
Offline


Posts: 146
Location: Liverpool, UK
Joined: Jan 13th, 2020
Re: Using the nucleo-64 SWD interface to debug another stm32?
Reply #5 - Feb 24th, 2020 at 5:24pm
Print Post  
Strange, i'm getting some errors about openocd.exe

Quote:
Starting: "C:\ProgramData\vmicro\tools\openocd-0.10.0.1\bin/openocd.exe" -d2 -l _DebugOpenOCD.log}" -s"C:\ProgramData\vmicro\tools\openocd-0.10.0.1/scripts/" -f  -f "C:\ProgramData\vmicro\tools\openocd-0.10.0.1/scripts/{build.openocdscript}" -c "init"
Starting: \4.8.3-2014q1/bin\arm-none-eabi-gdb.exe" --interpreter=mi
"C:\ProgramData\vmicro\tools\openocd-0.10.0.1\bin/openocd.exe" exited with code 1 (0x1).


The DebugOpenOCD.log contains:
Quote:
embedded:startup.tcl:60: Error: Can't find C:\ProgramData\vmicro\tools\openocd-0.10.0.1/scripts/{build.openocdscript}
in procedure 'script' 
at file "embedded:startup.tcl", line 60


I'm going to try a different board although non match my "STM32 L452RE" chip specifically.

« Last Edit: Feb 24th, 2020 at 5:28pm by Bambo »  

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: Using the nucleo-64 SWD interface to debug another stm32?
Reply #6 - Feb 24th, 2020 at 5:30pm
Print Post  
Here's the list of boards, which one do i use for just STM32 L452RE without nucelo-64?
« Last Edit: Feb 24th, 2020 at 5:30pm by Bambo »  

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: Using the nucleo-64 SWD interface to debug another stm32?
Reply #7 - Feb 24th, 2020 at 5:32pm
Print Post  
Here's another log output when trying to build and upload using stlink 2.1

Quote:
Program SAIN size: 148,532 bytes (used 28% of a 524,288 byte maximum) (21.30 secs)
Minimum Memory Usage: 5296 bytes (3% of a 163840 byte maximum)
 
# Copy build result to 'Project>Property Pages>Intermediate Directory'
# Destination: 

Uploading 'SAIN' to 'Nucleo-64' using 'COM15'
Open On-Chip Debugger 0.10.0
Licensed under GNU GPL v2
For bug reports, read
     http://openocd.org/doc/doxygen/bugs.html
debug_level: 0
adapter speed: 1000 kHz
adapter_nsrst_delay: 100
none separate
****[vMicro]**** Uploading ELF :none separate
Error: libusb_open() failed with LIBUSB_ERROR_NOT_SUPPORTED
The uploader process failed
# Copy build result to 'Project>Property Pages>Intermediate Directory'
Error: libusb_open() failed with LIBUSB_ERROR_NOT_SUPPORTED
# Destination: 

Error: expected 1 of 1: 0x1ba01477
in procedure 'program' 
in procedure 'init' called at file "embedded:startup.tcl", line 495
in procedure 'ocd_bouncer'
** OpenOCD init failed **
shutdown command invoked
  
Back to top
 
IP Logged
 
Bambo
Member
***
Offline


Posts: 146
Location: Liverpool, UK
Joined: Jan 13th, 2020
Re: Using the nucleo-64 SWD interface to debug another stm32?
Reply #8 - Feb 24th, 2020 at 5:37pm
Print Post  
Here is the configuration

  

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: Using the nucleo-64 SWD interface to debug another stm32?
Reply #9 - Feb 24th, 2020 at 6:03pm
Print Post  
Thanks for the additional information, and I don't know enough about these specific boards and configurations, however you should always be able to flash it back if its not right.

With the Nucleo L4x board selected, the issue with the "embedded:startup.tcl:60: Error: Can't find C:\ProgramData\vmicro\tools\openocd-0.10.0.1/scripts/{build.openocdscript}" can be resolved by adding a local board.txt and the below lines before starting the debugger / uploader (will add fixes in next release)
Code
Select All
build.openocdscript=target/stm32l4x.cfg
tools.openocd.upload.openocdscript=target/stm32l4x.cfg
 



That should at least align the Debug/Upload OpenOCD tool with the correct chip for your board.
  
Back to top
 
IP Logged
 
Bambo
Member
***
Offline


Posts: 146
Location: Liverpool, UK
Joined: Jan 13th, 2020
Re: Using the nucleo-64 SWD interface to debug another stm32?
Reply #10 - Feb 24th, 2020 at 8:21pm
Print Post  
Hi, the custom board.txt worked! However i am getting this error. I'm trying to troubleshoot it but i'm not sure what to do using this https://www.visualmicro.com/page/Troubleshooting-Debugging.aspx
« Last Edit: Feb 24th, 2020 at 8:24pm by Bambo »  

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: Using the nucleo-64 SWD interface to debug another stm32?
Reply #11 - Feb 24th, 2020 at 9:34pm
Print Post  
I have attached the debug information with this configuration:

Board: Nucleo-64
Board part number : Nucleo L452RE
Debug: Hardware
Optimize: Smallest
Upload method: STLink v2.1 + OpenOCD (vmicro)



  

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: Using the nucleo-64 SWD interface to debug another stm32?
Reply #12 - Feb 24th, 2020 at 9:40pm
Print Post  
There should be a log created when the debugging starts, in the build directory, which all of the output is sent to when debugging (search for "build.path" in the build output with Show Build Properties Enabled).

Code
Select All
e.g. INK_GDB\STM32_Nucleo_64\Debug
 



After you attach there should be the commands being run in the Output: Debug window (used on that page for driver checking), we are interested in the first one:
Code
Select All
Starting: "C:\ProgramData\vmicro\tools\openocd-0.10.0.1\bin/openocd.exe" -d2 -l TM32_Nucleo_64\Debug/STM32-NUCLEO_STLLINKv21_BLINK_GDB.ino_DebugOpenOCD.log}" -s"C:\ProgramData\vmicro\tools\openocd-0.10.0.1/scripts/" -f  -f "C:\ProgramData\vmicro\tools\openocd-0.10.0.1/scripts/target/stm32l4x.cfg" -c "init"
 



This is also useful as you can run the command in the prompt separately, and remove the "-l {logfilelocation}" part of the command and have it output to the prompt.

This will hopefully tell us something more about what the issue is between the OpenOCD software and the debugger / target (configuration, voltage, signals etc...)
  
Back to top
 
IP Logged
 
Bambo
Member
***
Offline


Posts: 146
Location: Liverpool, UK
Joined: Jan 13th, 2020
Re: Using the nucleo-64 SWD interface to debug another stm32?
Reply #13 - Feb 24th, 2020 at 10:07pm
Print Post  
Here is the output of OpenOCD.

Quote:

Info : auto-selecting first available session transport "hla_swd". To override use 'transport select <transport>'.
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
adapter speed: 500 kHz
adapter_nsrst_delay: 100
none separate
Info : Unable to match requested speed 500 kHz, using 480 kHz
Info : Unable to match requested speed 500 kHz, using 480 kHz
Info : clock speed 480 kHz
Error: libusb_open() failed with LIBUSB_ERROR_NOT_SUPPORTED
Error: libusb_open() failed with LIBUSB_ERROR_NOT_SUPPORTED
Info : STLINK v2 JTAG v35 API v2 SWIM v26 VID 0x0483 PID 0x374B
Info : using stlink api v2
Info : Target voltage: 3.266094
Info : stm32l4x.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : accepting 'gdb' connection on tcp/3333
Info : device id = 0x20016462
Warn : Cannot identify target as a STM32L4 family.
Error: auto_probe failed
Error: Connect failed. Consider setting up a gdb-attach event for the target to prepare target for GDB connect, or use 'gdb_memory_map disable'.
Error: attempted 'gdb' connection rejected


Note the upload only works with the Upload Method "STM32CubeProgrammer: SWD "option, it does not work with the "STLink v2.1 + OpenOCD (vmicro) option".
« Last Edit: Feb 24th, 2020 at 10:16pm by Bambo »  
Back to top
 
IP Logged
 
Bambo
Member
***
Offline


Posts: 146
Location: Liverpool, UK
Joined: Jan 13th, 2020
Re: Using the nucleo-64 SWD interface to debug another stm32?
Reply #14 - Feb 25th, 2020 at 8:05pm
Print Post  
I have resorted to purchasing an STLink v2 just to simplify things Smiley
  
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2145
Joined: Feb 13th, 2019
Re: Using the nucleo-64 SWD interface to debug another stm32?
Reply #15 - Feb 25th, 2020 at 8:48pm
Print Post  
Sorry for the delayed reply, all I could think to try now would be an updated OpenOCD version, but this still may be problematic.

The STLink is a good choice, and it removes so many connections and other potential issues it should be well worth it.

Let us know if you have any further issues, or if you want to try the OpenOCD update before it is released in the next major build.
  
Back to top
 
IP Logged
 
Bambo
Member
***
Offline


Posts: 146
Location: Liverpool, UK
Joined: Jan 13th, 2020
Re: Using the nucleo-64 SWD interface to debug another stm32?
Reply #16 - Feb 25th, 2020 at 9:00pm
Print Post  
No problem Simon, i learnt lots Smiley Sure i can try a newer version of openocd, which version?
  
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2145
Joined: Feb 13th, 2019
Re: Using the nucleo-64 SWD interface to debug another stm32?
Reply #17 - Feb 26th, 2020 at 12:43am
Print Post  
The updated version is detailed below, I'd just try it from the command line for now (steps 2+3):

1)  [urlhttps://www.visualmicro.com/downloads/tools/openocd-0.10.0.20200213/openocd-0.10.0.20200213.zip]Download Updated OpenOCD ZIP[/url] and Extract to a folder e.g. "C:\ProgramData\vmicro\tools\" (so you should have a new openocd-0.10.0.20200213 folder within tools)

2) Alter the paths in the command line from before for this new folder (it has the same internal structure)

3) Alter the configuration from "stlink-v2-1.cfg" to just "stlink.cfg"

Ideally the output will improve (or recognise it as the correct family at least), and there is potentially more logging which can be enabled using -d3 instead of -d2 in the command, however this is extremely verbose and may not reveal more than the messages we see already.
  
Back to top
 
IP Logged
 
Bambo
Member
***
Offline


Posts: 146
Location: Liverpool, UK
Joined: Jan 13th, 2020
Re: Using the nucleo-64 SWD interface to debug another stm32?
Reply #18 - Feb 26th, 2020 at 9:17am
Print Post  
Yep, that resolved the errors, here's what the command line output looks like. How do i connect it to vmicro?

  

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: Using the nucleo-64 SWD interface to debug another stm32?
Reply #19 - Feb 26th, 2020 at 12:31pm
Print Post  
Brilliant, this can be added in for debugging easily: (will only affect this project + board configuration)

1) Ensure vMicro > Upload > Verbose is checked
2) Try and attach the Debugger (there will be some JSON output in the Output > Micro Debug window)
3) Right Click on Project and Add > Add Custom GDB Debugger (Advanced)
4) Replace the contents of the file with the JSON copied from step 2 output (including outer {} brackets)
5) Edit the paths/commands in the JSON file to match the updates which have worked
6) Save the JSON file and try the Debug > Attach to Process again

Ill let you know when I have had another look at the programmer entries, and how they can be easily edited.  In theory now you can run the Upload command and then perform the same edits and run it at the command prompt to try the upload as well.

  
Back to top
 
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send TopicPrint