Hi,
As the title says, I am trying to build an "OS" that loads programs from SD into memory, and executes them. Now I'm not an expert on this, but I think I have an idea of what needs to be done.
If I'm correct, I need something that will compile the programs, e.g. the esp-idf toolchain. Then, I need a ELF parser to find out at which location in the memory the functions are(e.g. "main"). Then, I need to load the whole file in memory, and point the program to the location where "main" is.(Location is retreived from ELF parser)
Now first, I'd like to know if it's actually possible to run code from ram. Secondly, does my explaination from above make sense? And last, is the esp-idf suitable for use as standalone program compiler.(e.g. using the .elf file it generates)
And do you maybe have any other ideas or corrections?
Thanks!
Running programs from sd using ESP32.
Re: Running programs from sd using ESP32.
Hello again, I did some research. And I believe in order for the loaded program to work, I need to put it in it's own Page Table. Which I believe is part of the MMU. The ESP32 has an MMU. So is it possible to create page tables? Is that implemented?
And I still hope someone can answer the questions in my first post.
Thanks!
Edit:
Currently the progress is is that I am able to read an esp32 .elf file and extract the entry point from it.(Using elfio) Now I believe I need to load the program in(probably in it's own page table) and point the program to the loaded entry point. Is that correct?
And I still hope someone can answer the questions in my first post.
Thanks!
Edit:
Currently the progress is is that I am able to read an esp32 .elf file and extract the entry point from it.(Using elfio) Now I believe I need to load the program in(probably in it's own page table) and point the program to the loaded entry point. Is that correct?
-
- Posts: 9727
- Joined: Thu Nov 26, 2015 4:08 am
Re: Running programs from sd using ESP32.
The ESP32 MMU does not have page tables as such, it just has a flat mapping. However, on a more general note, in the architecture for the ESP32 you can only execute from either flash or internal IRAM. This implies that you either need to flash your program into the SPI flash chip, or it needs to be small enough to fully fit into IRAM (disqualifying e.g. anything that does anything with WiFi/TCP/IP).
Re: Running programs from sd using ESP32.
Thanks for your reply! So if I understand it correctly, not all ram banks on the ESP32 can contain executable memory. And there are no page tables. So the architecture makes it impossible to load programs into ram and execute them.(Because afaik I need page tables for the loaded programs adresses to be correct)ESP_Sprite wrote: ↑Mon Dec 31, 2018 12:23 pmThe ESP32 MMU does not have page tables as such, it just has a flat mapping. However, on a more general note, in the architecture for the ESP32 you can only execute from either flash or internal IRAM. This implies that you either need to flash your program into the SPI flash chip, or it needs to be small enough to fully fit into IRAM (disqualifying e.g. anything that does anything with WiFi/TCP/IP).
Then, I have another question. Is it possible to attach a second spi flash chip to the esp, and load programs on there and execute them? While still keeping the ability to boot from the first chip?
Thanks!
Edit:
I'm a bit confused on page tables. Do I need them to run programs from memory? Let's say I have a small enough program to fit inside the IRAM, can I succesfully execute it? Or do I need an MMU/page tables for that?
And how would I load something in IRAM specifically?
Re: Running programs from sd using ESP32.
See here for what might be a similar question in the GitHub issues.
I also found this this post which seems to sum it up:
Here is more info about the IRAM that ESP_Sprite mentioned.
Seems like SPI flash is the closest thing to what you want, but I am not an expert - spi_flash_mmap Page 557, ESP32 Technical Manual
I also found this this post which seems to sum it up:
There isn't an equivalent for mmap-ing from a filesystem or any other device
Here is more info about the IRAM that ESP_Sprite mentioned.
Seems like SPI flash is the closest thing to what you want, but I am not an expert - spi_flash_mmap Page 557, ESP32 Technical Manual
Re: Running programs from sd using ESP32.
Thanks!ayan4m1 wrote: ↑Mon Dec 31, 2018 9:23 pmSee here for what might be a similar question in the GitHub issues.
I also found this this post which seems to sum it up:
There isn't an equivalent for mmap-ing from a filesystem or any other device
Here is more info about the IRAM that ESP_Sprite mentioned.
Seems like SPI flash is the closest thing to what you want, but I am not an expert - spi_flash_mmap Page 557, ESP32 Technical Manual
Re: Running programs from sd using ESP32.
why don't you just have multiple images inside the SD card... and have your GUI "ota" the image you want to run.
Who is online
Users browsing this forum: MicroController and 59 guests