Forum: Mikrocontroller und Digitale Elektronik STM32-Discovery unter Linux flashen/debuggen


von Befedo (Gast)


Lesenswert?

Hallo, liebe µC Community...

Ich versuche gerade, wie im Betreff zu erkennen ist, ein STM32-Discovery 
Board mittels openOCD zu flashen/debuggen. Mein größtes Problem ist, 
dass ich unter Linux arbeite und auf diesem Sektor recht wenig Erfahrung 
habe.

Doch erstmal kurz zu meinem System/Problem:
->Eclipse IDE
->Codesourcery Toolchain
->openOCD 0.4.0

Jetzt fehlt mir allerdings ein Config Script *.cfg jeweils für den 
STLink und das Board, weshalb ich hier nachfragen würde ob Jemand sowas 
schonmal für das STM32-Discovery implementiert hat!?

Wenn man jetzt Google etwas bemüht, ist dieses Problem weiter 
verbreitet, doch eine Lösung seitens openOCD noch nicht in sicht. Der 
acces Test wie hier (http://capitanio.org/mlink/index.html) beschrieben 
läuft jedenfalls, siehe Konsolenotput:
1
cp stlink-access-test /tmp/
2
sudo /tmp/stlink-access-test /dev/sg2
3
*** stlink access test ***
4
Using sg_lib 1.58 20100329 : scsi_pt 2.05 20100321
5
6
*** stlink_open [/dev/sg2] ***
7
found bsg_major=253
8
open /dev/sg2 with flags=0x802
9
10
*** stlink_version ***
11
CDB[ 0xf1 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00]
12
      duration=941 ms
13
      notice: requested 96 bytes but got 6 bytes)
14
data_in_len = 6
15
 0x12 0xc0 0x83 0x04 0x44 0x37
16
st vid         = 0x0483 [0x0483]
17
stlink pid     = 0x3744 [0x3744]
18
stlink version = 0x1jtag version   = 0xbswim version   = 0x0
19
    notice: swim interface is not supported
20
21
*** stlink_force_open ***
22
23
*** stlink_current_mode ***
24
CDB[ 0xf5 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00]
25
      duration=10 ms
26
      notice: requested 96 bytes but got 2 bytes)
27
data_in_len = 2
28
 0x00 0x00
29
 mode: dfu
30
31
*** trying hard to open a broken stlink, please wait
32
33
*** stlink_exit_dfu_mode ***
34
CDB[ 0xf3 0x07 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00]
35
ioctl(SG_IO v3) failed with os_err (errno) = 19
36
scsi_pt error: pass through os error: No such device
37
38
*** stlink_close ***
39
*** wait 5000 ms
40
41
*** stlink_open [/dev/sg2] ***
42
open /dev/sg2 with flags=0x802
43
44
*** stlink_version ***
45
CDB[ 0xf1 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00]
46
      duration=4 ms
47
      notice: requested 96 bytes but got 6 bytes)
48
data_in_len = 6
49
 0x12 0xc0 0x83 0x04 0x44 0x37
50
st vid         = 0x0483 [0x0483]
51
stlink pid     = 0x3744 [0x3744]
52
stlink version = 0x1jtag version   = 0xbswim version   = 0x0
53
    notice: swim interface is not supported
54
55
*** mode_force_swd ***
56
57
*** stlink_current_mode ***
58
CDB[ 0xf5 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00]
59
      duration=6 ms
60
      notice: requested 96 bytes but got 2 bytes)
61
data_in_len = 2
62
 0x01 0x00
63
 mode: mass
64
65
*** mode_force_swd: 1. attempt
66
67
*** stlink_enter_swd_mode ***
68
CDB[ 0xf2 0x20 0xa3 0x00 0x00 0x00 0x00 0x00 0x00 0x00]
69
      duration=1991 ms
70
  transport: Host_status=0x05 [DID_ABORT]
71
Driver_status=0x00 [DRIVER_OK, SUGGEST_OK]
72
73
*** stlink_current_mode ***
74
CDB[ 0xf5 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00]
75
      duration=10 ms
76
      notice: requested 96 bytes but got 2 bytes)
77
data_in_len = 2
78
 0x02 0x00
79
 mode: jtag or swd
80
81
*** stlink_core_id ***
82
CDB[ 0xf2 0x22 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00]
83
      duration=10 ms
84
      notice: requested 96 bytes but got 4 bytes)
85
data_in_len = 4
86
 0x77 0x14 0xa0 0x1b
87
88
*** stlink_get_core_status ***
89
CDB[ 0xf2 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00]
90
      duration=10 ms
