/picoruby

PicoRuby is an integration of PicoRuby compiler with mruby/c VM for one-chip microcontrollers

Primary LanguageCMIT LicenseMIT

C/C++ CI

PicoRuby

PicoRuby is an alternative mruby implementation which is:

  • Small foot print
    • ROM: 256 KB
    • RAM: 128 KB or less (depending on app code)
    • (Figures in 32 bit architecture)
  • Portable
    • Depends on only standard C library such as glibc, Newlib or Newlib-nano
  • Reference microcontroller boards
    • Raspberry Pi Pico - Arm Cortex-M0+, 264 KB RAM, 2 MB ROM
    • PSoC5LP - Arm Cortex-M3, 128 KB RAM, 256 KB ROM

Depends on

Used by

PRK Firmware

Build

  • Prerequisites
    • C toolchain
    • git
    • ruby (should be CRuby)
  • git clone --recursive this repository
  • cd picoruby
  • rake builds binaries for your machine
    • PicoRuby basically uses mruby's build system as it is
    • rake -T shows available subcommands
  • You can build library files for PSoC5LP by hitting rake psoc5lp_lib
    • It requires you to have Docker though,
    • You can make arm-none-eabi tools if you don't want to use Docker
    • hasumikin/cross_compilation_toolchains may help you to make an environment
    • This feature is under reconstruction as of 2022

Cross compilation

See an example: build_config/r2p2-cortex-m0plus.rb

Binaries

rake command will make three kinds of executable binary

  • bin/picorbc
    • bin/picorbc path/to/source.rb makes path/to/source.mrb that is VM code runs on an mruby-compatible virtual machine
  • bin/picoruby
    • bin/picoruby source.rb executes Ruby just like normal ruby command
    • You can also do like bin/picoruby -e 'puts "Hello World!"'
  • bin/picoirb
    • A REPL implementation like irb and mirb

--verbose option

bin/picoruby --verbose -e 'puts "Hello World!"' shows debug-print like this:

(Replace [path/to/]mmruby with bin/picoruby --verbose in mind. It's an old name)

Presentations about PicoRuby

The author gave a talk about PicoRuby in RubyConf 2021. See the video on YouTube.

Japanese talks are available at RubyKaigi Takeout 2020 and RubyKaigi Takeout 2021.

Roadmap

PicoRuby is still developing halfway towards finishing as of 2022.

See implementation roadmap on issue/6

Contributing to PicoRuby

Fork, patch, then send a pull request.

Acknowledgement

Part of this project was coded by Monstarlab with the support of the Ruby Association Grant Program 2020 and 2021.

See also picoruby/picoruby/wiki.

License

Copyright © 2020-2022 HASUMI Hitoshi & Monstarlab. See MIT-LICENSE for further details.