SlideShare a Scribd company logo
Now is the time to create your own (m)Ruby computer
What’s your childhood dream ?
PLAYING VIDEO GAMES FREELY
CREATING VIDEO GAMES
FAMILY BASIC
My longing programing hardware using BASIC on Family Computer(NES)
CREATING VIDEO GAME
HARDWARE??
You can make
your own computer
with mruby!
WHO AM I?
Katsuhiko Kageyama
“kishima” @ twitter/github
• Embedded software engineer in a manufacturing
company
• Making mruby devices
• Personally, producing technical books about
mruby and original devices in TechBookFest,
Comic Market and Maker Faire(2020 Tsukuba).
MY
DEVICES
MY HOBBY
Agenda
•How to create your computer
•Why mruby?
•Important technical things about mruby
GOAL OF MY DEVELOPMENT
•Creating my small
computer to run Ruby
scripts like “Family BASIC”
•I call it “Family mruby”
How to create your computer
DEFINE
REQUIREMENTS
FIND
COMPONENTS
MAKE A
SCHEMATICS
MANUFACTURING
THE DEVICE
IMPLEMENT
SOFTWARE
Define requirements
Find components
Make a schematics
Manufacturing the device
Implement software
Each steps are no so difficult for software
engineers
According to your idea
Find components which satisfy your requirements.
DigiKey is a good worldwide supplier
Digital signal schematics could be simple
We can use KiCAD
Chinese company offers 5$ / 5 boards
You need to implement basic software
Write application using Ruby!
•I love Ruby
•No one likes to wait for compiling C and flashing img
•Shorter code is nice for the small device
Why mruby?
•mruby can run on some small processors with
limited memory (>400KB RAM preferred)
•Simple implementation of mruby VM helps to port
it to your own hardware
FINDING THE CORE PROCESSOR
Board MCU ROM size RAM size
Arduino ATmega328p 32KB 2KB
ProMicro ATmega32U4 32KB 2.5KB
ESP32 dev board ESP32-WROOM-32 4MB 520KB
ESP32 dev board ESP32-WROVER-B 4MB 8MB
Raspberry Pi zero ARM1176JZF-S >1GB
(external)
512MB
(external)
*mruby requires >400kB memory
Requirements Schematics
Manufacturing
Implement basic software
•Small processor doesn’t support rich OS like Linux.
•C, C++ are common language
•Difficult to avoid C/C++ because low layer are
provided by C/C++ usually
My idea : System diagram
Dev host
ESP-IDF
my device
ESP32Arduino core
FabGL
mrbgem fro esp32
mruby compiler/VM
mruby user App
System
App
(C++)
family_mruby
Micro SD
xtensa tool chain
Serial communication
PS/2 key board
ESP32-WROVER-B
Updating software
Active speaker
VGA monitor
My hardware
•Small
manufacturing was
done by Chinese
company
•Case was made by
my 3D-printer
DIFFICULTY OF IMPLEMENTATION
•Limited memory
•Always need to take care of remaining memory
• Avoid creating so many Ruby objects
•Low performance
•Use HW function(Interruption, DMA etc.) as much as possible
INTERRUPTION
• Hardware interruption is good for receiving
HW event
CPU
Button
Electrical signal
Function A
(running)
Function B
(Interruption handler)
Interruption signal will change the program counter to
an interruption hander
MRUBY CANNOT HANDLE HW INTERRUPTION
• Cannot not touch mruby VM’s resource from the interruption handler
• The handler has higher priority
• Common solution is a polling method
loop do
if Input::available
if Input::keydown?(Key::K_UP)
my=-2
end
if Input::keydown?(Key::K_DOWN)
my=2
end
end
sp.move(mx*1,my*1)
end
Checking inputs in
a loop
• This is not the best in the limited CPU
performance condition
SOFTWARE-LAYER INTERRUPTION
• Compromised solution for handling interruption
• Similar idea is applied in eLua and MicroPython
https://github.com/kishima/mruby-interrupt
CPU
Button
Electrical signal
Function A
(running)
Function B
(Interruption handler)
mruby VM
mruby VM do polling
events
Storing int. event in the
handler
Example:
Implementation
(experimental)
* vm.c *
#ifndef MRB_SW_INTERRUPT
#define CASE(insn,ops) L_ ## insn: pc0=p
c++; FETCH_ ## ops (); L_ ## insn ## _BO
DY:
#else
#define CASE(insn,ops) L_ ## insn: pc0=p
c++; exec_interrupt(mrb); FETCH_ ## ops
(); L_ ## insn ## _BODY:
#endif
* vm.c *
#ifdef MRB_SW_INTERRUPT
static void exec_interrupt(mrb_state *mrb){
if(!mrb->interrupt_func)
return;
while( !(mrb->interrupt_flag & 0x8000) && mrb-
>interrupt_flag & 0x7FFF){
for(int i=0;i<16;i++){
int bit = (mrb-
>interrupt_flag >> i) & 0x0001;
if(bit){
mrb->user_mutex_func(mrb,1);
uint16_t backup = mrb->interrupt_flag;
mrb-
>interrupt_flag |= 0x8000; //Interrupt flag
mrb->interrupt_func(mrb,i);
mrb->interrupt_flag = backup;
mrb->interrupt_flag &= ~(1 << i);
mrb->user_mutex_func(mrb,0);
}
}
}
}
#endif
exec_interrupt() will be executed
when VM fetchs each mruby byte
code.
Now is the time to create your own (m)Ruby computer
SUMMARY
•We can create our own device
•I have created Family mruby
•Software interruption is a good
tool for making devices
•Enjoy your maker life
https://kishima.github.io/family_mruby/
THANK YOU!

