--- /dev/null
+# This file was taken from arm-utilites project, located at
+# http://code.google.com/p/arm-utilities/, which is licensed under GPL3.
+# An explicit permission to include any code from that project in
+# this one under BSD license was granted by arm-utilites author, Donald Becker.
+
+# This file watches for a STMicro ST-Link or STM32VLDiscovery board
+# and creates a device named /dev/stlink
+# See udev(7) for syntax.
+#
+# Written 2010,2011 by Donald Becker
+#
+# The STLink on the Discovery has a USB ID 0483:3744 and presents itself
+# as a mass storage (i.e. SCSI) device. The SCSI emulation is signficantly
+# broken, and the kernel spews error reports for a while until it is
+# accepted. Further problems are encountered when if it is automatically
+# mounted.
+#
+# Options that may prevent the mount are
+# ENV{UDISKS_PRESENTATION_HIDE}:="1",
+# ENV{UDISKS_PRESENTATION_NOPOLICY}:="1",
+# ENV{DM_UDEV_DISABLE_DISK_RULES_FLAG}:="1"
+
+ACTION!="add|change", GOTO="stlink_rules_end"
+
+SUBSYSTEMS=="usb", ATTR{idVendor}=="0483", ATTR{idProduct}=="3744", \
+ MODE="0664", GROUP="tape", NAME="stlinkusb%n", ENV{STLINK}="1", \
+ ENV{UDISKS_PRESENTATION_HIDE}:="1", \
+ ENV{UDISKS_PRESENTATION_NOPOLICY}:="1", \
+ ENV{DM_UDEV_DISABLE_DISK_RULES_FLAG}:="1", \
+ OPTIONS="last_rule"
+
+# Other possible settings:
+# OPTIONS="last_rule", ATTRS{vendor}=="STM32"
+
+KERNEL=="sg[0-9]*", STLINK=="1", MODE="0664", GROUP:="tape", \
+ NAME+="stlink-sg%n", SYMLINK+="stlink", \
+ ENV{UDISKS_PRESENTATION_HIDE}:="1", \
+ ENV{UDISKS_PRESENTATION_NOPOLICY}:="1", \
+ ENV{DM_UDEV_DISABLE_DISK_RULES_FLAG}:="1"
+
+SUBSYSTEM=="scsi", ATTR{vendor}=="STM32", MODE="0664", GROUP="tape", NAME="stlinksg-scsi%n", SYMLINK+="stlinkscsi", OPTIONS="last_rule"
+
+LABEL="stlink_rules_end"
HOWTO
=====
+First, load the sg kernel module.
+# modprobe sg
+
To run the gdb server, do (you do not need sudo if you have set up
permissions correctly):
$ make -C build && sudo ./build/st-util 1234 /dev/sg1
Remember that you can shorten the commands. `tar ext :1111' is good enough
for GDB.
+Setting up udev rules
+=====================
+
+For convenience, you may install udev rules file, 10-stlink.rules, located
+in the root of repository. You will need to copy it to /etc/udev/rules.d,
+and then either reboot or execute
+$ udevadm control --reload-rules
+
+Udev will now create a /dev/stlink file, which will point at appropriate
+/dev/sgX device. Good to not accidentally start debugging your flash drive.
+
Running programs from SRAM
==========================