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