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
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
930
Other Decks in Programming
See All in Programming
typoなんかねぇよ
raspython3
0
550
そこに3びきプロダクトがいるじゃろう——生成AI時代における“価値が届かない理由”の構造
kosuket
0
580
AI Engineeringは、AIプロダクトだけのものか? 〜AIがソフトウェアを作る時代の新しい当たり前〜 / No AI in your product. AI Engineering in your development.
rkaga
5
530
私のClaude Code活用法 (個人開発編) - PHPerKaigi mini #4(2026/08/24)
panda_program
1
160
メールのエイリアス機能を履き違えない
isshinfunada
0
250
源内ハンズオン概要編
hideg
0
210
AIと壁打ちしながら進めるコスト管理
fufuhu
2
1.7k
30年振りにコンパイラの定数整数除算を改善した
herumi
9
4.2k
GDG Korea Android: 2026 I/O Extended ~ What's new in Android development tools
pluu
0
240
承認済みなのに差戻しできてしまうバグ、型で潰せます
shinchit
0
110
in-process GraphQL のすすめ #ginzajs
izumin5210
4
1.5k
AI時代に学ぶ 好きなルール 嫌いなルール Linter編
shorty5121
0
150
Featured
See All Featured
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
820
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.8k
How to train your dragon (web standard)
notwaldorf
97
6.8k
For a Future-Friendly Web
brad_frost
183
10k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
480
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
220
How to make the Groovebox
asonas
2
2.3k
Bootstrapping a Software Product
garrettdimon
PRO
306
120k
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
1.1k
4 Signs Your Business is Dying
shpigford
187
23k
Designing Powerful Visuals for Engaging Learning
tmiket
1
510
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
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作ろう!
• そして、錆ありベアメタルの群れを作ろう!