Run linux on the ESP32?

timl12332
Posts: 27
Joined: Wed May 10, 2017 3:05 pm

Run linux on the ESP32?

Postby timl12332 » Fri Aug 10, 2018 11:24 am

Hi there!

I recently read that there are ESP32 modules with 4MB and I heard even 8MB ram. This made me wonder if we can run Linux?
Now I know Linux needs a MMU, but I thought older Linux versions(3.x?) that had the UClinux changes integrated and thus can compile without MMU.
Is it maybe interesting for someone to try?
Or would it at least be possible?

Thanks!

username
Posts: 528
Joined: Thu May 03, 2018 1:18 pm

Re: Run linux on the ESP32?

Postby username » Fri Aug 10, 2018 1:28 pm

You'd be stretching yourself to thin in doing so, not to mention what real gain would you get by doing so.
For just a few more bucks you can get a Allwinner H2+, Quad-core Cortex-A7 that is meant to run it
https://www.friendlyarm.com/index.php?r ... uct_id=197

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: Run linux on the ESP32?

Postby kolban » Fri Aug 10, 2018 2:45 pm

.... for technical completeness, the ESP32 does indeed have an MMU as well as hardware assistance for process instance isolation of memory.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

timl12332
Posts: 27
Joined: Wed May 10, 2017 3:05 pm

Re: Run linux on the ESP32?

Postby timl12332 » Fri Aug 10, 2018 2:56 pm

kolban wrote:.... for technical completeness, the ESP32 does indeed have an MMU as well as hardware assistance for process instance isolation of memory.
I thought that one was not complete enough for Linux?
But what is it needed for anyway? Is it just preventing a process from modifying another process's ram?(Hacking or something)

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: Run linux on the ESP32?

Postby kolban » Fri Aug 10, 2018 9:06 pm

Typically memory isolation is used for robustness. In a privileged address space (ESP32 default), an error in an application or subroutine or task could merrily step all over the memory of other applications. By leveraging process isolation, one adds an extra degree of resiliency to a solution. Assuming an application is composed of multiple coarse grained components, each of those components could be insulated and isolated from the others so a logic error in one component would have that much more resiliency from interfering with the operation of another. While security is a possible utilization, historically, memory isolation between processes was designed for robustness and form simplifcation of the overall environment in which applications run.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

timl12332
Posts: 27
Joined: Wed May 10, 2017 3:05 pm

Re: Run linux on the ESP32?

Postby timl12332 » Fri Aug 10, 2018 9:13 pm

kolban wrote:Typically memory isolation is used for robustness. In a privileged address space (ESP32 default), an error in an application or subroutine or task could merrily step all over the memory of other applications. By leveraging process isolation, one adds an extra degree of resiliency to a solution. Assuming an application is composed of multiple coarse grained components, each of those components could be insulated and isolated from the others so a logic error in one component would have that much more resiliency from interfering with the operation of another. While security is a possible utilization, historically, memory isolation between processes was designed for robustness and form simplifcation of the overall environment in which applications run.
That's interesting. So if I e.g. am writing outside of an array, into another process. The MMU(if active) would just terminate the process? Or reset the ESP?

Also I did some research on MMU's, and one thing I read was that it gives each process it's own memory space. Is that correct?
If so, does this mean, I could load precompiled programs from an SD, into memory. Give a process a memory space(using the MMU), and have multiple programs running?
As I would love to turn an ESP into some mini PC, developing my own mini OS.

Thanks!

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: Run linux on the ESP32?

Postby kolban » Fri Aug 10, 2018 11:31 pm

There is a super detailed ESP32 manual called the ESP32 Technical Reference. In chapter "26 - PID/MPU/MMU" there are descriptions of the hardware support for these areas of functions. What I would suggest is to have a good slow read of that section and see how much of it makes sense. I had to read it multiple times and am still novice level.

See:

https://www.espressif.com/sites/default ... ual_en.pdf
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

Deouss
Posts: 425
Joined: Tue Mar 20, 2018 11:36 am

Re: Run linux on the ESP32?

Postby Deouss » Sat Aug 11, 2018 1:41 am

I must admit I also don't understand quite well how exactly memory management looks like.
What I found out is that it is all done by special memory mapping tables that assign certain context of the process to addressees.
I don't understand why PSRAM space cannot be executed by CPU - is it because MPU disallows it meaning the addresses don't exist in the tables or they have forbidden access flags assigned. This is supposed to be more straightforward.

timl12332
Posts: 27
Joined: Wed May 10, 2017 3:05 pm

Re: Run linux on the ESP32?

Postby timl12332 » Sat Aug 11, 2018 10:52 am

kolban wrote:There is a super detailed ESP32 manual called the ESP32 Technical Reference. In chapter "26 - PID/MPU/MMU" there are descriptions of the hardware support for these areas of functions. What I would suggest is to have a good slow read of that section and see how much of it makes sense. I had to read it multiple times and am still novice level.

See:

https://www.espressif.com/sites/default ... ual_en.pdf
Thanks, I'll read it when I have some time!
Deouss wrote:I must admit I also don't understand quite well how exactly memory management looks like.
What I found out is that it is all done by special memory mapping tables that assign certain context of the process to addressees.
I don't understand why PSRAM space cannot be executed by CPU - is it because MPU disallows it meaning the addresses don't exist in the tables or they have forbidden access flags assigned. This is supposed to be more straightforward.
PSRAM can't contain executable instructions? That's unfortunate. Would have been useful for making a little OS that can load programs into ram and execute them.

suhanko
Posts: 1
Joined: Tue Dec 03, 2019 2:26 pm

Re: Run linux on the ESP32?

Postby suhanko » Tue Dec 03, 2019 2:28 pm

Hello.
Today I saw an article about Linux running over no MMU processors, included some xtensa.
I hope someday I can to run Linux on ESP32.
https://www.cnx-software.com/2019/12/03 ... -go-board/

Who is online

Users browsing this forum: No registered users and 214 guests