Added udev rules file.
authorPeter Zotov <whitequark@whitequark.org>
Mon, 4 Apr 2011 15:10:04 +0000 (19:10 +0400)
committerPeter Zotov <whitequark@whitequark.org>
Mon, 4 Apr 2011 16:20:47 +0000 (20:20 +0400)
10-stlink.rules [new file with mode: 0644]
README

diff --git a/10-stlink.rules b/10-stlink.rules
new file mode 100644 (file)
index 0000000..a47b2f9
--- /dev/null
@@ -0,0 +1,43 @@
+# 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"
diff --git a/README b/README
index 920786ebf407b57d062bafbfbba5ac5484630004..58bd3ca2ae26236cd83c28fd9a38b13e19c93d26 100644 (file)
--- a/README
+++ b/README
@@ -1,6 +1,9 @@
 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
@@ -26,6 +29,17 @@ Starting program: /home/whitequark/ST/apps/bally/firmware.elf
 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
 ==========================