This Arduino Debugger Uses The CH552

One of the things missing from the “classic” Arduino experience is debugging. That’s a shame, too, because the chips used have that capability. However, the latest IDE has the ability to work with external debuggers and if you want to get started with a classic ATMega Arduino, [deqing] shows you how to get started with a cheap CH552 8-bit USB microcontroller board as the debugging dongle.

The CH552 board in question is a good choice, primarily because it is dirt cheap. There are design files on GitHub (and the firmware), but you could probably pull the same trick with any of the available CH552 breakout boards.

There was a time when having a god-eye view of your embedded system required an expensive in-circuit emulation system. These were expensive, difficult to deploy, and rare. Then, CPUs started adding debugging hardware right on the chip. A few spare pins on the CPU and some sort of adapter would give you most of what you wanted from an emulation system. Although these adapters are often proprietary, sometimes they aren’t, or they have been reverse-engineered. If you know the protocol, it is easy enough to get a processor to speak it for you. That’s why you often see, for example, Raspberry Pi Picos debugging other Picos. There’s nothing you can’t do a million other ways here, but it is an excellent step-by-step tutorial for getting started without breaking the bank.

16 thoughts on “This Arduino Debugger Uses The CH552

  1. Gosh, I thought the ATMEGA328 did not have debugging hardware on board, but I just checked the datasheet and it does have debugwire.
    Now why does this Hackaday article not mention debugwire? Debugwire is mentioned in at least 8 other Hackaday articles.

    As for the CH552. I have difficulty in seeing why an MCS51 uC is a “good choice” for a thing like this. If a debug platform is based on the same family of chips as it debugs, then this makes it a lot easier for a lot of people to attempt to improve the debug platform itself. My guess is that is far more important then whether a microcontroller costs 50ct or EUR2.

    1. The CH552 was chosen during lockdown and remote teaching. And that chip has a few advantages:

      1. Has USB
      2. USB bootloader that solves the chicken egg problem which in common in most AVR chips.
      3. 1.27mm pitch package that can be soldered by a person as the first soldering practice.
      4. The chip cost me less than $0.25, that is some difference if you times the price by 20.

      Since the debugger generally only keep one version of firmware, the architecture matter less than the above factors in my understanding.

    2. I’m pretty sure all microcontrollers that feature in circuit serial programming have some form of debugging hardware included. It makes them much easier to use for developers.
      In case of Arduino this feature is not included because it requires an external programming interface, and that adds costs. The usual way is to use serial interface instead. Or blinkenlights. Or look at pins with DSO.

      Personally I rarely use debugging features of my PICKit3, as most of the stuff I do is not that complex. In some cases I just toggle the pin whenever a particular function is executed just to see, if and how fast it works. The one time I actually really wanted to use a debugger, the particular pins were used for the function I wanted to debug, and connecting ANYTHING to them would make the function not work properly. This made me abandon the project until I get better at programming. Now I’ll have to rewrite the entire thing, because I believed that code is its own documentation, which turned out to be a lie.

  2. Atmega328p is getting more expensive than whole nRF52840 boards like (nRF52840 XIAO) which are debuggable by standard SWD.
    (Other alternatives in current atmega328p price range are those ESP powerhogs with weird nonwestern architecture and ccp wifi firmware but those are too not to easy to debug afaik.)

    1. “wierd nonwestern architecture”
      Architecture has geography now? I mean maybe the Tensilica stuff is odd or hard to debug. I will buy that. But “nonwestern” is an odd choice of words here.

    2. The ESP chips use Tensilica cores–a silicon valley based company. They’re owned by Cadence now who is, wait for it, based in San Jose, CA. Can’t get much more Western than the West coast of the Westernmost nation in the ‘Western world’.

  3. Massimo Banzi blocked me for explaining in two xweets on Xitter why I believe Arduino is a terrible choice for teaching new embedded coders because of the crappy IDE and lack of debugging.

    I’m glad that V2 of the IDE has debug capability now but it’s still awful in so many other ways.

    1. > I’m glad that V2 of the IDE has debug capability now but it’s still awful in so many other ways.

      Massimo should have renamed the IDE and given it v1.0. It’s really the first version, since the original was taken from his (uncredited) student..,

    2. You’re right. It’s much easier to set up Code Composer Studio with the 1 GB download or whatever. The UI is really really intuitive too.

      Perhaps you should just realize Arduino is not for you specifically and move on?

      1. They didn’t say it wasn’t for them, they said it wasn’t good for teaching new embedded coders. And it is. Starting them in an IDE with no debugging ability is bad enough, but using C++ just shows they don’t even care about teaching well.

  4. if you want cheap dongle with CH5xx architecture those cheapest daplink cmsis-dap debuggers like that look like stlinkv2 dongles use CH549 which is basically CH552 with 2KB ram,64KB flash and USB host. Also those WCH-Link RISC-V/SWD debuggers use it

    Also here is bare CH549G PCB

    There is even arduino for it based on SDCC

    OTOH those ‘normal’ STLINK V2 dongles are for similar price and have STM32F103 ARM chip which at least works with proper free C compiler unlike the 8051 architecture

  5. Hi there!

    I just bought a macro keyboard with three buttons and rotary encoder. it has a ch552g on the board I want to reprogram it to add more buttons onto it like let’s say 21 more extra buttons. for a project that I am working on. it has three Leds which I would also like to have to reprogram it as well. I am used to attiny85 and atmega but not this type of chip. Any help would do.


Leave a 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.