Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
The RP2040 Stamp (github.com/solderparty)
99 points by _Microft on March 26, 2022 | hide | past | favorite | 63 comments


RP2040 is pretty underwhelming as a microcontroller. Its sleep mode draws 0.8 mA. And the ADC has DNL issues [1] Capabilities-wise it feels like "NIH syndrome" ESP32-alike with USB in lieu of wireless.

At least it's much cheaper than Arduino (like 2-3x compared to Uno). The price of Arduino Uno is not justified by anything when its NRE cost must have been recouped long ago.

[1] https://pico-adc.markomo.me/


Yes, having played with the pico, ESP32 and predessor I kinda agree, thouogh ADC's in microcontrollers are limited depending upon what you want to do and will often lean towards an external.

The ESP also has hardware floating point, which if you need to use that sure does blast past the pico's core's.

What the pico does shine well at is the PIO controllers and a good documentation user base. The fact that within a year it had early on full support in the ecosystem of microcontrollers is pretty darn amazing, more so given Espressif not exactly known for their doumentation and the whole intergration with IDE's like the ardiuno was dedicated users off their own steam driving it.

Another plus for the PICO is that you can get for a dollar the chip itself and with the advent and ease of doing your own circuits, afforded the ability to roll your own controller board how you want them. Sure can do that with the ESP's but not sure so easily accesable price wise as the PICO chip is and not as cheap.

Yes the whole lack of wifi and BT upon the PICO in todays times with IOT this and other projects, does leave shortfalls, though there are boards that do that, sadly many get WIFI by adding something like an ESP01 chip and the whole ironic aspect of a microcontroller needing another microcontroller for it's wifi when maybe what you wanted to do could be done upon the ESP01 alone, well. Bit of a chuckle.

So for me, were the PICO stands out is the PIO controllers and how they with the USB host option allow many device avenues. Want your own joystick - doable, want to emulate some odd protocol - may well find the PIO can take a lot of strain from that.


I'm currently working on a keyboard with a pico, and am not the most experienced at working with microcontrollers. It's crazy how much easier it is for me to do things on the pico then the old standard, the pro micro. I can just have my vscode open, and the serial port just connects. Changing a file causes the controller to reboot and run the new code. No flashing, or dealing with compiling QMK.

Given that you can buy a pico chip in the pro micro form factor, with usb c, for cheaper then an elite c, I'm hoping these end up in a lot more keyboards.


> I can just have my vscode open, and the serial port just connects. Changing a file causes the controller to reboot and run the new code

Are you using micropython? This sounds like a treat.


> the whole ironic aspect of a microcontroller needing another microcontroller

But it is a microservices architecture!


You've raised real downsides (for some applications), but the rp2040 also many features that are unheard of at its price point (1$): dual core, PIO, lots of ram. In fact the RAM + dual core means you're almost getting two Cortex-M0+ MCUs for the price of one (with shared peripherals).

For comparison, Microchip (formerly atmel) SAMD21 (also Cortex-M0+, of Arduino Zero fame) is about 3-4 $, single core, less RAM.


>For comparison, Microchip (formerly atmel) SAMD21 (also Cortex-M0+, of Arduino Zero fame) is about 3-4 $, single core, less RAM.

But it has built in flash.

Sure, external flash is still cheaper* (512K for ~$0.2) but it's a major downside having a mandatory extra chip because of how much more physical space it takes up.

* Might not actually be cheaper if you consider pick&place cost of an extra part you're not likely to use anywhere else.


External flash also messes with real-time response times - if your IRQ handler is not forced to be in RAM it can take tens-hundreds of microseconds to start, which in many applications is not acceptable. Built-in flash is much more predictable.

Last time I tried RP2040 SDK (a few months back) many functions you would need to use in these IRQ handlers were not marked as RAM, which means you have to copy&paste them from SDK to your code and add the attribute.

The ESP32 suffers from similar problem, but at least they seem to have been more thoughtful about slapping these RAM attributes here and there.

