MacOS での VScode での PlatformIO Core のスタック インストールと、新しいプロジェクトの作成速度の遅さの解決策

最近、smartknob を投げるために、vscode+platformIO を試してみましたが、インストールと構成で多くの落とし穴に遭遇しました. 以下は、解決プロセスです.

1.PlatformIO Installer: Installing PlatformIO Core立ち往生

vscode に PlatformIO プラグインをインストールした後、カードはPlatformIO Installer: Installing PlatformIO Core約 10 分後にエラーを報告します。開発者モードのコンソールを読んだ後、理由がわかりません。インターネットによると、フォルダの削除.platformio.cacheまたはpip.confファイルの変更は効果がありません。
解決策は、公式 Web サイト のスクリプト インストール方法に従うことです。

  • 1.1前提条件
    端末には科学インターネット プロキシが設定されており、私のマシンはローカル Clash プロキシですexport https_proxy=http://127.0.0.1:7890 http_proxy=http://127.0.0.1:7890 all_proxy=socks5://127.0.0.1:7890
  • 1.2コマンドラインで実行
python3 -c "$(curl -fsSL https://raw.githubusercontent.com/platformio/platformio/master/scripts/get-platformio.py)"

または、最初にこのスクリプトをダウンロードします。

wget https://raw.githubusercontent.com/platformio/platformio-core-installer/master/get-platformio.py

次に実行します。

python3 get-platformio.py

以下は私のインストールログです:

~/> python3 get-platformio.py
Installer version: 1.1.2
Platform: macOS-10.15.7
Python version: 3.9.13 (main, May 24 2022, 21:28:12)
[Clang 12.0.0 (clang-1200.0.32.29)]
Python path: /usr/local/opt/[email protected]/bin/python3.9
Creating a virtual environment at /Users/simonliu/.platformio/penv
Updating Python package manager (PIP) in a virtual environment
PIP has been successfully updated!
Virtual environment has been successfully created!
Installing PlatformIO Core
Collecting platformio
  Using cached platformio-6.1.4-py3-none-any.whl
Collecting marshmallow==3.*
  Using cached marshmallow-3.17.1-py3-none-any.whl (48 kB)
Collecting semantic-version==2.10.*
  Using cached semantic_version-2.10.0-py2.py3-none-any.whl (15 kB)
Collecting aiofiles==0.8.*
  Using cached aiofiles-0.8.0-py3-none-any.whl (13 kB)
Collecting wsproto==1.1.*
  Using cached wsproto-1.1.0-py3-none-any.whl (24 kB)
Collecting colorama
  Using cached colorama-0.4.5-py2.py3-none-any.whl (16 kB)
Collecting pyserial==3.5.*
  Using cached pyserial-3.5-py2.py3-none-any.whl (90 kB)
Collecting uvicorn==0.18.*
  Using cached uvicorn-0.18.3-py3-none-any.whl (57 kB)
Collecting click<9,>=8.0.4
  Using cached click-8.1.3-py3-none-any.whl (96 kB)
Collecting requests==2.*
  Using cached requests-2.28.1-py3-none-any.whl (62 kB)
Collecting tabulate==0.8.*
  Using cached tabulate-0.8.10-py3-none-any.whl (29 kB)
Collecting starlette==0.20.*
  Using cached starlette-0.20.4-py3-none-any.whl (63 kB)
Collecting zeroconf<1
  Using cached zeroconf-0.39.0-py3-none-any.whl (106 kB)
Collecting bottle==0.12.*
  Using cached bottle-0.12.23-py3-none-any.whl (90 kB)
Collecting ajsonrpc==1.*
  Using cached ajsonrpc-1.2.0-py3-none-any.whl (22 kB)
Collecting pyelftools<1,>=0.27
  Using cached pyelftools-0.29-py2.py3-none-any.whl (174 kB)
Collecting packaging>=17.0
  Using cached packaging-21.3-py3-none-any.whl (40 kB)
Collecting urllib3<1.27,>=1.21.1
  Using cached urllib3-1.26.12-py2.py3-none-any.whl (140 kB)
Collecting certifi>=2017.4.17
  Using cached certifi-2022.6.15-py3-none-any.whl (160 kB)
Collecting charset-normalizer<3,>=2
  Using cached charset_normalizer-2.1.1-py3-none-any.whl (39 kB)
Collecting idna<4,>=2.5
  Using cached idna-3.3-py3-none-any.whl (61 kB)
Collecting anyio<5,>=3.4.0
  Using cached anyio-3.6.1-py3-none-any.whl (80 kB)
Collecting typing-extensions>=3.10.0
  Using cached typing_extensions-4.3.0-py3-none-any.whl (25 kB)
Collecting h11>=0.8
  Using cached h11-0.13.0-py3-none-any.whl (58 kB)
Collecting async-timeout>=4.0.1
  Using cached async_timeout-4.0.2-py3-none-any.whl (5.8 kB)
Collecting ifaddr>=0.1.7
  Using cached ifaddr-0.2.0-py3-none-any.whl (12 kB)
