commands to try out from tutorial
[openocd-rpi2-stm32] / openocd-rpi.txt
1 https://www.youtube.com/watch?v=hWYzgw0WhYU
2
3 pi@pihdmi:~/openocd $ ./src/openocd -f tcl/interface/raspberrypi2-native.cfg
4 Open On-Chip Debugger 0.10.0+dev-01489-g06c7a53f1-dirty (2020-11-14-15:21)
5 Licensed under GNU GPL v2
6 For bug reports, read
7         http://openocd.org/doc/doxygen/bugs.html
8 BCM2835 GPIO nums: swclk = 11, swdio = 25
9
10 Info : Listening on port 6666 for tcl connections
11 Info : Listening on port 4444 for telnet connections
12 Info : BCM2835 GPIO JTAG/SWD bitbang driver
13 Error: An adapter speed is not selected in the init script. Insert a call to "adapter speed" or "jtag_rclk" to proceed.
14
15 ## Switch input
16 +3.3V 3V3
17   IO1 gpio17 level=1 fsel=0 func=INPUT "ds18b20_temp@2" out hi
18   IO2 gpio18 level=0 fsel=0 func=INPUT                                  io
19   IO3 gpio27 level=0 fsel=0 func=INPUT                                  clk
20   GND GND
21
22 pi@pihdmi:~/openocd-stm32 $ openocd -f pihdmi-rpi2.cfg
23 Open On-Chip Debugger 0.10.0+dev-01489-g06c7a53f1-dirty (2020-11-14-15:21)
24 Licensed under GNU GPL v2
25 For bug reports, read
26         http://openocd.org/doc/doxygen/bugs.html
27 swd
28 Info : Listening on port 6666 for tcl connections
29 Info : Listening on port 4444 for telnet connections
30 Info : BCM2835 GPIO JTAG/SWD bitbang driver
31 Info : clock speed 100 kHz
32 Warn : gdb services need one or more targets defined
33
34 addresses from
35 https://github.com/antongus/stm32tpl/blob/master/stm32.h
36
37 > mdw 0xE0042000 4
38 0xe0042000: 20036410 00000000 00000000 00000000
39
40 > mdw 0x1FFF7A10 2
41 SWD DPIDR 0x1ba01477
42 Failed to read memory at 0x1fff7a14
43
44 > mdw 0x1FFFF7E8 4
45 0x1ffff7e8: 0670ff48 56558967 67064740 ffff00ff
46
47
48
49 openocd -f pihdmi-rpi2.cfg -f target/stm32f1x.cfg
50
51 > flash banks
52 #0 : stm32f1x.flash (stm32f1x) at 0x08000000, size 0x00000000, buswidth 0, chipwidth 0
53
54 > flash read_bank 0 bank0.bin
55 device id = 0x20036410
56 flash size = 128kbytes
57 wrote 131072 bytes to file bank0.bin from flash bank 0 at offset 0x00000000 in 1.273383s (100.520 KiB/s)
58
59
60 # write flash back
61
62 halt
63 stm32f2x unlock 0
64 # if it failed, re-try command again
65 flash write_bank 0 image.bin
66 reset
67
68 # gdb
69
70 gdb
71
72 (gdb) set architecture arm
73 The target architecture is assumed to be arm
74
75 (gdb) target remote localhost:3333
76 Remote debugging using localhost:3333
77 warning: No executable has been specified and target does not support
78 determining executable automatically.  Try using the "file" command.
79 0x08000194 in ?? ()
80
81 (gdb) info reg
82
83 (gdb) stepi
84
85 (gdb) x/10pi $pc
86 => 0x8000194:   subs    r0, r0, #1
87    0x8000196:   cmp     r0, #0
88    0x8000198:   bne.n   0x8000194
89    0x800019a:   bx      lr
90    0x800019c:   push    {r3, lr}
91    0x800019e:   movs    r1, #1
92    0x80001a0:   movs    r0, #16
93    0x80001a2:   bl      0x80002ec
94    0x80001a6:   mov.w   r0, #8192       ; 0x2000
95    0x80001aa:   strh.w  r0, [sp]
96
97 (gdb) b *0x800019a
98 Breakpoint 1 at 0x800019a
99
100 (gdb) c
101 Continuing.
102 Note: automatically using hardware breakpoints for read-only addresses.
103
104 Breakpoint 1, 0x0800019a in ?? ()
105
106