One of the tools I knew I was going to want straight away on my new LattePanda Alpha is Sigrok – or to be more precise, the PulseView logic analyser tool. I already have this running on my old Windows 7 laptop, but who the hell wants to use that, right?
However, Sigrok is created by hackers for hackers and if you’re a lowly beginner installing it can be a bit fiddly. The online documentation has that haughty attitude so common, alas, among coders that you’re just expected to know how to do things. It is, in short, newbie hostile. So here’s how I got things working under Ubuntu 18.04.
First up, I’m using the cheapest possible logic analyser device. You’ll find these things like a rash all over Ebay, usually passing themselves off as ‘Saleae Logic’ devices. They’re nothing of the kind, but they they are based on the Saleae Logic design, albeit without the bizarrely high price.
They use the Cyprus FX2 chip and Sigrok has developed its own firmware for this. So that should make life easier, right?
But first things first. I downloaded PulseView from the Sigrok downloads page. I opted for the 64-bit Linux binary. This comes as an AppImage file, a somewhat new and welcome development for Linux. Much like the app bundles on macOS, all you need to do with an AppImage file is make it executable (chmod +x filename.AppImage) and lo! It runs! No installation process. No configuration files in obscure locations. It’s all neatly packaged. So that’s good.
I tend to keep programs I’ve installed myself in /usr/local/sbin/ (don’t ask me why, it’s how I roll), so that’s where I put the file. As the filename is long, including the version, I also created a symlink in the same dir to call the program with something snappier:
ln -s /usr/local/sbin/PulseView-0.4.1-x86_64.AppImage /usr/local/sbin/PulseView
(That’s all on one line, by the way.) That way, if I upgrade the package at some time, I only have to modify the symlink to keep everything working.
The next thing to do was make a desktop icon for it. I headed over to this git page to grab an icon image (the 122×122 PNG works fine). We’ll be coming back to this page soon. I put the icon image in the same directory as the executable, to keep everything neat, but renamed it PulseView.png.
Next, I opened my text editor and created a file called PulseView.desktop in my ~/Desktop/ folder:
[EDIT: I changed the version number in the example above. The version number refers not to the executable but to the desktop file itself. 1.0 is a safe value to use. Or you can leave out that line altogether.]
Having saved that file, I made it executable with:
chmod +x PulseView.desktop
That puts a clickable icon on the desktop, but I wanted a bit more. So I installed desktop-file-utils:
sudo apt install desktop-file-utils
While in the ~/Desktop directory, I checked the file I’d just created was error-free with:
And once happy, ‘installed’ it with:
Now PulseView appears in the launcher – apps you see when you click the ‘Show Applications’ icon – and from there you can add it to the favourites in the dock. At that point I could delete the desktop version.
It runs, but…
So far, so good. Clicking on the icon runs PulseView fine. But it couldn’t see my logic analyser. That’s because it didn’t have the firmware files that need to get loaded into the analyser when it’s plugged in and PulseView is run.
Well, no problem, the firmware files are here. Just need to download them and decompress them into a place PulseView can find them.
Looking at the ‘About’ info in PulseView tells you its firmware search paths. The first of these was ~/.local/share/sigrok-firmware/, so that’s where I put them. Restarted PulseView and… hmm, no dice. Another popular location is /usr/local/share/sigrok-firmware/ so I tried that and – still nothing.
Then it occurred to me to run PulseView as root. I headed to the command line and used ‘sudo PulseView’ and, sure enough, the program ran and could see the logic analyser.
Oops, yes, I forgot that you also have to mess with udev.
That git page I mentioned? It has three udev rules, of which you need two. Which two? Work it out. I’m running Ubuntu 18.04 which, I believe, uses systemd, so it appears that I need these two files:
The other file, 61-libsigrok-plugdev.rules, is if you’re using plugdev and your user (ie, you) has to be a member of the plugdev group. This is ‘explained’ here. Except you’re just expected to know which rule set you need.
Anyhoo, I put those rules files into /etc/udev/rules.d/ and, just to be on the safe side, rebooted.
Dammit, still not working.
Then I noticed I’d made a mistake. To save some typing, I’d used a bit of copy & paste and ended up naming 61-libsigrok-uaccess.rules as 60-libsigrok-uaccess.rules. It turns out the order in which order those rules files are executed is crucial. The ‘-uaccess’ set must come after the main rule set. Renaming ’60’ to ’61’ and another reboot finally had PulseView running fine.
Whew! And yes, I know this isn’t difficult for Linux adepts, but neither is it exactly ‘click to install’. And the fact is, with a bit more effort on the web pages that document this stuff, it could be so much easier.The simple description above of how to get PulseView running obscures the amount of searching and Googling I did, much of which could have been avoided with a bit of effort on the documentation side. For example, the fx2lafw page tells you to install the udev rules. But would it have killed them to include a link to those rules in that section? You know, like I just did?
But at least it’s working now.