Collecting sniffio>=1.1
  Using cached sniffio-1.3.0-py3-none-any.whl (10 kB)
Collecting pyparsing!=3.0.5,>=2.0.2
  Using cached pyparsing-3.0.9-py3-none-any.whl (98 kB)
Installing collected packages: pyserial, pyelftools, ifaddr, bottle, urllib3, typing-extensions, tabulate, sniffio, semantic-version, pyparsing, idna, h11, colorama, click, charset-normalizer, certifi, async-timeout, ajsonrpc, aiofiles, zeroconf, wsproto, uvicorn, requests, packaging, anyio, starlette, marshmallow, platformio
Successfully installed aiofiles-0.8.0 ajsonrpc-1.2.0 anyio-3.6.1 async-timeout-4.0.2 bottle-0.12.23 certifi-2022.6.15 charset-normalizer-2.1.1 click-8.1.3 colorama-0.4.5 h11-0.13.0 idna-3.3 ifaddr-0.2.0 marshmallow-3.17.1 packaging-21.3 platformio-6.1.4 pyelftools-0.29 pyparsing-3.0.9 pyserial-3.5 requests-2.28.1 semantic-version-2.10.0 sniffio-1.3.0 starlette-0.20.4 tabulate-0.8.10 typing-extensions-4.3.0 urllib3-1.26.12 uvicorn-0.18.3 wsproto-1.1.0 zeroconf-0.39.0

PlatformIO Core has been successfully installed into an isolated environment `/Users/simonliu/.platformio/penv`!

The full path to `platformio.exe` is `/Users/simonliu/.platformio/penv/bin/platformio`

If you need an access to `platformio.exe` from other applications, please install Shell Commands
(add PlatformIO Core binary directory `/Users/simonliu/.platformio/penv/bin` to the system environment PATH variable):

See https://docs.platformio.org/page/installation.html#install-shell-commands
  • 1.3 環境変数の更新
    最後に、 PATH を追加し、次の行を/Users/simonliu/.platformio/penv/binユーザー プロファイルに追加して (私はそれを使用します)、現在のターミナルで有効にします。~/.zshrcsource ~/.zshrc
export PATH="$PATH:/Users/simonliu/.platformio/penv/bin"

2. 新しいプロジェクトが遅すぎる

上記が完了した後でも、システムが対応するプラットフォームの SDK、ツールチェーン、および Arduino フレームワークをダウンロードするため、VSCode で新しいプロジェクトを作成するのは非常に遅くなります。
Arduino フレームワークを使用した ESP32 の開発を例にとると、ソリューションは依然としてコマンド ラインを介して行われます。

  • 2.1 前提
    端末で科学インターネット プロキシを設定する必要があります。
  • 2.2 関連するプラットフォーム sdk、ツールチェーン、arduino フレームワークなどをインストールします。
#安装espressif32 sdk和toolchain等
pio platform install espressif32
# 新建一个项目文件夹
mkdir ~/Documents/PlatformIO/Projects/testproj1
cd ~/Documents/PlatformIO/Projects/testproj1
# 初始化一个nodemcu32-s board项目
pio project init --board nodemcu-32s

ログは次のとおりです。

~/Documents/platformIO/Projects/testproj1> pio platform install espressif32
WARNING: This command is deprecated and will be removed in the next releases.
Please use `pio pkg install` instead.
Platform Manager: Installing espressif32
Unpacking  [####################################]  100%
Platform Manager: [email protected] has been installed!
Tool Manager: Installing espressif/toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch3
Downloading  [####################################]  100%
Unpacking  [####################################]  100%
Tool Manager: [email protected]+2021r2-patch3 has been installed!
Tool Manager: Installing platformio/tool-esptoolpy @ ~1.30300.0
Downloading  [####################################]  100%
Unpacking  [####################################]  100%
Tool Manager: [email protected] has been installed!

~/Documents/platformIO/Projects/testproj1> pio project init --board nodemcu-32s
Resolving nodemcu-32s dependencies...
Tool Manager: Installing platformio/framework-arduinoespressif32 @ ~3.20004.0
Downloading  [####################################]  100%
Unpacking  [####################################]  100%
Tool Manager: [email protected] has been installed!
Already up-to-date.
Project has been successfully updated!

これら 2 つのダウンロードが完了したら、vscode の platformIO IDE インターフェイスから新しい ESP32-Arduino プロジェクトを作成すると、非常に高速になります。
他の MCU からのサポートが必要な場合は、次の手順に従ってください。

3. サポートされているプラ​​ットフォームとボードを表示する

# 查看支持的所有board列表
pio boards
#查看某个ESP32相关的board列表
pio boards esp32

注: ターミナル プロンプトpio platformコマンドは非推奨になりますが、使用することをお勧めしますpio pkg installが、実際のpio pkg installインストールではプロンプトが表示されます。

おすすめ

転載: blog.csdn.net/toopoo/article/details/126690401