ARM Embedded Tutorial - Raspberry Pi Pico Setting up for Development
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:
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
Keep the website open in your browser, we will come back to download more stuff during this article.
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.
Building / Downloading OpenOCD
Now there are only two steps missing, first you either have to build your own copy of openocd as described in the 'Build OpenOCD' chapter in the pdf or you use the pre-built binaries provided here:
Configuring debugging in Lazarus
Last step in the process is now to configure Debugging from within Lazarus.