Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Baremetal Rust for RISC-V
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
tomoyuki-nakabayashi
November 26, 2018
Programming
1.2k
5
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Baremetal Rust for RISC-V
RustのLT会 #6
tomoyuki-nakabayashi
November 26, 2018
More Decks by tomoyuki-nakabayashi
See All by tomoyuki-nakabayashi
Nature Remo SDKアップデートの軌跡
tomoyuki
1
1.3k
How to learn Embedded Rust Edition 2021
tomoyuki
0
1.6k
Embedded-Rust
tomoyuki
1
3.2k
hello-world-on-RTOS
tomoyuki
0
920
Other Decks in Programming
See All in Programming
継続モナドとリアクティブプログラミング
yukikurage
3
680
仕様駆動開発の消費期限
watany
6
1.2k
わからない話を追いかけたら、プログラミング言語を作る側にいた
ydah
3
450
What's New in Android 2026
veronikapj
0
250
AI時代に設計が 最大の生産性レバーになる 意図駆動開発とデータを消さない設計|Don't Delete Your Data or Your Intent — Design as the Deepest Lever in the AI Era
tomohisa
1
630
Claude Code全社展開のためにやったことn選~プラグイン302個・コミッター271人を支えるために~
kenchan
4
1.3k
信頼性について考えてみる(SRE NEXT 2026 miniLT)
hayama17
0
240
為什麼你並不需要ViewModel / No, you don't need a ViewModel
lovee
1
480
ITヒヤリハットを整理してみた ~ライフサイクルと原因から考える再発防止策~
koukimiura
1
140
Claude Opus 4.6以後の受託開発エンジニアの変化(Claude Code開発ノウハウ大公開スペシャルbyクラスメソッド)
iidatakuma
1
960
AIエージェントで 変わるAndroid開発環境
takahirom
2
770
5分で問診!Composer セキュリティ健康診断
codmoninc
0
850
Featured
See All Featured
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
400
Testing 201, or: Great Expectations
jmmastey
46
8.2k
30 Presentation Tips
portentint
PRO
1
360
The Spectacular Lies of Maps
axbom
PRO
1
890
Building an army of robots
kneath
306
46k
Optimising Largest Contentful Paint
csswizardry
37
3.9k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.9k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
980
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.7k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
560
Practical Orchestrator
shlominoach
191
12k
Transcript
RustでRISC-Vをターゲットに ベアメタる @LDScell 2018/11/26 RustのLT会!Rust入門者の集い #6
自己紹介 • @LDScell • tomoyuki-nakabayashi(github) – 孤独に、黙々と、 Rustでベアメタってます
Motivation • 目指せ孤独脱出!
Background • ベアメタルプログラミング (no_std)とは? • RISC-Vとは? – オープンなCPUの命令セット – CPU自作して販売しても合法
CPU (Metal) OS library apps CPU (Metal) apps
Rust 1.30リリース! (2018/10) • `no_std` applications – #![no_std]自体は1.6からstableだったが、 #[panic_handler]が追従せず、stableではライブラ リしか作れなかった
• Added RISC-V target compiler – riscv32imc-unknown-none-elf
stableでRISC-Vベアメタれる! • Hello world! • お作法
stableでRISC-Vベアメタれる! • ね、簡単でしょ? 良い子はUARTのTXバッファがFullでないかのチェックをしよう!
後は・・・
ちょっとアセンブリ書いて
ちょっとリンカスクリプト書いて
ちょっとcargoの設定書いて
ちょっとbuild script書いて
cargo runで完了! RISC-Vエミュレータの実行結果 めっちゃ簡単にベアメタれるやん! ※stableでは、アセンブラにriscv-toolchain (gcc)が必要
そこで僕は考えた
RISC-V用のOS作ろう! (ある意味必然)
• Deviceの利用を排他制御したい • 原始的な方法⇒spin lock – Deviceが利用中であれば、ループして待つ CPU 絶賛困っていること 安全なHWアクセスを作りたい
Thread 1 Thread 2 Device (Serial/Monitor)
spin crate They are usable without `std` and static initializers
are available. no_stdでも利用可能なspin lock用crate ```:Cargo.toml [dependencies] spin = "0.4.10“ ``` https://crates.io/crates/spin
早速spin crateを使え・・・ない! $ cargo build 命令セットレベルの問題? RISC-Vは(x86と違って)、compare_and_swap命令 がない 鋭意調査中 めっちゃ辛そうなエラー
Conclusion • Rustでベアメタルプログラミング簡単にできる よ! • RISC-Vというイケイケの命令セットをターゲット にできるよ! • 軽い気持ちでベアメタろう! OS作ろう!
• そして、錆ありベアメタルの群れを作ろう!