Why you should fall in love with the RP2350

Table of Contents

  1. The complaint & wish list
  2. A year of keeping a secret
    1. Wishes granted
  3. My first public RP2350 project
  4. Joy to all!
  5. Disclaimer
  6. Comments...

The complaint & wish list

RaspberryPi’s RP2040 was a pretty cool microcontroller, and I’ve used it in a large number of my projects, but while it had a number of very cool features, it also had a number of significant shortfalls for many use cases. These shortfalls sometimes forced me to (with much chagrin) reach for an STM32H7-series chip. This was hard to force myself to do since STM32H7 is a buggy-as-all-hell series of chips and STMicros’s continuing denial of errata demonstrated to their face does not help inspire confidence in their chips. I have been anti-recommending STM’s chips to everyone for a few years now due to STM’s behaviour with regards to the clearly-demonstrated-to-them hardware issues.

It is hard to pick the coolest thing about RP2040. It is probably a three-way-tie between the PIO, the well-designed DMA system, and the extreme overclockability of the chip. PIO + DMA is a very powerful combo that i’ve used to create all sorts of things from fancy display drivers to boards pretending to be a complete system bus with RAM and ROM to a MC68328 processor. If I were making wishes, i’d probably ask for the DMA unit to have a "forever" transfer mode since otherwise one needs to use another channel to re-trigger the first. I’d also ask for a few more channels, since I have run out of them before. For PIO I'd ask for a few more registers to store temporary variables, since some things I wanted to make using PIO did not fit into the small number of locals that PIO state machines can have - two. I would probably also ask for more PIO units. In fact, screw all other peripherals, scrap them all and give me more PIO! Some PIO units could be pre-loaded (by the BootROM) with state machine code to pretend to be SPI/UART/I2C units to quiet down the people who would complain about their lack. It is hard to complain about the overclockability. It was awesome! I guess having more than 32 instruction slots per PIO would be nice too. And, of course, I would love more GPIOs!

It should be noted, however, the high speed was mainly used as a way to paper over the weakness of the Cortex-M0+ core. An RP2040 with a better core (Cortex-M4F, for example) would be epic, especially for workloads requiring floating point or some light SIMD. The other thing that would be awesome would be the ability to use QSPI PSRAM. In fact, I did some nasty things to sort of make this work. And, of course, even more RAM would be nice.

The problem is that properly supporting QSPI PSRAM is hard. Just ask STMicro - their "support" for QSPI RAM in STM32H7 chips is so shit that no matter how you try use it, it will find a way to not work. Without cache it loses writes. With cache, it will write random garbage around some 1-byte-sized writes. Cache-or-not, if you run code from it, it will hang the entire chip bad enough for even a debugger to be unable to attach after a few billion accesses due to STMicro not having properly read how to integrate peripherals with the AXI bus. I’ve reported this to them and gave demos, no fucks were given. Which brings us to: Please trust me, do not ever use STM32H7 in any project where you want to use QSPI RAM. Just don’t! I did find workarounds for all of these issues, but they cost you 7-10% of performance, making the whole chip much less useful.

Well, in any case, back to RP2040...

A year of keeping a secret

For the entire last year I’ve had to (with much effort) keep my mouth shut about the fact that I’ve been playing with RP2350 samples at home. With many thanks to RaspberryPi, I’ve been able to spend a year trying it, reporting bugs, making suggestions, and seeing how it will make my previous RP2040 use-cases better yet! Amazingly, it seems like I got almost all of my wishes granted with RP2350!

Wishes granted

A better core? It has two Cortex-M33F cores! Floating point support? It is there, but RP2350 is better than just the single-precision that Cortex-M33F usually has. It also has a custom instruction set that accelerates double-precision math. It is not single-cycle, but it is 2-3 cycles per op, which is insanely fast! It overclocks insanely well. I’ve been running the device at 300MHz in all of my projects with no issues at all. For RISC-V lovers there are also some RISC-V cores to play with, but I do like my Cortex-M33s, so I’ve been sticking to those. The RAM size is doubled!

PIO improvements? Oh yeah! You can now use the FIFOs as memory, randomly reading and writing them, allowing all sorts of wicked-cool PIO machinery that previously was not possible due to lack of enough temporaries. Oh, and there are now THREE PIOs in the chip! And now they can also send interrupts to each-other allowing cross-PIO sync and making even more complex things! For example, I’ve used the new RP2350 PIO units, together with the newly-improved DMA units to implement a completely working Sony Memory Stick protocol slave, successfully convincing every device I insert it into that it is a real functional Memory Stick. For an encore, I also implemented a SDIO-slave device using the new PIO+DMA combo in RP2350, which successfully acts like an SDIO device well enough to convince every device I tried it with.

