World’s Cheapest ARM Debugger Is Actually RISC-V

[bogdanthegeek] has a lot of experience with the ARM platform, and their latest escapade into working with cheap ARM chips recovered from disposable vapes involved a realization that it was just plain wrong to debug such recovered silicon with something as expensive as a Pi Pico. No, they needed to build a debugger using the super cheap CH32V003.

What follows is an interesting tour around ARM Debug Access Port (DAP) programmers and creating a practical USB-connected device that actually works with modern toolchains. The first problem to be solved was that of host connectivity. These days, it’s USB or go home, which immediately limits the microcontrollers you can choose. Luckily for [Bogdan], they were aware of the excellent work by [cnlohr] on wedging low-speed USB support onto the RISC-V CH32v003 with the software-only bit-banging rv003usb, which provided a starting point. The next issue was to check for interrupt-driven endpoint support (needed for low-speed USB) in the Mac OS X kernel, which they knew was being dropped at an alarming rate (well, at least for full-speed). Luckily, the CMSIS-DAP standard required support for interrupt-driven USB endpoints, so kernel support was likely intact.

Next, [Bogdan] noticed that the DAPLink project had been ported to the bigger, native-USB WCH chips like the CH32V203, so it was a matter of porting this code to the diminutive CH32V003 using the rv003usb stack for the USB support using [cnlohr]’s ch32fun toolchain. There were a few bumps along the way with a lack of clarity in the DAPLink code, and some inconsistencies (across platforms) with the USB library dependencies of the upstream tool pyOCD, but they did get some tools working on at least Mac OS and some others on Linux. Which was nice.

We’ve covered the CH32V003 a fair bit, with people trying to give it all kinds of big-CPU tricks, such as speech recognition (of sorts) or even building a supercluster.

18 thoughts on “World’s Cheapest ARM Debugger Is Actually RISC-V

      1. Life is not just about computers. Beekeeping is an awesome hobby! It connects you with nature and helps support the environment. If you’re into it and just joined the Kingdom of Christ, you can use your passion for bees to connect with others and share some good vibes. You could set up workshops in your community to teach people about beekeeping: like how to start a hive, manage bees, and harvest honey. Plus, this could be a great way to bring people together, especially if you’re sharing the message of community and care (which btw. was not allowed in the Soviet Union). And think about how you can use your skills to help local charities. You could create pollinator gardens or bee habitats in schools, promoting awareness of how important bees are to producing honey. It’s all about spreading the love for bees and making a positive impact while connecting with your faith..

  1. I’m all for hacking on the CH32 series, though on that front i’m not sure this project brings anything new? A hack for a hack’s sake, sure. I found the premise stated in the article to be wrong though :)

    The Pico is specifically a powerful chip in a convenient format that happens to be cheap enough to use it to scrape the mud off your boots. I’m a little sad using a $25 STM 32 Value Line Discovery board as just a USB-SWD interface. But the $4 pico is perfectly suited to this task.

    Though i see since the last time i looked, the stm32 board seems to have gotten a lot cheaper…competition!

    1. Echoing my thoughts when I read the article. hacking for hacking sake is great fun. But calling the Pico and Pico 2 expensive is a real stretch! $4 to $8 dollars for what you get is ‘cheap’, versatile, and a time save.

    2. WeAct sells an st-link/v2 clone that seems to use real STM32 chips, to the point it works in the current version of stm32cubeide, unlike the normal cheap stlink clones, if you don’t want to use a Discovery board.

    1. Yes, exactly. I prefer the opposite way, not low speed but CMSIS-DAP with 480Mbit HS mode. There are working builds of CMSIS-DAP on github for CH32V305 used in WChlink-E and its clones and another one is for BL616 chip (Sipeed M0S or othet similar boards), both are risc-v with HS node with price similar to Pico (about US$3-5 including shipping from aliexpress)

  2. A single-task interactive OS running on the target hosting a standalone
    BASIC or a Forth obviates need for an external debugger?

    These systems can be contained on a single board which can be plugged into
    the target … and removed when not needed. :)

  3. I realise it’s a minor point but DAP = Debug Access Port (I don’t blame [Dave], it’s actually wrong in [Bogdan]’s writeup).
    It’s made up of Debug Ports (JTAG or SWD) and Access Ports (AXI, AHB, APB, JTAG), to further hammer home the “Port” part of it’s name. Strictly it’s also not an interface in its own right but a bridge from external world interfaces onto various on-chip interfaces (hence all the ports).

  4. neat intellectual excercise. Not all that useful in the real world, though. Those speeds are PAINFUL. Especially if you have more than a few Kb to write. DAPv1 used here, over HID is much slower than DAPv2 using bulk transfers.

    You could get a MUCH faster debugger for just a few cents more. Something with hardware USB. CH32X033 might be a good candidate, for a whopping .25c

Leave a Reply to William PayneCancel reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.