From d1c3176f3a7cdbd7a0c4df832c627bc508a75296 Mon Sep 17 00:00:00 2001 From: Peter Zotov Date: Mon, 4 Apr 2011 19:10:04 +0400 Subject: [PATCH 1/1] Added udev rules file. --- 10-stlink.rules | 43 +++++++++++++++++++++++++++++++++++++++++++ README | 14 ++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 10-stlink.rules diff --git a/10-stlink.rules b/10-stlink.rules new file mode 100644 index 0000000..a47b2f9 --- /dev/null +++ b/10-stlink.rules @@ -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 920786e..58bd3ca 100644 --- 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 ========================== -- 2.30.2