Skip to content

a-shiomaneki/mrubyc-esp-idf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mrubyc-esp-idf

An example of mruby/c on ESP-IDF

Description

I tested the latest mruby/c (Dec 27, 2024) on ESP-IDF v5.3.2, and the target is esp32c3. The original hal/esp32/hal.c caused errors related to the timer function, so I modified it with ChatGPT o1 and o1-mini support.

The code arrangement is based on the following repository: https://github.com/mruby-esp32/mrubyc-esp32

mruby/c code is placed in components/mrubyc/mrubyc as a git submodule. Because hal/esp32 is required as the hal subdirectory in mruby/c's src, I wrote automation logic in top-level CMakeLists.txt, which creates a symbolic link from hal/esp32 to src/hal.

Also, automation logic for converting ruby code to bytecode is in top-level CMakeLists.txt

There are three type codes in main/main.c; these are activated macros SAMPLE_TASK_WITW_NO_MRBC_SCHEDULER, SAMPLE_TASK_WITW_MRBC_SCHEDULER, and SAMPLE_EXEC_IN_MAIN.

When you try the SAMPLE_TASK_WITW_NO_MRBC_SCHEDULER code, the sleep 1 code in resource/hello.rb should be commented out because can't use the sleep object without the mruby/c scheduler.

Installation instructions

  1. Install ESP-IDF v5.3.2 and configure for esp32c3 target.

    ESP-IDF Programing Guide - Get Started

  2. For Linux/Mac users, execute export.sh in ESP-IDF to configure the shell environment. For Windows users, install wizard can configure the environment.

    Step 4. Set up the Environment Variables

  3. Install the Ruby package, which requires the bytecode compiler mrbc. You can find this package in your Linux and Mac package system. For Windows users, you can download a prebuilt binary from ITOC(Shimane IT Open-Innovation Center). Of course you can build from the source code.

    itoc - ダウンロード mruby/c

    https://github.com/mruby/mruby

  4. Clone this repository.

    git clone --recursive https://github.com/a-shiomaneki/mrubyc-esp-idf.git
    
  5. To build the binary, execute idf.py build in the top-level directory of this repository.

    Start a Project on Window Start a Project on Linux and macOS

  6. Attach your ESP32C3 device to your computer.

  7. To flash binary to the device, execute idf.py -p <port> -b <baud rate> flash.

    Build System

  8. To see the response from this app, execute idf.py -p <port> -b <baud rate> monitor.

    Monitor the Output

About

An example of mruby/c on ESP-IDF

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published