Having said that, the RP2040 is generally much more pleasant to program than ATSAMD21 or ESP32 and the PIOs are awesome. Also you can easily get it with assembly from JLCPCB at $1.20 or thereabouts.

edit: typo


> Its sleep mode draws 0.8 mA.

What's your source for this? The RP2040 datasheet claims 0.18 mA for Dormant state and 0.39 mA for Sleep. As you've got detailed control over what gets clock gated in sleep state suspect you can bring that 0.39 mA down if you've only got one or two wake events to care about.


The datasheet is really skimpy about the power draw, especially compared to what ST Micro tells you. In STM32 parts the Sleep mode is usually pretty bad (say half of normal consumption) and you need to go to Stop mode, where the core and most peripherals are not clocked to get into micro-amp range. However, once there you can typically get by with under 5uA. You can wake up from that in a few microseconds if you clock from internal oscillator with no PLL (so you run at 8-16MHz not 48-64MHz).

In that context, 180uA is pretty bad, but again, the datasheet is not very clear.


That's still really high though. nRF51 sleep current is around 2 microamps. You can run it off a coin cell for years (depending on what you're doing). Sounds like an RP2040 would last maybe a week.


The onboard RAM is a bit light, I agree. But the chip is quite powerful, they can usually be overclocked to about 250 Mhz, and have dual cores. The real star of the show is the PIO system.

You've got 2 sets of 4 state machines, that can do a whole lot of stuff at really impressive I/O rates. People have used them to generate VGA or DVI (HDMI) with just some resistors and connectors.

It's almost as good as having an FPGA. I suspect people will be wringing more and more performance out of this chip over the next year or two.


Can you recommend some PIO tutorials that go beyond the simple example in the SDK?


Here is a posting about driving an LCD. It starts with a bitbanged version and goes through rewriting it using PIO and thereby reducing CPU usage from full load to "almost negligible". Maybe that's an interesting read?

https://www.zephray.me/post/rpi_pico_driving_el/

https://news.ycombinator.com/item?id=30714943


As I understand it the chip was partly intended as a starter project for RPi's newly founded in House silicon design team, so not using an existing design could be partly deliberate.

However the PIO state machines set it apart.


I've seen "claims" the ESP32 can do 0.1 mA in sleep, but haven't seen anyone actually implement that in a functional application.

My use case is different though, I will be adding an NRF9160 for connectivity so ESP32-based stuff just didn't make sense. It's also for academic customers who want to be able to work using MicroPython should I get hit by a bus.


The Raspberry Pi foundation focuses on accessibility and education. In that regard, the RP2040 excels. The price is especially advantageous and the beginner-focused documentation are great for introducing people to microcontrollers.

But I do agree that this feels like the Arduino situation all over again, where many people mistake the sudden popularity and influx of Tweets, YouTube videos, and headlines as an indicator that it’s the premier microcontroller on the market or the only logical choice for new projects.

It has a few unique and cool features, but we should periodically remind everyone that every microcontroller is a set of tradeoffs and compromises that the user should evaluate.

On the other hand, if you’re going for maximum clicks or views, putting “Raspberry Pi” in your headlines is a guaranteed way to bring in more eyeballs. It’s constantly a hot topic.


People don't use Arduino because it's "the premier microcontroller," they use it because it's easy to use.


The price of an Uno is very low, considering that "Buying an Arduino" usually means "Buying a clone".

But yeah, the only reason I'd use an RP2040 is as a USB peripheral, and even then I'd use an ESP32 S2 or something.

I just... don't have much use for non-connected chips as a hobbyist. On a pro project, I get it that there's sometimes demand for non-connected stuff, but it's usually not super exciting.


Note that the price of a genuine Arduino UNO is essentially funding the development of the Arduino IDE and open source tooling and documentation. Pretty clever really, since few like to pay for ide or dev environment. The Arduino ide isn’t fancy but it helped spur change in the embedded world.


Nearly all of the stuff that makes the Arduino interesting comes from places other than the Arduino company itself, though - even the IDE and the user-friendly Arduino libraries that ship with it were basically just copied from the Wiring project. Their ports to microcontroller architectures other than the one Wiring was based on have also been kind of poor compared to community-developed and third party ports.


It's definitely worth supporting, they are the best thing to happen to embedded in a long time.


The actual Uno (i.e. AVR-GCC) toolchain I wouldn't expect to change a lot. But they do have a habit of releasing a crapton of boards on different uC archs.

And the libraries are written mostly by 3rd parties.


Given that RP2040 needs external flash, I'm quite worried about the performance when pulling uncached code from it (on top of using M0 core - I'm used to M4 by now). I know the MCU has 16kB of cache, but my firmware for which I'm still deciding on whether to port it to RP2040 or not is about 80k. Does anyone here has some real-life data on this?


With 80k of firmware, you can just put it all in RAM ;)

The M0 is not much slower than M4 when running at the same clock, and the RP2040 can run quite fast. Of course it's different if you comparing to M4F and need float32.

If you end up putting code in SPI flash and you need predictable latency, you will need to put ISRs and everything they depend on in RAM [0]. However, if you don't need down-to-microsecond latency, then it's just fine.

[0] eg https://github.com/lancaster-university/codal-rp2040/blob/ma...


RP2040 PIO has better timer resolution then ESP32 (in part because GPIO in ESP32 has to go through IO MUX).


acronyms in your post:

ADC

DNL

NIH

NRE


ADC Analog to Digital Converter DNL Differential Non-Linearity NIH Not Invented Here NRE Non Recurring Engineering


This is 2x the size of a xiao/qtpy, has less stuff(?), and is more expensive. What are the advantages?

https://www.seeedstudio.com/XIAO-RP2040-v1-0-p-5026.html

https://www.adafruit.com/product/4900


It's best to treat Tindie as a venue to support the developer/creator, not as a source of inexpensive stuff.

If you want it cheap - this project is fully open source - one can make the board themselves, might be possible even order it assembled in larger quantities from PCBWay or JLCPCB.


Exposed pins, for one. There's 30 GPIOs on an RP2040, only having 12 or so of them available is a weakness of rhe tiny boards.


Especially with the RP2040, having less pins exposed is kinda dumb. The programmable GPIO ("PIO") is the chip's whole raison d'etre.


Raspberry Pi Pico has 26 GPIO and is $4 assembled.


Yeah, but the question was why buy the stamp when smaller boards exist. You won't get much smaller than the stamp with so many exposed pins, since it's basically just 2mm pitch pads packed on every edge.

I'd probably say suck it up and solder the QFN directly if you need all the GPIO in minimal space, though.


Those extra 4 pinouts can be key to being able to use a board for a given project.


Gotta wonder how often that happens: 30 pins are enough, but 26 aren't?

I've had stuff that wanted 3-5 pins, or maybe 10 pins. I've had stuff that wanted 100's of pins. I can't think of anything that wanted, specifically, between 27 and 30 inclusive.

Does the Pico really fail to bring out 4 of them anyway? That is kind of surprising. I know that it uses one of the ADC's for battery monitoring, leaving just 3, but maybe you can get it back by cutting a trace or something.

Is it practical and useful to connect 20+ of the pins to PIO ports? The PIO's are very limited.


That’s like asking why someone would choose a bigger FPGA when a smaller one does the same thing for less cost. The answer is: the bigger one has a different feature set. In this case, it’s access to all 30 of the GPIO.


Ah I see. I hadn't thought about using all the pins. This brings out 23 of them and is about the same size as the stamp: https://www.adafruit.com/product/4888

This brings out 20 and has castellated pads: https://www.adafruit.com/product/5302

This is bigger but fancier, has a lipo charger and other stuff. I think it brings out all available pins, though the # mentioned is 21. More of an SBC than a solder-down, I guess. I have one (old version) but am trying to figure out where I left it: https://www.adafruit.com/product/5302


