4 First, you have to know there are several boards supported by the software.
5 Those boards use a chip to translate from USB to JTAG commands. The chip is
6 called stlink and there are 2 versions:
7 . STLINKv1, present on STM32VL discovery kits,
8 . STLINKv2, present on STM32L discovery and later kits.
10 2 different transport layers are used:
11 . STLINKv1 uses SCSI passthru commands over USB,
12 . STLINKv2 uses raw USB commands.
17 . libusb-1.0 (You probably already have this, but you'll need the
18 development version to compile)
21 IF YOU HAVE AN STLINKv1
22 ~~~~~~~~~~~~~~~~~~~~~~~
23 The STLINKv1's SCSI emulation is very broken, so the best thing to do
24 is tell your operating system to completely ignore it.
26 Options (do one of these before you plug it in)
27 *) modprobe -r usb-storage && modprobe usb-storage quirks=483:3744:i
28 or *)1. add "options usb-storage quirks=483:3744:i" to /etc/modprobe.conf
29 *)2. modprobe -r usb-storage && modprobe usb-storage
30 or *)1. cp stlink_v1.modprobe.conf /etc/modprobe.d
31 *)2. modprobe -r usb-storage && modprobe usb-storage
33 IF YOU HAVE AN STLINKv2
34 ~~~~~~~~~~~~~~~~~~~~~~~
38 To run the gdb server, do (you do not need sudo if you have set up
39 permissions correctly):
40 $ make && [sudo] ./st-util
42 There are a few options:
46 -h, --help Print this help
47 -vXX, --verbose=XX specify a specific verbosity level (0..99)
48 -v, --verbose specify generally verbose logging
49 -s X, --stlink_version=X
50 Choose what version of stlink to use, (defaults to 2)
51 -1, --stlinkv1 Force stlink version 1
52 -p 4242, --listen_port=1234
53 Set the gdb server listen port. (default port: 4242)
55 Then, in gdb: (remember, you need to run an _ARM_ gdb, not an x86 gdb)
56 (gdb) target remote :4242
60 Resetting the chip from GDB
61 ===========================
63 You may reset the chip using GDB if you want. You'll need to use `target
64 extended-remote' command like in this session:
65 (gdb) target extended-remote localhost:4242
66 Remote debugging using localhost:4242
67 0x080007a8 in _startup ()
69 Kill the program being debugged? (y or n) y
71 Starting program: /home/whitequark/ST/apps/bally/firmware.elf
73 Remember that you can shorten the commands. `tar ext :4242' is good enough
79 For convenience, you may install udev rules file, 49-stlinkv*.rules, located
80 in the root of repository. You will need to copy it to /etc/udev/rules.d,
81 and then either reboot or execute
82 $ udevadm control --reload-rules
84 Udev will now create a /dev/stlinkv2_XX or /dev/stlinkv1_XX file, with the appropriate permissions.
85 This is currently all the device is for, (only one stlink of each version is supported at
88 Running programs from SRAM
89 ==========================
91 You can run your firmware directly from SRAM if you want to. Just link
92 it at 0x20000000 and do
93 (gdb) load firmware.elf
95 It will be loaded, and pc will be adjusted to point to start of the
96 code, if it is linked correctly (i.e. ELF has correct entry point).
101 The GDB stub ships with a correct memory map, including the flash area.
102 If you would link your executable to 0x08000000 and then do
103 (gdb) load firmware.elf
104 then it would be written to the memory.
110 Q: My breakpoints do not work at all or only work once.
112 A: Optimizations can cause severe instruction reordering. For example,
113 if you are doing something like `REG = 0x100;' in a loop, the code may
114 be split into two parts: loading 0x100 into some intermediate register
115 and moving that value to REG. When you set up a breakpoint, GDB will
116 hook to the first instruction, which may be called only once if there are
117 enough unused registers. In my experience, -O3 causes that frequently.
119 Q: At some point I use GDB command `next', and it hangs.
121 A: Sometimes when you will try to use GDB `next' command to skip a loop,
122 it will use a rather inefficient single-stepping way of doing that.
123 Set up a breakpoint manually in that case and do `continue'.
125 Currently known working combinations of programmer and target
126 =============================================================
128 STLink v1 (as found on the 32VL Discovery board)
130 Known Working Targets:
131 * STM32F100xx (Medium Density VL)
132 * STM32F103 (according to jpa- on ##stm32)
137 STLink v2 (as found on the 32L and F4 Discovery boards)
138 Known Working Targets:
139 * STM32F100xx (Medium Density VL, as on the 32VL Discovery board)
140 * STM32L1xx (STM32L Discovery board)
141 * STM32F107RC, STM32L151RB, STM32F205RE and STM32F405RE on a custom boards
142 (https://github.com/UweBonnes/wiki_fuer_alex/layout/usps...)
143 * STM32F407xx (STM32F4 Discovery board)
145 Please report any and all known working combinations so I can update this!