R2P2 (Ruby Rapid Portable Platform) is a shell system runs on Raspberry Pi Pico written in picoruby/picoruby.
(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
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.
R2P2 uses dual CDC (Communications Device Class) USB ports to separate standard output and debug output:
- CDC 0 (in Linux, typically
/dev/ttyACM0
): Main terminal for shell interaction and application stdout - CDC 1 (as in,
/dev/ttyACM1
): Debug output (stderr) for system messages and debug prints
Debug output is only enabled in debug builds (rake debug
or PICORUBY_DEBUG=1 rake
).
To view debug output:
# Terminal 1: Main shell
gtkterm --port /dev/ttyACM0
# Terminal 2: Debug messages
gtkterm --port /dev/ttyACM1
In Ruby code, use Machine.debug_puts
to output to the debug port:
Machine.debug_puts "Debug message"
- 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.
- 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.
- Use the multi-line editor feature of IRB.
- 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.
- 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.
The presentation video (JA) from RubyWorld Conference 2022: Link
- 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)
If you are building on macOS, please use gcc-arm-embedded
.
brew install --cask gcc-arm-embedded
git clone https://github.com/picoruby/R2P2.git
cd R2P2
rake setup
rake
You'll find an executable in build
directory.
rake debug
The elf file can be debugged with Picoprobe and gdb-multiarch.
See the gist: https://gist.github.com/hasumikin/f508c092ced0b5d51779d472fbaf81e8
(TODO)
- 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