More Related Content

KEY
Raspberry pi on java 20121110
PPTX
Practical Guide for Optimizing Unity on Mobiles
PDF
Unity3D Tips and Tricks or "You are doing it wrong!"
PDF
Unty3D Awesome Assets - uTomate
PPTX
Optimizing mobile applications - Ian Dundore, Mark Harkness
PDF
Mobile UX Tools & Methods for UX Australia 2011
PPTX
Desktop Apps in a Javascript World - Electron
PDF
Docker experience @inbotapp
Raspberry pi on java 20121110
Practical Guide for Optimizing Unity on Mobiles
Unity3D Tips and Tricks or "You are doing it wrong!"
Unty3D Awesome Assets - uTomate
Optimizing mobile applications - Ian Dundore, Mark Harkness
Mobile UX Tools & Methods for UX Australia 2011
Desktop Apps in a Javascript World - Electron
Docker experience @inbotapp

Similar to Now is the time to create your own (m)Ruby computer (20)

PDF
mruby/c and data-flow programming for small devices
PDF
How to control physical devices with mruby
PDF
mRuby - Powerful Software for Embedded System Development
PPT
Embedded system apsd
PDF
Rapid IoT prototyping with mruby
PDF
使用Eclipse快樂的mruby開發
PPTX
Computer Organization : CPU, Memory and I/O organization
PDF
Summer training embedded system and its scope
PDF
Unit I_MT2301.pdf
PPTX
Embedded systems
PPTX
SYBSC IT SEM IV EMBEDDED SYSTEMS UNIT IV Designing Embedded System with 8051...
PPTX
CST 20363 Session 4 Computer Logic Design
PDF
Whyp97
PPT
My seminar new 28
PDF
System Software ( Os )
PDF
ruby2600 - an Atari 2600 emulator written in Ruby
PPT
Basics of micro controllers for biginners
PPT
Embedded systemppt2343
DOC
Embedded training report(mcs 51)
PPTX
ROM Hacking for Fun, Profit & Infinite Lives
mruby/c and data-flow programming for small devices
How to control physical devices with mruby
mRuby - Powerful Software for Embedded System Development
Embedded system apsd
Rapid IoT prototyping with mruby
使用Eclipse快樂的mruby開發
Computer Organization : CPU, Memory and I/O organization
Summer training embedded system and its scope
Unit I_MT2301.pdf
Embedded systems
SYBSC IT SEM IV EMBEDDED SYSTEMS UNIT IV Designing Embedded System with 8051...
CST 20363 Session 4 Computer Logic Design
Whyp97
My seminar new 28
System Software ( Os )
ruby2600 - an Atari 2600 emulator written in Ruby
Basics of micro controllers for biginners
Embedded systemppt2343
Embedded training report(mcs 51)
ROM Hacking for Fun, Profit & Infinite Lives
Ad

