Skip to content

Commit b463d50

Browse files
committed
Update documentation removing all sg-utils notes
Just libusb now. Verified the modprobe.conf on Ubuntu 10.04
1 parent 3dd1add commit b463d50

6 files changed

+54
-68
lines changed

10-stlink.rules

-43
This file was deleted.

README

+38-12
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,47 @@ called stlink and there are 2 versions:
1111
. STLINKv1 uses SCSI passthru commands over USB,
1212
. STLINKv2 uses raw USB commands.
1313

14-
It means that if you are using a STM32VL board, you have to install and load
15-
SCSI related software. First, load the sg kernel module:
16-
# modprobe sg
14+
Common requirements
15+
~~~~~~~~~~~~~~~~~~~
1716

18-
Then, you need to install the package libsgutils2-dev. On Ubuntu:
19-
# sudo apt-get install libsgutils2-dev
17+
libusb-1.0 (You probably already have this, but you'll need the
18+
development version to compile)
2019

21-
LIBUSB is required for both cases.
20+
IF YOU HAVE AN STLINKv1
21+
~~~~~~~~~~~~~~~~~~~~~~~
22+
The STLINKv1's SCSI emulation is very broken, so the best thing to do
23+
is tell your operating system to completely ignore it.
24+
25+
Options (do one of these before you plug it in)
26+
*) modprobe -r usb-storage && modprobe usb-storage quirks=483:3744:i
27+
or *)1. add "options usb-storage quirks=483:3744:i" to /etc/modprobe.conf
28+
*)2. modprobe -r usb-storage && modprobe usb-storage
29+
or *)1. cp stlink_v1.modprobe.conf /etc/modprobe.d
30+
*)2. modprobe -r usb-storage && modprobe usb-storage
31+
32+
IF YOU HAVE AN STLINKv2
33+
~~~~~~~~~~~~~~~~~~~~~~~
34+
35+
You're ready to go :)
2236

2337
To run the gdb server, do (you do not need sudo if you have set up
2438
permissions correctly):
25-
$ make -C build && sudo ./build/st-util [/dev/sgX]
39+
$ make && [sudo] ./gdbserver/st-util
40+
41+
There are a few options:
42+
43+
./gdbserver/st-util - usage:
2644

27-
Currently, the GDB server listening port is hardcoded to 4242:
45+
-h, --help Print this help
46+
-vXX, --verbose=XX specify a specific verbosity level (0..99)
47+
-v, --verbose specify generally verbose logging
48+
-s X, --stlink_version=X
49+
Choose what version of stlink to use, (defaults to 2)
50+
-1, --stlinkv1 Force stlink version 1
51+
-p 4242, --listen_port=1234
52+
Set the gdb server listen port. (default port: 4242)
2853

29-
Then, in gdb:
54+
Then, in gdb: (remember, you need to run an _ARM_ gdb, not an x86 gdb)
3055
(gdb) target remote :4242
3156

3257
Have fun!
@@ -50,13 +75,14 @@ for GDB.
5075
Setting up udev rules
5176
=====================
5277

53-
For convenience, you may install udev rules file, 10-stlink.rules, located
78+
For convenience, you may install udev rules file, 49-stlinkv2.rules, located
5479
in the root of repository. You will need to copy it to /etc/udev/rules.d,
5580
and then either reboot or execute
5681
$ udevadm control --reload-rules
5782

58-
Udev will now create a /dev/stlink file, which will point at appropriate
59-
/dev/sgX device. Good to not accidentally start debugging your flash drive.
83+
Udev will now create a /dev/stlinkv2_XX file, with the appropriate permissions.
84+
This is currently all the device is for, (only one stlinkv2 is supported at
85+
any time presently)
6086

6187
Running programs from SRAM
6288
==========================

TODO

-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
. documentation
88
. make README points to doc/tutorial
99

10-
. remove libsg dependency using:
11-
https://github.com/afaerber/stlink/tree/master/libstlink
12-
1310
. compile and test a realtime kernel, for instance:
1411
http://www.chibios.org/dokuwiki/doku.php?id=chibios:articles:stm32l_discovery
1512
svn checkout https://chibios.svn.sourceforge.net/svnroot/chibios/trunk ;

src/stlink-sg.c

+15-9
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
The stlink related constants kindly provided by Oliver Spencer (OpenOCD)
1313
for use in a GPL compatible license.
1414
15-
Code format ~ TAB = 8, K&R, linux kernel source, golang oriented
1615
Tested compatibility: linux, gcc >= 4.3.3
1716
1817
The communication is based on standard USB mass storage device
@@ -31,10 +30,18 @@
3130
CBW - Command Block Wrapper
3231
CSW - Command Status Wrapper
3332
RFU - Reserved for Future Use
34-
scsi_pt - SCSI pass-through
35-
sg - SCSI generic
3633
37-
* usb-storage.quirks
34+
Originally, this driver used scsi pass through commands, which required the
35+
usb-storage module to be loaded, providing the /dev/sgX links. The USB mass
36+
storage implementation on the STLinkv1 is however terribly broken, and it can
37+
take many minutes for the kernel to give up.
38+
39+
However, in Nov 2011, the scsi pass through was replaced by raw libusb, so
40+
instead of having to let usb-storage struggle with the device, and also greatly
41+
limiting the portability of the driver, you can now tell usb-storage to simply
42+
ignore this device completely.
43+
44+
usb-storage.quirks
3845
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob_plain;f=Documentation/kernel-parameters.txt
3946
Each entry has the form VID:PID:Flags where VID and PID are Vendor and Product
4047
ID values (4-digit hex numbers) and Flags is a set of characters, each corresponding
@@ -54,18 +61,17 @@
5461
5562
Example: quirks=0419:aaf5:rl,0421:0433:rc
5663
http://permalink.gmane.org/gmane.linux.usb.general/35053
64+
65+
For the stlinkv1, you just want the following
5766
58-
modprobe -r usb-storage && modprobe usb-storage quirks=483:3744:l
67+
modprobe -r usb-storage && modprobe usb-storage quirks=483:3744:i
5968
6069
Equivalently, you can add a line saying
6170
62-
options usb-storage quirks=483:3744:l
71+
options usb-storage quirks=483:3744:i
6372
6473
to your /etc/modprobe.conf or /etc/modprobe.d/local.conf (or add the "quirks=..."
6574
part to an existing options line for usb-storage).
66-
67-
https://wiki.kubuntu.org/Kernel/Debugging/USB explains the protocoll and
68-
would allow to replace the sg access to pure libusb access
6975
*/
7076

7177

stlink.modprobe.conf

-1
This file was deleted.

stlink_v1.modprobe.conf

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
options usb-storage quirks=483:3744:i

0 commit comments

Comments
 (0)