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
930
Other Decks in Programming
See All in Programming
Pythonの実行はどこまで賢くなったのか? CPythonとPyPyから見る最適化のしくみ
curekoshimizu
3
1.9k
まずはプロンプトガイドを読もう、話はそれからだ
kiakiraki
1
210
ソフトウェアエンジニアにとっての生成AI - 特性を知って使い倒す / generative ai for software enginner
kishida
7
2.1k
実装をデザインガイドラインに追従させるための取り組み / 260731-dip-mosh-design-system
dachi023
0
7.8k
170k Jobs a Day on GKE: Scaling Mercari's CI Platform - and What's Next for AI-Native Development
junyaokabe
0
120
How I Won Prize Money at a Hackathon Using Codex and Symphony Alpha
yasei_no_otoko
0
120
仕様駆動開発へのトライを機に チームに適合する手法を模索し続けている話
freee
PRO
0
620
わからない話を追いかけたら、プログラミング言語を作る側にいた
ydah
3
550
Gmail/Google DriveをトリガーにAIエージェントを動かそう! / Run AI agents with Gmail/Google Drive as triggers!
har1101
2
440
Oxlintはいいぞ(続)
yug1224
1
450
React本体のコードリーディング
high_g_engineer
1
160
Detecting Compromised CI with eBPF and Cilium Tetragon
lizrice
0
260
Featured
See All Featured
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
4.5k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
23k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.6k
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
3k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.9k
Between Models and Reality
mayunak
4
410
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
35
2.8k
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4.1k
Tell your own story through comics
letsgokoyo
1
1k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
2.1k
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作ろう!
• そして、錆ありベアメタルの群れを作ろう!