More from kishima7 (16)

PPTX
mrubyで作るマイコンボード
PDF
自分だけのデバイスを作るお話
PDF
オリジナルmrubyデバイス作り
PDF
mruby VM を調べてみた話
PDF
Stairway to my Family mruby
PDF
VMを改めて学んで見る
PDF
mruby/cで始めるM5Stack &mrubyスクリプト開発
PDF
Wio LTEとmruby/cでIoT
PDF
Unityにmrubyを組み込んで抽選をしてみた
PDF
Introduction of mruby & Webruby script example
PDF
Dalvik Source Code Reading
PDF
Ruby and Android
PDF
Google TV hack
PDF
くみこみからひとことReturns
PPT
ネット家電じゃなくて?
PPT
くみこみからひとこと
mrubyで作るマイコンボード
自分だけのデバイスを作るお話
オリジナルmrubyデバイス作り
mruby VM を調べてみた話
Stairway to my Family mruby
VMを改めて学んで見る
mruby/cで始めるM5Stack &mrubyスクリプト開発
Wio LTEとmruby/cでIoT
Unityにmrubyを組み込んで抽選をしてみた
Introduction of mruby & Webruby script example
Dalvik Source Code Reading
Ruby and Android
Google TV hack
くみこみからひとことReturns
ネット家電じゃなくて?
くみこみからひとこと
Ad

Recently uploaded (20)

PPTX
Lecture Notes Electrical Wiring System Components
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PDF
Well-logging-methods_new................
PPTX
bas. eng. economics group 4 presentation 1.pptx
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PPT
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
PPTX
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PPTX
Geodesy 1.pptx...............................................
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PPTX
Welding lecture in detail for understanding
DOCX
573137875-Attendance-Management-System-original
PPTX
CH1 Production IntroductoryConcepts.pptx
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PPTX
Internet of Things (IOT) - A guide to understanding
Lecture Notes Electrical Wiring System Components
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
Well-logging-methods_new................
bas. eng. economics group 4 presentation 1.pptx
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
UNIT-1 - COAL BASED THERMAL POWER PLANTS
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
Model Code of Practice - Construction Work - 21102022 .pdf
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
Operating System & Kernel Study Guide-1 - converted.pdf
Geodesy 1.pptx...............................................
Embodied AI: Ushering in the Next Era of Intelligent Systems
Welding lecture in detail for understanding
573137875-Attendance-Management-System-original
CH1 Production IntroductoryConcepts.pptx
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
Internet of Things (IOT) - A guide to understanding

