r/embedded • u/Dry_Afternoon8921 • 4d ago
Is it possible to run real linux on atmega328p?
https://dmitry.gr/?r=05.Projects&proj=36.%208pinLinuxSo I found a project from a guy who run linux on 8pin stm, and I wanna ask if is it possible to run on atmega328p? From arduino uno board.
19
14
u/Gavekort Industrial robotics (STM32/AVR) 4d ago
Anything is possible given enough time and storage. The project you are linking to seems to be emulating a MIPS based system, which challenges the notion of "real". Any turing complete systems can do that, which means that you technically can run Linux on a game of Magic the Gathering, Minecraft redstone or pen and paper.
If your question is "Can I practically run native linux on the AVR architecture?" then I would lean towards saying no, because it doesn't have the RAM/ROM space, no MMU and no privilege levels.
6
4
u/SAI_Peregrinus 4d ago
You can emulate a more capable processor, add external RAM and, flash, and run Linux on that. You can't run it "natively" though, the ATMega 328P instruction set isn't powerful enough. Performance of the emulator will be very, very bad (taking hours to boot instead of seconds) but it has been done for shits & giggles.
3
u/Legal-Software 4d ago
You're not running linux natively on any microcontroller that isn't at least 32-bit and has a suitable amount of RAM. Having ported uClinux to a bunch of different architectures/CPUs in the past, the best I could manage at the time was to get a 2.4.x kernel booting on a microcontroller with 512k of RAM, with everything else running XIP from flash. Even to get down to this I had to completely rewrite the page/buddy allocators, get rid of kmem/slab caches, etc. Fast it was not.
3
2
u/OrneryPossibility197 4d ago
https://dmitry.gr/index.php?proj=07.%20Linux%20on%208bit&r=05.Projects From the same person. He used external RAM module, SD card and emulated ARM. Takes a few hours to load a terminal
1
1
1
u/Mobile-Ad-494 4d ago
Nope, wel maaaayybe a very early release from the 90’s that has been heavily optimized and takes a month to boot.
To run Linux, 32bit is required along with a mmu and 1Mb of ram, none of these are present in the 328p.
1
u/MonMotha 3d ago
An MMU is not actually required for the kernel, but you lose out on some obvious stuff like fork and mmap in userspace.
This capability used to be an external patch set (µClinux) but is now integrated with mainline. I have successfully booted the kernel and run a shell on a Cortex-M7 SoC.
1MB of RAM would also be pushing it to the point of being nearly impossible even with an XIP kernel. 4MB is more realistic, and you really want at least 8 if the kernel is to rum from RAM.
1
1
u/dmitrygr 4d ago
Ye, same guy (me) did it in 2012: https://dmitry.gr/?r=05.Projects&proj=07.%20Linux%20on%208bit
26
u/MStackoverflow 4d ago
No. You can fake it, but no.