LoginSignup
1
0

M5StickCPlusの開発環境をVSCode(Devcontainer)で作成したい話

Posted at

目的

PCを新調するので開発環境をシンプルに構成(汚したくない)と思い、M5StickCPlusの開発環境もDevcontainerに対応させたい。(備忘録)

事前準備

私はこれらの記事を参考にDevcontainerを作成しました。

devcontainer.jsonの作成

といっても、今回は先駆者がいたので、丸々コピーした上で日本語訳しただけって形になってしまいますね。

{
	// 名前を決める
	"name": "PlatformIO (Community)",
	//Dockerファイルを指定
	"dockerFile": "Dockerfile",
	//dockerをカスタマイズ
	"customizations": {
		//vscodeの設定
		"vscode": {
			"settings": {
				//ターミナルシェルをzshに指定
				"terminal.integrated.defaultProfile.linux": "zsh"
			},
			//拡張機能
			"extensions": [
				//c++の拡張機能
				"ms-vscode.cpptools",
				//platformIO IDE
				"platformio.platformio-ide"
			]
		}
	},
	//使用するポートの指定
	"forwardPorts": [
		8008
	],
	//接続するArduinoやM5のマウント設定
	"mounts": [
		"source=/dev/,target=/dev/,type=bind,consistency=consistent"
	],
	//ホストに接続されたすべてのデバイスへのアクセスを許可
	"runArgs": [
		"--privileged"
	],
	//python環境も入れておく
	"features": {
		"ghcr.io/devcontainers/features/python:1": {}
	},
	"postAttachCommand": "sudo service udev restart"
}

Dockerfile

そのまんま

ARG VARIANT=20-bullseye
FROM mcr.microsoft.com/vscode/devcontainers/typescript-node:0-${VARIANT}

RUN <<EOF 
  apt-get update 
  export DEBIAN_FRONTEND=noninteractive 
  apt-get -y install --no-install-recommends \
    clang \
    udev     
  
  curl -fsSL https://raw.githubusercontent.com/platformio/platformio-core/develop/platformio/assets/system/99-platformio-udev.rules | sudo tee /etc/udev/rules.d/99-platformio-udev.rules
  service udev restart 
  usermod -a -G dialout node
  usermod -a -G plugdev node 
  
EOF

あとは再起動すれば拡張機能込みで起動しました。

参考

1
0
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
1
0