Skip to content
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

Open
jockm opened this issue Jan 11, 2019 · 5 comments
Open

Advice on embedding in an application #12

jockm opened this issue Jan 11, 2019 · 5 comments

Comments

@jockm
Copy link

jockm commented Jan 11, 2019

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?

@stevenvar
Copy link
Owner

I'm not quite sure what you are asking here. Can you give me an example of what you're thinking of?

@modlfo
Copy link

modlfo commented May 4, 2020

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.

@stevenvar
Copy link
Owner

stevenvar commented May 4, 2020 via email

@modlfo
Copy link

modlfo commented May 4, 2020

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:

ocaml_byterun env1 = new_ocaml_byterun();
ocaml_byterun env2 = new_ocaml_byterun();

env1.run("program1");
env2.run("program2");

I don't know if something like this is in your objectives. But this would make OCaml more "embeddable".

@jockm
Copy link
Author

jockm commented Aug 25, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants