At this point, a Pi Pico is equivalent to a bag full of programmers and debugging accessories. For instance, when you want to program an SPI flash chip, do you use one of those wonky CH341 dongles, or perhaps, even a full-on Raspberry Pi with a Linux OS? If so, it might be time to set those two aside – any RP2040 board can do this now. This is thanks to work of [stacksmashing] who implemented
serprog protocol for the RP2040, letting us use a Pi Pico with stock
flashrom for all our SPI flash chip needs.
After flashing the code to your RP2040 board, all you need to do is to wire your flash chip to the right pins, and then use the
serprog programmer type in your
flashrom commandline – instructions are available on GitHub along with the code, as you’d expect. Don’t feel like installing
flashrom, or perhaps you happen to run Windows and need a flasher in a pinch? [stacksmashing] has a WebSerial-based SPI flasher tool for you, too, and shows it off with a fancy all-the-pinouts board of his own making.
This kind of tool is indispensable – you don’t need to mod one of these CH341 programmers to fix the bonkers 5 V default IO, or keep an entire Linux computer handy when you likely already have one at your fingertips. All in all, yay for one more RP2040 trick up our sleeve – this SPI flashing helper joins an assortment of applets for SWD, JTAG, UART, I2C and CAN, and in a pinch, your Pi Pico will also work as a digital and analog logic analyzer or an FPGA playground.
10 thoughts on “Programming SPI Flash Chips? Use Your Pico!”
https://hackaday.io/project/7758-spi-flasher works over Ethernet :-)
Flashrom support was added to DirtyJTAG:
“Successfully tested with DirtyJTAG 1.4 running on an Olimex STM32-H103 development board and a SST25VF020B SPI flash chip.”
>flashrom for all our SPI flash chip needs.
flashrom can’t handle SPI NAND or multi-plane chips AFAIK so all of you SPI flash needs has to fit within the hackaday article hype filter notion of SPI flash chips which is the most basic SPI NOR.
a… hackaday article hype filter? consider this – as a rule, the SPI flash chips hackers see, are flashrom-supported; if these two exceptions were prominent enough, either flashrom would add support for them, or they’d be well-known as exceptions and worth a mention. It’s cool that you got to show off your “flashrom doesn’t work with SPI thisandthat”, but you don’t have to imply something derogatory.
>as a rule, the SPI flash chips hackers see, are flashrom-supported;
Not really. flashrom supports chips that are commonly used for BIOS chips on PCs and PC expansion cards which happen to be SPI NOR.
>if these two exceptions were prominent enough, either flashrom would add support for them,
flashrom doesn’t add support for them because it’s generally used for the above mentioned use cases. flashrom is pretty unfriendly for just updating a piece of a chip and other stuff you commonly want to do when messing with SPI flash.
>they’d be well-known as exceptions and worth a mention
All the big SPI flash vendors make SPI NAND chips. They are supported in u-boot, the linux kernel, boot roms for SoCs and there are tools that work like flashrom (with the bonus of being to update parts of a chip without making yourself go insane) but work with SPI NOR and SPI NAND like SNANDer (https://github.com/McMCCRU/SNANDer)
>but you don’t have to imply something derogatory.
So maybe s/letting us use a Pi Pico with stock flashrom for all our SPI flash chip needs./letting us use a Pi Pico with stock flashrom to read and write the numerous SPI flash chips it supports/
The NOR flash chips are basically everywhere, and that’s what hackers work with as a rule. I appreciate the nuance, met the “can’t just update part of chip” stuff myself, but you just don’t gotta start out with “hype filters” if the balance of “verbosity vs clarity” doesn’t match what you work with.
Last I checked flashrom worked on Windows, where I’ve used it with my implementation of serprog (https://github.com/bit2shift/serprog-due) to dump and flash the firmware of some laptops.
yeah, serprog method sounds like it’d would work wonders, which makes this firmware even more valuable! as opposed to CH341A+flashrom+Windows – if that makes sense, I’m not hopeful =D
“You don’t need to hack the ch341 to fix the 5V…”
Erm, sure, I’ll skip the 2-minute fix, ditch the very easy, cheap and convenient $4 CH341 and make an entirely new programmer from scratch.
Please be kind and respectful to help make the comments section excellent. (Comment Policy)