LoginSignup
6
5

CH32V003の開発環境をVisual Studio Code + PlatformIO で構築 (M1 Mac環境)

Last updated at Posted at 2023-07-03

初めに

M1 Macの環境でWCH CH32V003を開発するには、
・MounRiver Studio IDE
・CLI(コマンドライン)
・Arduino
・Visual Studio Code + PlatformIO
・Visual Studio Code + PlatformIO + Arduino
があるようです。
今回は、Visual Studio Code + PlatformIO の環境を構築してLチカプログラムをビルドしてみました。

Visual Studio Codeのインストール

ここを参考に、VSC、PlatformIOをインストールします。
https://pio-ch32v.readthedocs.io/en/latest/installation.html#

PlatformIO にpio-ch32をインストール

【蟻マーク】→【Platform】→【Advanced Installation】をクリックします。
スクリーンショット 2023-07-03 15.22.17.png
※注、このスクリーンショットはWCH CH32Vがインストールされた状態です

リポジトリの入力画面になりますので、以下のURLを設定して、【Install】をクリックします。
https://github.com/Community-PIO-CH32V/platform-ch32v.git

スクリーンショット 2023-07-03 14.40.21.png

【OK】ボタンを押下します。
スクリーンショット 2023-07-03 14.42.07.png

VScodeを立ち上げ直します。
【蟻マーク】→【Platform】 を確認すると、WCH CH32Vが登録されています。
スクリーンショット 2023-07-03 14.42.51.png

新規プロジェクト作成

【蟻マーク】→【home】 を選択して、【Quick Access】→【New Project】をクリックします。
スクリーンショット 2023-07-03 15.14.22.png
name:にプロジェクト名を入力します。
スクリーンショット 2023-07-03 15.14.59.png
つぎに、Board:に【CH32V003】と入力するとCH32V003シリーズの候補が出てきます。
今回は8pinタイプを使用するため、【CH32V003J4M6】を選択します。
スクリーンショット 2023-07-03 15.15.14.png
【Finish】ボタンを押下します。
スクリーンショット 2023-07-03 15.15.28.png
Prject Wizardが動き出し数分間?待ちます。
スクリーンショット 2023-07-03 15.16.16.png
【はい】ボタンを押下します。
スクリーンショット 2023-07-03 15.16.29.png
雛形が出来上がりました。
スクリーンショット 2023-07-03 15.16.53.png
PlatformIOのビルドは下の方の水色バーのレ点を押します。
スクリーンショット 2023-07-03 17.41.50.png
適当なLチカのソースを貼り付けてビルドすると正常にできました。
スクリーンショット 2023-07-03 17.36.32.png

書き込み

スクリーンショット 2023-07-03 19.15.27.png

スクリーンショット 2023-07-03 17.25.49.png
なんか、エラーになって書けない・・・
Reason: tried: '/opt/homebrew/opt/hidapi/lib/libhidapi.0.dylib' (no such file), '/usr/local/lib/libhidapi.0.dylib' (no such file), '/usr/lib/libhidapi.0.dylib' (no such file)

Library not loaded 対策

hidapiシェアドライブラリを入れれば良いのかな?ということで。
% brew install hidapi
https://zenn.dev/elfmimi/articles/c85b113e3c4479

macuser@MacMiniM1 ~ % brew install hidapi

==> Downloading https://formulae.brew.sh/api/formula.jws.json
############################################################################################ 100.0%
==> Downloading https://formulae.brew.sh/api/cask.jws.json
############################################################################################ 100.0%
==> Fetching hidapi
==> Downloading https://ghcr.io/v2/homebrew/core/hidapi/manifests/0.14.0
############################################################################################ 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/hidapi/blobs/sha256:4330e0a273dcb943f27e2be002fad0
############################################################################################ 100.0%
==> Pouring hidapi--0.14.0.arm64_monterey.bottle.tar.gz
🍺  /opt/homebrew/Cellar/hidapi/0.14.0: 19 files, 191.3KB
==> Running `brew cleanup hidapi`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
macuser@MacMiniM1 ~ %  

uploadやってみましょう。書けました!!!
スクリーンショット 2023-07-09 19.13.04.png

6
5
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
6
5