Skip to content

picoruby/R2P2

Repository files navigation

R2P2

R2P2 (Ruby on Raspberry Pi Pico) is a shell system written in picoruby/picoruby.

Usage

(TODO)

  • Download a release binary
  • Drag and drop it into the RPI-RP2 drive of Pi Pico
  • Connect the shell through a serial port with a terminal emulator
    gtkterm --port /dev/ttyACM0

About serial port terminal emulators

GTKTerm is strongly recommended. Traditional CUI/TUI emulator such as cu, screen, and minicom don't work well.

If you use Windows or macOS, try TeraTerm or PuTTY though the author didn't confirm them. You may need to look for a fine configuration.

Anyway, it seems almost problems on the terminal emulator come from CR/LF handling.

Demonstration

Opening crawl

Tutorial short clips

Part 1

  1. Preparation | https://youtu.be/s4M4rBnPSus
  • Install R2P2 into Raspberry Pi Pico.
  • Open R2P2 in a terminal emulator.
  1. R2P2 shell | https://youtu.be/ISU6TbIoIlQ
  • Use some shell commands to see a filesystem working on R2P2.
  1. Hello World! | https://youtu.be/2ZKpOOjzKJc
  • Run some small Ruby scripts in IRB.

Part 2

  1. GPIO | https://youtu.be/qbs25xDu7t8
  • Blink the on-board LED of Raspberry Pi Pico using the GPIO class of PicoRuby.
  1. ADC | https://youtu.be/dPGCyQrX6Zg
  • Measure the temperature using Pi Pico's on-chip ADC with the ADC class of PicoRuby.

Part 3

  1. IRB deeper | https://youtu.be/PVkP_uNBOo0
  • Use the multi-line editor feature of IRB.
  1. Time class | https://youtu.be/0uj4m4RI7lE
  • Set the current time in the RTC of Pi Pico.
  • Confirm the date command in the shell is implemented with the Time class of PicoRuby.
  1. Text editor | https://youtu.be/X1RdA6IE780
  • Create a Ruby script with the Vim-like text editor and execute it.
  1. Drag and Drop | https://youtu.be/7nHNEUZnuKQ
  • Drag and drop a Ruby script that is written outside R2P2 and execute it.
  1. /home/app.rb | https://youtu.be/6_RomLChvYE
  • Make Pi Pico an autostart device by writing /home/app.rb file.

Presentation video

The presentation video (JA) from RubyWorld Conference 2022: Link

Presentation slide

Build and development

Prerequisites

  • git
  • pico-sdk including tinyusb
  • pico-sdk including btstack (for pico_w)
  • env PICO_SDK_PATH
  • env PICO_EXTRAS_PATH
  • ruby (CRuby)
  • cmake
  • arm-none-eabi-gcc
  • arm-linux-gnueabihf-gcc
  • qemu-arm-static

The author is working on WSL2-Ubuntu (x86-64 Windows host) and Ubuntu (x86-64 native)

Build

Build process below doesn't work on macOS. Docker will solve it (TODO).

git clone https://github.com/picoruby/R2P2.git
cd R2P2
rake setup
rake

You'll find an executable in build directory.

Debug build

rake debug

The elf file can be debugged with Picoprobe and gdb-multiarch.

Usage of Picoprobe

See the gist: https://gist.github.com/hasumikin/f508c092ced0b5d51779d472fbaf81e8

Documentation

(TODO)

Roadmap

  • Fix many bugs, and
  • PicoRuby and Shell
    • More functionality of vim
    • UTF-8 support
    • Multi-task controll on the fly
    • Redirect and pipeline
  • Peripherals
    • FAT filesystem with SD card (SPI)
    • Real-time clock (RTC)
    • WiFi and TCP/IP on Raspberry Pi Pico W