reset
Put the RP2040 into a clean initial state, as though it had just powered up, so
that it is ready to run our code.
exit
Disconnect from the RP2040 and exit. Our freshly-programmed code will
start running once OpenOCD disconnects.
TIP
If you see an error like Info: DAP init failed then OpenOCD could not see an RP2040 on the SWD interface it used.
The most common reasons are that your board is not correctly powered via e.g. a USB cable; that the SWD wiring is
not correct (e.g. the ground wire is not connected, or SWDIO and SWCLK have been swapped); or that there is some
signal integrity issue caused by long or loose jumper wires.
To check that you really have loaded a new program, you can modify blink/blink.c to flash the LED more quickly, and
then rebuild, and rerun the
openocd command above:
int main() {
Ê
const uint LED_PIN = 25;
Ê gpio_init(LED_PIN);
Ê gpio_set_dir(LED_PIN, GPIO_OUT);
Ê
while (true) {
Ê gpio_put(LED_PIN,
1);
Ê
// Blink faster! (this is the only line that's modified)
Ê sleep_ms(25);
Ê gpio_put(LED_PIN,
0);
Ê sleep_ms(
250);
Ê }
}
And then,
$ cd pico-examples/build
$ make blink
$ # (the application is rebuilt)
$ openocd -f interface/raspberrypi-swd.cfg -f target/rp2040.cfg -c "program blink/blink.elf
verify reset exit"
Getting started with Raspberry Pi Pico
5.3. Loading a Program 21