Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Baremetal Rust for RISC-V
Search
tomoyuki-nakabayashi
November 26, 2018
Programming
1.3k
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
カツオ、ご期待ください
suneo3476
0
130
iOSDC2026登壇資料.pdf
riofujimon
0
200
KiroのSpecで「五目並べ」を作ってみる
satoshi256kbyte
1
320
SREの越境 / SRE Collaboration
y0hgi
2
290
Java 27新機能 / Java 27 new features
kishida
2
190
iOSDCのペンライトを自動制御したい!
akkeylab
0
280
市販E-Readerを乗っ取れ 〜Embedded Swiftで電子ペーパーガジェットを制御する〜
trickart
0
220
Heart of Swift Concurrency
koher
0
1.1k
Starting & Sustaining Code-Based E2E Testing for Non-Coding QA Teams( #jasstniigata )
teyamagu
PRO
1
790
iOSDC Japan 2026 - Swiftで作って学ぼう!データベース自作入門
kaseken
2
410
Agents on Rails - Rails at Scale 2026
irinanazarova
0
300
Security issues being discussed on Web Platforms
petamoriken
0
1.4k
Featured
See All Featured
Why Our Code Smells
bkeepers
PRO
340
58k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.8k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
440
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
730
The Curious Case for Waylosing
cassininazir
1
550
How to Talk to Developers About Accessibility
jct
2
560
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
270
Joys of Absence: A Defence of Solitary Play
codingconduct
1
530
Product Roadmaps are Hard
iamctodd
55
13k
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
470
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
20k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
2
290
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作ろう!
• そして、錆ありベアメタルの群れを作ろう!