|
@@ -19,14 +19,76 @@ Then do this to build.
|
19
|
19
|
mkdir build
|
20
|
20
|
cd build
|
21
|
21
|
cmake ..
|
22
|
|
- make trackball
|
|
22
|
+ make -j4 trackball
|
23
|
23
|
|
24
|
24
|
And flash the resulting `trackball.uf2` file to your Pico as usual.
|
25
|
25
|
|
26
|
26
|
For convenience you can use the included `flash.sh`, as long as you flashed the binary manually once before.
|
27
|
27
|
|
28
|
|
- make trackball
|
|
28
|
+ make -j4 trackball
|
29
|
29
|
../flash.sh trackball.uf2
|
30
|
30
|
|
31
|
|
-For debugging a serial port will be presented by the firmware.
|
|
31
|
+This will use the mass storage bootloader to upload a new uf2 image.
|
|
32
|
+
|
|
33
|
+For old-school debugging a serial port will be presented by the firmware.
|
32
|
34
|
Open it using eg. `picocom`, or with the included `debug.sh` script.
|
|
35
|
+
|
|
36
|
+## Proper Debugging
|
|
37
|
+
|
|
38
|
+You can also use the SWD interface for proper hardware debugging.
|
|
39
|
+
|
|
40
|
+This follows the instructions from the [RP2040 Getting Started document](https://datasheets.raspberrypi.com/pico/getting-started-with-pico.pdf) from chapter 5 and 6.
|
|
41
|
+
|
|
42
|
+For ease of reading the disassembly, create a debug build.
|
|
43
|
+
|
|
44
|
+ mkdir build_debug
|
|
45
|
+ cd build_debug
|
|
46
|
+ cmake -DCMAKE_BUILD_TYPE=Debug ..
|
|
47
|
+ make -j4 trackball
|
|
48
|
+
|
|
49
|
+You need a hardware SWD probe.
|
|
50
|
+This can be made from another Pico, see Appendix A in the document linked above.
|
|
51
|
+For this you need to compile the `picoprobe` firmware, like this.
|
|
52
|
+
|
|
53
|
+ git clone https://github.com/raspberrypi/picoprobe.git
|
|
54
|
+ cd picoprobe
|
|
55
|
+ git submodule update --init
|
|
56
|
+ mkdir build
|
|
57
|
+ cd build
|
|
58
|
+ PICO_SDK_PATH=../../../pico-sdk cmake ..
|
|
59
|
+ make -j4
|
|
60
|
+
|
|
61
|
+And flash the resulting `picoprobe.uf2` to your probe.
|
|
62
|
+Connect `GP2` of the probe to `SWCLK` of the target and `GP3` of the probe to `SWDIO` of the target.
|
|
63
|
+Of course you also need to connect GND between both.
|
|
64
|
+
|
|
65
|
+You need some dependencies, mainly `gdb-multiarch` and the RP2040 fork of `OpenOCD`.
|
|
66
|
+
|
|
67
|
+ sudo apt install gdb-multiarch # Debian / Ubuntu
|
|
68
|
+ sudo pacman -S arm-none-eabi-gdb # Arch Linux
|
|
69
|
+
|
|
70
|
+ cd ../.. # back to build_debug directory from before
|
|
71
|
+
|
|
72
|
+ git clone https://github.com/raspberrypi/openocd.git --branch rp2040 --recursive --depth=1
|
|
73
|
+ cd openocd
|
|
74
|
+
|
|
75
|
+ # install udev rules
|
|
76
|
+ sudo cp contrib/60-openocd.rules /etc/udev/rules.d
|
|
77
|
+ sudo udevadm control --reload-rules && sudo udevadm trigger
|
|
78
|
+
|
|
79
|
+ ./bootstrap
|
|
80
|
+ ./configure --enable-ftdi --enable-sysfsgpio --enable-bcm2835gpio
|
|
81
|
+ make -j4
|
|
82
|
+
|
|
83
|
+Now we can flash a firmware image via OpenOCD.
|
|
84
|
+
|
|
85
|
+ ./openocd/src/openocd -s openocd/tcl -f interface/cmsis-dap.cfg -f target/rp2040.cfg -c "adapter speed 5000" -c "cmsis_dap_vid_pid 0x2e8a 0x000c" -c "program trackball.elf verify reset exit"
|
|
86
|
+
|
|
87
|
+And also start a GDB debugging session.
|
|
88
|
+
|
|
89
|
+ ./openocd/src/openocd -s openocd/tcl -f interface/cmsis-dap.cfg -f target/rp2040.cfg -c "adapter speed 5000" -c "cmsis_dap_vid_pid 0x2e8a 0x000c"
|
|
90
|
+ arm-none-eabi-gdb trackball.elf
|
|
91
|
+ target extended-remote localhost:3333
|
|
92
|
+
|
|
93
|
+These commands have also been put in the `flash_swd.sh` and `debug_swd.sh` scripts, respectively.
|
|
94
|
+Call them from the `build_debug` folder where you checked out and built OpenOCD.
|