30 GPIO pins broken out vs. 13 is a good start. I also see no mention of the battery charging stuff on either of the boards you linked.


Oh! Solderparty is based in Malmö, Sweden.

The southern region seems to have so much exciting tech going on, it really feels like it's starting to do laps around the Stockholm region.

The city embraced digital culture decades ago with a crazy amount of game dev jobs per capita and even a brief precense in Second Life. Now it seems full of startups and it's nice to see smaller projects pop up as well!


Wait what? I live here and it seems pretty dead technologically, aside from the small number of game studios.


There isn't a small number of game studios. You have at least 5 just in the first 200 meters from the station, and afaik 35+ total studios.


How many of those are online casinos?


I didn't even count those. But they exist too =/


I'm curious which you meant though, there's King, "Hero Gaming" (gambling) and Sharkmob close to central station.. that's all I can think of.

To get to Massive you have to go to Triangeln since it's closer to Mollan these days.

Paradox is mostly in Stockholm, not really in Malmo. IO is mostly Copenhagen, Avalanche is primarily Stockholm too.

I guess there's Tarsier?

So, Tarsier, Sharkmob and Massive, the rest being sattelites. :\

What else is there?


It looks very neat, too bad it costs three times as much as a regular Pico. I'm not sure it was essential to include the NeoPixel and LiPo charging.


It’s priced about the same as the other tiny rp2040 boards. I wish this would have existed around the time I was building my last project, because I wanted something without a usb connector.


Are the pico's PWM channels true hardware PWM (truly on/off) or software-emulated PWM (flickering on "fast enough" to create an envelope)

Some cheap, learning platforms like the micro:bit do emulated PWM which yields jittery servo demos. Sure you could put a circuit to smooth the on/off cycle, but as an instructional tool, I like the external hardware to be as minimal as possible.


The NRF51 on micro:bit doesn't have a PWM, so indeed it's emulated. The NRF52 on micro:bit v2 has PWM, so you should see no jitter. RP2040 can also generate PWM signals in multiple ways.

BTW, the problem with servo is not about "flickering not fast enough" but about length of the pulse. Servos require ~0.5-1.5ms pulse every 20ms, where the length of the short pulse maps ~linearly to angles of the servo. If you miss the timing by say 50us you get jitter.


Are you sure about the nRF51? It doesn't have dedicated PWM but as I recall you can connect the timer peripheral to the GPIOs so it's still all done in hardware. Maybe that was not worth the software effort though.


RP2040 has 16 hardware-based PWM channels with freq from 7.5Hz to 62.5MHz.


Am a noob wrt RP2040. I use rPI model B boards to run piHole, media server, apc daemon etc. What can I use this RP2040 stamp for? Which OS runs on it? Is stamp a standard form factor?


The RP2040 is a CortexM0 microcontroller. This is a completely different segment than the previous mini-computers from raspberry pi.

It just has a few hundreds KB of Ram.

It usually runs bare metal or some RT OS.


You could use it like an Arduino. It has good software support but limited connectivity.

The stamp draws its legacy from the BASIC Stamp, a small stamp sized (by a stretch) module that could be programmed with BASIC.

It's not a standard form factor.


I like the principle of doing all of the highest-density routing on the smallest possible board, with minimum peripherals.


Where is this claimed USB port? I don't see it in the pics.

Think it can output 4k video?


It says "USB broken out" which means the pins are available, you need to connect your own cable or port though.

It's also a microcontroller, which in general don't output video signals at all. You might be confusing it with a Raspberry Pi.


I'm very newbie to microcontrollers and I bought 10 pico boards, 5 with pins, 5 bare. What I've found not very nice is that there's no official programmer for RP2040. I can use one board, upload firmware and connect it to the other board with wires, actually that's what I'm doing right now with breadboard, but that's not very nice to use, I have lots of wires laying around.

