A lightweight desktop environment for writing, simulating, and flashing mruby/c programs to the PIC32MX170F256B microcontroller — all from one window.
This is not a full IDE. It is a purpose-built, single-window tool that connects three things you already need:
| Step | Tool |
|---|---|
| Write Ruby code | Built-in editor with syntax highlighting |
| Compile to bytecode | mrbc (mruby compiler) |
| Test on your desktop | simulator.exe — a virtual PIC32 environment |
| Flash to real hardware | mrbwrite.exe — writes .mrb over UART to your board |
- Code editor — Dark-themed, Ruby syntax highlighting, line numbers, error markers
- One-click compile — Runs
mrbcand shows errors inline in the editor - Built-in simulator — Output streams directly into the editor's console, no separate window
- GPIO simulation —
GPIO.new,gpio.write,gpio.read,sleepandloopall work - Flash writer — Integrated
mrbwritewith COM port selection and baud rate config - Settings dialog — Configure all tool paths without touching any file
- Python 3.8+
- PyQt6 or tkinter (tkinter is bundled with Python on Windows)
pyserial(optional — improves COM port detection)
pip install pyserial-
mrbc — the mruby compiler
On Windows with MSYS2 UCRT64:
pacman -S mingw-w64-ucrt-x86_64-mruby
- A PIC32MX170F256B board running the mruby/c firmware with UART programming support
mrbwrite.exeis already included as a pre-built binary
# 1. Clone the repo
git clone https://github.com/yourname/mrubyc-workbench.git
cd mrubyc-workbench
# 2. Launch the editor
python main.pyOn first launch, go to Settings → Tool Paths to point the editor at your mrbc.exe on disk.
Write standard mruby/c-compatible Ruby in the editor. The supported subset follows the mruby/c language spec.
Example — blink an LED:
gpio = GPIO.new(5, GPIO::OUT)
loop do
gpio.write(1)
sleep(1)
gpio.write(0)
sleep(1)
endClick Compile (or press Ctrl+B). If there are errors, the offending line is highlighted in red and the message appears in the console.
Click Run in Simulator. The virtual PIC32 boots, loads your bytecode into simulated 256 KB Flash, and runs the mruby/c VM. All puts output appears live in the console. Press Stop to kill it at any time.
- Select your COM port from the dropdown (auto-detected).
- Click Write to Board.
- The editor runs
mrbwriteand streams its output to the console.
Note: The board must be in programming mode. Power-cycle it (or press SW1) while
mrbwriteis running.
The simulator implements a real software model of the PIC32MX170F256B peripheral registers.
| Class / Method | Description |
|---|---|
GPIO.new(pin, mode) |
Configure a GPIO pin |
GPIO::OUT, GPIO::IN |
Pin direction constants |
GPIO::PULL_UP, GPIO::PULL_DOWN, GPIO::HIGH_Z |
Input mode constants |
gpio.write(value) |
Drive pin HIGH (1) or LOW (0) |
gpio.read |
Read pin state |
gpio.high? / gpio.low? |
Predicate methods |
leds_write(mask) |
Control up to 4 onboard LEDs by bitmask |
sw |
Read the onboard switch state |
sleep(seconds) |
Real-time delay |
.
├── main.py # The desktop editor (Python/Tkinter)
├── simulator.exe # Pre-built Windows simulator binary
├── mrbwrite.exe # Pre-built Windows flash writer binary
├── simulator_main.cpp # Simulator entry point and VM setup
├── model_dependent.cpp / .h # Simulated PIC32 peripheral register layer
├── pic32mx.h / xc.h # Hardware abstraction headers
├── Makefile # Build system for simulator.exe
├── sys/ # Compiler compatibility shims
├── mrbwrite/ # mrbwrite source code (submodule)
│ ├── mrbwrite.cpp
│ ├── mrbwrite.h
│ └── mrbwrite.pro # Qt project file
└── pic32mx170_mrubyc-master/ # mruby/c VM source code
└── src/ # VM core (vm.c, alloc.c, class.c, ...)
If you want to recompile simulator.exe yourself, you need the MSYS2 UCRT64 toolchain:
# Install MSYS2 from https://www.msys2.org, then:
pacman -S mingw-w64-ucrt-x86_64-gcc mingw-w64-ucrt-x86_64-mruby
# In the project root (using UCRT64 shell):
makeTo recompile mrbwrite.exe, Qt6 with SerialPort support is required:
pacman -S mingw-w64-ucrt-x86_64-qt6-base mingw-w64-ucrt-x86_64-qt6-serialport
cd mrbwrite
qmake mrbwrite.pro
make releaseThis project bundles compiled binaries and source code from the following open-source projects. Their licenses are reproduced in full below as required.
Source: https://github.com/mrubyc/mrubyc
Included in: pic32mx170_mrubyc-master/
BSD 3-Clause License
Copyright (C) 2015- Kyushu Institute of Technology. All rights reserved.
Copyright (C) 2015-2026 Shimane IT Open-Innovation Center. All rights reserved.
Copyright (C) 2026- Shimane Institute for Industrial Technology. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Source: https://github.com/mrubyc/mrbwrite
Included in: mrbwrite/ and mrbwrite.exe
BSD 3-Clause License
Copyright (c) 2015- Kyushu Institute of Technology. All rights reserved.
Copyright (c) 2015- Shimane IT Open-Innovation Center. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Source: https://github.com/kishima/pic32mx170_mrubyc
Included in: pic32mx170_mrubyc-master/
BSD 3-Clause License
Copyright (c) 2020, Shimane Johoshori Center Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The original code in this repository (main.py, simulator_main.cpp, model_dependent.cpp) is released under the BSD 3-Clause License.