KiCAD Tutorial: Hardware Design for RP2040 (Part 1: Schematic)
The Raspberry Pi RP2040 is a sleek new microcontroller. While the Raspberry Pi Pico is gaining popularity as a maker or prototyping board, the RP2040 (the Pico's brains) can be used in the same way as any other microcontroller. That is, you can design your printed circuit board (PCB) for it.
We'll give you some pointers to keep in mind as you design your RP2040-based board.
The schematic and layout files for the board (created in KiCad v5.1) are available here: https://github.com/ShawnHymel/rpi-pico-debugger-shoe
Reading Suggestions
Before you begin, we strongly advise you to review the following documents (or videos) or keep them handy for future reference:
- RP2040 Datasheet - This document contains important electrical and mechanical information for the RP2040 chip.
- Hardware Design with RP2040 - Official Raspberry Pi guide for creating a PCB with the RP2040.
- Intro to KiCad - Video series demonstrating how to use KiCad (note: the video uses an older version of KiCad)
- Creating a Raspberry Pi Compute Module 4 (CM4) Carrier Board - A step-by-step guide for creating a PCB for the CM4 in KiCad, complete with USB-C schematics and instructions for calculating differential pair impedance for USB data lines.
What Am I Creating?
More than anything, this is a demonstration of how to make a working PCB for the RP2040. You are free to use this design as a starting point for your projects. However, for my purposes, I wanted to create a "debugger helper." Right now, using the picoprobe debugger requires wiring up two separate Pico boards, which can take up a lot of space on a breadboard.
My goal was to design a "shoe" (rather than a "hat") that sits beneath the target Pico and connects via SWD and UART pins to provide debugging support without taking up extra breadboard space. I'd still have to manually connect the SWD pins, but it makes for a much cleaner step-through debugging and prototyping experience in my opinion. It was probably unnecessary, but it was a fun project for me.
The extra-long pins on the shoe are identical to those found on many Arduino shields. The majority of the shoe's pins are not connected and simply pass signals from the target Pico to the breadboard. The SWD pins and UART (pins 0 and 1), on the other hand, would be connected to the debugger and unavailable for use.
Finding Replacement Parts
At the time of writing, the world is experiencing a chip shortage. Finding replacement parts is either difficult or expensive. As a result, we had to make a few changes to the parts recommended in the RP2040 hardware design guide.
The guide, for example, recommends a Winbond Electronics W25Qxx quad-SPI flash memory. It does, however, provide a list of instructions that the flash memory chip must support. If the chip supports those instructions, it should be a good substitute. So, rather than the W25QJVSSIQ (which was out of stock when I ordered parts), I went with the MX25L3233FM2I, which, according to the datasheet, uses the same instruction set.
Edit: I later discovered that the Macronix chip is not a drop-in replacement! If you're looking to build your RP2040-based PCB, I recommend getting a Winbond W25Q series flash chip, which is known to work with the RP2040.
I didn't think a full buck-boost converter was necessary for this simple debugger on the Raspberry Pi Pico. We only need to reduce the USB 5V to 3.3V, so a less expensive LDO should suffice. SparkFun and Adafruit both sell a lot of the AP2112K-3.3V fixed voltage LDO. However, it was also out of stock, so I found a suitable substitute: the XC6210B332MR-G. It's more expensive, but it should suffice for my purposes.
Making Use of Pre-Made KiCad Parts
To save time, I recommend visiting the Digi-Key product page and looking for links to Ultra Librarian or SnapEDA. If you don't see any such links, go to either of those websites and search for your part. Download your part's KiCad schematic and footprint. You will almost certainly need to unzip the files. I keep these third-party libraries in my project directory in the hardware/pcb-name>/libraries folder.
If you can't find your part, you'll have to design your part and footprint. Always read the datasheet for your part!
Please keep in mind that the RP2040 Ultra Librarian symbol and footprint can be found here.
Open the Project Manager window after you've created your project in KiCad and go to Preferences > Manage Symbol Libraries. Navigate to the Project Specific Libraries section. To add an existing library to the table, click the folder button. Choose the .lib file from the downloaded library. To save, click OK.
After that, navigate to Preferences > Manage Footprint Libraries. Navigate to the Project Specific Libraries section. To add an existing library to the table, click the folder button. In each downloaded library, navigate to the .pretty folder. It's worth noting that the .pretty folders in the Ultra Librarian libraries will all be called footprints .pretty. I recommend changing the Nickname to reflect the part name to avoid conflicts with your library manager (e.g. rp2040). To save, click OK.
Schematic
The schematic for my RPi Pico Debugger Shoe. A PDF version is available here.
A few words about the schematic:
- To match the Pico, I used a USB Micro B connector. You are free to replace this with a USB-C connector in your design. Just keep in mind that you'll need some pull-down resistors to get it to work.
- On the USB D+ and D- lines, 27 series termination resistors are required.
- If you prefix the USB data lines with _P/ N or +/-, KiCad will route those lines as a differential pair.
- Each IOVDD, DVDD, and ADC AVDD pin on the RP2040 requires a single 0.1 F decoupling capacitor. During layout, keep these capacitors close to those pins.
- The RP2040 contains a 1.1V regulator that powers the core. You must connect 3.3V to the regulator's input (VREG VIN) and the output (1.1V) to the DVDD pins. A 1 F decoupling capacitor should be installed on both the input and output lines.
- The recommended crystal/oscillator speed for the RP2040 is 12 MHz to get the PLL working and everything working for USB speeds. Here's a good article that explains how to calculate the crystal's supporting capacitor values.
- On boot, the RP2040 samples the QSPI CS line. If this line is low, the computer will enter its USB bootloader mode (i.e. enumerate as a mass storage device so you can upload new firmware). If this line is high when the computer boots up, it will begin reading program instructions from the quad-SPI flash chip.
- The RUN pin functions similarly to the RESET pin on other microcontrollers. If you want to reset the processor, connect this line to the ground.
- In the picoprobe firmware, GPIO2 through GPIO5 are used as UART and SWD host functions, which is why we connect these to the target Pico on this board.
- I enabled the debugger RP2040 SWD pins in case I need to debug this chip or upload code manually. It should not be connected to the SWD port of the target Pico.
Footprint Assignment
I recommend using the provided third-party library footprints for the parts you downloaded when associating footprints with schematic symbols. I also recommend double-checking that the footprints are correct.
For the supporting capacitors and resistors on my board, I chose 0603 SMD parts with "HandSolder" (extra long) pads. This allows me to hand-solder some of the components. However, because the decoupling capacitors competed for space near the power pins, the layout became quite crowded around the RP2040.
Conclusion
The RP2040 documentation is fantastic, and I hope this post has given you an idea of how to create a schematic for your own RP2040-based PCB!
If you want to see this content in video form, go here:
[source]