rabbit-slide-hasumikin-RubyKaigi2025 2025.04.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.rabbit +2 -0
- data/MicroRuby.md +622 -0
- data/README.md +32 -0
- data/Rakefile +17 -0
- data/config.yaml +24 -0
- data/images/MicroRuby.png +0 -0
- data/images/RubyKaigi 2025 Graphics Kit/RubyKaigi 2025 Graphics Kit/Assets/RubyKaigi 2025_Assets_cmyk.pdf +0 -0
- data/images/RubyKaigi 2025 Graphics Kit/RubyKaigi 2025 Graphics Kit/Assets/RubyKaigi 2025_Assets_rgb.pdf +0 -0
- data/images/RubyKaigi 2025 Graphics Kit/RubyKaigi 2025 Graphics Kit/Assets/RubyKaigi 2025_Assets_rgb.svg +887 -0
- data/images/RubyKaigi 2025 Graphics Kit/RubyKaigi 2025 Graphics Kit/Assets/logo.svg +250 -0
- data/images/RubyKaigi 2025 Graphics Kit/RubyKaigi 2025 Graphics Kit/ogp/ogp.jpg +0 -0
- data/images/assets/background-slide-headline.png +0 -0
- data/images/assets/background-slide.svg +243 -0
- data/images/assets/background-title.png +0 -0
- data/images/assets/banner.jpg +0 -0
- data/images/assets/logo.svg +247 -0
- data/images/assets/mikan.svg +95 -0
- data/images/assets/mikan24.png +0 -0
- data/images/assets/mikan28.png +0 -0
- data/images/assets/mikan32.png +0 -0
- data/images/assets/mikan36.png +0 -0
- data/images/assets/mikan40.png +0 -0
- data/images/ep2-2.png +0 -0
- data/images/ep2.png +0 -0
- data/images/estalloc.png +0 -0
- data/images/hachi.png +0 -0
- data/images/hasumi.jpg +0 -0
- data/images/matz.jpg +0 -0
- data/images/memory_profile/mrb_init_core.png +0 -0
- data/images/memory_statistics.png +0 -0
- data/images/nmonth.png +0 -0
- data/images/r2p2_release.png +0 -0
- data/pdf/RubyKaigi2025-MicroRuby.pdf +0 -0
- data/theme.rb +220 -0
- metadata +91 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 55099b7310f3a86cbae37d6857f566ee0dd95e731b4dccd041f2d73cbf4c8895
|
4
|
+
data.tar.gz: 417b84ca64f95a3e0e995257acb4f93a82cad782c52da752acd4066c9e7b9753
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1bffb69e52d397994687f8f11121418d19728d8a84ec34678e4ea53da45048e9814eb9a3e4e75703ebee09c9cf10cbe8a07a34f8b4cbfda536ad84a646340453
|
7
|
+
data.tar.gz: 25d0254da4718171716bacc903a300ff5947256a60ebf9cf356762b39dbabe87cb20a97d18aaaf8c1809b6cb08d8454fca692f022b0d648c79199303a869d4c7
|
data/.rabbit
ADDED
data/MicroRuby.md
ADDED
@@ -0,0 +1,622 @@
|
|
1
|
+
# MicroRuby
|
2
|
+
|
3
|
+
subtitle
|
4
|
+
: True Microcontroller Ruby
|
5
|
+
|
6
|
+
author
|
7
|
+
: hasumikin
|
8
|
+
|
9
|
+
content-source
|
10
|
+
: RubyKaigi 2025
|
11
|
+
|
12
|
+
date
|
13
|
+
: 17th April 2025
|
14
|
+
|
15
|
+
allotted-time
|
16
|
+
: 30m
|
17
|
+
|
18
|
+
theme
|
19
|
+
: theme
|
20
|
+
|
21
|
+
# Three Proposals for RubyKaigi 2025
|
22
|
+
|
23
|
+
- MicroRuby (this talk)
|
24
|
+
- PicoRuby.wasm
|
25
|
+
- Keyboard
|
26
|
+
|
27
|
+
# Contents
|
28
|
+
\\n
|
29
|
+
{:.center}
|
30
|
+
{::tag name="x-large"}Part1: DISCUSSION{:/tag}
|
31
|
+
{::tag name="x-large"}Part2: IMPLEMENTATION{:/tag}
|
32
|
+
{::tag name="x-large"}Part3: HARD WORK{:/tag}
|
33
|
+
|
34
|
+
# Acknowledgement
|
35
|
+
|
36
|
+
{:.center}
|
37
|
+
\\n\\n
|
38
|
+
This project is developed under the support of the Ruby Association Grant 2024 with Matz advisory
|
39
|
+
|
40
|
+
# A Sequel of the Grant 2021
|
41
|
+
{:
|
42
|
+
relative_height="100"
|
43
|
+
}
|
44
|
+
|
45
|
+
# chapter
|
46
|
+
|
47
|
+
Part1: DISCUSSION
|
48
|
+
|
49
|
+
## properties
|
50
|
+
hide-title
|
51
|
+
: true
|
52
|
+
|
53
|
+
# mruby for Microcontroller
|
54
|
+
- People make mruby(/c) applications with their embed-programming skills
|
55
|
+
- But, no friendly microcontroller framework unlike MicroPython and PicoRuby (R2P2)
|
56
|
+
|
57
|
+
{:.center}
|
58
|
+
{::tag name="xx-large"}*Guess why?*{:/tag}
|
59
|
+
|
60
|
+
# mruby for Microcontroller
|
61
|
+
- Making a MicroPython-like ecosystem is hard
|
62
|
+
- It requires skills of integrating Embedded systems and Ruby
|
63
|
+
|
64
|
+
{:.center}
|
65
|
+
{::tag name="xx-large"}*One Problem Found*{:/tag}
|
66
|
+
|
67
|
+
# One Problem Found
|
68
|
+
|
69
|
+
\\n
|
70
|
+
|
71
|
+
```text
|
72
|
+
"I'm clumsy and can't do electronics"
|
73
|
+
```
|
74
|
+
{: width="400" }
|
75
|
+
|
76
|
+
# One Problem Found
|
77
|
+
|
78
|
+
\\n
|
79
|
+
|
80
|
+
```text
|
81
|
+
🤔(Why he makes mruby then?)
|
82
|
+
```
|
83
|
+
{: width="400" }
|
84
|
+
|
85
|
+
# One Problem Found
|
86
|
+
|
87
|
+
\\n
|
88
|
+
|
89
|
+
```text
|
90
|
+
"Anyway, let me do it💪"
|
91
|
+
```
|
92
|
+
{: width="400" }
|
93
|
+
|
94
|
+
# PicoRuby and MicroRuby👀
|
95
|
+
```text
|
96
|
+
| | PicoRuby | MicroRuby |
|
97
|
+
==========================================
|
98
|
+
| Compiler | picoruby-compiler |
|
99
|
+
------------------------------------------
|
100
|
+
| VM | mruby/c | mruby |
|
101
|
+
------------------------------------------
|
102
|
+
| Gems | Picogems | Picogems + Mgems |
|
103
|
+
```
|
104
|
+
|
105
|
+
# diff mruby..mruby/c (Features)
|
106
|
+
|
107
|
+
```text
|
108
|
+
| | mruby | mruby/c |
|
109
|
+
========================================================================
|
110
|
+
| Standard Libraries | Enough | Less |
|
111
|
+
| Singleton Method | Yes | No |
|
112
|
+
| Module features | Yes | Limited |
|
113
|
+
| Method Visibility | Yes (version 3.4+) [new!] | No |
|
114
|
+
| Meta-Programming | Yes | Less |
|
115
|
+
| Able to Call Ruby Method in C | Yes | No |
|
116
|
+
| RVALUE Boxing | Word or NaN | No |
|
117
|
+
| Presym [*] | Yes | No |
|
118
|
+
------------------------------------------------------------------------
|
119
|
+
| Garbage Collector | Tri-color Incremental GC | Refcount |
|
120
|
+
| Library Management | Mrbgem + Rake | No |
|
121
|
+
------------------------------------------------------------------------
|
122
|
+
| Built-in Task Scheduler [*] | No | Yes |
|
123
|
+
| Footprint (in general) | Bigger | Smaller |
|
124
|
+
|
125
|
+
[*] mentioned later
|
126
|
+
```
|
127
|
+
|
128
|
+
# In Short,
|
129
|
+
|
130
|
+
{:.center}
|
131
|
+
\\n
|
132
|
+
{::tag name="xx-large"}mruby's Footprint is Bigger than mruby/c{:/tag}
|
133
|
+
|
134
|
+
# Three Years Ago
|
135
|
+
{: relative_height="100" }
|
136
|
+
|
137
|
+
# Is mruby Footprint Too Big to Use??
|
138
|
+
|
139
|
+
{:.center}
|
140
|
+
\\n\\n
|
141
|
+
{::tag name="xx-large"}TBH, I am not sure😇{:/tag}
|
142
|
+
|
143
|
+
# A Confession
|
144
|
+
|
145
|
+
{:.center}
|
146
|
+
\\n\\n
|
147
|
+
{::tag name="x-large"}`Hello, World!` is not what we want to do in the real world{:/tag}
|
148
|
+
|
149
|
+
# What Comsumes RAM in Ruby?
|
150
|
+
- Stack and heap objects in C functions
|
151
|
+
- Ruby objects and data in object
|
152
|
+
- data: String, Bignum, and CDATA, etc.
|
153
|
+
- Ruby call stack (callinfo)
|
154
|
+
- *IREP*
|
155
|
+
- *Symbol table*
|
156
|
+
|
157
|
+
# IREP
|
158
|
+
- Memory-developed object of VM code and literals
|
159
|
+
- An IREP represents a code block
|
160
|
+
- Code block
|
161
|
+
- Top-level code, class, module, def, do...end, {...}
|
162
|
+
- Consists of iseq, literals, nested ireps
|
163
|
+
|
164
|
+
# Presym is the Key to Win
|
165
|
+
- A unique feature of mruby
|
166
|
+
- Shipped with mruby 3.0 in *March 2021*
|
167
|
+
- CRuby and mruby/c don't have presym
|
168
|
+
- *Symbol table* and *IREPs* are located in ROM instead of RAM
|
169
|
+
|
170
|
+
# One More Key: ObjectSpace
|
171
|
+
- Heap Page management: Each RVALUE doesn't contain meta-data and padding
|
172
|
+
|
173
|
+
```text
|
174
|
+
CRuby : |meta-data|RVALUE|RVALUE|....................
|
175
|
+
mruby ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
176
|
+
Single Allocation
|
177
|
+
|
178
|
+
mruby/c : |meta-data+mrbc_value| |meta-data+mrbc_value|
|
179
|
+
^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^
|
180
|
+
Single Allocation Single Allocation
|
181
|
+
```
|
182
|
+
|
183
|
+
# Hypothesis
|
184
|
+
- mruby's *Presym* and *Heap Paging* would be keys to small footprint especially,
|
185
|
+
- A big MicroRuby application that bundles *many gems (IREPs)* and allocates *a lot of objects (RVALUEs)* might be effective than a PicoRuby application
|
186
|
+
|
187
|
+
# hasumikin Conjecture
|
188
|
+
|
189
|
+
```text
|
190
|
+
RAM [KB]
|
191
|
+
| PP
|
192
|
+
🍺.............................. MMMMMMMM🍻P
|
193
|
+
| M PP :
|
194
|
+
| MMMMMMMM PP :
|
195
|
+
| M PP :
|
196
|
+
| MMMMMMMMM PP :
|
197
|
+
| M PP :
|
198
|
+
| MM PP :
|
199
|
+
| MMMMM PP :
|
200
|
+
| M : PP
|
201
|
+
| M : PP P: RAM consumption of PicoRuby(mruby/c)
|
202
|
+
| M : PP M: RAM consumption of MicroRuby(mruby)
|
203
|
+
| M : PP 🍻: Kanpai Point
|
204
|
+
| M PP :
|
205
|
+
|MPP : :
|
206
|
+
0 +-----^---------------------------------🍺--->App scale
|
207
|
+
0 Hello, World! [gems & objects]
|
208
|
+
```
|
209
|
+
|
210
|
+
# Kanpai🍻 Point?
|
211
|
+
```text
|
212
|
+
Raspberry Pi Pico (W) : 264 KB
|
213
|
+
Raspberry Pi Pico 2 (W) : 520 KB
|
214
|
+
```
|
215
|
+
|
216
|
+
- If the🍻point < 240 KB, MicroRuby could replace PicoRuby
|
217
|
+
- If the🍻point < 500 KB, MicroRuby could be an alternative to PicoRuby
|
218
|
+
|
219
|
+
# chapter
|
220
|
+
|
221
|
+
Part2: IMPLEMENTATION
|
222
|
+
|
223
|
+
## properties
|
224
|
+
hide-title
|
225
|
+
: true
|
226
|
+
|
227
|
+
# How to Prove MicroRuby Eligible?
|
228
|
+
- Run a big application for microcontroller:
|
229
|
+
- *R2P2*: Ruby Rapid Portable Platform
|
230
|
+
- Things to do to achieve running R2P2:
|
231
|
+
- Integrate mruby's *presym*-build with PicoRuby
|
232
|
+
- Introduce *preemptive task scheduling* to mruby
|
233
|
+
|
234
|
+
# Demo: R2P2
|
235
|
+
|
236
|
+
```ruby
|
237
|
+
https = Net::HTTPSClient.new("ambidata.io")
|
238
|
+
adc = ADC.new(:temperature)
|
239
|
+
|
240
|
+
now = Time.now - INTERVAL # INTERVAL = 60
|
241
|
+
while true
|
242
|
+
now = Time.now
|
243
|
+
if last + INTERVAL <= now
|
244
|
+
temp = 27 - (adc.read - 0.706) / 0.001721
|
245
|
+
puts "#{now} / #{temp} C"
|
246
|
+
body = JSON.generate({
|
247
|
+
writeKey: WRITE_KEY,
|
248
|
+
data: [ { created: now.to_i, time: 1, d1: temp } ]
|
249
|
+
})
|
250
|
+
HEADERS["Content-Length"] = body.length
|
251
|
+
https.post(PATH, HEADERS, body)
|
252
|
+
last = now
|
253
|
+
end
|
254
|
+
sleep_ms 100
|
255
|
+
end
|
256
|
+
```
|
257
|
+
|
258
|
+
# What We're Gonna Do Is To
|
259
|
+
|
260
|
+
{:.center}
|
261
|
+
{::tag name="xx-large"}\\nImplement
|
262
|
+
Task Scheduler
|
263
|
+
for mruby{:/tag}
|
264
|
+
|
265
|
+
# Preemptive Task and Fiber
|
266
|
+
- Preemptive Task model:
|
267
|
+
- Shares control impartially by interrupt
|
268
|
+
- Fiber model:
|
269
|
+
- Yields control only to an adjoining Fiber
|
270
|
+
- R2P2, a kind of OS, could be implemented on top of the preemptive task scheduling
|
271
|
+
|
272
|
+
# mruby Has Fiber
|
273
|
+
- One fiber corresponds to an `mrb_context`
|
274
|
+
- `mrb_context` can be also used to manage task
|
275
|
+
- We can introduce task scheduling by taking advantage of `mrb_context`
|
276
|
+
|
277
|
+
# Task Scheduler Concept (Pseudo Code)
|
278
|
+
|
279
|
+
```ruby
|
280
|
+
while true
|
281
|
+
$mrb.tick += 1
|
282
|
+
if ($mrb.current_task.timeslice -= 1) == 0 # timeslice 10 to 0
|
283
|
+
$mrb.switch = true
|
284
|
+
end
|
285
|
+
sleep_ms 1
|
286
|
+
end
|
287
|
+
#--------------- 👆IRQ and 👇mruby run parallel ---------------#
|
288
|
+
task_queue = TaskQueue.new # Array-like object
|
289
|
+
task_queue << task1 << task2 # << task3 ...
|
290
|
+
while true ##########################################
|
291
|
+
task_queue.find_next.run do |task| #
|
292
|
+
while true ############################## # Task
|
293
|
+
execute_iseq(task.current_iseq.shift) # VM # scheduler
|
294
|
+
break if $mrb,switch || task.raised? # loop # loop
|
295
|
+
end end end #
|
296
|
+
```
|
297
|
+
|
298
|
+
# Tick Counter
|
299
|
+
|
300
|
+
```c
|
301
|
+
// Called every 1 ms
|
302
|
+
void mrb_tick(mrb_state *mrb)
|
303
|
+
{
|
304
|
+
tick_++;
|
305
|
+
...
|
306
|
+
current_task->timeslice--;
|
307
|
+
// ^^^^^^^^^ starts from 10
|
308
|
+
if (current_task->timeslice == 0) {
|
309
|
+
mrb->task.switching = TRUE;
|
310
|
+
}
|
311
|
+
...
|
312
|
+
}
|
313
|
+
```
|
314
|
+
|
315
|
+
# mruby VM Loop (Original)
|
316
|
+
|
317
|
+
```c
|
318
|
+
mrb_value mrb_vm_exec(...)
|
319
|
+
{
|
320
|
+
while (1) {
|
321
|
+
insn = BYTECODE_DECODER(*ci->pc);
|
322
|
+
switch (insn) {
|
323
|
+
case OP_MOVE: { regs[a] = regs[b]; break; }
|
324
|
+
case OP_xxxx: { ...; break; }
|
325
|
+
...
|
326
|
+
case OP_STOP: { return regs[irep->nlocals]; }
|
327
|
+
}
|
328
|
+
}
|
329
|
+
}
|
330
|
+
```
|
331
|
+
|
332
|
+
# mruby VM Loop (Hacked)
|
333
|
+
|
334
|
+
```c
|
335
|
+
mrb_value mrb_vm_exec(...)
|
336
|
+
{
|
337
|
+
while (1) {
|
338
|
+
insn = BYTECODE_DECODER(*ci->pc);
|
339
|
+
switch (insn) {
|
340
|
+
case OP_MOVE: { regs[a] = regs[b]; break; }
|
341
|
+
case OP_xxxx: { ...; break; }
|
342
|
+
...
|
343
|
+
case OP_STOP: { return regs[irep->nlocals]; }
|
344
|
+
}
|
345
|
+
if (mrb->task.switching || mrb->exc) { // new
|
346
|
+
return mrb_nil_value(); // new
|
347
|
+
} // new
|
348
|
+
}
|
349
|
+
}
|
350
|
+
```
|
351
|
+
|
352
|
+
# Task Scheduler Wraps VM Loop
|
353
|
+
|
354
|
+
```c
|
355
|
+
mrb_value mrb_tasks_run(mrb_state *mrb)
|
356
|
+
{
|
357
|
+
while (1) { // Task scheduler loop
|
358
|
+
...
|
359
|
+
// VM loop entry point
|
360
|
+
mrb_vm_exec(mrb, mrb->c->ci->proc, mrb->c->ci->pc);
|
361
|
+
...
|
362
|
+
current_task->state = TASKSTATE_READY;
|
363
|
+
hal_disable_irq();
|
364
|
+
q_delete_task(mrb, current_task);
|
365
|
+
q_insert_task(mrb, current_task);
|
366
|
+
hal_enable_irq();
|
367
|
+
...
|
368
|
+
continue;
|
369
|
+
}
|
370
|
+
}
|
371
|
+
```
|
372
|
+
|
373
|
+
# Mark Contexts in GC Root Scan Phase
|
374
|
+
|
375
|
+
```c
|
376
|
+
/* mruby/src/gc.c */
|
377
|
+
static void
|
378
|
+
root_scan_phase(mrb_state *mrb, mrb_gc *gc)
|
379
|
+
{
|
380
|
+
...
|
381
|
+
if (mrb->c_list) {
|
382
|
+
for (int i = 0; i < mrb->c_list_len; i++) {
|
383
|
+
mark_context(mrb, mrb->c_list[i]);
|
384
|
+
}
|
385
|
+
}
|
386
|
+
...
|
387
|
+
}
|
388
|
+
```
|
389
|
+
|
390
|
+
# chapter
|
391
|
+
|
392
|
+
Part3: HARD WORK
|
393
|
+
|
394
|
+
## properties
|
395
|
+
hide-title
|
396
|
+
: true
|
397
|
+
|
398
|
+
# Port Picogems for MicroRuby
|
399
|
+
```text
|
400
|
+
mruby-compiler2 - mruby compiler using a universal parser
|
401
|
+
picoruby-adc - ADC class / General peripherals
|
402
|
+
picoruby-base16 - Base16 for PicoRuby
|
403
|
+
picoruby-base64 - Base64 for PicoRuby
|
404
|
+
picoruby-bin-microruby - (microruby|picoruby) command
|
405
|
+
picoruby-bin-r2p2 - R2P2 executable for POSIX
|
406
|
+
picoruby-cyw43 - CYW43 class
|
407
|
+
picoruby-editor - Library for editor-like application
|
408
|
+
picoruby-env - ENV
|
409
|
+
picoruby-filesystem-fat - FAT filesystem
|
410
|
+
picoruby-gpio - GPIO class / General peripherals
|
411
|
+
picoruby-i2c - I2C class / General peripherals
|
412
|
+
picoruby-io-console - IO class
|
413
|
+
picoruby-machine - Machine class
|
414
|
+
picoruby-mbedtls - Mbed-TLS porting for PicoRuby
|
415
|
+
picoruby-net - Network functionality for PicoRuby
|
416
|
+
picoruby-picorubyvm - PicoRubyVM class
|
417
|
+
picoruby-pwm - PWM class / General peripherals
|
418
|
+
picoruby-rng - Random Number Generator for PicoRuby
|
419
|
+
picoruby-sandbox - Sandbox class for shell and picoirb
|
420
|
+
picoruby-shell - PicoRuby Shell library
|
421
|
+
picoruby-spi - SPI class / General peripherals
|
422
|
+
picoruby-uart - UART class / General peripherals
|
423
|
+
picoruby-vfs - Virtual-File-System-like wrapper for filesystems
|
424
|
+
picoruby-vim - vim-like text editor
|
425
|
+
picoruby-watchdog - Watchdog class
|
426
|
+
```
|
427
|
+
|
428
|
+
# Hard Work (as of 13 April)
|
429
|
+
|
430
|
+
```sh
|
431
|
+
# mruby/mruby
|
432
|
+
$> git diff --stat master
|
433
|
+
include/mruby.h | 22 ++++++++++++++++++++++
|
434
|
+
src/gc.c | 8 ++++++++
|
435
|
+
src/vm.c | 30 +++++++++++++++++++++++++++++-
|
436
|
+
3 files changed, 59 insertions(+), 1 deletion(-)
|
437
|
+
|
438
|
+
# picoruby/picoruby
|
439
|
+
$> git diff --shortstat master
|
440
|
+
237 files changed, 12621 insertions(+), 5445 deletions(-)
|
441
|
+
```
|
442
|
+
|
443
|
+
# R2P2 on MicroRuby 🎉
|
444
|
+
|
445
|
+
{:
|
446
|
+
relative_height="100"
|
447
|
+
}
|
448
|
+
|
449
|
+
# How to Compare RAM Consumption?
|
450
|
+
- Finally, R2P2 on MicroRuby works
|
451
|
+
- Now we want to compare the RAM consumption on *microcontroller*
|
452
|
+
- We no longer use glibc's allocator and valgrind
|
453
|
+
|
454
|
+
# How to Compare RAM Consumption?
|
455
|
+
```text
|
456
|
+
| | Default Allocator | Algorithm |
|
457
|
+
===========================================
|
458
|
+
| mruby | Libc (newlib) | dlmalloc |
|
459
|
+
-------------------------------------------
|
460
|
+
| mruby/c | Built-in | TLSF |
|
461
|
+
```
|
462
|
+
|
463
|
+
- Not fair to compare different allocators
|
464
|
+
- newlib doesn't have a measure method
|
465
|
+
- Might as well make a TLSF (Two-Level Segregated Fit) allocator for mruby?
|
466
|
+
|
467
|
+
|
468
|
+
# Make an Allocator
|
469
|
+
|
470
|
+
{:
|
471
|
+
relative_height="100"
|
472
|
+
}
|
473
|
+
|
474
|
+
# ESTALLOC
|
475
|
+
- https://github.com/picoruby/estalloc
|
476
|
+
- Derived from mruby/c's built-in allocator
|
477
|
+
- Originally only supports 4-byte alignment
|
478
|
+
- Improved to support alignment options:\\n 4-byte and 8-byte
|
479
|
+
|
480
|
+
# Let's See
|
481
|
+
|
482
|
+
{:
|
483
|
+
relative_height="74"
|
484
|
+
}
|
485
|
+
|
486
|
+
```text
|
487
|
+
( 165716 - (2237 * 24) ) / 1024 ~= 109 KB
|
488
|
+
^^^^^^ ^^^^ ^^ ^^^^^^
|
489
|
+
Allocated Free sizeof(RVALUE) Actual Used
|
490
|
+
```
|
491
|
+
|
492
|
+
# R2P2 RAM Consumption
|
493
|
+
```text
|
494
|
+
| R2P2 on PicoRuby (initial) | 49 KB |
|
495
|
+
| R2P2 on PicoRuby (gems loaded) | 78 KB |
|
496
|
+
-------------------------------------------
|
497
|
+
| R2P2 on MicroRuby (presymed) | 109 KB |
|
498
|
+
```
|
499
|
+
|
500
|
+
- PicoRuby will use more RAM by adding gems
|
501
|
+
|
502
|
+
# hasumikin Conjecture
|
503
|
+
|
504
|
+
```text
|
505
|
+
RAM [KB]
|
506
|
+
| PP
|
507
|
+
🍺.............................. MMMMMMMM🍻P
|
508
|
+
| M PP :
|
509
|
+
| MMMMMMMM PP :
|
510
|
+
| M : PP :
|
511
|
+
| MMMMMMMMM : PP :
|
512
|
+
| M PP :
|
513
|
+
| MM PP : : P: PicoRuby
|
514
|
+
| MMMMM PP : : M: MicroRuby
|
515
|
+
| M : PP : :
|
516
|
+
| M : PP : :
|
517
|
+
| M : PP : :
|
518
|
+
| M : PP : :
|
519
|
+
| M PP : :
|
520
|
+
|MPP : : :
|
521
|
+
0 +-----^--------------------^------------🍺--->App scale
|
522
|
+
0 Hello, World! R2P2 (at init) ?🤔?
|
523
|
+
```
|
524
|
+
|
525
|
+
# Practicality
|
526
|
+
```text
|
527
|
+
| | RAM | PicoRuby | MicroRuby |
|
528
|
+
=================================================
|
529
|
+
| Raspi Pico | 264KB | ✅ | ✅ |
|
530
|
+
| Raspi Pico W | 264KB | ✅ | ❌ |
|
531
|
+
| Raspi Pico 2 | 520KB | ✅ | ✅ |
|
532
|
+
| Raspi Pico 2 W | 520KB | ✅ | ✅ |
|
533
|
+
```
|
534
|
+
|
535
|
+
- `W` : WiFi and BLE module
|
536
|
+
- You need to share RAM for these stacks like MbedTLS and LwIP
|
537
|
+
|
538
|
+
# Released!!! (with Bugs)
|
539
|
+
|
540
|
+
{:
|
541
|
+
relative_height="100"
|
542
|
+
}
|
543
|
+
|
544
|
+
# chapter
|
545
|
+
|
546
|
+
{:.center}
|
547
|
+
{::tag name="xx-large"}🍻🍻🍻🍻🍻🍻{:/tag}
|
548
|
+
|
549
|
+
## properties
|
550
|
+
hide-title
|
551
|
+
: true
|
552
|
+
|
553
|
+
# Wrap Up
|
554
|
+
- R2P2 on MicroRuby runs within a reasonable size of RAM🍻
|
555
|
+
- (Soon) You can easily write IoT apps with almost full-spec Ruby🎊
|
556
|
+
|
557
|
+
# What If PicoRuby Introduces Presym?
|
558
|
+
|
559
|
+
```text
|
560
|
+
RAM [KB]
|
561
|
+
| M🍺
|
562
|
+
| MMMMMMMM
|
563
|
+
| M
|
564
|
+
| MMMMMMMM
|
565
|
+
| M
|
566
|
+
| MMMMMMMMM No Kanpai Anymore😭
|
567
|
+
| M
|
568
|
+
| MM
|
569
|
+
| MMMMM PPPPPP🍺
|
570
|
+
| M PPPPPP
|
571
|
+
| M PPPPPP
|
572
|
+
| M PPPPPP
|
573
|
+
| M PPPPPP
|
574
|
+
| M PPPPPP
|
575
|
+
|MPP
|
576
|
+
0 +-------------------------------------------->App scale
|
577
|
+
0 [gems & objects]
|
578
|
+
```
|
579
|
+
|
580
|
+
# Coming Up Title Would Be
|
581
|
+
|
582
|
+
{:.center}
|
583
|
+
\\n
|
584
|
+
{::tag name="xx-large"}*MAKE PICORUBY*{:/tag}
|
585
|
+
{::tag name="xx-large"}*SMALL AGAIN*{:/tag}
|
586
|
+
{::tag name="x-small"}(not serious){:/tag}
|
587
|
+
|
588
|
+
# n-Monthly Lambda Note Vol.4, No.1
|
589
|
+
|
590
|
+
{:
|
591
|
+
align="right"
|
592
|
+
relative_height="90"
|
593
|
+
relative_margin_top="0"
|
594
|
+
relative_margin_left="5"
|
595
|
+
}
|
596
|
+
|
597
|
+
- WebAssemblyの\\n制約を越える\\n*@kateinoigakukun*
|
598
|
+
- PicoRubyといっしょに\\n学ぶ、プログラミング\\n言語が電気回路を動かす\\n仕組み @hasumikin
|
599
|
+
|
600
|
+
{:.center}
|
601
|
+
*Autograph Session Right after This Talk! @.bookstore on the 2nd floor*
|
602
|
+
|
603
|
+
# Rubyではじめる電子工作
|
604
|
+
|
605
|
+
{:
|
606
|
+
align="right"
|
607
|
+
relative_height="98"
|
608
|
+
relative_margin_left="7"
|
609
|
+
relative_margin_top="-3"
|
610
|
+
}
|
611
|
+
|
612
|
+
- 副題: ラジコンを作ろう\\n*@hachi*
|
613
|
+
- n月刊ラムダノート\\n(前頁)が理論編なら\\nこちらが実践編
|
614
|
+
- {::tag name="large"}*Only at RubyKaigi :\\nGet Both Books!*{:/tag}
|
615
|
+
|
616
|
+
# chapter
|
617
|
+
|
618
|
+
🍊THANK YOU🍊
|
619
|
+
|
620
|
+
## properties
|
621
|
+
hide-title
|
622
|
+
: true
|
data/README.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# MicroRuby: True Microcontroller Ruby
|
2
|
+
|
3
|
+
Presentation slide for RubyKaigi 2025
|
4
|
+
|
5
|
+
## For author
|
6
|
+
|
7
|
+
### Show
|
8
|
+
|
9
|
+
```
|
10
|
+
rake
|
11
|
+
```
|
12
|
+
|
13
|
+
# Publish
|
14
|
+
|
15
|
+
```
|
16
|
+
rake publish
|
17
|
+
```
|
18
|
+
|
19
|
+
## For viewers
|
20
|
+
|
21
|
+
### Install
|
22
|
+
|
23
|
+
```
|
24
|
+
gem install rabbit-slide-hasumikin-RubyKaigi2025
|
25
|
+
```
|
26
|
+
|
27
|
+
### Show
|
28
|
+
|
29
|
+
```
|
30
|
+
rabbit rabbit-slide-hasumikin-RubyKaigi2025.gem
|
31
|
+
```
|
32
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require "rabbit/task/slide"
|
2
|
+
|
3
|
+
# Edit ./config.yaml to customize meta data
|
4
|
+
|
5
|
+
spec = nil
|
6
|
+
Rabbit::Task::Slide.new do |task|
|
7
|
+
spec = task.spec
|
8
|
+
# spec.files += Dir.glob("doc/**/*.*")
|
9
|
+
# spec.files -= Dir.glob("private/**/*.*")
|
10
|
+
# spec.add_runtime_dependency("rabbit-theme-YOUR-THEME")
|
11
|
+
end
|
12
|
+
|
13
|
+
desc "Tag #{spec.version}"
|
14
|
+
task :tag do
|
15
|
+
sh("git", "tag", "-a", spec.version.to_s, "-m", "Publish #{spec.version}")
|
16
|
+
sh("git", "push", "--tags")
|
17
|
+
end
|
data/config.yaml
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
---
|
2
|
+
id: RubyKaigi2025
|
3
|
+
base_name: MicroRuby
|
4
|
+
tags:
|
5
|
+
- MicroRuby
|
6
|
+
- PicoRuby
|
7
|
+
- mruby
|
8
|
+
presentation_date: '2025-04-17'
|
9
|
+
presentation_start_time:
|
10
|
+
presentation_end_time:
|
11
|
+
version: 2025.04.17.0
|
12
|
+
licenses: ["MIT"]
|
13
|
+
slideshare_id:
|
14
|
+
speaker_deck_id:
|
15
|
+
ustream_id:
|
16
|
+
vimeo_id:
|
17
|
+
youtube_id:
|
18
|
+
author:
|
19
|
+
markup_language: :md
|
20
|
+
name: HASUMI Hitoshi
|
21
|
+
email: hasumikin@gmail.com
|
22
|
+
rubygems_user: hasumikin
|
23
|
+
slideshare_user:
|
24
|
+
speaker_deck_user:
|
Binary file
|
Binary file
|