Git Product home page Git Product logo

nthnn / rishka Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 978 KB

RISC-V core virtual runtime written in C/C++ (Arduino platform) intended for ESP32-WROVER with PSRAM.

Home Page: https://rishka.vercel.app

License: GNU General Public License v3.0

Assembly 0.90% C 18.40% C++ 69.46% Rust 10.41% Shell 0.83%
arduino arduino-platform arduino-platformio arduino-project esp32 esp32-arduino risc-v risc-v-emulator risc-v-simulator kernel

rishka's Introduction

Rishka

Arduino CI Arduino Lint Rust Build CI SDK Build CI GitHub repo size

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.

How Does It Work?

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.

Installation

Rishka VM

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:

  1. Clone Rishka to your Arduino libraries, by typing the command below:
cd ~/Arduino/libraries
git clone --depth 1 https://github.com/nthnn/rishka.git
  1. Open your Arduino IDE, then navigate to File > Examples > rishka and select an example suitable for your project.

  2. You're all set! Integrate Rishka into your project and start leveraging its capabilities.

Compiling Examples

Using rishka-cc tool

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.

Manually Compiling

To compile SDK examples provided with Rishka, follow these steps:

  1. If you haven't already, install Qrepo by following the instructions available here.

  2. Ensure you have the RISC-V64 GCC toolchain installed by running:

sudo apt install gcc-riscv64-unknown-elf
  1. Open a terminal and navigate to the directory where you cloned the Rishka repository.

  2. 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.

Example

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("> ");
}

Contributing

Contributions to Ladivic are highly encouraged and appreciated! To contribute new features, bug fixes, or enhancements, please adhere to the following guidelines:

  1. Fork the rishka repository.
  2. Create a new branch for your changes: git checkout -b feature-name.
  3. Implement your changes and commit them: git commit -m "Added new feature".
  4. Push your changes to the branch: git push origin feature-name.
  5. Submit a pull request for review and inclusion.

License

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/>.

rishka's People

Contributors

nthnn avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.