ARM Embedded Tutorial - Raspberry Pi Pico Setting up for Development

From Free Pascal wiki

Download Documentation

After having Lazarus and FPC in place the next step is to download information related to the RP2040 chip and the Pico board.

Raspberry Foundation has done a pretty good job at documentation, to get our feet wet it makes sense to read through their pdf documentation that can be found on this page:

Getting Started with Raspberry Pi Pico

scroll down to the Documentation Section and download at least the "RP2040 Datasheet" and "Getting started with Raspberry Pi Pico" documents.

You can later use the RP2040 Datasheet for reference on implementation details of the microcontroller, for now we only need the 'Getting Started' pdf

Now read through the Getting started and if you want to get your feet really wet also clone their SDK and Examples repositories from github.

This will not be strictly necessary but when you want to dig really deep into development on the Pico it makes sense that you also dip your feet into the C/C++ world (Brrrr...... cold water, indeed....)

Setting up a Debug Probe

For our next steps we need to either set up a Raspberry Pi as a debug probe or, when you followed my advice and bought a second board, convert our 2nd Raspberry Pi Pico to a debug Probe.

Setting up the Raspberry Pi is very well covered in the Getting started pdf documentation, I will not cover that here.

Converting a Pico to a Picoprobe is very easy, so here are the steps in a nutshell:

First download an UF2 image for the Pico, you can find the link on the getting Started webpage, scroll down to Utilities and download the UF2 under "Debugging using another Raspberry Pi Pico".

Then push the BOOTSEL button on your Pico and while keeping it pressed connect it to your computer via USB or re-plug the already connected USB cable. The Pico will now statup as a flash drive RPI-RP2.

Now drop the downloaded UF2 file in that drive and the device will flash the software and reboot as a Picoprobe.

When you are on Windows then follow the steps in the 'Appendix A' of the getting started pdf about installing the Picoprobe driver.

For wiring up your freshly created Picoprobe to your development board work through the 'Picoprobe Wiring' chapter.

Here's a setup on a Breadboard for your reference:

pico-debug.png

The picoprobe is the pico on the left, the pico that runs the program to be debugged is on the right side.

Preparing usage of OpenOCD

Together with the installation Lazarus/FPC you have also automagically downloaded a pre-compiled version of openocd that you can use together with your PicoProbe.

Windows only:

before we continue you need to install an USB driver for your probe, as described in the Raspberry Pico manual.

Read the instructions in the Getting started manual (End of Appendix A) or follow them here:

Download zadig from this link:

http://zadig.akeo.ie/

and then connect your pico to your computer.

Start zadig, select picoprobe (Interface 2) and libusb-win32


pico-zadic.png

Hit install driver.... done..


Navigate to the directory where FPCUPdeluxe installed you FPC/Lazarus and check the directory ccr/develtool4fpc/bin:

pico-included-openocd.png

or on Windows:

pico-included-openocd2.png

Note down the path and open a fresh terminal / cmd shell.

Start openocd-rp2040 with the full path to openocd-rp2040 as found on your computer:

 ~/fpcupdeluxe/ccr/develtools4fpc/bin/openocd-rp2040 -f board/pico.cfg

pico-start-openocd2.png


 C:\fpcupdeluxe\ccr\develtools4fpc\bin\openocd-rp2040.exe -f board/pico.cfg

pico-start-openocd.png

Back to main Pico Page