Difference between revisions of "STLink"

From PaparazziUAV
Jump to navigation Jump to search
(added Category:Developer_Documentation)
m
Line 9: Line 9:
[http://www.arm.com/products/system-ip/debug-trace/coresight-soc-components/serial-wire-debug.php SWD] can be used to upload the firmware to stm32fx MCU.  
[http://www.arm.com/products/system-ip/debug-trace/coresight-soc-components/serial-wire-debug.php SWD] can be used to upload the firmware to stm32fx MCU.  


A ST-Link is needed, any stm32-discovery board has a ST-LinkV2 on it (starts @ 8€). stm32vl discovery has a ST-LinkV1.
A ST-Link is needed, any STM32-Discovery board has a ST-LinkV2 on it (starts @ 8€). STM32VL Discovery has a ST-LinkV1 (needs a bit more work when used with [https://github.com/texane/stlink Tools from texane's code]).


A standard ST-Link costs from 17€
A standard ST-LinkV2 costs from 17€
==SWD Header==
==SWD Header==
{| border="1" cellspacing="0" style="text-align:center" cellpadding="2%"
{| border="1" cellspacing="0" style="text-align:center" cellpadding="2%"
Line 67: Line 67:


stm32f4-discovery shoud be found at /dev/stlinkv2_2
stm32f4-discovery shoud be found at /dev/stlinkv2_2
'''how can that be tested ? please fix me :)'''


usb device
usb device
Line 76: Line 75:


Connect the ST-Link to the MCU.
Connect the ST-Link to the MCU.
If a complete stm32fx-discovery board is used, CN3 jumpers need to be set. To program a external MCU, remove CN3 jumpers and connect the external MCU with the SWD header.
If a complete STM32F-Discovery board is used, CN3 jumpers need to be set. To program a external MCU, remove CN3 jumpers and connect the external MCU with the SWD header.


To use SWD<br/>
To use SWD<br/>

Revision as of 08:26, 17 November 2013

ST-LinkV2 (stm32f4-Discovery)

SWD can be used to upload the firmware to stm32fx MCU.

A ST-Link is needed, any STM32-Discovery board has a ST-LinkV2 on it (starts @ 8€). STM32VL Discovery has a ST-LinkV1 (needs a bit more work when used with Tools from texane's code).

A standard ST-LinkV2 costs from 17€

SWD Header

Pin\Function CN2 Use
●1 VDD_Target Voltage supply for target
2 SWDCLK SWD clock
3 GND Ground
4 SWDIO SWD data input/output
5 NRST reset for target
6 SWO reserved

Pin 1 has a withe dot on the left side.

Needed Tools

st-flash and st-util are needed Tools from texane

download and compile

git clone git://github.com/texane/stlink.git stlink
cd stlink
./autogen.sh
./configure
make

copy in the suitable directory (so it can be accessed direct with terminal, without enviroment variable)

sudo cp st-flash /usr/bin
sudo cp st-util /usr/bin

add udev rules (replace user with your username)

sudo cp /home/user/stlink/49-stlinkv*.rules /etc/udev/rules.d
sudo udevadm control --reload-rules


For ST-LinkV1 take a look at the readme.txt !

Test it

To copy the file from the MCU

st-flash read ~/STM32F4-Discovery.bin 0x8000000 0x100000


Output (just a example for the factory preload image)

INFO src/stlink-usb.c: -- exit_dfu_mode
INFO src/stlink-common.c: Loading device parameters....
src/stlink-common.c: Device connected is: F4 device, id 0x10016413
INFO src/stlink-common.c: SRAM size: 0x30000 bytes (192 KiB), Flash: 0x100000 bytes (1024 KiB) in pages of 16384 bytes


stm32f4-discovery shoud be found at /dev/stlinkv2_2

usb device

lsusb
Bus 002 Device 007: ID 0483:3748 SGS Thomson Microelectronics ST-LINK/V2

Howto

Connect the ST-Link to the MCU. If a complete STM32F-Discovery board is used, CN3 jumpers need to be set. To program a external MCU, remove CN3 jumpers and connect the external MCU with the SWD header.

To use SWD
Set FLASH_MODE=SWD
To use stlink (requires line above)
Set STLINK=y

Update the STLink to blackmagic probe

The STM32F103 (STLink MCU) can be flashed with the blackmagic's firware.
This is irveversable !

How to upload the blackmagic probe firmware to the STLink of a discovery board