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.1k
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
1k
How to learn Embedded Rust Edition 2021
tomoyuki
0
1.4k
Embedded-Rust
tomoyuki
1
2.9k
hello-world-on-RTOS
tomoyuki
0
810
Other Decks in Programming
See All in Programming
パスキーのすべて ── 導入・UX設計・実装の紹介 / 20250213 パスキー開発者の集い
kuralab
3
780
iOSエンジニアから始める visionOS アプリ開発
nao_randd
3
130
Open source software: how to live long and go far
gaelvaroquaux
0
630
第3回関東Kaggler会_AtCoderはKaggleの役に立つ
chettub
3
1k
クリーンアーキテクチャから見る依存の向きの大切さ
shimabox
2
290
dbt Pythonモデルで実現するSnowflake活用術
trsnium
0
150
SwiftUI Viewの責務分離
elmetal
PRO
1
240
2024年のWebフロントエンドのふりかえりと2025年
sakito
2
250
さいきょうのレイヤードアーキテクチャについて考えてみた
yahiru
3
750
WebDriver BiDiとは何なのか
yotahada3
1
140
プログラミング言語学習のススメ / why-do-i-learn-programming-language
yashi8484
0
130
color-scheme: light dark; を完全に理解する
uhyo
3
310
Featured
See All Featured
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.3k
Optimising Largest Contentful Paint
csswizardry
34
3.1k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
30
4.6k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
4
410
jQuery: Nuts, Bolts and Bling
dougneiner
63
7.6k
Building a Scalable Design System with Sketch
lauravandoore
461
33k
It's Worth the Effort
3n
184
28k
Rails Girls Zürich Keynote
gr2m
94
13k
We Have a Design System, Now What?
morganepeng
51
7.4k
Rebuilding a faster, lazier Slack
samanthasiow
80
8.8k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
12
960
Mobile First: as difficult as doing things right
swwweet
223
9.3k
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作ろう!
• そして、錆ありベアメタルの群れを作ろう!