Introduction to the RP2040
Introduction
The Raspberry Pi foundation recently started shipping the Raspberry Pi Pico, a flexible $4 USD microcontroller board. This is Raspberry’s first foray into the world of microcontroller boards, typically Raspberry Pi’s are low cost complete Linux computers and the microcontroller world has been typically dominated by the Arduino line of products, which are typically based on low cost 8-bit processors. One notable part of this announcement is that the processor included on the Pico is a dual core ARM processor with the System on a Chip (SoC) being designed by the Raspberry Pi foundation. In the past all Raspberry Pis have been based on Broadcom SoCs.
This new processor is the RP2040. Not only is this processor being used in the Pi Pico, but the Raspberry Pi foundation is selling this chip to other board manufacturers to use in their own product. Already many companies and foundations that develop Arduino boards are starting to ship products based on the RP2040, but designed to fit into their own eco-system whether it is Arduino or one of its competitors. For instance Arduino, Pimoroni, SparkFun, and Adafruit have all announced either shipping or near shipping products. I haven’t been able to order a Raspberry Pi Pico yet, since they instantly sold out, but I have been able to buy a similar Adafruit board.
All these RP2040 based boards are under $10USD and all of them have lots of GPIO ports to integrate them into your hardware projects. In this article we are going to look into some of the details of the RP2040 chip itself.
RP2040 Overview
The heart of the RP2040 are dual core ARM Cortex-M0+ 32-bit CPUs that operate at 133MHz, along with 264Kb of SRAM. This may not seem like much compared to regular Raspberry Pis or other common inexpensive computers, but in the microcontroller world this is really good. Most microcontrollers are based on slower 8-bit microcontrollers with only a few k of memory, for instance the Arduino Uno operates at 16MHz and has 6kb of memory. There are a sprinkling of 32-bit based microcontrollers based on various ARM or RISC-V models, but the RP2040 is the first to take these mainstream. Keep in mind that the original Apple II operated at 1MHz on an 8-bit CPU and only supported up to 48kb of RAM, yet it was fully capable of word processing, spreadsheets and arcade like video games. The original IBM PC only operated at 4.77MHz, had a 16-bit processor and upto 640Kb of RAM. This $4 microcontroller has far more computing power than any of these early PCs, so it will be pretty amazing to see what people produce.
The ARM Cortex-M0+ core is a low energy 32-bit processor. My book “Raspberry Pi Assembly Language Programming” covers 32-bit Assembly Language programming for a full A series ARM CPU. The M series ARM CPUs for microcontrollers contain a subset of the processing units in the full A series CPUs. For instance, there is no floating point unit (FPU) and no NEON vector processing unit. Further, it doesn’t use the full 32-bit sized instructions, instead it only uses the so called “thumb” instructions which are 16 bit in size. This means there are only eight 32-bit registers for integer arithmetic and other processing (there is only room for three bits to specify a register). With these limitations, the transistor count is greatly reduced for the CPU, reducing power usage and reducing cost. Even with these restrictions, the RP2040 is powerful enough to run Tensorflow Lite.
The RP2040 is manufactured by TSMC using an old 40nm process. This greatly reduces the cost of the chip, since there isn’t much competition for this manufacturing technology. Apple’s latest chips use a 5nm manufacturing process and there is a long waiting list of companies waiting for capacity.
Programming
Typically you program the Raspberry Pi Pico in MicroPython or C/C++ without an operating system. You write your program, compile it and download it to the Pico where it runs as a single program with no operating system. The Raspberry Pi foundation offers full support for MicroPython as well as provides a C/C++ SDK that allows you to compile programs in C, C++ or Assembly Language.
If you are familiar with Arduino and how you program these, then this is exactly how you program the Pico. Which means you need another computer to run the IDE (this could be a regular Raspberry Pi). Then the Pico is connected to this computer via USB.
Of course the Linux folks aren’t sitting still, they take the challenge that Linux should run anywhere quite seriously and have already ported Fuzix, a lightweight Linux to the Pico.
This is more likely to be used for embedded type Linux applications, since connecting monitor, keyboard and mouse are a major challenge that the Pico isn’t designed for.
Will Raspberry Produce Other Chips?
It will be interesting to see if the Raspberry Pi Foundation sticks with Broadcom chips for the regular Raspberry Pis. Will the Raspberry Pi 5 be based on a Pi Foundation designed SoC? If it is, would it allow them to use newer CPU cores? Will it mean they can incorporate an ARM Mali GPU rather than the Broadcom GPU they have been using? Will there be other models of embedded chips beyond the RP2040? Evidently the numbers are significant, the 2 is for the number of cores and the 4 indicates the memory size and then the 0’s are for possible future features. We’ll have to watch Raspberry’s product announcements closely over the next year or two.
Summary
The RP2040 is exciting because it could take the microcontroller market from 8-bit to 32-bit, increasing the programming capabilities of all these DIY electronics projects greatly. Not everyone will move to this, since it will also push the price of 8-bit microcontrollers even lower. But perhaps your next microwave or toaster will contain AI software running on an RP2040.
[…] Last week we talked about the Raspberry Pi’s entry into the microcontroller market with their new RP2040 chip. I had ordered a couple of these, but had yet to receive one. Last Wednesday I received my Adafruit Feather RP2040, this is Adafruit’s entry into this market using Raspberry’s new ARM based RP2040 microcontroller. In this article, I’ll give my first impressions of this Adafruit board, with the caveat that I’ve only had it two days now. […]
Adafruit Feather RP2040 First Impressions | Stephen Smith's Blog
April 2, 2021 at 11:16 am
[…] Introduction to RP2040 and Raspberry Pi Pico – smist09 WordPress. […]
ICYMI Python on Microcontrollers Newsletter: CircuitPython 6.2.0 released and More! #Python #Adafruit #CircuitPython @micropython @ThePSF #ICYMI « Adafruit Industries – Makers, hackers, artists, designers and engineers!
April 7, 2021 at 6:32 am
[…] RP2040 microcontroller. I’ve now received a Raspberry Pi Pico which is also based on the ARM RP2040 processor. The Adafruit version is oriented around programming with CircuitPython and then […]
Raspberry Pi Pico First Project | Stephen Smith's Blog
April 8, 2021 at 3:12 pm
[…] Raspberry Pi Pico is the Raspberry Foundation’s first entry into the domain of Arduino style microcontrollers. The […]
Assembly Language on the Raspberry Pi Pico | Stephen Smith's Blog
April 16, 2021 at 9:43 am
[…] last week’s article, I presented my first Assembly Language program on the Raspberry Pi Pico. The program worked, but it included some C code that I wasn’t happy with. In this article, […]
Calling Main in Assembly Language on the RP2040 | Stephen Smith's Blog
April 23, 2021 at 9:11 am
[…] this article, we’ll look at the structure for the GPIO registers on the RP2040 and how to access these. The procedure we are using is called bit-banging because we are using one […]
Bit-Banging the Raspberry Pi Pico’s GPIO Registers | Stephen Smith's Blog
April 24, 2021 at 11:50 am
[…] time we looked at how to access the RP2040’s GPIO registers directly from the CPU in Assembly Language. This is a common technique to access […]
I/O Co-processing on the Raspberry Pi Pico | Stephen Smith's Blog
April 30, 2021 at 10:02 am
[…] “RP2040 Assembly Language Programming” and goes into detail on how to program Raspberry’s RP2040 SoC. This chip is used in the Raspberry Pi Pico along with boards from several other manufacturers […]
RP2040 Assembly Language Programming | Stephen Smith's Blog
November 5, 2021 at 10:42 am
[…] to get use of every single bit available to you. With the newer microcontrollers like Raspberry’s RP2040 which are based on ARM 32-bit M-series CPUs, these are much more powerful and have more memory. […]
Assembly Language is Number 8 | Stephen Smith's Blog
November 13, 2021 at 4:48 pm
[…] the built-in GPU from that Broadcom thingy to a proper ARM Mali GPU. Now that ARM designs their RP2040 SoC, it will be interesting to see if they stick with a Broadcom SoC, or switch to one that they […]
Technology Predictions for 2022 | Stephen Smith's Blog
December 17, 2021 at 10:59 am
Nice!!! I tested this board with NuttX RTOS to compare with ESP32 chips. I was expecting a better result, ESP32-S3 for example is 10x faster!
acassis
February 10, 2022 at 6:06 am