Turn $1.5 Blue Pill STM32 board into a Sigrok compatible logic analyzer

Blue Pill” is a popular STM32 development board thanks to its low cost – now as low as $1.50 on Aliexpress – and Arduino compatibility via the STM32duino project.

People have created all sorts of projects around the tiny STM32 board, but I find Mark (aka thanks4opensource) buck50 test and measurement firmware very interesting as it turns the Blue Pill board into a logic analyzer compatible with the open-source Sigrok command-line tool and PulseView GUI.

Blue pill STM32 logic analyzer sigrokMark explains the firmware is still at the beta stage, so bugs will most likely have to be fixed. Nevertheless, Buck50 firmware should enable the following key features on the Blue Pill board:

  • 8 channel, 6+ MHz logic analyzer
    • Approx. 5K sample buffer depth
    • Samples stored only at signal edges for efficient memory usage
    • Complex triggering via user-defined state machine supporting combinations of sequential (“A then B then C”) and logical-OR (“A or B or C”) conditionals
    • Output to VCD and other file formats for export to waveform viewing programs that include Pulseview, but also gnuplot, gtkwave, and Saleae Logic
    • Live monitoring and logging of digital, analog, USART (sync/async), SPI (MOSI/MISO), and I2C (master/slave/TX/RX) data
  • Dual-channel approx. 1 MHz digital storage oscilloscope, approx. 5K sample buffer depth (10K if single channel)
  • Triple-channel digital pulse train generator with user-defined frequency and per-channel duty cycle and polarity
  • Bidirectional bridge/converter from USART/UART (async/synchro), SPI (master/slave), or I2C … to USB … to host terminal, UNIX socket, or UNIX pty device file
  • 8-bit parallel output counter (binary or gray code)
  • Host terminal ASCII or binary input data to 8-bit parallel output
Blue pill Buck50 connection diagram
Connection diagram for Buck50 test and measurement firmware

The firmware is written in C++ and ARM Thumb-2 assembly code, and a Python host driver program is also provided to control the board. There’s amazingly detailed documentation on Github, and the developer invites people to submit bug reports on the issue tracker as well.

