-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Advice on embedding in an application #12
Comments
I'm not quite sure what you are asking here. Can you give me an example of what you're thinking of? |
I was thinking about something like this. I have this application running on a Cortex-M4. Most of the application is written in C and I have embedded Lua to run some small scripts. The reason why I use Lua was because of the capability of sending the code through the serial port and not needing to reprogram the device flash. It would be very interesting having something like that with OCaml. It would require having the full bytecode runner compiled for a generic device. The script could be compiled in the main computer and sent to the device through a serial port (or embedded with the application). As I mention, I'm doing this with Lua because the full VM can be easily compiled in any platform. I convert the final script to an .h file (as a constant string) and then I compile it an flash it. |
As a matter of facts this has been in the back of our minds for a while (inspired by MicroPython, but I guess it is the same idea).
If I am not mistaken the OCaml interpreter ("top-level") is written in OCaml so it seems completely feasible to compile the toplevel to a bytecode and run it a microcontroller. We would however need to be able to send expressions / scripts through the serial port. This is not supported at the moment but does not sound unfeasible (still needs some time though 😔)
Thanks for your input!
… On 4 May 2020, at 20:00, Leonardo Laguna Ruiz ***@***.***> wrote:
I was thinking about something like this. I have this application running on a Cortex-M4. Most of the application is written in C and I have embedded Lua to run some small scripts. The reason why I use Lua was because of the capability of sending the code through the serial port and not needing to reprogram the device flash.
It would be very interesting having something like that with OCaml. It would require having the full bytecode runner compiled for a generic device. The script could be compiled in the main computer and sent to the device through a serial port (or embedded with the application).
As I mention, I'm doing this with Lua because the full VM can be easily compiled in any platform. I convert the final script to an .h file (as a constant string) and then I compile it an flash it.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub <#12 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ABOYTSUM5OAZSLDZSGNTX7TRP4GGLANCNFSM4GPKNYUA>.
|
Cool. That goes a bit further than what I was thinking. I don't know if a small microcontroller can run the whole OCaml top-level. That's why I was thinking about generating the bytecode in the main computer and just send the bytecode. In any case, this project is very interesting. I will give it a try with the boards I have. There are other interesting variations of embedding an application. A few weeks ago I had to give up on the idea of using OCaml in one of my applications. The main issue was that the GC is "global" and I was not able of having two ocaml environments running on the same application. It would be great if this bytecode runner could have multiple instances, for example:
I don't know if something like this is in your objectives. But this would make OCaml more "embeddable". |
Sorry for taking more than a year to respond, but basically you have discussed what I was asking for. I want to be able to take precompiled ocaml bytecode from EEPROM, SD Card, downloaded over serial, whatever and run it. More to the point, I don't want OMicroB to be "in charge". I want to have my program invoke OMicroB and point it to the bytecode I want to run, and then have it come back when done, and have a way of adding native functions I don't know if you have made any strides in the direction, but I would love to see it. Right now I am using MicroPython as an extension language in my embedded projects, but it would be nice to have other options |
I am curious about the idea of embedding OMicroB in an existing application as a way of running user scripts in a low (4-8K) RAM environment.
Do you have any advice on how to do this?
The text was updated successfully, but these errors were encountered: