Difference between revisions of "STLink"

From PaparazziUAV
Jump to navigation Jump to search
m
(update)
Line 1: Line 1:
{| align=right
<div style="float: right; width: 20%">
|-
<categorytree style="float:right; clear:right; margin-left:1ex; border: 1px solid gray; padding: 0.7ex;" mode=pages>Firmware Flashing</categorytree>
|<categorytree style="float:right; clear:right; margin-left:1ex; border: 1px solid gray; padding: 0.7ex;" mode=pages>Firmware Flashing</categorytree>
</div>
|}


<div style="float: right; width: 60%">
[[Image:St-link.jpg|right|450px]]
</div>
__TOC__
__TOC__


[[Image:St-link.jpg|right|300px|ST-LinkV2 (stm32f4-Discovery)]]
[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 (needs a bit more work when used with [https://github.com/texane/stlink Tools from texane's code]).
[http://www.arm.com/products/system-ip/debug-trace/coresight-soc-components/serial-wire-debug.php SWD] is a program und debug protocoll for ARM processors.
 
Every STM discovery board comes with a ST-LinkV2 on board (except STM32VL comes with ST-LinkV1).
 
Every dicovery board from STM comes wih a [http://www.st.com/web/catalog/tools/FM146/CL1984/SC724/SS1677/PF251168 ST-LinkV2], except STM32VL (ST-LinkV1).


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 31: Line 34:
|}
|}


Pin 1 has a withe dot on the left side.
Pin 1 is marked with a white dot.


==Needed Tools==
==Install Software==
st-flash and st-util are needed [https://github.com/texane/stlink Tools from texane]
st-flash and st-util are needed [https://github.com/texane/stlink Tools from texane]


Line 43: Line 46:
  make
  make


copy in the suitable directory (so it can be accessed direct with terminal, without enviroment variable)
copy the two tools into bin directory
  sudo cp st-flash /usr/bin
  sudo cp st-flash /usr/bin
  sudo cp st-util /usr/bin
  sudo cp st-util /usr/bin
Line 51: Line 54:
  sudo udevadm control --reload-rules
  sudo udevadm control --reload-rules


ST-LinkV1 requires a bit different treatment, read the [https://github.com/texane/stlink/blob/master/README Readme.txt]


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


==Test it==
==Airframe.xml setup==
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.
Connect the ST-Link to the MCU.
Line 82: Line 67:
Set '''STLINK=y'''<br/>
Set '''STLINK=y'''<br/>


==Update the STLink to blackmagic probe==
==Update the ST-Link to blackmagic probe==
 
The STM32F103 (STLink MCU) can be flashed with the blackmagic's firware.<br/>
The STM32F103 (STLink MCU) can be flashed with the blackmagic's firware.<br/>
This is irveversable !
This is irveversable !

Revision as of 10:42, 4 December 2013

St-link.jpg


SWD is a program und debug protocoll for ARM processors.

Every STM discovery board comes with a ST-LinkV2 on board (except STM32VL comes with ST-LinkV1).

Every dicovery board from STM comes wih a ST-LinkV2, except STM32VL (ST-LinkV1).

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 is marked with a white dot.

Install Software

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 the two tools into bin directory

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

ST-LinkV1 requires a bit different treatment, read the Readme.txt


Airframe.xml setup

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 ST-Link 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