Hacker News new | ask | show | jobs
by kragen 29 days ago
You aren't going to be running ERICI's Linux on a Cortex-M0-like RV32E, no, but I'd think that most industrial equipment has a lot more need for RV32E or similar than it does for Linux.
1 comments

You can certainly do a lot even with low end CPUs in automation (and they are certainly used a lot there).

But there's a lot of basically-desktop CPUs in industrial automation too, because those are not that expensive and very useful for higher bandwidth interfaces (think ethernet based), cycle times in the microsecond range (higher CPU clock gives you a much more generous cycle budget) and just a generally easier time doing anything where a FPU and memory helps (motion planning, driving some UI on a touch panel, etc).

See:

https://www.beckhoff.com/en-en/products/ipc/embedded-pcs/

This is certainly true, but I think that some of it is a question of industrial designs lagging behind the state of the art in computery stuff.

The CPU clock cycle time of any random Cortex-M0+ is on the order of 30 nanoseconds, a much higher clock speed than the microsecond range you're taking about. The microcontroller also has much better response-time predictability than you can get on a basically-desktop CPU, with its TLBs, three layers of cache, DRAM CAS latency, variable latency to open DRAM pages, SMM, Intel ME, high-priority DMA delaying the CPU's RAM access, etc.

ERICI's plan to run Linux under a real-time hypervisor is definitely a thing that can be done, and a thing that is regularly done on cellphones and industrial-control systems, and has been since the 01990s, among other things, with RTLinux and Linux-CNC. But, although I need to say that I lack any experience in the area, I'm skeptical that it is a sensible tradeoff in 02026, where by rearchitecting the entire system to run under a hypervisor you can maybe avoid spending 9.97¢ on a 48MHz Cortex-M0+ https://www.lcsc.com/product-detail/Microcontrollers-MCU-MPU... or 17¢ on a 48MHz RV32E CH32V003 https://www.lcsc.com/product-detail/Microcontrollers-MCU-MPU.... I think it made more sense in the 01990s where EMC/LinuxCNC was running on an 80486 that was half as fast as the Cortex-M0+ but cost US$2500. I think it might be a better tradeoff to avoid having any CPUs that have to run "mixed-criticality" workloads, as seL4 calls them — where the same CPU is timeshared between a best-effort Linux workload and hard real-time code. The problem with hard real-time code in industrial automation is that, if it misses a deadline, it can crash your lathe and cost you US$159,532.53. You're depending on your real-time hypervisor to make sure that nothing Linux can do can make that happen.

It seems like it would probably be better engineering now to run the hard real-time control loops on a tiny dedicated computer that costs 37¢, and communicate with the Linux box over I²C or USB or a UART or PCIe or something. To get the response times lower than microcontrollers can guarantee, people seem to be moving to FPGAs. You can get a small FPGA for US$2 now, and the latency from inputs to outputs is typically on the order of 10 nanoseconds, much quicker than a microcontroller can respond from an ISR.

Avoiding one crashed lathe can pay for a lot of microcontrollers.

> ERICI's plan to run Linux under a real-time hypervisor...

Why plan? It's working right now, alongside QSOE/N. Resources nicely partitioned: graphics controller and UFS storage for Linux; NVMe, Ethernet UART for QSOE. Please see the demonstration video.

As I said, it's been working since the 01990s. Barabanov's original research on what would become RT-Linux and Yodaiken's paper about it were 01996. L⁴Linux was 01997. Heck, MERT was 01975. And, I'm sorry, but I'm not going to watch your demonstration video.
Excuse me, but what Barabanov, Yodaiken and all the stuff you mentioned have to do with the subject?

Have you noticed that Linux on the diagram is a general-purpose OS, used for non-critical tasks? Or, refusing to watch the video, you refuse also to see what's actually depicted on the page?

> it's been working since the 01990s

What's been working since the "01990s"? What hypervisor in 1990s drove real-time OSes on industrial computers alongside general-purpose OSes, providing full resource isolation?

L4: https://pdos.csail.mit.edu/6.828/2026/readings/microkernel.p... and RTLinux: https://web.archive.org/web/19970307183643/https://luz.cs.nm...

LinuxCNC (EMC2) was using that approach too, but at first I think they were trying to get hard-real-time performance out of Linux itself, and later I think they might have been using paravirtualization rather than full virtualization, which was conventionally considered impossible on the i386.

You do have valid points with the "better to avoid mixed criticality when possible" and "isolate the most latency sensitive compontents on dedicated hardware".

I work in embedded software and I have some insight on why the reality often looks very different from this:

Software "cost" works differently. In a startup environment, you can spread the fixed costs for software development on thousands of installs (or even more). Automation software is very different, and solutions are often bespoke; even if you're building and selling machines, the numbers will be much lower than for consumer stuff.

This means that fixed costs for software development matter much more, and that hard developer productivity (as in: how many factories can your PLC programmers automate per year) is much more important. Vendoring dependencies is much more costly, splitting your codebase over multiple subsystems is less desirable (=> overhead for general development, update, configuration management, redundant subcomponents, slower iteration), heterogenous systems are very undesirable (because specialized employees are more expensive to manage and less flexible).

This is why much of the industry is so willing to shell out for "overpriced" PLC controllers (when freely programmable MCUs can be had for cents), proprietary frameworks and what you might perceive as obsolete garbage tooling for HMI/cloud integration: All those things help to build solutions that are "good enough" with less programmers, less training, less specialization and thus, crucially, less software-fixed-costs (that you wouldn't be able to recoup).

One other thing: software being formally correct vs. reliable/robust is much more orthogonal in practice than you might assume, and industry typically cares more about the latter. My perspective is that formalizing/certifying software is (overly) concerned with eliminating lower risk holdouts (think: proving latency bounds on memory allocation or somesuch), while "robustifying" software looks at "actual highest risk" parts first (sanity checking requirements/specifications, avoiding pitfalls for users when configuring/operating your system, fixing false positives).

That makes a lot of sense, and I greatly appreciate you sharing your experience. It helps me to understand why the industrial automation world looks the way it does.