[Raspberry Pi Pico Review] 1. Develop Pico without MicroPython and C++
[Copy link]
This post was last edited by tjCFeng on 2021-3-23 13:38
Winter has gone and spring has arrived. After the New Year, Pico is finally here. This is my first time applying for a development board on EEWorld. I am very grateful to be selected and to start a new trial journey on EEWorld. RPI Pico's RP2040 is a new thing with pretty good performance. Although it is slightly inferior to ESP32 in terms of price and configuration, the unique PIO function is a highlight. I will focus on learning about it later. Perhaps future microcontrollers will have this function. Pico is currently priced at US$4. Excluding other things, RP2040 is equivalent to about RMB 20. There are many microcontrollers of this level in China. I will pick one to compare.
RPI Pico's main development method is MicroPython, which is really convenient to develop. You can run it by downloading the source code directly. However, due to inherent limitations, MicroPython occupies more memory and needs to embed an interpreter in the MCU. At the same time, MicroPython is an interpreted language, which will definitely have some impact on performance. RPI Pico also provides C++ development methods. I tried to install it, but it was only successful on CLion, not on VSCode. There are too many places to set up, which is very inconvenient so far. I look forward to better plug-ins and other things in the future.
After trying the C++ of RPI Pico, I accidentally discovered that FreePascal can also compile Pico programs, which immediately aroused my interest. Before learning embedded development, I had been working on Delphi programs for more than ten years, and I had deep feelings for it, which can be regarded as a kind of sentiment. Since Borland added OOP features to Pascal, Delphi has changed from a tool to a language. Although Delphi has declined with Borland due to commercial reasons, some of Delphi's concepts are still very advanced. A hero does not mention his past achievements. The paid Delphi gradually disappeared, and the free FreePascal came. The IDE name is Lazarus, spicy pork shreds. Lazarus is different from Delphi in direction. Not only is it 99% compatible with Delphi in syntax, it is also known as write once and compile everywhere on various platforms. In other words, after writing a program, it can be compiled into a local executable file regardless of Win, Linux, or MAC, and it can also be compiled on Android and iOS. The most important thing is that it is related to Pico, and embedded ARM is not a problem.
Whether it is for sentiment or to add another development method for Pico, I broke my promise. I originally planned to use C++ to encapsulate the library, but now I am going to use Pascal, and use classes to implement it, which will be more convenient to call. Let me say a little more here. Pascal is a compiled language, and its efficiency is similar to C. It will definitely be higher than MicroPython, Lua and the like. It can also support Debug online debugging, so as long as it is easy to use, you can rest assured about the performance.
Let's get down to business and install Lazarus. Lazarus provides binary files for various platforms, but there is a more convenient installation method. First, go to to download the fpcupdeluxe installation tool.
After running, select the path to be installed in the upper left corner, and then click the "Pico" button below
All that's left is to wait, without doing anything else, until the installation is complete.
After installation, a shortcut will be created on the desktop. Run it
An old Delphi7-like separated IDE is released, with a window on it. Click the green triangle in the upper left corner to get a Windows program with an interface. This program can run in various systems from Win95 to Win10 without any runtime support. The same is true for Linux and MAC. Of course, this window has nothing to do with Pico, and Pico cannot display a window.
If you are not used to this separation mode, it doesn’t matter. You can set it up and change the IDE language to Chinese.
Needless to say, the Chinese settings are in the menu "Tools->Options", and there are other settings according to your own habits. The fusion mode is not in the settings. In the menu "Package->Install/Uninstall Package", select "anchordocking" and "anchordockingdsgn", then click "Install->Save and Recompile IDE", and it will automatically restart after completion, and the appearance will change.
This is much better. Open the Lazarus installation folder
The four files are over 650M, isn't it too big? Don't be afraid, there is a way. Lazarus.old.exe can be deleted directly, which is the backup file when recompiling just now and is no longer needed. Then find strip.exe in the fpc folder and copy it. Do not execute it. Hold down the mouse and drag the large file onto strip.exe
The same is true for other files. Let's take a look at the current size.
I think you can accept it.
So far, the IDE settings are complete. What else is there to do? Download the example from and unzip it. First open the simplest blinky project.
There are a lot of things here, but only two are useful. The lpi file is the project file, and the lpr file is the project code, so you need to open the lpi. Several lpis correspond to a series of development boards of rp2040. We use Pico, so of course we need to open the lpi of pico. There is no associated file when installing the IDE just now, so just select Lazarus.exe to open it.
After opening, ignore the code and directly click the menu "Run->Build". The compilation is completed instantly and the prompt is successful. What changes will occur after success?
There is a new folder called bin under blinky. All the required files are in it. You should be familiar with the uf2 file. Now we need to verify the compilation result.
Plug the Pico into the computer's USB and it will recognize a new partition. Just like other development methods, drag the uf2 file into it and the effect will appear immediately.
The lights flashed.
So far, the whole process from installing Lazarus to setting up, compiling and running is over. It is quite simple, right? There is nothing to input. The key is the network speed, especially for github, svn and the like. If you are blocked by a firewall, it will greatly affect the installation speed. Find a way to turn it over by yourself.
(End)
|