Using STLink-v2 with debug adapter

Discussions and questions about the Crazyflie Nano Quadcopter
Post Reply
KiteFlier
Beginner
Posts: 3
Joined: Sat Mar 24, 2018 8:53 am

Using STLink-v2 with debug adapter

Post by KiteFlier » Sat Mar 24, 2018 9:11 am

Hi,

I am trying to using STLink-V2 with debug adapter to debug and flash crazyflie 2. I use make flash and encounter error ("Unable to connect to target"). Am I doing it in the right way by (1) connecting the STLink v2 to the debug adapter via STM32 Discovery Debug pin and SWV to the CrazyFlie 2 and (2) get into the DFU mode by press and hold the on/off button and power the crazyflie via the lipo?

If the STLink-v2 is to connect to the debug adapter via STM32 Discovery Debug pin, please advise if the below connection is correct:
GND (STLink-V2) --> GND (STM32 Discovery Debug pin)
SWDIO (STLink-V2) --> SWDIO (STM32 Discovery Debug pin)
SWCLK (STLink-V2) --> SWCLK (STM32 Discovery Debug pin)

Do I need to buy a Jlink adaptor instead in order to debug?

arnaud
Bitcraze
Posts: 1672
Joined: Tue Feb 06, 2007 12:36 pm

Re: Using STLink-v2 with debug adapter

Post by arnaud » Mon Mar 26, 2018 9:54 am

Are you using one of these colorful stlink viewtopic.php?f=5&t=2806&start=10#p14286? They have been confirmed to work and we are only using STLink V2 (the original white/blue one) for development so a JLink should not be necessary.

I think you need to connect the reset pin as well in order to program the STM32, this might be the problem.

If you are using a SWD debugger like the STLink, you do not need the DFU mode. Just type "make flash" in the crazyflie-firmware project and openocd will reset, flash, and reset again the STM32.

KiteFlier
Beginner
Posts: 3
Joined: Sat Mar 24, 2018 8:53 am

Re: Using STLink-v2 with debug adapter

Post by KiteFlier » Mon Mar 26, 2018 12:47 pm

Hi,

My STLink v2 is the blue one. Just to confirm the below connection is correct as I still encounter "Unable to connect to target" when make flash.

GND (STLink-V2) --> GND (STM32 Discovery Debug pin)
SWDIO (STLink-V2) --> SWDIO (STM32 Discovery Debug pin)
SWCLK (STLink-V2) --> SWCLK (STM32 Discovery Debug pin)
RST (STLink-V2) -> NRST (STM32 Discovery Debug pin)

arnaud
Bitcraze
Posts: 1672
Joined: Tue Feb 06, 2007 12:36 pm

Re: Using STLink-v2 with debug adapter

Post by arnaud » Mon Mar 26, 2018 1:00 pm

Do you mean this one? http://uk.farnell.com/productimages/sta ... 523-40.jpg. If so, why not using a ribbon cable?

Could you copy-paste the console you get from openocd when running make flash?

KiteFlier
Beginner
Posts: 3
Joined: Sat Mar 24, 2018 8:53 am

Re: Using STLink-v2 with debug adapter

Post by KiteFlier » Mon Mar 26, 2018 1:12 pm

Hi,

Thanks.
Mine is http://artofcircuits.com/product/st-li ... lic-case.

Console output is as follows:

Code: Select all

openocd -d2 -f interface/stlink-v2.cfg  -f target/stm32f4x_stlink.cfg -c init -c targets -c "reset halt" \
                 -c "flash write_image erase cf2.bin 0x8004000 bin" \
                 -c "verify_image cf2.bin 0x8004000 bin" -c "reset run" -c shutdown
Open On-Chip Debugger 0.9.0 (2018-01-24-01:05)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
debug_level: 2
WARNING: target/stm32f4x_stlink.cfg is deprecated, please switch to target/stm32f4x.cfg
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: 2000 kHz
adapter_nsrst_delay: 100
none separate
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : clock speed 1800 kHz
Info : STLINK v2 JTAG v17 API v2 SWIM v4 VID 0x0483 PID 0x3748
Info : using stlink api v2
Info : Target voltage: 3.284042
Error: init mode failed (unable to connect to the target)
in procedure 'init' 
in procedure 'ocd_bouncer'
Makefile:361: recipe for target 'flash' failed
make: *** Error 1

arnaud
Bitcraze
Posts: 1672
Joined: Tue Feb 06, 2007 12:36 pm

Re: Using STLink-v2 with debug adapter

Post by arnaud » Wed Apr 04, 2018 9:35 am

Are you sure the ST-Link is working properly, do you have any other board to test it with. If you want you can send a picture of your setup I could double check the cabling to make sure it is correct.

Post Reply