91
      notice: requested 96 bytes but got 2 bytes)
92
data_in_len = 2
93
 0x80 0x00
94
  core mode: running
95
96
*** stlink_reset_core ***
97
CDB[ 0xf2 0x03 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00]
98
      duration=10 ms
99
      notice: requested 96 bytes but got 2 bytes)
100
data_in_len = 2
101
 0x80 0x00
102
  core reset: ok
103
104
*** stlink_get_core_status ***
105
CDB[ 0xf2 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00]
106
      duration=11 ms
107
      notice: requested 96 bytes but got 2 bytes)
108
data_in_len = 2
109
 0x81 0x00
110
  core mode: halted
111
112
*** stlink_read_all_regs ***
113
CDB[ 0xf2 0x04 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00]
114
      duration=8 ms
115
      notice: requested 96 bytes but got 0 bytes)
116
r 0 = 0x00000005
117
r 1 = 0xb3d7f7fa
118
r 2 = 0xe000ed18
119
r 3 = 0x00000003
120
r 4 = 0x0000000a
121
r 5 = 0xff767cf8
122
r 6 = 0xa2fcf7fb
123
r 7 = 0xb3d7f7fa
124
r 8 = 0x45b5db4d
125
r 9 = 0xf7fbf97d
126
r10 = 0xfef3adfe
127
r11 = 0xbc77fddf
128
r12 = 0x20000000
129
r13 = 0x20000400
130
r14 = 0xffffffff
131
r15 = 0x08000b4c
132
xpsr       = 0x01000000
133
main_sp    = 0x20000400
134
process_sp = 0xfad6bbfc
135
rw         = 0xfad6bbfc
136
rw2        = 0x00000000
137
138
*** stlink_step ***
139
CDB[ 0xf2 0x0a 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00]
140
      duration=6 ms
141
      notice: requested 96 bytes but got 2 bytes)
142
data_in_len = 2
143
 0x80 0x00
144
  step core: ok
145
146
*** stlink_read_all_regs ***
147
CDB[ 0xf2 0x04 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00]
148
      duration=9 ms
149
      notice: requested 96 bytes but got 0 bytes)
150
r 0 = 0x00000005
151
r 1 = 0xb3d7f7fa
152
r 2 = 0xe000ed18
153
r 3 = 0x00000003
154
r 4 = 0x0000000a
155
r 5 = 0xff767cf8
156
r 6 = 0xa2fcf7fb
157
r 7 = 0xb3d7f7fa
158
r 8 = 0x45b5db4d
159
r 9 = 0xf7fbf97d
160
r10 = 0xfef3adfe
161
r11 = 0xbc77fddf
162
r12 = 0x20000000
163
r13 = 0x20000400
164
r14 = 0x08000b51
165
r15 = 0x08000b94
166
xpsr       = 0x01000000
167
main_sp    = 0x20000400
168
process_sp = 0xfad6bbfc
169
rw         = 0xfad6bbfc
170
rw2        = 0x00000000
171
172
*** stlink_read_reg (0) ***
173
CDB[ 0xf2 0x05 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00]
174
      duration=6 ms
175
      notice: requested 96 bytes but got 4 bytes)
176
data_in_len = 4
177
 0x05 0x00 0x00 0x00
178
r_idx ( 0) = 0x00000005
179
180
*** stlink_read_reg (1) ***
181
CDB[ 0xf2 0x05 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00]
182
      duration=6 ms
183
      notice: requested 96 bytes but got 4 bytes)
184
data_in_len = 4
185
 0xfa 0xf7 0xd7 0xb3
186
r_idx ( 1) = 0xb3d7f7fa
187
188
*** stlink_read_reg (2) ***
189
CDB[ 0xf2 0x05 0x02 0x00 0x00 0x00 0x00 0x00 0x00 0x00]
190
      duration=6 ms
191
      notice: requested 96 bytes but got 4 bytes)
192
data_in_len = 4
193
 0x18 0xed 0x00 0xe0
194
r_idx ( 2) = 0xe000ed18
195
196
*** stlink_read_reg (3) ***
197
CDB[ 0xf2 0x05 0x03 0x00 0x00 0x00 0x00 0x00 0x00 0x00]
198
      duration=6 ms
199
      notice: requested 96 bytes but got 4 bytes)
200
data_in_len = 4
201
 0x03 0x00 0x00 0x00
202
r_idx ( 3) = 0x00000003
203
204
*** stlink_read_reg (4) ***
205
CDB[ 0xf2 0x05 0x04 0x00 0x00 0x00 0x00 0x00 0x00 0x00]
206
      duration=6 ms
