ラズパイPico の picotool を使う
こんばんは!!
熱帯夜ですね
それでは本題です
今回の目的
プログラムのデバックを準備していたら debugprobe_on_pico.uf2
を書き込んだはずの Pico 1 が OpenOCD に反応していないようだったので picotool 2で Pico の中身を確認する
picotoolを使う準備
picotool は コマンドプロンプト (DOS窓)で使うので cmd.exe を起動する
- タスクバーの検索アイコンで cmd と打って コマンドプロンプトを起動する
- picotoolのあるディレクトリに Path を通しておきたいので コマンドラインで
PATH=%PATH%;C:\<SDKのインストールディレクトリ>\picotool;
と打って Pathに追加する 3.4
<SDKのインストールディレクトリ>
の部分は各々に合わせて修正する コマンドラインで
picotool
と打ってみるPICOTOOL: Tool for interacting with a RP2040 device in BOOTSEL mode, or with a RP2040 binary SYNOPSIS: picotool info [-b] [-p] [-d] [-l] [-a] [--bus <bus>] [--address <addr>] :(中略) COMMANDS: info Display information from the target device(s) or file. :(中略) Use "picotool help <cmd>" for more info
上記のように使い方が表示されれば準備完了
Picoの準備
PicoはBOOTSELモードにして使う
picotoolを使う
コマンドプロンプトで
picotool info -a
6と打ってみるProgram Information name: debugprobe features: PROBE UART INTERFACE uart1 PROBE UART BAUDRATE 115200 UART stdin / stdout binary start: 0x10000000 binary end: 0x1000a2e0 Fixed Pin Information 0: UART0 TX, UART0 TX 1: UART0 RX 2: PROBE SWCLK 3: PROBE SWDIO 4: PROBE UART TX 5: PROBE UART RX 25: LED Build Information sdk version: 1.5.1 pico_board: pico boot2_name: boot2_w25q080 build date: Apr 16 2024 build attributes: Release Device Information flash size: 4096K ROM version: 3
Picoボードの情報が表示された
プログラムはdebugprobeが書き込まれているようだ
その他の使い方
Picoプログラムのファイルへの読み書きをする
コマンドプロンプトで 作業フォルダへ移動しておく
cd <作業フォルダのパス>
今回の作業フォルダは仮で C:\PICO\flash_image をつくった
書き込みの実験用に blink.uf2 をここにコピーしておく
picotoolのSAVEコマンド
picotool save -p <filename> -t uf2
プログラムの読み出しとファイルへの保存C:\PICO\flash_image>picotool info Program Information name: debugprobe features: PROBE UART INTERFACE uart1 PROBE UART BAUDRATE 115200 UART stdin / stdout C:\PICO\flash_image>picotool save -p onboard_fw.uf2 -t uf2 Saving file: [==============================] 100% Wrote 83456 bytes to onboard_fw.uf2 C:\PICO\flash_image>dir :(中略) 2024/07/04 23:33 83,456 onboard_fw.uf2 :
ファイル
onboard_fw.uf2
にプログラムがSAVEされたpicotoolのLOADコマンド
picotool load <filename>
ファイルを読み込んでPicoへプログラムを書き込みC:\PICO\flash_image>dir :(中略) 2024/06/23 21:23 43,520 blink.uf2 2024/07/04 23:33 83,456 onboard_fw.uf2 : C:\PICO\flash_image>picotool load blink.uf2 Loading into Flash: [==============================] 100% C:\PICO\flash_image>picotool reboot The device was rebooted into application mode.
PicoをRebootすると blinkプログラムが走る
再度BOOTSEL
モードにしてC:\PICO\flash_image>picotool info Program Information name: blink web site: https://github.com/raspberrypi/pico-examples/tree/HEAD/blink
blinkプログラムが書き込まれているのがわかる
1でSAVEしたonboard_fw.uf2
を書き戻してみるC:\PICO\flash_image>picotool load onboard_fw.uf2 Loading into Flash: [==============================] 100% C:\PICO\flash_image>picotool info Program Information name: debugprobe features: PROBE UART INTERFACE uart1 PROBE UART BAUDRATE 115200 UART stdin / stdout
ファイルにSAVEしておいたプログラムに書き戻されているようである