I found the project announced on Sigrok mailing list, where some discussed the potential for STM32 fakes, and that using more recent STM32 chips may deliver better solutions without going into details (yet(.  This made me think about the NXP Cortex-M7 powered Teensy 4.1 board, but there’s already a logic analyzer firmware for that board: TeensyLogicAnalyzer, also compatible with Sigrok.

Share this:
FacebookTwitterHacker NewsSlashdotRedditLinkedInPinterestFlipboardMeWeLineEmailShare

Support CNX Software! Donate via cryptocurrencies, become a Patron on Patreon, or purchase goods on Amazon or Aliexpress

ROCK 5 ITX RK3588 mini-ITX motherboard

22 Replies to “Turn $1.5 Blue Pill STM32 board into a Sigrok compatible logic analyzer”

  1. Thanks for this! I coincidentally I just restarted working with bluepills! I’m going to need to try it out

    I think it’s amusing how you can use bluepills to flash bluepills and now bluepills to debug bluepills 🙂

    I originally wanted to try something out with a Longan Nano, but setting up the tools ended up being a bit onerous.. so I came back to the venerable these. A couple of things I’ve found:

    1 – There are some “improved” bluepill that has USB-C: https://github.com/WeActTC/BluePill-Plus I just ordered a couple and I’m waiting for them to arrive. Though it’s my first time Taobaoing to Taiwan and Taiwanese customs are a draconian bureaucratic nightmare.. so we’ll see if I get them. I’ll write an update if I get them and get them working

    2- Another coincidence… just the other day there has been a big update on this project: https://github.com/ObKo/stm32-cmake . I was trying to set something similar up a couple of years ago (https://geokon-gh.github.io/bluepill/) – but this guy’s cmake template is much cleaner than anything I could have done. I played around with it and it makes working with the HAL and embedded *much* more pleasant. I need to test it some more – but I anticipate it’ll make IDE/GDB integration much smoother and you should be able to jump around code and debug in any dev environment you want using just your distro’s packages

    Maybe … down the road.. if everything goes smoothly and I have some free time I’ll try compiling with a riscv compiler and flashing the GD32V … (one can dream)

      1. Oh yes, sorry – I was being a bit pedantic and yak-shave-y. To be more precise I was trying to get things working with libopencm3 and without platformio. But that’s my own hangup.. I’m not a fan of platformio. Obviously their devs put in a lot of work b/c the whole premise is wrong.. and it’s intentionally reinventing the wheel to create lock-in for their platform. It doesn’t do anything that you can’t accomplish with cmake/gcc/gdb/openocd

        I’d really recommend giving the cmake/openocd workflow a try. It’s a breath of fresh air. Using a knock off STLink and a bluepill

        That gives you an elf file.

        Then you can go into ../stm32-cmake/examples/fetch-cmsis-hal/CMakeLists.txt to see how the libraries are hooked up and modify it to correspond to your chip and whatever libraries you wanna use

        I think already at this point you can open the project in any IDE.. KDevelop/CLion/etc. and have full incremental builds and jump around library code etc.

        I’ll make a better write up with GDB etc. once I get something interesting working.

        There are probably some catches here.. but in theory you should be able point to a RISCV toolchain file and generate a RISCV equivalent for the elf file and then flash the Longan Nano. Though I’m not quite sure how that works.. b/c it’s not STLink/OpenOCD. Instead it uses some other mechanism which I’m not familiar with (dfu? something like that..)

        To flash you make a openocd.cfg file in the build directory. Mine looks like this:

        and then you just run

        And the chip gets flashed. Done!

        The only catch so far has been that I had a knockoff chip so I needed to modify the device ID number in /usr/share/openocd/scripts/target/stm32f1x.cfg

  2. Found that one a while back, while desperately needing a logic analyser. Never got to try it yet.

    Just ordered a couple of black pills with STM32 M4F cores, sounds like the perfect starting point for a DSO 😉

      1. Same here, waiting for shipment.

        I ordered the 411 variant, not sure which chip exactly, as I never got into M4f so far. But with 10$ for 2 incl. tracked shipping can’t complain ?

        1. I ended up with four of each variant F411 and F401 for around $28 shipped to the USA. Took two goes at it because it seems the first order got flagged by customs for some strange reason. Had to dispute the order and reorder (and wait). It appears the boards are clones, not actual WeAct boards, FWIW.

          1. Definitely hard to know who are clones and who are not.

            Here customs are pretty reasonable, up to about 60 -65$ its free, if they don’t trust the declaration they send a letter asking for cc statement. If it’s above you pay sales tax and around 20$ postal fees. Never anything didn’t make it. Except if our FCC counterpart has something on their list, but not sure what would happen then.

          2. As I linked above – they have a github with links to what I expect to be legit online stores

            (or maybe I’m naive..)

          3. Well to be honest I don’t think the pills have enough engineering into them to whine over IP. In pre Arduino times we would do such minimal boards over n over again by ourselves…

  3. Anyone familiar with Sigrok/Pulseview? I understand it’s an open source GUI for various logic analyzers / oscilloscopes…

    I’ve got a DMM that can transmit its readings to a PC via a (usb) serial port. I was thinking I could write a serial driver that gets the dmm samples and plots.. is it possible to integrate this with Sigrok? I imagine, Pulseview would have to repeatedly poll my driver for data and plot. I’ve looked at the Sigrok files, but don’t see the big picture on how it works, or more specifically, where I would need to tap into it to provide my data.

    Thanks!

    1. Yes, I use Sigrok/Pulseview sometimes. The simplest/cheapest way to get started is to first do some reading on the Sigrok/Pulseview pages.

      The next step is to get a Logic Analyzer (hardware). Most people start with one of the cheap Saleae/USBee-AX-Pro 8 channel 24 MHz logic analyzer clones that cost between ~$5.00 and ~$13.00 USD depending on where you buy it (e.g. AliExpress/Ebay/Amazon) and whether shipping is included.

      For example, this logic analyzer costs $12.49 on Amazon, it is sold by a fairly reputable seller, it has a warranty, is returnable, and it comes with “free” trackable 2-day ConUS shipping if you are an Amazon Prime member:

      https://amzn.to/32S1LGC

      In contrast, this is essentially the same device on AliExpress selling for $3.94 plus what is likely a couple/few dollars more for worldwide non-trackable shipping:

      https://fave.co/2K8mNdE

      The AliExpress version comes with the usual gotchas; the cheap shipping may take a month or more, the shipping may not be trackable, and even if it comes with a warranty it will probably cost too much and take too long to actually use it.

      Make sure you read all the instructions on the Sigrok and Pulseview pages. If you are installing in Windows pay special attention to the part about using Zadig to install the USB driver (if need be). If you work with embedded systems, there is a good chance you have used Zadig before and the correct driver may already be on your machine. Try plugging in the analyzer first and see if is recognized. As always, when messing around with USB drivers disable Bluetooth first.

      The article explains what is inside these cheap logic analyzer clones:

      https://atadiat.com/en/e-hands-on-test-saleae-usb-logic-analyzer-24mhz-8ch-clone/

      * Here is a better/faster but more expensive Logic Analyzer option:

      Take a look at the $50.00 USD “Open Bench Logic Sniffer” (OLS):

      http://dangerousprototypes.com/docs/Open_Bench_Logic_Sniffer

      https://bit.ly/3kxVMgo

      The OLS has a real FPGA on board, it uses the SUMP protocol, and it can do this:

      200Msps captures / 100MHz waveforms on 16 channels
      100Msps captures / 50MHz waveforms on 32 channels
      8 channels with 24K sample depth
      16 channels with 12K sample depth
      32 channels with 6K sample depth

      The OLS Logic Analyzer client software is cross-platform. However, finding the latest/best version can be a be a hunting expedition. I suggest you begin the search by asking on the OLS section on the Dangerous Prototypes forum here:

      http://dangerousprototypes.com/forum/index.php?board=23.0

      Sigrok also supports the SUMP protocol and the OLS, but there are some limitations. See this:

      https://sigrok.org/wiki/Openbench_Logic_Sniffer

      You should also familiarize yourself with the SUMP protocol by Michael Poppitz, and some of the SUMP extensions added by the OLS:

      https://www.sump.org/projects/analyzer/protocol/
      https://sigrok.org/wiki/SUMP_compatibles

      Happy sniffing…

        1. I feel compelled to point out that if someone wants to skip all the building, you can get the Salee clones very inexpensively and that gives you 8 channels at 24MS/s. Looks like I paid $5 (USD) for the last ones I bought–shipping included.

          1. The appeal of the blue pill solution is just I’m having one in my drawer, as opposed to waiting for weeks for a chinese parcel to arrive once I need a LA ?

          2. I agree that it’s not a bad solution if you have some urgency, but this thread is now talking about trying out boards they don’t have for this application. In that context, just buy the little logic analyzer boards. Heck, everyone go out and order one now so that you have it should you need it. Once you have a tool, you’ll be surprised at how often you end up using it. We work around problems because we don’t have the right tool. But once we have the tool, all that working around is no longer necessary and we really start to get the advantages of the tool. In this case it’s a $5 tool, just buy it!

          3. Well true.

            As a hobbyist sometimes we just do work arounds because we can, as a (semi) professional, I would probably get something slightly more capable, i.e. more channels etc.

            And a uC never makes a decent DSO, or specan, so once you have to deal with CE, FCC, UL, IC and other similar things you better be equipped.

Leave a Reply

Your email address will not be published. Required fields are marked *

Boardcon Rockchip and Allwinner SoM and SBC products
Boardcon Rockchip and Allwinner SoM and SBC products