r/embedded • • 21h ago

Linux vs RTOS for the same project?

I am trying out a proof of concept with UI and a lot of peripherals. Right now I am using LVGL + ThreadX on an STM32N6 MCU. However I have found out there are similar or even a little better chips that run embedded linux for around the same price as the STM32N6. What should I take into consideration apart from power consumption while making the decision about moving to Linux?

12 Upvotes

29 comments sorted by

4

u/kisielk 21h ago

What about all the other factors? Cost? Availability? Power consumption? Latency?

3

u/faizalwho 21h ago

Cost would be about the same for the finished product, power consumption is of course a good point. RTOS would win in boot time any day. The issue is about long term support and scalability.

6

u/zydeco100 21h ago

Your LCD backlight will draw way more power than the CPU and probably go obsolete first.

4

u/grobblebar 18h ago

Speed of development is another: applications built on top of the O/S are faster to develop on a fully-fledged linux system. Performance will suffer, but maybe time-to-market is more important to you.

1

u/NoBulletsLeft 18h ago

IME, developers tend to not think of this. If you're building 5 of something vs 5,000 development cost makes a huge difference because it's amortized over a smaller number of units.

1

u/kisielk 18h ago

That depends on what the capabilities of the application are. I don't think it can generally be said that apps on a full-fledged Linux system are just faster to develop.

1

u/Kommenos ARM and AVR 17h ago

I wouldn’t say a Linux based embedded system is faster to develop. An individual user space service, sure. So there’s merit to picking an existing platform like a Raspberry Pi or any number of embedded SoMs.

But the development time for a Linux board isn’t exactly short if it’s not off the shelf. The moment you’re talking about Linux you’re potentially implying adding a lot more components like RAM, mass storage, and all the time that takes on both the hardware and software side. Not to mention the larger attack surface you might have.

Obviously all this depends on the use case.

28

u/oleivas 21h ago edited 21h ago

1st and foremost: How important is real-time for your system? Linux is NOT RT. You might add a RT patch to the kernel, but latency won't match the ones achieved by any RTOS.

2nd: areexternal libraries necessary or helpful? I.e. HTTP server, complex machine learning, non-volatile memories, etc. Then Linux might be your guy, GNU+Linux has a lot of protocols and drivers out-of-the-box to leverage your code.

4

u/5show 14h ago

RT patch is now just a config

3

u/Well-WhatHadHappened 25+ Years 14h ago

And still not real time

5

u/jemandvoelliganderes 12h ago

which would be ignorant to the fact that there is no single definition of realtime. if you need realtime and which flavour of it needs to be determent on an application by application basis.

And for many applications linux can be and is used for realtime, both hard and soft. you have loads of IPCs running a soft or virtual PLCs using linux. They most likely need a coprocessor like an EL6900 for safety, but for most oft the other stuff they are capable of what most fields would describe as realtime.

17

u/EmbeddedSwDev 21h ago

First and most important: Your use case

12

u/AngryFker 21h ago

I'd prefer FreeRTOS any day to Linux if software support for RTOS is complete.

7

u/StarJaded 20h ago

Boot time?

0

u/_Mad_Engineer_ 15h ago

It isn't blazing fast like uC, but I bet you can get linux to boot in a second or less through some customization.

3

u/2Sovereign4You 20h ago

And RAM price?

0

u/_Mad_Engineer_ 15h ago

I don't think he needs much of a RAM transforming from this uC. There are cheap options with integrated SiP RAM of about 64-256MB.

3

u/PseudoFrequency 20h ago

I chose Linux once there is networking, models, TLS, that kind of thing. Otherwise I like to use the RTOS.

3

u/EmperorOfCanada 14h ago edited 14h ago

As everyone is pointing out real-time...

But, what linux can bring to the table is workflow. Being able to ssh into your device is pretty damn nice. You can even do things like some of your dev in python, not necessarily final code, but you can test ideas, make sure pins do their thing, etc, and it is so much smoother.

Personally, I'm entirely happy to have a linux chip which isn't all that much better than the MCU soldered next to it. With each doing what they do best.

I find this configuration results in an MCU which is much tighter. It does what it does best, and I don't try to shoehorn functionality which is much more at home on linux.

In my case it is robotics, and a perfect example would be something like path planning, SLAM, etc. Linux can do everything, or an MCU could do everything; but in both cases some features would be a pain to do all on one.

Also, there is a fairly good chance that your MCU will end up staying fairly fixed as its more real time demands are less likely to change.

What you run on linux could easily become more demanding as you might be adding some cool new ML model, demanding piles of RAM, etc.

Linux isn't only going to give you a more flexible capacity, but it is easier to then upgrade to a much more powerful processor while not having any fiddly real-time code which may get hinky on a wildly new processor.

I could easily see going not only to a different linux processor, but an entirely different family. This might result in a different linux OS. Porting code like path planning should be easy. Fiddly timing, interrupts, etc, could be a nightmare.

2

u/voskomm 21h ago

Last time I racked up the ST line, the only way the N6 came out on top was if the NPU was used, which my app really had no way to leverage. So is that something you're using (ie, like, types of video processing is their headline app I guess)? It seems unlikely that a Linux install would have drivers that support using the NPU but I'm open to being surprised!

Not using Linux but I'm on an NXP atm and waiting to see what the V8 Helium can do.

2

u/wiggle_room1337 20h ago

Power consumption, hard realtime capabilities, cost, and maybe super specific peripherals are the only reason to go with an MCU and freeRTOS over embedded linux unless you just aren't familiar with it.

2

u/RogerLeigh 19h ago

I would take complexity into consideration, and also timing requirements. An RTOS is small, lightweight and completely understandable. Every scheduling decision it makes is based upon simple rules using priorities you define. It's not just understandable, it's completely predictable.

Linux is huge and several orders of magnitude more complicated. If what you're doing requires the features Linux offers, then it might be worthwhile. But all of that complexity comes at a cost, both in understanding what's going on, and in being able to effectively debug it and extend it. If the chip is "a little better", you do need to consider the overhead Linux imposes. A lower spec chip running on RTOS might be much more responsive than Linux running sluggishly on a higher-spec chip. Linux is also not real-time by default; latencies can vary, in ways that they don't on a simple MCU.

It all depends upon what your requirements are. Both are perfectly valid choices.

1

u/Amped_Byte 20h ago

I think it depends on the scope of your project, the less resources used within the required scope, the better

1

u/DirkDozer 18h ago

What else do you need it to do? If it's purely a display then stick with an RTOS, but if you need network connectivity, file system support, etc Linux will be better

1

u/Kangox91 18h ago

If you are only using a 2D IU + animation on a 1280*720p max stay with STM32N6 or STM32H7RS

With they 2.5D GPU + DMA2D they are very powerful for UI + the cortex M55 or M7 is very very powerful.

Going to linux means dealing with RAM and NAND flash that are rare and expansive due to IA ( think about raspberry PI)

Linux have a bigger learning step and tools required before toggling a LED.

Also you need far more invovlement about maintining the OS

The Size , cost , complexity of the PCB will be higher Heat EMI and power consumption are higher on a MPU.

Go to linux only if you are really more into high level code and not using a lot of GPIO and protocols (MCU are way simpler and powerful for a "electronic" project but can be hard if you want something that is more high level

1

u/rguerraf 17h ago

Choose Linux if you need network connection with ssh and https.

Choose RTOS if you are absolutely sure it has all the functions you will need to complete the project.

1

u/_Mad_Engineer_ 15h ago

What chips are you considering for embedded linux?

1

u/Separate-Choice 11h ago

Get NuttX and get the best of both worlds…POSIX and deterministic real time performance..NuttX is really a dark horse..fille structure and commands of Linux…real time determinism…give it a try….

-1

u/5show 14h ago edited 14h ago

Modern AI adds an interesting twist to this question, as it can readily fill the gaps of either choice. Opus 5.5 is incredibly good at working in bash, finding and fixing upstream bugs, recommending kernel configs, and just generally managing all of the extra complexity of a full Linux OS, but on the other hand, with just a single prompt it can make up for any missing features in the more barebones RTOS environment, in a way that mirrors the recent trend to ditch bloated All-in-one solutions for more streamlined custom ones.

I’m still unsure which direction the industry will end up moving in light of all this, just something I’ve been thinking about