News for hackers. Stuff that matters.
Re:What? More 8-Bit Microcontrollers? by Glawen on Friday July 01, 2022 @07:28AM (#31944891)
I just came out of a embedded Linux training, and the guy basically told us that if we want to have hard real time constraints, it is easier to execute real time stuff on a dedicated microcontroller on the side. I find it crazy that we need such a powerful MCU to run Linux, but still it is not fit for real time.
Re:What? More 8-Bit Microcontrollers? by radarsat1 on Friday July 01, 2022 @07:42AM (#31945016)
It really depends on what you're doing, but there are certainly versions of Linux that are capable of hard real-time performance. But it shouldn't be too surprising that the goals of an operating system designed for multiuser, multiprocess context is not well aligned with the needs of real-time machine control applications. The trainer is correct, often times it really is appropriate to just delegate those requirements to a dedicated controller whose job is to do nothing else than keep performing the same DSP loop over and over in a well-timed manner. However, there are certainly cases where you might want to interact smoothly between real-time and non-real-time components of a system and use things like shared memory, and in those cases, there definitely are Linux-based solutions available. Like most things in engineering, there are trade-offs along this continuum, so knowing the options and the pros and cons so that you can make a good design decision is just part of the job.
Re:What? More 8-Bit Microcontrollers? by monocasa on Friday July 01, 2022 @10:30AM (#31946903)
The only version of linux I know of that's capable of hard real time performance isn't really linux anymore but instead just runs an rtos microkernel underneath linux to make real time guarantess and simply runs linux as the lowest priority task on that kernel.

https://en.wikipedia.org/wiki/RTLinux

Re:What? More 8-Bit Microcontrollers? by zozbot234 on Friday July 01, 2022 @11:02AM (#31947330)
RTLinux is quite old. There's an official patchset for real-time preemption in Linux that's making its way to the mainline kernel.
Re:What? More 8-Bit Microcontrollers? by monocasa on Friday July 01, 2022 @11:19AM (#31947614)
If you're talking about the preempt-rt patches being merged, those are very soft real time.
Re:What? More 8-Bit Microcontrollers? by freemint on Friday July 01, 2022 @10:20AM (#31946769)
Hard real time, yes. But with very high tolerances compared to what a MHz processor can accomplish just running the application.
Re:What? More 8-Bit Microcontrollers? by nousermane on Friday July 01, 2022 @10:19AM (#31946752)
Each job requires a tool that does it best, within some limits.

To set a bit in GPIO:

- on AVR, one assembly instruction, 2 bytes machine code, 1 CPU cycle (unless interrupts are enabled);

- on microcontroller-style ARM (Pi-pico), 2-4 assembly instructions, 8-20 bytes machine code (depending on compiler options), 4-12 CPU cycles. All numbers deterministic within the same build (unless code cache is cold, then 50+ cycles, and don't forget interrupts);

- on ARM+linux, hardcore mode: same as above + small, deterministic number of extra cycles since GPIO runs at slower clock than CPU. That assumes you go out of your way to reserve CPU core, set rt_prio for your task, etc...;

- on linux, via sysfs: who knows. 1000 CPU cycles is probably the lower bound, but each run is going to take different amount of time. On a busy system, some - as long as a few seconds.

Re:What? More 8-Bit Microcontrollers? by monocasa on Friday July 01, 2022 @11:35AM (#31947898)
The pi-pico does have that cute PIO state machine though to baby sit GPIO and get single cycle granularity out of it.
Re:What? More 8-Bit Microcontrollers? by jjoonathan on Friday July 01, 2022 @04:27PM (#31952358)
Yep, I suspect that will be the path forward. Same high level strategy, but integrated into a single package. It will be interesting to see if the babysitters remain state machines or if they grow into tiny little microcontrollers.
Re:What? More 8-Bit Microcontrollers? by monocasa on Friday July 01, 2022 @08:58PM (#31954955)
Or tiny little FPGAs connected to the GPIO lines would be neat too.
Re:What? More 8-Bit Microcontrollers? by wheelin on Saturday July 02, 2022 @04:23AM (#31957238)
Many automotive MCUs have complexe timer coprocessors integrated for hard real time I/O purpose. Examples are GTM, eTPU and N2HET that I know about. Does the PIO work in the same way?
Re:What? More 8-Bit Microcontrollers? by Thetawaves on Friday July 01, 2022 @01:41PM (#31949954)
Perhaps counter-intuitively, big complex CPUs are incredibly bad at real time control. Instruction latency and jitter can be huge when dealing with complex caching systems, deep instruction pipelines, etc.

If you have serious hard real time requirements, you will be using a very simple 8bit mcu.

Re:What? More 8-Bit Microcontrollers? by bluGill on Friday July 01, 2022 @09:10AM (#31945868)
If you are hard real time, then the ability to country hose many cycles each assember instruction will take makes it easy to prove your code is correct. Run on a much faster modern 64 bit CPU with branch prediction, caches, and other tricks and there is no way to know how long any instruction will take. Getting non-real time things done is faster on the 64bit CPU, but the 8 bit is going to get the things it does done one time every time.
Re:What? More 8-Bit Microcontrollers? by HeyLaughingBoy on Friday July 01, 2022 @01:14PM (#31949556)
This is exactly the division of labor my current project has. The UI and data storage run on a Linux System On Module and the real time control is on an STM32 processor running an RTOS. Pretty standard these days.

I've been on projects where the Linux part would have been offloaded to a tablet or an Android SBC running an app and communicating to the real time processor via BLE.

Re:What? More 8-Bit Microcontrollers? by otter-rock on Saturday July 02, 2022 @04:46PM (#31962225)
Both processor hardware and the Linux operating system are powerful in large part because they're opportunistic. But that's the opposite of predictable, which is what defines hard real-time.
Re:What? More 8-Bit Microcontrollers? by 2rsf on Friday July 01, 2022 @07:40AM (#31944998)
When I worked at Qualcomm this is exactly what we used to do, if I rememeber correctly even parts of the USB driver used to run on one.
Re:What? More 8-Bit Microcontrollers? by schaefer on Friday July 01, 2022 @08:15AM (#31945367)
Can I ask, which training was that?
Re:What? More 8-Bit Microcontrollers? by Glawen on Friday July 01, 2022 @09:46AM (#31946295)
A week long course with a Linux greybeard in my country. It focused on how to make our own Linux distribution (using yocto) for our future embedded platform.