2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

AVR-rustガイドブックを使って行っていく

環境

ubuntu 22.04
rustup 1.27.1 (54dd3d00f 2024-04-24)
cargo 1.79.0-nightly (d438c80c4 2024-03-19)
rustc 1.79.0-nightly (0ad927c0c 2024-03-21)

rustの環境構築

省略

コンパイラと関連ライブラリをインストール

rustupを使ってコンパイラとコンポーネントをインストール

$ rustup toolchain install nightly
...
$ rustup component add rust-src --toolchain nightly

ubuntu向け関連ライブラリのインストール

$ sudo apt install binutils gcc-avr avr-libc avrdude

サンプルをビルド

$ git clone https://github.com/avr-rust/blink.git
$ cd /blink
$ rustup override set nightly

# Compile the crate to an ELF executable.
$ cargo build -Z build-std=core --target avr-atmega328p.json --release

or

cargo +nightly build -Z build-std=core --target avr-atmega328p.json --release

ボードの種類によってjsonファイルは編集する。
指定するボード以外のjsonファイルも用意しておくと便利かも…

arduinoへ書き込む

avrdude -patmega328p -carduino -P/dev/ttyUSB1 -b115200 -D -Uflash:w:target/avr-atmega328p/release/blink.elf:e

デバイスパスは都度変わるため確認してから書き込むとストレスがない
アクセス制限かかる場合はchmodコマンドで+666を付与
/dev/ttyUSB* or /dev/ttyACM*

LEDがチカチカすれば成功

まとめ

今回はLチカだけですし備忘録的にざっくりまとめました。なんとなくrustでarduino使えそうな感じしてきたので今度はarduinoのライブラリも使えるようにしてもう少し使い勝手良く動かせるようにしていきます。

参考

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?