Bring Linux To CH32V003 Through, Yes, RISC-V Emulation

a CH32V003 Linux-bearing PCB, single-sided, hand-etched, lovely

Like playing around with Linux on low-power devices? You’d be hard pressed to find a better example than the [tvlad1234]’s linux-ch32v003 project. It’s not just a one-off — it’s something you could build right now, since it requires hardly any extra parts.

With help of a 8 MB PSRAM chip for RAM supplementation purposes and an SD card, plus some careful tailoring of the Linux .config parameters, you get Linux on a chip never meant to even come close to handling this much power. The five minutes it takes to boot up to a prompt is part of the experience.

As usual with [tvlad1234]’s projects, there’s a fun twist to it! Running Linux on this chip is only possible thanks to [chlohr]’s mini-rv32ima project, which, as you might remember, is a RISC-V emulator. Yes, this runs Linux by running a RISC-V emulator on a RISC-V chip. The main reason for that is because the MCU can’t map the PSRAM chip into RAM, but if you use an emulator, memory mapping is only a matter of software. Having applied a fair amount of elbow grease, [tvlad1234] brings us buildroot and mainline Linux kernel configs you can compile to play with this — as well as a single-layer-ready KiCad board project on GitHub. Yep, you could literally etch a PCB for this project from single-sided copper-clad FR4 with a bit of FeCl3.

While the CH32V003 is undoubtedly a more impressive target for Linux, the RP2040 Linux project might be more approachable in terms of having most of the parts in your parts box. At least, up until we start valuing the CH32V003 for all the cool stuff it can do!

14 thoughts on “Bring Linux To CH32V003 Through, Yes, RISC-V Emulation

  1. “you could literally etch a PCB for this project…”
    Could you connect this Linux system to a larger screen, install KiCAD on this Linux system, then design this board in KiCAD, use software running on this Linux system to convert KiCAD in to gerbers then in to Gcode to route out this board with, and then use another of these Linux boards as the controller for the CNC machine doing the routing?

  2. Cool, but why? The main purpose of Linux is to be a convolution of cheap device drivers, or so I thought.
    That’s why Android uses Linux as a base, after all.

    Windows 9x did same with DOS, essentially.
    The underlying DOS that was being moved into its own VM was good to keep old device drivers (CD-ROM, exotic network stacks etc) functioning.

    1. Why? Because you can. And it may be the cheapest MCU to run Linux on.

      That said, much more powerful is ESP32 with FabGL, which can emulate: CP/M, MS-DOS, FreeDOS, Windows 3.1 and Linux ELKS.

      1. Well, it makes sense for all the other OSes you mentioned, except Linux.

        Linux is about anti-binary compatibility, it follows the philosophy that assembler code and proccesor dependency is evil.
        C++ is what it’s all about. Maybe Rust and C#, eventually.

        The only exception here is x86 Linux, maybe, because of commercial products (binaries) that had actually being created for it.
        There are pre-compiled packages, I mean, which do require maintaining compatibility.

        Otherwise, Linux isn’t important. Someone could use BSD just as well. Its only real world purpose is to provide a large collection of free drivers made by volunteers.

        But in an emulated environment, who needs those drivers?
        The limited emulation hasn’t anything meaningful to provide that could have a need for those Linux drivers, kernel modules, demons etc.

          1. I read uClinux is included in mainline linux these days? Ow, even your source sais so. Buildroot does the target selection and configuration for your smaller system and you can tailor it aswell to your liking.

        1. > Linux is about anti-binary compatibility

          Not true. It is true that *inside* the kernel, there’s no ABI compatibility guarantees, but the kernel team goes out of their way to not break user-space. That’s why we still have iptables even though nftables exist, old versions of syscalls are retained etc. In theory, you could grab a statically linked executable from Linux 1.0 and run it on a modern box (I also want to try that out some time, but I do remember seeing a video where they did something like this).

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.