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
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
tomoyuki-nakabayashi
November 26, 2018
Programming
1.2k
5
Share
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.2k
How to learn Embedded Rust Edition 2021
tomoyuki
0
1.6k
Embedded-Rust
tomoyuki
1
3.2k
hello-world-on-RTOS
tomoyuki
0
910
Other Decks in Programming
See All in Programming
PHPでローカル環境用のSSL/TLS証明書を発行することはできるのか? #phpconkagawa
akase244
0
350
ハーネスエンジニアリングにどう向き合うか 〜ルールファイルを超えて開発プロセスを設計する〜 / How to approach harness engineering
rkaga
28
19k
空間オーディオの活用
objectiveaudio
0
140
How We Benchmarked Quarkus: Patterns and anti-patterns
hollycummins
1
180
AI-DLC Deep Dive
yuukiyo
9
5.6k
【26新卒研修資料】TDD実装演習
dip_tech
PRO
0
170
いつか誰かが、と思っていた フロントエンド刷新5年間の実践知
kiichisugihara
1
260
決定論 vs 確率論:Gemini 3 FlashとTF-IDFを組み合わせた「法規判定エンジン」の構築
shukob
0
160
実践ハーネスエンジニアリング:ステアリングループを実例から読み解く / Practical Harness Engineering: Understanding Steering Loops Through Real-World Examples
nrslib
5
4.5k
tRPCの概要と少しだけパフォーマンス
misoton665
2
270
WebAssembly を読み込むベストプラクティス 2026年春版 / Best Practices for Loading WebAssembly (Spring 2026)
petamoriken
5
1.1k
Making the RBS Parser Faster
soutaro
0
670
Featured
See All Featured
Building Flexible Design Systems
yeseniaperezcruz
330
40k
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.5k
How to Ace a Technical Interview
jacobian
281
24k
WENDY [Excerpt]
tessaabrams
10
37k
Fireside Chat
paigeccino
42
3.9k
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
Large-scale JavaScript Application Architecture
addyosmani
515
110k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.7k
What does AI have to do with Human Rights?
axbom
PRO
1
2.1k
Prompt Engineering for Job Search
mfonobong
0
300
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
280
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
240
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作ろう!
• そして、錆ありベアメタルの群れを作ろう!