I'm thinking about creating a programmer with 3D printer and some spring contacts, but I really would love some tiny device with RP2040 inside where I can put another RP2040 and have all pins available for further connecting if necessary. Right now it's a mess of wires.

Another RP2040 aspect which I didn't like is a complexity of boot process. Now I have no idea whether it's common to microprocessors or not. What I wanted to do is to write my software with pure assembly without any SDKs. So far my research is as follows:

RP2040 contains unmodifiable boot1 code. You can't modify it at all. It contains some preliminary initialization code and some procedures like float point operations, etc. That looks very weird to me: why put that code in unmodifiable ROM. There're few revisions of this ROM with different procedures (I guess they optimize them in later revisions).

Boot1 connects to flash and loads 256 bytes of boot2 loader which contains 252 bytes of code and CRC32.

Boot2 is compiled from SDK. It configures flash for some kind of faster access mode and calls sdk initializtion procedures. I didn't investigate further yet.

I managed to learn ARM Cortex M0 assembly, at least most of it, and it's interesting to try to program with it. But now I'm stuck with reading about flash, those QSPI protocols and their commands to make sense of their boot2 bootloader (I could just re-use one from SDK but I don't like this way). And then I still need to understand how to configure the whole stack to run code from flash.

Basically to re-implement writing hello world to UART, I have to learn a lot of things. Which is fine, I guess, but I didn't imagine this being that hard. I thought that I would need to learn about UART hardware and how to interact with it and that's about it.

And I really don't like their SDK. I managed to get it up and running, but they're using cmake which is cryptic for me, it takes seconds to compile my software, I have enough of that in my Java work. I guess that's fine for professionals who need to get things done.

That's not to say that I don't like this project, I still think that's the most friendly ARM, at least when I tried to use STM32 it was much worse. RP2040 datasheets are very readable for beginner. I just wish their setup was not so convoluted.

At this stage I'm considering to drop flash usage at all. I have 256 KB of RAM anyway, ought to be enough for anybody, right? Just copy my program from flash to RAM and run it from RAM. On the plus side is predictable performance. I still don't understand how can one write timing-sensitive code with flash where jump to non-cached address could stall CPU for some unspecified number of tacts.


The programming interface and the bootloader in rom setup is more-or-less standard in the ARM microcontroller world.

For programming the RP2040 you can use any SWD debugging probes (which you can also use to debug the chip, single stepping, setting breakpoints and more).

Many like the Segger J-Link (the EDU Mini might be an option), while I prefer to use daplink based probes, of which there many available.

The RP2040 is especially egregious with it's RAM caching, but many ARM Cortex chips, especially the faster ones, utilize some sort of caching, since internal flash might not be fast enough.

Often dedicated peripherals are used (the PIOs for the RP2040) and/or critical routines are copied into RAM (but usually not everything).


> I can use one board, upload firmware and connect it to the other board with wires

Yes, the picoprobe is the official programmer/debugger. It's super cheap, easy to set up, and I'm not sure why you'd want anything else.


The boot process you describe is a side effect of using external flash. Microcontrollers with internal flash like the STM32 will just start executing at a certain memory address depending on which boot mode is selected.

I'm curious what you think made the STM32 worse however, as in my experience they have good documentation and good options for the development software (and also a few not so good ones)


I particularly "like" the how they copy&paste manual sections for TIM1, TIM3/4, TIM6/7, TIM14, TIM15/16/17 (this is from STM32G0). I get it, there are some features only available on say TIM1, but why on earth would just copy everything, instead of having one TIMx section and saying "only available on TIM1-4" on specific registers?

It's particularly fun if you want to write a driver for all TIMx - you have to de-dup in your head.

I find the LL (low level) library from STM relatively nice; OTOH their (high-level) HAL is plain awful. Simply writing registers isn't too bad either, especially that even in that case what you write will mostly work across their different microcontrollers.

In general, I find the NRF52 docs and hardware to be much more straightforward but it could be that they don't have to support every single feature on the planet like STM ;)

edit: typos, wording


> A Neopixel

Nice touch!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: