logoalt Hacker News

dsign • today at 4:00 PM • 6 replies • view on HN

I’ve been developing a guitar pedal firmware in an ESP32-P4, and the flash image size is still under 1 MB and the PSRAM sits unused. It has not only a bunch of sound filters, control code for ADC, DAC a couple of USB devices, SDIO and LittleFS, but also a full-blown serial terminal TUI to control all sorts of details and to monitor performance. Said performance is good, but what blows me away is that there’s no jitter in the number that measures the number of cycles the processor executes while processing a sound frame, i.e. no preemption by the kernel to go and take care of its business.

There’s no way a multi-user OS such as Linux can be as efficient as a firmware blob that does one thing. Tell me if I’m wrong, but in my mental model, one can get about the same mileage with 16 MB of PSRAM in an MCU running FreeRTOS as one can get in a 512 MB SBC running Linux. For my use case, the winner combination would, of course, be a 512 MB SBC running FreeRTOS, but I’ve so far been unable to find such a wondrous thing.


Replies

ValdikSS • today at 4:23 PM

The benefit of running Linux on a what used to be an MCU is that you're getting the best network stack, Bluetooth/Wi-Fi stack, one of the best device drivers (say for USB Host), stock and very well tested software, etc.

For your use case, you need raw performance and low-level control, and you have it. But for IoT device which is all about network more or less, there's usually no need to go low-level.

ESP32 for Wi-Fi handling uses wpa_supplicant port from Linux for example.

You can run a real, multi-user Linux with as low RAM as 8 MB. You get the benefit of running any Linux-supported programming languages (and combine any amount of them without extra effort, just on a real machine), established portable abstractions, established memory protection model, ease of debugging.

You can run both though. Both FreeRTOS and Linux simultaneously, where Linux is a FreeRTOS task on a dedicated core. That's how several Linux ports work, haven't checked if Espressif's works this way as well.

➕ show 1 reply
zelo • today at 4:26 PM

Zephyr rtos on raspberry pi sbc https://github.com/jetpax/PiZZa/tree/main

yjftsjthsd-h • today at 4:36 PM

> There’s no way a multi-user OS such as Linux can be as efficient as a firmware blob that does one thing

Yes, obviously. The advantage is in how easy it is to port software to the board, and how much work you need to do to get any given amount of functionality.

andrewstuart • today at 6:51 PM

NXP i.MX6 / i.MX8 Has the ram you seek.

nicman23 • today at 4:36 PM

you can assign cores to rt processes - that are not used by the kernel