This tutorial explains how to debug a Wiznet W6100-EVB-Pico (or other RP2040 boards) using a Raspberry Pi Debug Probe and Linux (Ubuntu) host PC using the terminal.
- Connect a USB cable from the Wiznet board to the host PC.
- Connect a USB cable from the Debug Probe to the host PC.
- Connect a 3-pin JST-SH to male cable from the "D" port of the Debug Probe to the SWD pins on the Wiznet board.
Note: Ensure the SWD pins are correctly connected. On the Debug Probe, the pins are SWCLK, GND and SWDIO from left to right. The SWD pins on the Wiznet board are labelled on the rear side of the PCB.
sudo apt install openocd
sudo apt install gdb-multiarch
Taken from Getting started with Raspberry Pi Pico (Chapter 2).
cd
mkdir pico
cd pico
git clone https://github.com/raspberrypi/pico-sdk.git --branch master
cd pico-sdk
git submodule update --init
cd ..
git clone https://github.com/raspberrypi/pico-examples.git --branch master
sudo apt update
sudo apt install cmake gcc-arm-none-eabi libnewlib-arm-none-eabi build-essential libstdc++-arm-none-eabi-newlib
We will build the blink
example here as explained the Getting Started guide (Chapter 3).
cd pico-examples
mkdir build
cd build
export PICO_SDK_PATH=../../pico-sdk
cmake ..
cd blink
make -j4
This should build the .elf
and .uf2
binaries in the blink
directory.
Taken from the Debug Probe documentation - Uploading new programs to your Pico.
Ensure you are inside the ../pico-examples/build/blink
directory and run the following command to load the binary to the Wiznet board using openocd
.
sudo openocd -f interface/cmsis-dap.cfg -f target/rp2040.cfg -c "adapter speed 5000" -c "program blink.elf verify reset exit"
Taken from the Debug Probe documentation - Debugging with SWD.
To allow debugging, you must build a debug version of the blink
example with CMAKE_BUILD_TYPE=Debug
as shown below.
cd ~/pico/pico-examples
rm -rf build
mkdir build
cd build
export PICO_SDK_PATH=../../pico-sdk
cmake -DCMAKE_BUILD_TYPE=Debug ..
cd blink
make -j4
sudo openocd -f interface/cmsis-dap.cfg -f target/rp2040.cfg -c "adapter speed 5000"
In another terminal window, run the following commands to start GDB and attach it to the OpenOCD server.
gdb-multiarch blink.elf
target extended-remote localhost:3333
Run these commands inside the GDB shell.
This will reset the board, but the program will not start until the continue
command is sent.
monitor reset init
Execution runs until a breakpoint is hit or the user presses Ctrl+C
.
continue
Replace with the actual line number.
b blink.c:<line-number>
You can also use a function name, e.g. b blink.c:main
.
info breakpoints
Replace with the actual breakpoint ID.
delete <breakpoint-id>
step
next
finish
print <variable-name>
info locals
list
list <line-number>
q