LoginSignup
0
0

Raspberry Pi Pico上でTOPPERS/FMP3をデバッグ

Last updated at Posted at 2024-02-05

以下の内容を試した時に、自分の場合は違ったという点をメモした。
Raspberry Pi PicoをWSL+OpenOCDでJTAG(SWD)デバッグする
https://qiita.com/yunkya2/items/4e3d89f08b2237ef551f
(picoprobeのアップデート等でパラメタが変化したと予想)

構成

WSL2 + Ubuntu + gdb -> MSYS2 + OpenOCD -> picoprobe -> ターゲット

環境(バージョンなど)と、大まかな進め方

ドキュメント:
getting-started-with-pico.pdf build-date: 2023-06-14
日本語版は、一部情報の抜けがあるので注意:
getting-started-with-pico-JP.pdf 作成日: 2023-03-22

WSL2にて、TOPPERSのビルドを実施
WSL2:Raspberry Pi Pico向けTOPPERS/FMP3のビルド
https://qiita.com/2hobata/items/581a99ede6b578623836

MSYS2 msys2-x86_64-20240113.exe にて、MINGW64を使用
OpenOCD 0.11.0-g8e3c38f (2024-01-28-20:55)
MSYS2上でソースからビルド

picoprobe.uf2 picoprobe-cmsis-v1.1: DAP: fix atomic command support
https://github.com/raspberrypi/picoprobe/releases から取得

手順における相違

結線

ターゲットのシリアルは、外付けのUSBシリアル変換アダプタ経由でホスト(Windows10 PC)に接続する。(picoprobe経由のシリアルは、TOPPERSのソースに手を加える必要があるので回避)

picoprobe

・「Windows側のドライバインストール」は不要

WLS2:Ubuntu

・以下を実行(技術的内容に違いなし)

sudo apt install gdb-multiarch
cd ~/pico
vim gdb.sh
----ここから
#!/bin/sh
gdb-multiarch -ex "target extended-remote `tail -1 /etc/resolv.conf|awk '{print $2}'`:3333" $*
----ここまで
chmod +x gdb.sh

MSYS2 MINGW64

・実行ファイルopenocd.shを作成(openocdに渡すパラメタの違いあり)

packman -S vim
cd ~/openocd
vim openocd.sh
----ここから
#!/bin/sh
cd ~/openocd/tcl
../src/openocd.exe -f interface/cmsis-dap.cfg -c 'adapter speed 5000' -f target/rp2040.cfg -c 'bindto 0.0.0.0' -s tcl
cd ~/openocd
----ここまで
chmod +x openocd.sh

実行結果:

WSL2

./gdb.sh
<タイトル的なメッセージは省略>
Type "apropos word" to search for commands related to "word"...
Reading symbols from fmp...
Remote debugging using 172.31.224.1:3333
0x000020e0 in ?? ()
(gdb) load
Loading section .text, size 0x9928 lma 0x10000000
Loading section .data, size 0x28 lma 0x10009928
Start address 0x10002368, load size 39248
Transfer rate: 22 KB/sec, 9812 bytes/write.
(gdb) monitor reset init
target halted due to debug-request, current mode: Thread
xPSR: 0xf1000000 pc: 0x000000ea msp: 0x20041f00
target halted due to debug-request, current mode: Thread
xPSR: 0xf1000000 pc: 0x000000ea msp: 0x20041f00
(gdb) continue
Continuing.
Polling target rp2040.core1 failed, trying to reexamine
SWD DPIDR 0x0bc12477
SWD DLPIDR 0x10000001
rp2040.core1: hardware has 4 breakpoints, 2 watchpoints
※Ctrl+Cを押すと以下を表示。
Thread 1 received signal SIGINT, Interrupt.
0x10000348 in consume_time (ctime=7497000) at ../fmp3/fmp3/sample/sample1.c:174
174             for (i = 0; i < ctime; i++) {
(gdb)

MSYS2 MINGW64

./openocd.sh
Open On-Chip Debugger 0.11.0-g8e3c38f (2024-01-28-20:55)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
adapter speed: 5000 kHz

Info : auto-selecting first available session transport "swd". To override use 'transport select <tr
ansport>'.
Info : Hardware thread awareness created
Info : Hardware thread awareness created
Info : RP2040 Flash Bank Command
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : Using CMSIS-DAPv2 interface with VID:PID=0x2e8a:0x000c, serial=E660D05113508A2A
Info : CMSIS-DAP: SWD  Supported
Info : CMSIS-DAP: FW Version = 2.0.0
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : SWCLK/TCK = 0 SWDIO/TMS = 0 TDI = 0 TDO = 0 nTRST = 0 nRESET = 0
Info : CMSIS-DAP: Interface ready
Info : clock speed 5000 kHz
Info : SWD DPIDR 0x0bc12477
Info : SWD DLPIDR 0x00000001
Info : SWD DPIDR 0x0bc12477
Info : SWD DLPIDR 0x10000001
Info : rp2040.core0: hardware has 4 breakpoints, 2 watchpoints
Info : rp2040.core1: hardware has 4 breakpoints, 2 watchpoints
Info : starting gdb server for rp2040.core0 on 3333
Info : Listening on port 3333 for gdb connections
Info : accepting 'gdb' connection on tcp/3333
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x00000184 msp: 0x20041f00
target halted due to debug-request, current mode: Thread
xPSR: 0x61000000 pc: 0x000020e0 msp: 0x50100898
Info : RP2040 B0 Flash Probe: 2097152 bytes @10000000, in 512 sectors

Info : New GDB Connection: 1, Target rp2040.core0, state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0xf1000000 pc: 0x000000ea msp: 0x20041f00
target halted due to debug-request, current mode: Thread
xPSR: 0xf1000000 pc: 0x000000ea msp: 0x20041f00
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x00000184 msp: 0x20041f00
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x00000184 msp: 0x20041f00
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x00000184 msp: 0x20041f00
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x00000184 msp: 0x20041f00
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x00000184 msp: 0x20041f00
Info : Writing 39248 bytes starting at 0x0
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x00000184 msp: 0x20041f00
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x00000184 msp: 0x20041f00
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x00000184 msp: 0x20041f00
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x00000184 msp: 0x20041f00
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x00000184 msp: 0x20041f00
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x00000184 msp: 0x20041f00
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x00000184 msp: 0x20041f00
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x00000184 msp: 0x20041f00
target halted due to debug-request, current mode: Thread
xPSR: 0xf1000000 pc: 0x000000ea msp: 0x20041f00
target halted due to debug-request, current mode: Thread
xPSR: 0xf1000000 pc: 0x000000ea msp: 0x20041f00
target halted due to debug-request, current mode: Thread
xPSR: 0xf1000000 pc: 0x000000ea msp: 0x20041f00
target halted due to debug-request, current mode: Thread
xPSR: 0xf1000000 pc: 0x000000ea msp: 0x20041f00
Polling target rp2040.core1 failed, trying to reexamine
Info : SWD DPIDR 0x0bc12477
Info : SWD DLPIDR 0x10000001
Info : rp2040.core1: hardware has 4 breakpoints, 2 watchpoints

その後、ターゲットのUART0にUSB-UARTアダプタを接続し、タスクが実行されていることを確認した。

TASK1_1 is running on prc1 (XXXX),     |
TASK2_1 is running on prc2 (XXXX),     |

XXXX は、値が1づつ増加(カウンタ)

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0