Did I say improved DMA? I did! DMA can now do infinite transfers without needing to waste another channel. There are also more ways to adjust memory addresses after each access. In RP2040 there was either "same address" or "increment by access size". Now there are also options for decrementing and incrementing by some other sizes. Overall, the DMA unit went from best-DMA-ever to bestest-yet-DMA-ever! It is like the opposite of the ATSAMD21 DMA unit. That one is so useless, it is painful to think about, this one is so awesome that it also hurts to think about.

rPi Pico 2 with a deadbuged SOIC-8 PSRAM chip on it

QSPI PSRAM is supported! It works for reads and writes! It has a cache. The cache works too! My memory tests that hang or crash an STM32H7 chip run on RP2350 indefinitely with no issues - no data is ever lost and the chip never hangs. Combinations are possible: one flash plus one PSRAM, two flashes, or even, with some cleverness, one boot flash and two runtime-used PSRAMs out of which code runs and where data is stored. It all works. Even the thing that kills an STM32H7 very fast works with no issues: point VTOR, SP, PC all into PSRAM, execute many LDM/STM instructions targeting PSRAM while taking interrupts. It just works! The configuration is literally three lines of C code. It has never been this simple to add 16 megabytes of RAM to a project on a two layer board assembled by hand! When I got the first RP2350 samples, the board (Pi Pico 2) had no PSRAM bootprints, so I dead-bugged a PSRAM onto the board. Even like that it worked at full speed! What I am saying is that the only reason one might want STM32H7 (PSRAM support) is gone. RP2350 does it better (or, to be precise: actually does it).

To be fair, some things did not change from RP2040 to RP2350. Peripherals are still well designed, well documented, and ACTUALLY work as promised (I am glaring at you, STMicro and Atmel). The SDK is clear and concise. There is no multi-gigabyte rPiCube32MX or rPiHALFullOfShit to download. The code is clear, not full of macro hell, and works well. The dev boards for RP2350 from rPi are rPiPico compatible. I’ve brought up a few projects on the PiPico 2 with great ease.

My first public RP2350 project

Actually, one of my recent RP2350 projects is out in public view as of today: The DEFCON 32 badge. The hardware was developed by my good friends at Entropic Engineering and the firmware was 100% my work - a port of my not-published-until-now tiny gameboy emulator uGB. One of the cores is used to upscale the gameboy screen by 1.5x in relatively good quality (using the SIMD instructions available in the Cortex-M33 core) while the other handles the emulation, UI, and the rest of it. Any valid gameboy game up to 2MByte (larger games are possible if you install a larger flash chip) should work on it. The preloaded gameboy game was written by the DEFCON folks. Here, the chip is clocked conservatively at 125MHz as I was asked to not do anything so fun as to overclock the chip since there was not much time for testing, and the production ramped up from 10 units to 28,000 with no intermediate steps and no plan B. The clock rate here was a function of the maximum clock rate the display can handle (62.5MHz) and the PIO state machine that feeds it, necessitating that the display clock is an integer multiple of the system clock. For extra credit, this same hardware is capable of running a full version of PalmOS, courtesy of my rePalm project. PalmOS will work on the stock badge (no PSRAM populated), but it is tight. Nonetheless, Infra-red beaming works, SD card works, simple games work, memo pad works, audio works, everything really. If you populate an AP memory 64Mbit PSRAM chip, however, the second image can be used, and there you have enough memory to really play around. Now you can load games or use TCPMP - the PalmOS video player to play MP4 videos realtime. Yup... The firmware images are here, and can be loaded by putting in on the SD card named "FIRMWARE.BIN", and opening the menu (press "FN" button) and selecting "firmware update". Restoring the stock firmware can be done using any computer over USB (using UF2 protocol). The stock image can be had here: here.

PS: there are a few easter eggs in the stock badge firmware, try to find them or come to the badge talk at DEFCON to see for yourself ;)

Joy to all!

So, in conclusion, go replan all your STM32H7 projects with RP2350, save money, headaches, and time. As a bonus, you’ll get an extra core to play with too! "But," you might say, "STMicro chips come with internal flash, while RP2350 still requires an external SPI chip to store the flash". Hold on to your hats... there are now RP2350 variants with built-in flash! They are called RP2354A nd RP2354B and they include 2MBytes of flash in-package. The pinouts are the same as the RP2350A/B, for a bonus! Why two pinouts? Because the "more GPIOs" dream also came true! There is now a variant with more GPIOS, available in an 80-pin package. That’s right! It is epic!

Disclaimer

I was not paid or compensated for this article in any way. I was not asked to write it. I did not seek or obtain any approval from anyone to say anything I said. My early access to the RP2350 was not conditional on me saying something positive (or anything at all) about it publicly. All thoughts and opinions are mine, unless my cats expressed them first, in which case they are theirs.

Comments...

© 2012-2024