Table of contents
- Installing Pico SDK
- Building and flashing Sigrok Pico
- Installing Pulseview and libsigrok
- Testing with Pulseview
- Breakout board
In this project I've tried using a Raspberry Pi Pico as a very cheap logic analyzer. From my crude testing it seems to be able to run at up to 120MHz and collect up to 50k samples.
Installing Pico SDK
I'm using arch linux at the moment so the commands assume arch linux.
We'll need the pico-sdk, we can either clone it directly from RaspberryPi's github page1 and install the required dependencies manually or we can use the AUR package2 which already depends on the right compiler. I chose the latter.
pikaur -S pico-sdk
Since I'm using fish and I'm not sure if the config installed in /etc/profile.d/pico-sdk.sh
will get picked up
properly I've added my own config to ~/.config/fish/conf.d/pico-sdk.fish
:
set -gx PICO_SDK_PATH /usr/share/pico-sdk
Building and flashing Sigrok Pico
This is the program program that will allow us to use Pico as a logic analyzer.
Clone the sigrok-pico
3 repository. At the time
of writing the latest commit is e4d6756
. Only the pico_sdk_sigrok
directory from this repository is of interest to us.
There is already a prebuilt UF2 file at pic_sdk_sigrok/build/pico_sdk_sigrok.uf2
which worked for me as well as the one I built.
To build successfully on Arch I needed to tell cmake to use the right compiler
first, also I found the PICOBuildNotes.md
file to be updated, so the build
commands which ended up working for me were:
cd pico_sdk_sigrok/
cp /usr/share/pico-sdk/external/pico_sdk_import.cmake .
cd build/
CROSS_COMPILE=arm-none-eabi- cmake ..
make -j4
To install this I've used the UF2 file. Plug the RPI Pico while holding down the BOOTSEL button,
a new USB storage medium appears. In my case as /dev/sdb1
.
usb 2-3: new full-speed USB device number 16 using xhci_hcd
usb 2-3: New USB device found, idVendor=2e8a, idProduct=0003, bcdDevice= 1.00
usb 2-3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 2-3: Product: RP2 Boot
usb 2-3: Manufacturer: Raspberry Pi
usb 2-3: SerialNumber: E0C9125B0D9B
usb-storage 2-3:1.0: USB Mass Storage device detected
scsi host3: usb-storage 2-3:1.0
scsi 3:0:0:0: Direct-Access RPI RP2 3 PQ: 0 ANSI: 2
sd 3:0:0:0: [sdb] 262144 512-byte logical blocks: (134 MB/128 MiB)
sd 3:0:0:0: [sdb] Write Protect is off
sd 3:0:0:0: [sdb] Mode Sense: 03 00 00 00
sd 3:0:0:0: [sdb] No Caching mode page found
sd 3:0:0:0: [sdb] Assuming drive cache: write through
sdb: sdb1
sd 3:0:0:0: [sdb] Attached SCSI removable disk
To flash the UF2 file we run:
sudo mkdir -p /mnt/usb
sudo mount /dev/sdb1 /mnt/usb
cat /mnt/usb/INFO_UF2.TXT # verify that it's our Pico
sudo cp pico_sdk_sigrok.uf2 /mnt/usb/
sync
sudo umount /mnt/usb
Now we should se a USB serial interface appear, we'll use this serial interface in Pulseview.
usb 2-3: new full-speed USB device number 21 using xhci_hcd
usb 2-3: New USB device found, idVendor=2e8a, idProduct=000a, bcdDevice= 1.00
usb 2-3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 2-3: Product: Pico
usb 2-3: Manufacturer: Raspberry Pi
usb 2-3: SerialNumber: E66118604B4D6724
cdc_acm 2-3:1.0: ttyACM0: USB ACM device
Installing Pulseview and libsigrok
At the time of writing the latest released libsigrok version does not yet
contain the Raspberry Pi Pico device driver so we'll need a newer build.
The easiest way to get those on Arch is via AUR4. I also installed the
sigrok-cli
tool in case it's needed for debugging or otherwise useful later.
pikaur -S pulseview-git sigrok-cli-git
At the time of writing the installed package versions are.
libserialport-git r401.fd20b0f-1
libsigrok-git 0.2.1.r4313.gb503d24c-1
libsigrokdecode-git 0.2.0.r1505.g0c35c5c-1
pulseview-git 0.3.0.r1160.g105ecffd-1
sigrok-cli-git 0.6.0.r119.g9d9f7b8-1
Testing with Pulseview
For testing I used a simple USB UART device I have laying around because I
wanted to try decoding real data with Pulseview. I've used the yes
command to
feed it data I could then recognize in the output. The sterm
5 command I'm
using is an alternative to something like minicom
, it was written by my uni
professor and I prefer it but you don't have to use it.
yes 'hello world' | sterm -s 115200 /dev/ttyUSB0
In Pulseview click the button which says "<No Device>" in the top bar, then
select the raspberrypi-pico
device driver, select serial port, scan for
devices and pick the Pico.
Connect GND and TX of the UART adapter to the Pico GND and any GPIO pin. Then press spacebar in Pulseview to trigger a recording, you should see all but one channel stay LOW and one will have the UART signal.
I've renamed the channel with signal to TX and disabled all other channels,
then I've added the UART decorder (which automatically picked up the TX channel)
to see the data. I can also see the repeated hello world\n
sequence in the
hexdump view.
Breakout board
To make the the Pico logic analyzer a bit nicer to handle (and mainly as an excuse to finally push through my fear of messing up), I've decided to design and build a breakout board around the logic analyzer use-case.
I wanted to use KiCAD, because it's open source and thus I don't have to worry about licencing nonsense or that it'll just disappear one day and the effort I've put into learning it will go to waste, and also because I was already a bit familiar with it. I've tried designing a couple boards before but I always got lost with picking the right components and their footprints and never managed to push a project to the end. This project was fortunately simple enough that I managed to do everything in a couple hours. Hopefully this experience will help me persevere with more complex project.
I want the signal pins ordered on a header so I won't have to remember where are the ground and power and other miscellaneous pins. I also need the ground pins but since I don't want them mixed up I've decided to put them in a different row of the header, and there is no harm in having a ground pin for every signal pin, at least I'll never have trouble reaching it with a jumper wire.
It'd be nice if I could use 40 pin 0.1 inch pitch headers, as they'll align neatly with the Pico which also has 20 pins with 0.1 inch spacing along each edge. I'll have a bunch of pins left over but that's ok. This is the schematic I came up with.
The board was pretty easy to lay out with a ground plane at the back, with a small section of analog ground for the analog pins, and all the signal traces on the top.
Ordering a PCB was my first time. My first attempt was missing .drl
files with
hole definitions which luckily the manufacturer's reviewer caught and on the
second attempt everything went through. I picked a purple solder mask because
green is boring. With the cheapest shipping option and the minimum order of 5
boards it ended up costing just under €4 which is absolutely incredible. I'm
curious how is the price going to scale with more complicated boards but it's
nice I'll be able to do more simpler practice projects without having to worry
about money.
aur/pic-sdk package,
which depends on arm-none-eabi-
builds of gcc
and binutils
. It also
optionally depends on gdb
which will be important for on chip debugging.
aur/pulseview-git and aur/sigrok-cli-git packages, both depend on aur/libsigrok-git.
github.com/wentasah/sterm, there is no AUR package for it but it's very easy to build and install.