Difference between revisions of "STLink"
Line 49: | Line 49: | ||
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/> | ||
===Two STLinkV2 Method=== | |||
Hardware Setup: | |||
One STLinkV2 (connected via USB) is programming the other one. Change the 4 Solder jumpers on the bottom of the target STLinkV2 from "DEFAULT" to "REVERSED".<br/> | |||
Connections between the two STLinks | |||
{|border="1" cellspacing="0" style="text-align:center" cellpadding="6" | |||
|+'''Connections [Header-Pin]''' | |||
!''Use''!!''From Programmer''!!''To Target'' | |||
|- | |||
|5V||P2-5V||P2-5V | |||
|- | |||
|SWDIO||CN2-4||CN3-2 | |||
|- | |||
|SWDCLK||CN2-2||CN3-3 | |||
|- | |||
|GND||CN2-3||CN3-4 | |||
|} | |||
Download and build the Firmware | |||
git clone https://github.com/blacksphere/blackmagic | |||
cd blackmagic | |||
git submodule init | |||
git submodule update | |||
make | |||
cd src | |||
make clean | |||
make PROBE_HOST=stlink | |||
Remove the readout protection, erase and flash | |||
openocd -f interface/stlink-v2.cfg -f target/stm32f1x_stlink.cfg -c "init" -c "halt" -c "stm32f1x unlock 0" -c "shutdown" | |||
st-flash erase | |||
st-flash --reset write blackmagic.bin 0x8002000 | |||
st-flash write blackmagic_dfu.bin 0x8000000 | |||
===Dokumentation=== | |||
[http://esden.net/2014/12/29/black-magic-discovery Black Magic Discovery from Esden] <-- This also describes how to remove the read out protection. <br/> | [http://esden.net/2014/12/29/black-magic-discovery Black Magic Discovery from Esden] <-- This also describes how to remove the read out protection. <br/> |
Revision as of 11:46, 2 April 2015
Every STM discovery / eval board comes with a ST-Link V2 on board, with one exception; the STM32VL version comes with a ST-Link V1.
SWD Header
Install Software
The st-flash and st-util tools are needed, provied by texane
Download and compile
$ cd /opt $ git clone git://github.com/texane/stlink.git stlink $ cd stlink $ ./autogen.sh $ ./configure $ make
Set enviroment variable
$ exportline="PATH=$PATH:/opt/stlink" $ if grep -Fxq "$exportline" ~/.profile; then echo nothing to do ; else echo $exportline >> ~/.profile; fi $ source ~/.profile
Add udev rules
$ sudo cp /opt/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 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.
To use SWD via STLink as default:
Set FLASH_MODE=STLINK
Update the ST-Link to blackmagic probe
The STM32F103 (STLink MCU) can be flashed with the blackmagic's firware.
Two STLinkV2 Method
Hardware Setup:
One STLinkV2 (connected via USB) is programming the other one. Change the 4 Solder jumpers on the bottom of the target STLinkV2 from "DEFAULT" to "REVERSED".
Connections between the two STLinks
Use | From Programmer | To Target |
---|---|---|
5V | P2-5V | P2-5V |
SWDIO | CN2-4 | CN3-2 |
SWDCLK | CN2-2 | CN3-3 |
GND | CN2-3 | CN3-4 |
Download and build the Firmware
git clone https://github.com/blacksphere/blackmagic cd blackmagic git submodule init git submodule update make cd src make clean make PROBE_HOST=stlink
Remove the readout protection, erase and flash
openocd -f interface/stlink-v2.cfg -f target/stm32f1x_stlink.cfg -c "init" -c "halt" -c "stm32f1x unlock 0" -c "shutdown" st-flash erase st-flash --reset write blackmagic.bin 0x8002000 st-flash write blackmagic_dfu.bin 0x8000000
Dokumentation
Black Magic Discovery from Esden <-- This also describes how to remove the read out protection.
embdev.net page