7
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

ESP-IDF4.0をEclipseで開発できるようにしてみた

Last updated at Posted at 2019-12-18

ESP-IDFが4.0からEclipseに正式対応するみたいなので試してみました

環境はWindows10です

以下のサイトに従って環境を構築していきます
idf-eclipse-plugin/README.md at master · espressif/idf-eclipse-plugin · GitHub
https://github.com/espressif/idf-eclipse-plugin/blob/master/README.md

トラブルが起きたときの備忘録として残そうと思ってこの記事を書いていたのですが最後のビルドの部分以外はほぼそのままです(´・ω・`)

ダウンロード

Java 8 and above : Download and install Java SE
https://www.oracle.com/technetwork/java/javase/downloads/index.html

Python 3.5 and above : Download and install Python
https://www.python.org/downloads/

Eclipse 2018-12 CDT and above : Download and install Eclipse CDT package
※Eclipse IDE for C/C++ Developers
https://www.eclipse.org/downloads/packages/

ESP-IDF 4.0 and above : Follow the download instructions from here
ページ一番下のesp-idf-v4.0.zip

Git : Get the latest git
https://git-scm.com/downloads

Use Windows'default console windowを選択した

それぞれをインストールして必要な場合PATHを設定します
自分の場合は
・JDKのbinへのパス
・GITのbinへのパス

ESP-IDFプラグインのインストール

Eclipseを起動して
HELP > Install New Software
Addをクリック

Nameに
Espressif IDF Plugins for Eclipse
を入力

Locationに
https://dl.espressif.com/dl/idf-eclipse-plugin/updates/latest/
を入力

image.png

Espressif IDFをチェックして全てをインストール

※「署名がついてないけど信用するか」みたいなことを聞かれるのでInstall Anywayをクリックする

ESP-IDF Toolのインストール

Help > Espressif IDF Tools Manager > Install Tools
image.png

Browse...をクリックしてESP-IDFのインストールディレクトリと
GITのexeの場所を選択
Pythonはインストールされていれば自動で表示されます

image.png

OKをクリックするとバックグラウンドでインストールが進行します

プロジェクトの作成

Window > Perspective > Open Perspective > Other...
をクリック

image.png

C/C++(default)を選択してクリックしてC/C++ Perspectiveを開きます
image.png

image.png

File > New > Espressif IDF Project をクリック
もし表示されていない場合は
Window > Perspective > Reset Perspective..
でPerspectiveをリセットすると表示されます

image.png

image.png

File > New > Espressif IDF Project をクリックしてNameにプロジェクト名を入力
Create a project using one of the templatesにチェックしてhello_worldを選択してfinishをクリック

image.png

Launchターゲットの設定

Launchバーの左から三番めのドロップダウンをクリックして
New Launch Targetを選択

image.png

ESP TargetをクリックしてNext >
Nameは適当につけてシリアルポートを選択
ESP32などを接続してからNew Launch Targetを選択すると自動で一覧に追加されます

image.png

HelloWorldプロジェクトが追加された直後はコンパイルエラーが表示されていますが構わずBuildボタンを押すと正常にコンパイルされてエラーも表示されなくなります

image.png

※公式チュートリアルから引用
image.png

v4.0Beta2からv4.0になった段階でビルドするとエラーがでるようになりました

Traceback (most recent call last):
  File "D:/uti/esp-idf-v4.0/tools/kconfig_new/confgen.py", line 571, in <module>
    main()
  File "D:/uti/esp-idf-v4.0/tools/kconfig_new/confgen.py", line 230, in main
    config = kconfiglib.Kconfig(args.kconfig)
  File "D:\uti\esp-idf-v4.0\tools\kconfig_new\kconfiglib.py", line 656, in __init__
    self.top_node)  # prev_node
  File "D:\uti\esp-idf-v4.0\tools\kconfig_new\kconfiglib.py", line 1636, in _parse_block
    node)         # prev_node
  File "D:\uti\esp-idf-v4.0\tools\kconfig_new\kconfiglib.py", line 1587, in _parse_block
    prev_node)
  File "D:\uti\esp-idf-v4.0\tools\kconfig_new\kconfiglib.py", line 1587, in _parse_block
    prev_node)
  File "D:\uti\esp-idf-v4.0\tools\kconfig_new\kconfiglib.py", line 1551, in _parse_block
    while self._has_tokens or self._next_line():
  File "D:\uti\esp-idf-v4.0\tools\kconfig_new\kconfiglib.py", line 1186, in _next_line
    self._line = self._file.readline()
UnicodeDecodeError: 'cp932' codec can't decode byte 0xef in position 3649: illegal multibyte sequence

これはWindows上でPythonを動かすとデフォルトでファイルをcp932(SHIFT-JIS)で読み込もうとするのでUTF-8の2バイト文字を読もうしてエラーが発生します

\esp-idf-v4.0\tools\kconfig_new\http://kconfiglib.pyの1128行目(def _open()の部分)にencodingを追加するとビルドが通るようになります

return open(filename)

return open(filename, encoding="utf-8")

シリアルコンソールを開く

ツールバーのOpen a Terminalをクリックしてから
image.png

Choose TerminalをSerial Terminalに変更、
以下は自分の環境に合わせて変更します

image.png

プロジェクトを書き込む

ESP32を接続した状態で▶ボタンを押すと転送されて実行されます!
image.png
image.png

sdkconfigの設定

sdkconfig.defaultsをコピーしてsdkconfigを作成
ダブルクリックするとsdkconfigエディタが立ち上がるはずがエラーが発生

image.png

何度かエディタを開いたり閉じたりしてるうちにStarting JSON Configuration Serverダイアログが開いてServerが起動します

image.png

image.png

何度かServer起動に失敗したので根気よくダブルクリックしましょう

7
4
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
7
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?