OCaml on Microcontrollers' Boards
OMicroB is an OCaml virtual machine dedicated at running OCaml programs on devices with very limited resources such as AVR Atmega32u4 microcontrollers (2.5 ko of RAM).
This tools, steming from the works of OCaPIC (https://github.com/bvaugon/ocapic) is seen as a generic virtual machine approach, which can be ported on various architectures.
OMicroB performs multiple static analysis passes in order to reduce the generated final executable.
An article describing our generic virtual machine approach has been published on ERTS 2018 :
- OPAM + OCaml (>= 4.03)
- obytelib (on OPAM)
- ocamlclean (on OPAM)
- ocamlbuild (on OPAM)
- gcc (for simulation)
- avr-gcc, avr-libc (for AVR microcontrollers)
- avrdude (for flashing to an AVR)
./configure && make && make install
Compiling an OCaml program
OMicroB is, at the moment, tied to the AVR C compiler. In order to compile an OCaml file for an AVR microcontroller, run
that will generate a
omicrob -help command will display the various available options, such as setting the stack size, the garbage collector algorithm, etc)
Flashing on a microcontroller
omicrob -flash <file.hex>
OMicroB comes with a circuit simulator, for example running
tests/snake-mustard folder will simulate an Arduboy device on your computer, running the Snake game described in this folder.