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
5
1.2k
Baremetal Rust for RISC-V
RustのLT会 #6
tomoyuki-nakabayashi
November 26, 2018
Tweet
Share
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.5k
Embedded-Rust
tomoyuki
1
3.1k
hello-world-on-RTOS
tomoyuki
0
890
Other Decks in Programming
See All in Programming
Fluid Templating in TYPO3 14
s2b
0
110
AIエージェント、”どう作るか”で差は出るか? / AI Agents: Does the "How" Make a Difference?
rkaga
4
1.9k
フロントエンド開発の勘所 -複数事業を経験して見えた判断軸の違い-
heimusu
7
2.6k
責任感のあるCloudWatchアラームを設計しよう
akihisaikeda
3
120
そのAIレビュー、レビューしてますか? / Are you reviewing those AI reviews?
rkaga
5
4.1k
なぜSQLはAIぽく見えるのか/why does SQL look AI like
florets1
0
340
Claude Codeの「Compacting Conversation」を体感50%減! CLAUDE.md + 8 Skills で挑むコンテキスト管理術
kmurahama
1
780
なるべく楽してバックエンドに型をつけたい!(楽とは言ってない)
hibiki_cube
0
130
ThorVG Viewer In VS Code
nors
0
750
疑似コードによるプロンプト記述、どのくらい正確に実行される?
kokuyouwind
0
340
副作用をどこに置くか問題:オブジェクト指向で整理する設計判断ツリー
koxya
1
540
React 19でつくる「気持ちいいUI」- 楽観的UIのすすめ
himorishige
11
5.7k
Featured
See All Featured
The Cult of Friendly URLs
andyhume
79
6.8k
[SF Ruby Conf 2025] Rails X
palkan
0
720
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
55
Thoughts on Productivity
jonyablonski
74
5k
Build your cross-platform service in a week with App Engine
jlugia
234
18k
Odyssey Design
rkendrick25
PRO
0
470
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
190
Un-Boring Meetings
codingconduct
0
180
Git: the NoSQL Database
bkeepers
PRO
432
66k
Technical Leadership for Architectural Decision Making
baasie
1
220
Raft: Consensus for Rubyists
vanstee
141
7.3k
The browser strikes back
jonoalderson
0
330
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作ろう!
• そして、錆ありベアメタルの群れを作ろう!