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
Ruby on cygwin 2025-02
fd0
0
140
Amazon Bedrock Multi Agentsを試してきた
tm2
1
280
Grafana Loki によるサーバログのコスト削減
mot_techtalk
1
130
自分ひとりから始められる生産性向上の取り組み #でぃーぷらすオオサカ
irof
8
2.7k
データベースのオペレーターであるCloudNativePGがStatefulSetを使わない理由に迫る
nnaka2992
0
130
XStateを用いた堅牢なReact Components設計~複雑なClient Stateをシンプルに~ @React Tokyo ミートアップ #2
kfurusho
1
890
Introduction to kotlinx.rpc
arawn
0
690
Open source software: how to live long and go far
gaelvaroquaux
0
630
社内フレームワークとその依存性解決 / in-house framework and its dependency management
vvakame
1
560
定理証明プラットフォーム lapisla.net
abap34
1
1.8k
Kubernetes History Inspector(KHI)を触ってみた
bells17
0
220
[JAWS-UG横浜 #79] re:Invent 2024 の DB アップデートは Multi-Region!
maroon1st
1
140
Featured
See All Featured
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
Build The Right Thing And Hit Your Dates
maggiecrowley
34
2.5k
Intergalactic Javascript Robots from Outer Space
tanoku
270
27k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
129
19k
Site-Speed That Sticks
csswizardry
4
380
Rails Girls Zürich Keynote
gr2m
94
13k
Building Your Own Lightsaber
phodgson
104
6.2k
Git: the NoSQL Database
bkeepers
PRO
427
64k
The Cost Of JavaScript in 2023
addyosmani
47
7.3k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
59k
Statistics for Hackers
jakevdp
797
220k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
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作ろう!
• そして、錆ありベアメタルの群れを作ろう!