Now is the time to create your own (m)Ruby computer

  • 5. FAMILY BASIC My longing programing hardware using BASIC on Family Computer(NES)
  • 7. You can make your own computer with mruby!
  • 8. WHO AM I? Katsuhiko Kageyama “kishima” @ twitter/github • Embedded software engineer in a manufacturing company • Making mruby devices • Personally, producing technical books about mruby and original devices in TechBookFest, Comic Market and Maker Faire(2020 Tsukuba).
  • 10. Agenda •How to create your computer •Why mruby? •Important technical things about mruby
  • 11. GOAL OF MY DEVELOPMENT •Creating my small computer to run Ruby scripts like “Family BASIC” •I call it “Family mruby”
  • 12. How to create your computer DEFINE REQUIREMENTS FIND COMPONENTS MAKE A SCHEMATICS MANUFACTURING THE DEVICE IMPLEMENT SOFTWARE
  • 13. Define requirements Find components Make a schematics Manufacturing the device Implement software Each steps are no so difficult for software engineers According to your idea Find components which satisfy your requirements. DigiKey is a good worldwide supplier Digital signal schematics could be simple We can use KiCAD Chinese company offers 5$ / 5 boards You need to implement basic software
  • 14. Write application using Ruby! •I love Ruby •No one likes to wait for compiling C and flashing img •Shorter code is nice for the small device
  • 15. Why mruby? •mruby can run on some small processors with limited memory (>400KB RAM preferred) •Simple implementation of mruby VM helps to port it to your own hardware
  • 16. FINDING THE CORE PROCESSOR Board MCU ROM size RAM size Arduino ATmega328p 32KB 2KB ProMicro ATmega32U4 32KB 2.5KB ESP32 dev board ESP32-WROOM-32 4MB 520KB ESP32 dev board ESP32-WROVER-B 4MB 8MB Raspberry Pi zero ARM1176JZF-S >1GB (external) 512MB (external) *mruby requires >400kB memory
  • 18. Implement basic software •Small processor doesn’t support rich OS like Linux. •C, C++ are common language •Difficult to avoid C/C++ because low layer are provided by C/C++ usually
  • 19. My idea : System diagram Dev host ESP-IDF my device ESP32Arduino core FabGL mrbgem fro esp32 mruby compiler/VM mruby user App System App (C++) family_mruby Micro SD xtensa tool chain Serial communication PS/2 key board ESP32-WROVER-B Updating software Active speaker VGA monitor
  • 20. My hardware •Small manufacturing was done by Chinese company •Case was made by my 3D-printer
  • 21. DIFFICULTY OF IMPLEMENTATION •Limited memory •Always need to take care of remaining memory • Avoid creating so many Ruby objects •Low performance •Use HW function(Interruption, DMA etc.) as much as possible
  • 22. INTERRUPTION • Hardware interruption is good for receiving HW event CPU Button Electrical signal Function A (running) Function B (Interruption handler) Interruption signal will change the program counter to an interruption hander
  • 23. MRUBY CANNOT HANDLE HW INTERRUPTION • Cannot not touch mruby VM’s resource from the interruption handler • The handler has higher priority • Common solution is a polling method loop do if Input::available if Input::keydown?(Key::K_UP) my=-2 end if Input::keydown?(Key::K_DOWN) my=2 end end sp.move(mx*1,my*1) end Checking inputs in a loop • This is not the best in the limited CPU performance condition
  • 24. SOFTWARE-LAYER INTERRUPTION • Compromised solution for handling interruption • Similar idea is applied in eLua and MicroPython https://github.com/kishima/mruby-interrupt CPU Button Electrical signal Function A (running) Function B (Interruption handler) mruby VM mruby VM do polling events Storing int. event in the handler Example:
  • 25. Implementation (experimental) * vm.c * #ifndef MRB_SW_INTERRUPT #define CASE(insn,ops) L_ ## insn: pc0=p c++; FETCH_ ## ops (); L_ ## insn ## _BO DY: #else #define CASE(insn,ops) L_ ## insn: pc0=p c++; exec_interrupt(mrb); FETCH_ ## ops (); L_ ## insn ## _BODY: #endif * vm.c * #ifdef MRB_SW_INTERRUPT static void exec_interrupt(mrb_state *mrb){ if(!mrb->interrupt_func) return; while( !(mrb->interrupt_flag & 0x8000) && mrb- >interrupt_flag & 0x7FFF){ for(int i=0;i<16;i++){ int bit = (mrb- >interrupt_flag >> i) & 0x0001; if(bit){ mrb->user_mutex_func(mrb,1); uint16_t backup = mrb->interrupt_flag; mrb- >interrupt_flag |= 0x8000; //Interrupt flag mrb->interrupt_func(mrb,i); mrb->interrupt_flag = backup; mrb->interrupt_flag &= ~(1 << i); mrb->user_mutex_func(mrb,0); } } } } #endif exec_interrupt() will be executed when VM fetchs each mruby byte code.
  • 27. SUMMARY •We can create our own device •I have created Family mruby •Software interruption is a good tool for making devices •Enjoy your maker life https://kishima.github.io/family_mruby/