207
      notice: requested 96 bytes but got 4 bytes)
208
data_in_len = 4
209
 0x0a 0x00 0x00 0x00
210
r_idx ( 4) = 0x0000000a
211
212
*** stlink_read_reg (5) ***
213
CDB[ 0xf2 0x05 0x05 0x00 0x00 0x00 0x00 0x00 0x00 0x00]
214
      duration=6 ms
215
      notice: requested 96 bytes but got 4 bytes)
216
data_in_len = 4
217
 0xf8 0x7c 0x76 0xff
218
r_idx ( 5) = 0xff767cf8
219
220
*** stlink_read_reg (6) ***
221
CDB[ 0xf2 0x05 0x06 0x00 0x00 0x00 0x00 0x00 0x00 0x00]
222
      duration=6 ms
223
      notice: requested 96 bytes but got 4 bytes)
224
data_in_len = 4
225
 0xfb 0xf7 0xfc 0xa2
226
r_idx ( 6) = 0xa2fcf7fb
227
228
*** stlink_read_reg (7) ***
229
CDB[ 0xf2 0x05 0x07 0x00 0x00 0x00 0x00 0x00 0x00 0x00]
230
      duration=6 ms
231
      notice: requested 96 bytes but got 4 bytes)
232
data_in_len = 4
233
 0xfa 0xf7 0xd7 0xb3
234
r_idx ( 7) = 0xb3d7f7fa
235
236
*** stlink_read_reg (8) ***
237
CDB[ 0xf2 0x05 0x08 0x00 0x00 0x00 0x00 0x00 0x00 0x00]
238
      duration=6 ms
239
      notice: requested 96 bytes but got 4 bytes)
240
data_in_len = 4
241
 0x4d 0xdb 0xb5 0x45
242
r_idx ( 8) = 0x45b5db4d
243
244
*** stlink_read_reg (9) ***
245
CDB[ 0xf2 0x05 0x09 0x00 0x00 0x00 0x00 0x00 0x00 0x00]
246
      duration=6 ms
247
      notice: requested 96 bytes but got 4 bytes)
248
data_in_len = 4
249
 0x7d 0xf9 0xfb 0xf7
250
r_idx ( 9) = 0xf7fbf97d
251
252
*** stlink_read_reg (10) ***
253
CDB[ 0xf2 0x05 0x0a 0x00 0x00 0x00 0x00 0x00 0x00 0x00]
254
      duration=6 ms
255
      notice: requested 96 bytes but got 4 bytes)
256
data_in_len = 4
257
 0xfe 0xad 0xf3 0xfe
258
r_idx (10) = 0xfef3adfe
259
260
*** stlink_read_reg (11) ***
261
CDB[ 0xf2 0x05 0x0b 0x00 0x00 0x00 0x00 0x00 0x00 0x00]
262
      duration=6 ms
263
      notice: requested 96 bytes but got 4 bytes)
264
data_in_len = 4
265
 0xdf 0xfd 0x77 0xbc
266
r_idx (11) = 0xbc77fddf
267
268
*** stlink_read_reg (12) ***
269
CDB[ 0xf2 0x05 0x0c 0x00 0x00 0x00 0x00 0x00 0x00 0x00]
270
      duration=6 ms
271
      notice: requested 96 bytes but got 4 bytes)
272
data_in_len = 4
273
 0x00 0x00 0x00 0x20
274
r_idx (12) = 0x20000000
275
276
*** stlink_read_reg (13) ***
277
CDB[ 0xf2 0x05 0x0d 0x00 0x00 0x00 0x00 0x00 0x00 0x00]
278
      duration=6 ms
279
      notice: requested 96 bytes but got 4 bytes)
280
data_in_len = 4
281
 0x00 0x04 0x00 0x20
282
r_idx (13) = 0x20000400
283
284
*** stlink_read_reg (14) ***
285
CDB[ 0xf2 0x05 0x0e 0x00 0x00 0x00 0x00 0x00 0x00 0x00]
286
      duration=6 ms
287
      notice: requested 96 bytes but got 4 bytes)
288
data_in_len = 4
289
 0x51 0x0b 0x00 0x08
290
r_idx (14) = 0x08000b51
291
292
*** stlink_read_reg (15) ***
293
CDB[ 0xf2 0x05 0x0f 0x00 0x00 0x00 0x00 0x00 0x00 0x00]
294
      duration=6 ms
295
      notice: requested 96 bytes but got 4 bytes)
