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
900
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
860
How to learn Embedded Rust Edition 2021
tomoyuki
0
1.2k
Embedded-Rust
tomoyuki
1
2.8k
hello-world-on-RTOS
tomoyuki
0
720
Other Decks in Programming
See All in Programming
Random\Randomizer クラスで日常のあれこれを解決しよう! / Random\Randomizer class solves familiar trouble
cocoeyes02
0
250
Code Reviews
bkuhlmann
4
890
Kotlin Multiplatform at Stable and Beyond (Android Makers 2024)
zsmb
0
270
Azure OpenAI Serviceのプロンプトエンジニアリング入門
tomokusaba
3
710
新宿ダンジョンを可視化してみた
satoshi7190
2
260
"config" ってなんだ? / What is "config"?
okashoi
0
240
単体テストを書かない技術 #phpcon_odawara
o0h
PRO
27
8.3k
Java 22 Overview
kishida
1
180
ONE WEDGE_company_guide
1wedge_one
0
490
『Railsオワコン』と言われる時代に、なぜブルーモ証券はRailsを選ぶのか
free_world21
0
250
Netty Chicago Java User Group 2024-04-17
sullis
0
180
Ruby GitHub Packages
bkuhlmann
0
630
Featured
See All Featured
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
25
2.3k
The Cost Of JavaScript in 2023
addyosmani
16
3.9k
Bash Introduction
62gerente
604
210k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
2
1.3k
The Brand Is Dead. Long Live the Brand.
mthomps
49
29k
4 Signs Your Business is Dying
shpigford
175
21k
Fireside Chat
paigeccino
21
2.6k
Unsuck your backbone
ammeep
663
57k
Rebuilding a faster, lazier Slack
samanthasiow
73
8.2k
No one is an island. Learnings from fostering a developers community.
thoeni
16
2.1k
Why You Should Never Use an ORM
jnunemaker
PRO
51
8.6k
Designing for humans not robots
tammielis
248
25k
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作ろう!
• そして、錆ありベアメタルの群れを作ろう!