Getting Started with Embedded Linux on RISC-V in QEMU

RISC-V is getting more and more popular, but if you want to run Linux on actual hardware it’s currently fairly expensive since you either need to rely on HiFive Unleashed SBC ($999), or expensive FPGAs.

Another solution is running Linux RISC-V via QEMU emulator,  and I showed how to do this using BBL (Berkeley Boot Loader),  Linux 4.14, and busybear rootfs. If you check the comments section of that earlier post you could also try out Fedora RISC-V images in QEMU.

embedded Linux RISC-V QEMU Buildroot

Bootlin has now published a presentation showing how to run embedded Linux on RISC-V in QEMU with many of the same components as in the previous instructions, but with a more up-to-date Linux kernel (5.4), and using Buildroot to build everything from scratch including the toolchain, BBL, the Linux kernel, and a Busybox based root file system.

They explain each step in detail in the 45-page presentation to allow you to customize your final firmware to your requirements for example for choosing between glibc, uClibc or musl C libraries. They also link to some video playing the command to run for example to configure buildroot as shown below.

It’s always good to get started with QEMU to make yourself familiar with some of the potential pitfalls before low-cost hardware to play with RISC-V Linux come to market. You may not have to wait too long however, as based on a comment, some Kendryte K210 based boards such as Longgan Nano ($5) or Maixduino ($24 kit with camera and display), may get a  uClinux port soon enough. uClinux is a version a Linux that works on hardware without MMU (memory management unit), and it can be a bit more complicated to debug notably due to kernel panics caused by stack overflows.

Share this:
FacebookTwitterHacker NewsSlashdotRedditLinkedInPinterestFlipboardMeWeLineEmailShare

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

ROCK Pi 4C Plus

9 Replies to “Getting Started with Embedded Linux on RISC-V in QEMU”

  1. If they want the architecture to succeed, they’d better partner up with some company to get sensible affordable hardware into the hands of people. $1000 for a board is a joke, and no thanks, not bending over backwards with QEMU just to learn your arch, if you don’t care about users to try meeting them even halfway, then users will not care about you and will just stay with ARM and ARM64 instead, which are here right now, cheap and work.

    1. This is such a weird position to take. Intel and AMD sell individual Core i9 and ThreadRipper consumer chips for well over $1000 just for the CPU chip and enthusiasts love them. Those aren’t even computers until you add a lot more stuff to them.

      Perhaps, also, you are not familiar with dev boards from other companies, such as ARM? Their A53 and A72 Juno dev board is $10,000.

      https://www.digikey.com/product-detail/en/arm/V2M-JUNO-0317D/V2M-JUNO-0317D-ND/7400345

      These boards are what processor IP companies such as SiFive and ARM provide to chip and product manufacturers to prototype their things to go into cars or TVs or mobile phones or whatever. That’s where the money is.

      Cheap consumer boards such as the Raspberry Pi use surplus production from real products (or at most a very minor variation on it).

      The Raspberry Pi has sold by now something just over 20 million in total over all four generations, plus variations such as the Zero or compute modules. The SoC manufacturer Broadcom probably got $1 or $2 on average for each chip. The processor core IP owner ARM might have got $0.10. That’s perhaps something like $2 million total revenue to ARM for all Raspberry Pis sold, ever, and $20m – $50m for Broadcom. ARM has annual revenues of over $1 billion. Broadcom has $20 billion annual revenues.

      The Raspberry Pi is a complete irrelevance to ARM, and the other SBCs even more so. The Raspberry Pi is is also a complete irrelevance to Broadcom. Amlogic will barely notice that a handful of their S905 set-top box chips are going into Odroid and NanoPi and Libre “Le Potato” SBCs. The same even with RockChip and AllWinner.

      The same with RISC-V. The money is in Western Digital hard disks and Sandisk flash memory products and Galanz microwave overs and fridges and hundreds of other products where you’ll never even think about there being a microprocessor inside it, let alone which instruction set it runs.

      *That’s* what determines whether or not the architecture succeeds.

    2. $1000 is nothing for a company that’s really interested in using RISC-V in a product. Hell if you want to try out some little Analog Devices thing the evaluation board for an 8 or 16 pin chip can be hundreds of dollars.

      SBCs and other maker grade stuff like Arduino hasn’t really done much for semiconductor vendors aside from some cheap PR. In the future when people that grew up on the maker stuff are running the industry maybe it’ll be different but right now its a drop in the ocean.

  2. Longan Nano is NOT based on Kendryte K210 and there is no chance to run any kind of Linux on it.
    Running even a smallest Linux on K210 makes no sense as it simply was not designed for that purpose.

    1. Uhh .. that’s not what that page says. It says an interrupt controller had support added “in preparation for” M-mode Linux. That doesn’t mean M-mode Linux is done.

      Also, the 32 KB of RAM in the Longan Nano won’t be enough to run M-mode Linux, and the 8 MB in the Kendryte K210 is likely to be insufficient or extremely marginal too.

  3. Does anybody know if there is a docker image with in it a running QEMU-RISC-V environment. That would be easier, IMHO

Leave a Reply

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

Khadas VIM4 SBC
Khadas VIM4 SBC