Rishka is a RISC-V virtual runtime in C/C++ made for ESP32-WROVER with PSRAM specifically developed as kernel for Jessy OS.
Note
Work in progress.
The Rishka virtual runtime is a system designed to run special RISC-V binaries smoothly on ESP32-WROVER microcontroller units. Under the hood, the virtual machine serves as the main engine, while the kernel acts as its core component. The kernel handles system calls efficiently, providing a range of interfaces for accessing different system features and services.
These include basic functions like managing files, as well as more complex tasks like controlling GPIO pins, attaching and detaching interrupts, and communication protocols such as I2C and SPI. Additionally, the kernel manages system utilities specific to the Jessy OS, handling tasks like sub-process runtime and memory allocation.
Rishka VM is a lightweight and efficient virtual runtime environment designed for RISC-V binaries on ESP32-WROVER microcontrollers. Follow these steps to integrate Rishka into your Arduino projects:
- Clone Rishka to your Arduino libraries, by typing the command below:
cd ~/Arduino/libraries
git clone --depth 1 https://github.com/nthnn/rishka.git
-
Open your Arduino IDE, then navigate to
File > Examples > rishka
and select an example suitable for your project. -
You're all set! Integrate Rishka into your project and start leveraging its capabilities.
To use rishka-cc
, you can get it from the release page if available or compile it yourself by typing the following on your terminal. Just make sure you have installed Rust compiler and Cargo package manager on your system.
cargo build --release
Alternatively, you can install the rishka-cc
tool by typing the following below on your system terminal:
sh -c "$(curl -fsSL https://raw.githubusercontent.com/nthnn/rishka/main/support/install_rishka_cc.sh)"
Before using rishka-cc
, you must configure two (2) environment variables, as shown below.
export RISHKA_LIBPATH=<path to sdk library folder>
export RISHKA_SCRIPTS=<path to scripts folder>
The RISHKA_LIBPATH
must be a folder where the librishka.h
header file is located, while the RISHKA_SCRIPTS
should be a folder where both launch.s
and the link.ld
files are located. For example, assuming Rishka was moved to the libraries folder on Arduino IDE:
export RISHKA_LIBPATH=/Arduino/libraries/rishka/sdk
export RISHKA_SCRIPTS=/Arduino/libraries/rishka/scripts
If no problems occured and was configured as instructed, you can now seamlessly use the rishka-cc
.
To compile SDK examples provided with Rishka, follow these steps:
-
If you haven't already, install Qrepo by following the instructions available here.
-
Ensure you have the RISC-V64 GCC toolchain installed by running:
sudo apt install gcc-riscv64-unknown-elf
-
Open a terminal and navigate to the directory where you cloned the Rishka repository.
-
Use Qrepo to compile the examples by executing the following command:
qrepo run compile <source-file> <output-name>
Replace <source-file>
with the path to the source file of the example you want to compile and <output-name>
with the desired name for the output binary.
Examples:
qrepo run compile examples/sdk/hello.cpp hello
# This will output the binary file to dist/hello.bin
Now you have successfully compiled the example and can proceed with using the generated binary file.
This example demonstrates the usage of Rishka virtual machine on an ESP32-WROVER microcontroller. It initializes serial communication and SD card, waits for user input via serial port, loads the specified file into the Rishka VM, executes it, and then waits for the next input.
#include <rishka.h>
rishka_virtual_machine vm;
void setup() {
// Begin serial communication at 115200 baud rate
Serial.begin(115200);
// Wait until serial connection is established
while(!Serial);
// Initialize SD card on pin 5
if(!SD.begin(5)) {
// If SD card initialization fails,
// print error message and halt execution
Serial.println("Failed to initialize SD card.");
while(true);
}
// Initialize Rishka virtual machine
rishka_vm_initialize(&vm);
// Print prompt
Serial.print("> ");
}
void loop() {
// Check if there is data available to read from serial port
if(!Serial.available())
return;
// Read input from serial port
String input = Serial.readString();
// Echo input back to serial port
Serial.print(input);
// Attempt to load specified file into Rishka virtual machine
if(!rishka_vm_loadfile(&vm, input.c_str())) {
// If loading file fails, print error message and return
Serial.println("Failed to load specified file: " + input);
return;
}
// Run loaded program on Rishka virtual machine
rishka_vm_run(&vm, 0, NULL);
// Reset Rishka virtual machine for next execution
rishka_vm_reset(&vm);
// Print prompt for next input
Serial.print("> ");
}
Contributions to Ladivic are highly encouraged and appreciated! To contribute new features, bug fixes, or enhancements, please adhere to the following guidelines:
- Fork the rishka repository.
- Create a new branch for your changes:
git checkout -b feature-name
. - Implement your changes and commit them:
git commit -m "Added new feature"
. - Push your changes to the branch:
git push origin feature-name
. - Submit a pull request for review and inclusion.
Rishka is distributed under the GNU General Public License v3.0. For further details, refer to the LICENSE file.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, version 3.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.