R2P2
R2P2 copied to clipboard
PicoRuby shell for Raspberry Pi Pico (RP2040)
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
- Install R2P2 into Raspberry Pi Pico.
- Open R2P2 in a terminal emulator.
- Use some shell commands to see a filesystem working on R2P2.
- Run some small Ruby scripts in IRB.
Part 2
- Blink the on-board LED of Raspberry Pi Pico using the GPIO class of PicoRuby.
- Measure the temperature using Pi Pico's on-chip ADC with the ADC class of PicoRuby.
Part 3
- Use the multi-line editor feature of IRB.
- Set the current time in the RTC of Pi Pico.
- Confirm the
datecommand in the shell is implemented with the Time class of PicoRuby.
- Create a Ruby script with the Vim-like text editor and execute it.
- Drag and drop a Ruby script that is written outside R2P2 and execute it.
- 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
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