296
data_in_len = 4
297
 0x94 0x0b 0x00 0x08
298
r_idx (15) = 0x08000b94
299
300
*** stlink_read_reg (16) ***
301
CDB[ 0xf2 0x05 0x10 0x00 0x00 0x00 0x00 0x00 0x00 0x00]
302
      duration=6 ms
303
      notice: requested 96 bytes but got 4 bytes)
304
data_in_len = 4
305
 0x00 0x00 0x00 0x01
306
r_idx (16) = 0x01000000
307
308
*** stlink_read_reg (17) ***
309
CDB[ 0xf2 0x05 0x11 0x00 0x00 0x00 0x00 0x00 0x00 0x00]
310
      duration=6 ms
311
      notice: requested 96 bytes but got 4 bytes)
312
data_in_len = 4
313
 0x00 0x04 0x00 0x20
314
r_idx (17) = 0x20000400
315
316
*** stlink_read_reg (18) ***
317
CDB[ 0xf2 0x05 0x12 0x00 0x00 0x00 0x00 0x00 0x00 0x00]
318
      duration=6 ms
319
      notice: requested 96 bytes but got 4 bytes)
320
data_in_len = 4
321
 0xfc 0xbb 0xd6 0xfa
322
r_idx (18) = 0xfad6bbfc
323
324
*** stlink_read_reg (19) ***
325
CDB[ 0xf2 0x05 0x13 0x00 0x00 0x00 0x00 0x00 0x00 0x00]
326
      duration=6 ms
327
      notice: requested 96 bytes but got 4 bytes)
328
data_in_len = 4
329
 0xfc 0xbb 0xd6 0xfa
330
r_idx (19) = 0xfad6bbfc
331
332
*** stlink_read_reg (20) ***
333
CDB[ 0xf2 0x05 0x14 0x00 0x00 0x00 0x00 0x00 0x00 0x00]
334
      duration=6 ms
335
      notice: requested 96 bytes but got 4 bytes)
336
data_in_len = 4
337
 0x00 0x00 0x00 0x00
338
r_idx (20) = 0x00000000
339
340
*** stlink_run ***
341
CDB[ 0xf2 0x09 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00]
342
      duration=6 ms
343
      notice: requested 96 bytes but got 2 bytes)
344
data_in_len = 2
345
 0x80 0x00
346
  run core: ok
347
348
*** stlink_get_core_status ***
349
CDB[ 0xf2 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00]
350
      duration=6 ms
351
      notice: requested 96 bytes but got 2 bytes)
352
data_in_len = 2
353
 0x80 0x00
354
  core mode: running
355
356
*** stlink_exit_debug_mode ***
357
CDB[ 0xf2 0x21 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00]
358
      duration=1788 ms
359
  transport: Host_status=0x05 [DID_ABORT]
360
Driver_status=0x00 [DRIVER_OK, SUGGEST_OK]
361
362
*** stlink_close ***

Eine weitere Option wäre die ST Firmware durch die von Versaloon zu 
ersetzen, wie hier 
(http://www.versaloon.com/bbs/viewtopic.php?f=2&t=17&start=0) 
beschrieben. Allerdings wäre dies ohne imensen Aufwand zu betreiben 
schwer wider rückgängig zu machen, weshalb ich die Lösung über eine 
openOCD Config bevorzugen würde.

Vielen Dank für eure Zeit und eure Mühen,

MfG Befedo
von Joghurt3k (Gast)


Lesenswert?

Hallo, ich arbeite auch unter Linux und verwende das hier: 
http://code.google.com/p/arm-utilities/wiki/STLinkDownload
von hp-freund (Gast)


Lesenswert?

Mit eclipse zusammen funktioniert bei mir st-util von hier:

http://steadman.cc/myprojects/projects/stmdiscovery/repository
von Uwe Bonnes (Gast)


Lesenswert?

http://code.google.com/p/arm-utilities/wiki/STLinkDownload

schreibt zu dem Device:

Usage notes

This is a deeply broken device. They apparently built the mass storage 
interface by cribbing the USB device table from a 32MB flash stick. But 
the device doesn't have 32MB, only hard-wired responses that presents 
three tiny 'files'. Not arbitrary responses, only ones to the exact USB 
commands that Windows would use, and only accurately filling in the 
fields that Windows uses.
von Uwe Bonnes (Gast)


Lesenswert?

Inzwischen habe ich Code der auf STLINKV1 und V2 nur noch ueber libusb 
zugreift. Ich hoffe, auf
https://github.com/texane/stlink/
sind sie bald zu finden.
Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.