executing code/bin from external storage
rwgast_logicdesign
Posts: 1,464
So when it comes to programming im a very modular and tidy kind of person. I was wondering if there is any way to get a prop to execute code from external flash/sram. Im kind of looking to maybe bundle up all the "drivers" for my system and have have them all stored externaly then loaded as needed and loaded. Im also looking to do this with spin or precompiled binarys which i know makes things a bit more tricky. How would one go about this maybe a virtual machine or something? I know what im asking isnt directly supported but i figure with things like cmm and xmm the proof of concepts is there.
Comments
So, what do I do in my current project:
1. I store the PASM code of drivers in upper part of EEPROM. Each program that needs for example FullDuplexSerial only needs a buffer to load the driver. It's then loaded/started at the beginning and then the buffer can be used for something else.
2. All drivers running have an entry in upper part of HUB-RAM and use a mailbox in upper part of HUB-RAM. This allows to load other program-parts which can then use exactly these drivers without loading on their own.
3. I store SPIN code as binaries in a SWAP-file. These binaries can be loaded into a buffer and executed there while the main program is waiting. If the loaded program is done it will return to the loading program.
This can be used to implement "commands" like in an OS. What's installed in this SWAP-file can be run.
What worked in CogOS is to load complete EEPROM-files from SD card. Problem with that is, that in this case each program has to take care of it's drivers by itself because the upper HUB-RAM table will be overwritten by loading an EEPROM-file.
With some changes in the SD card driver it should be possible to do this with a BIN-file as well. In that case the driver table would be available for the new program as well and it can reuse the already running drivers.
If you are interested I can go into more details this evening.
I don't see a reason for using a battery-buffered RAM. Upper part of EEPROM is good enough for me. I'd not expect RAM to be much faster if it has a serial interface. RAM with parallel interface would be a to big waste of pins.
If EEPROM is to small, you could have the most important drivers (SD card driver) on EEPROM and additional drivers on SD card. SD card reads at ~1MB/sec.
Here is an example of an OS loading drivers:
What I also do to save valuable HUB-RAM is, storing text messages in "virtual memory" (a SWAP-file).
Maybe later this evening I can upload a zip containing the current state of my project. The missing part is a good description on how to setup the whole stuff.