つまりなにしたの?
ESP-WROOM-32の開発環境を構築してHello worldのコードを実行してその結果を標準出力から確認した。
用意したもの
- MacBook Pro (13-inch, 2016, Four Thunderbolt 3 Ports) MacOS 10.12.4
- ESP-WROOM-32 開発ボード
- USBマイクロBケーブル
- (USB Type-Cから普通のUSBに変換するアダプタ)
環境の用意
公式セットアップドキュメント
Get Started — ESP-IDF Programming Guide audio-weekly-170503-47-g55fb4c5 documentation
ほぼこれに従っている。
ツールチェインをインストールする
# Pythonを準備 pyenv virtualenv 2.7.13 esp #ココは任意 mkdir esp cd esp pyenv local esp #ココも任意 pip install pyserial # ツールチェインを準備 wget https://dl.espressif.com/dl/xtensa-esp32-elf-osx-1.22.0-61-gab8375a-5.2.0.tar.gz cp ~/.bash_profile ~/.bash_profile.backup echo export 'PATH=$PATH:/Your/DevEnv/Path/esp/xtensa-esp32-elf/bin' >> ~/.bash_profile source ~/.bash_profile
ESP-IDFのインストールする
http://esp-idf.readthedocs.io/en/latest/get-started/index.html#get-started-get-esp-idf
対象はこれ
github.com
git clone --recursive https://github.com/espressif/esp-idf.git cd esp-idf echo export 'IDF_PATH=/Your/DevEnv/Path/esp/esp-idf' >> ~/.bash_profile source ~/.bash_profile
ESP-WROOM-32をPCにつなぐまで
www.silabs.com
からMacOSのドライバを選んでダウンロードしてインストール
インストールが完了したらESP-WROOM-32をUSBマイクロBケーブルで繋ぐ
ls -l /dev/tty.*
で/dev/tty.SLAB_USBtoUARTが
出てきて認識されていることを確認する。
初めてのプロジェクトを準備する
http://esp-idf.readthedocs.io/en/latest/get-started/index.html#start-a-project
cd /Your/DevEnv/Path/esp cp -r $IDF_PATH/examples/get-started/hello_world . cd hello_world make menuconfig
ここでメニューが開く
Serial flasher configを選択
Default Serial portとFlash sizeをこの状態にしてExit
Saveを選択してExit
ビルドして書き込む
make flash .... esptool.py v2.0-beta3 Flashing binaries to serial port /dev/tty.SLAB_USBtoUART (app at offset 0x10000)... esptool.py v2.0-beta3 Connecting........_____.. Uploading stub... Running stub... Stub running... Configuring flash size... Auto-detected Flash size: 4MB Flash params set to 0x0220 Compressed 15824 bytes to 9227... Wrote 15824 bytes (9227 compressed) at 0x00001000 in 0.8 seconds (effective 155.0 kbit/s)... Hash of data verified. Compressed 355088 bytes to 167196... Wrote 355088 bytes (167196 compressed) at 0x00010000 in 15.0 seconds (effective 189.5 kbit/s)... Hash of data verified. Compressed 3072 bytes to 82... Wrote 3072 bytes (82 compressed) at 0x00008000 in 0.0 seconds (effective 2130.6 kbit/s)... Hash of data verified. Leaving... Hard resetting...
ビルドログのあとに書き込みのログが表示される。
Hash of data verifiedが出たら正しく書き込まれたことが確認できている。
実行状態を見る
make monitor
※Ctrl+]で止めることができる。
I (0) cpu_start: App cpu up. I (972) heap_alloc_caps: Initializing. RAM available for dynamic allocation: I (994) heap_alloc_caps: At 3FFAE2A0 len 00001D60 (7 KiB): DRAM I (1014) heap_alloc_caps: At 3FFB6418 len 00029BE8 (166 KiB): DRAM I (1036) heap_alloc_caps: At 3FFE0440 len 00003BC0 (14 KiB): D/IRAM I (1057) heap_alloc_caps: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM I (1079) heap_alloc_caps: At 4009310C len 0000CEF4 (51 KiB): IRAM I (1099) cpu_start: Pro cpu start user code I (1157) cpu_start: Starting scheduler on PRO CPU. Hello world!
こんなんが出てきて、10秒待ってまた実行しようとする。
おまけ: ビルドして書き込んで実行状態を見る
make flash monitor
一発でビルドして書き込んで実行状態を見られる
次回
センサを付けて、そのセンサデータをウェブサービスにPOSTする。