Animula means "a little soul" in Latin. It is a highly optimized and functional programming flavored Virtual Machine for compact embedded system. You just need 10KB to run a functional programming language, such as Scheme.
This is the Animula VM core.
You may want to read this annoucment: LambdaChip renamed to Animula
lambdachip.com is obsoleted, we'll move all the docs here gradually.
The official reference compiler implementation of Animula is Laco. Laco aims to be a highly optimized compiler infrasturcture for compact embedded system.
It's possible to support multiple funciontal languages on Animula. Here're the expected languages list:
- Scheme R7RS-small
- Python 3.10 (WIP)
- Lua 5.2 (WIP)
Contributions are welcome!
Please visit Animula documents for more information.
Download for Linux: animula-linux
Download for ZephyrRTOS: animula-zephyr
The code can not be built directly, you have to use building project for specific platform.
Animula VM supports LEF (lightweight executable format) which is optimized for embedded system. You need to compile your source code to LEF with Laco compiler, and run the LEF with Animula VM.
Please make sure you've installed Guile-3.0+:
sudo apt install -y guile-3.0
# download laco source code
./configure
make -j5 # try more cores to speedup, it's not a tiny project
sudo make install
Or you don't have to install it, and you may use it locally:
./pre-inst-env scripts/laco
laco foo.scm -o foo.lef
If you have API token of OpenAI, you may take advantage of powerful AI to give you advices to debug the code.
sudo apt install -y curl jq
export LACO_OPENAI_KEY=your_openai_key
If Laco encounter compiling error, and you've set LACO_OPENAI_KEY, then Laco will call ChatGPT to review the code. Just try it, Enjoy!
For users behind firewall, you may need to set https_proxy with you VPN.
For more information of Laco compiler, please checkout Animula documents
Animula-linux is used for testing on CI, however, it is possible to implemnt practical Functional Programming language on POSIX operating system. Contributions are welcome!
# In Animula repo
make # if you haven't built Animula VM
./animula-vm foo.lef
Sometimes, animula-linux is good to debug the VM, but sometimes you may have to debug on board. If you use Alonzo board, you may debug the VM via BLE.
You must have a ZephyrRTOS supported board to run Animula. And Animula developers always prefer Alonzo board to test.
Traditionally, when you start to learn a new programming environment, the first program is always hello world which is a trivial program to print a "hello world" string. However, in embedded software programming, the "hello world" is different, we call it blink which is also a trivial program to make LED blinking.
Open your favorite editor or IDE, and create a new file named program.scm. Just copy and paste the code below:
(define (main x)
(gpio-toggle! 'dev_led0)
(usleep 200000)
(if (= x 0)
#t
(main (- x 1))))
(main 10)
The code is self-explain, you may try to modify it to verify your ideas. Don't worry, the Alonzo board will never be bricked.
NOTE: If you bricked it, congrats! You have the chance to learn how to flash the bootloader of the Alonzo board.
Now we can compile the program with the Laco compiler:
laco program.scm
If the compilation works successfully, you may not see anything output when it is finished. Now you should find there's a new file named program.lef. That's the generated bytecode file for the Animula virtual machine.
Copy the program.lef to TF card and then insert the TF card to Alonzo board.
Animula virtual machine will scan the TF card and find the file named program.lef. When it's found then run it automatically. If you use other names then it doesn't work at all.
Everything is OK! Please connect the Alonzo to your PC or power bank with a USB Type-C cable, and the board will power on, then you should see the LED blinking periodically.