ESP32를 OSX에서 개발하기위한 설정

어쩌면 Anaconda 들어 있었기 때문이라고 생각합니다만, 막혔으므로 써 둡니다.

기본적으로는 ESP-IDF Programming Guide 을 참조하고 있습니다만, 어디선가 PATH가 맞지 않거나, Eclipse의 화면 표시가 바뀌거나 하고 있기 때문에.

Python 2 (3과 함께) 설치



실은, 한 번 ESP-IDF의 지시에 따라 진행해 가고, hello_world를 make 하려고 하면, 아래와 같은 에러가 나와 버렸습니다.
Kosuke-no-MacBook:hello_world kocko$ make
(中略)
TypeError: unorderable types: PartitionDefinition() < PartitionDefinition()
make: *** [/Users/kocko/esp/esp-idf/examples/get-started/hello_world/build/partitions_singleapp.bin] Error 1

구구했는데, github에서 이슈 를 발견. 나는 anaconda에서 Python3을 사용하고 있지만 분명히 Python3에는 지원되지 않는 것 같습니다.

I get this error if I run the gen_esp32part.py tool in Python 3. At the moment, esp-idf's Python-based tools only support Python 2 (Python 2+3 support is coming but it's not available now.)

그렇다면 더 구그는 osx - How to install 2 Anacondas (Python 2.7 and 3.4) on Mac OS 10.9 - Stack Overflow을 참고하여 anaconda3와 2를 공존하여 설치합니다.
그렇다고 해도, 순서는 단 2행.
> conda create -n python2 python=2.7 anaconda
> source activate python2

두 번째 줄의 source 명령은 콘솔을 열 때마다 두드려야하기 때문에주의하십시오. 이런 식으로 콘솔에 입력하면 머리에 (Python2)가 붙게되므로 편리합니다.
Last login: Fri Apr 28 20:34:51 on ttys002
Kosuke-no-MacBook:~ kocko$ source activate python2
(python2) Kosuke-no-MacBook:~ kocko$ which python
/Users/kocko/anaconda3/envs/python2/bin/python
(python2) Kosuke-no-MacBook:~ kocko$ 

ESP-IDF 설치



가이드에 따라 담담하게. 아나콘다의 파이썬은 자신의 홈 디렉토리에 있으므로 sudo가 필요하지 않은 것 같습니다.
(python2)$ easy_install pip
(python2)$ pip install pyserial
(python2)$ mkdir -p ~/esp
(python2)$ cd ~/esp
(python2)$ tar -xzf ~/Downloads/xtensa-esp32-elf-osx-1.22.0-61-gab8375a-5.2.0.tar.gz
(python2)$ export PATH=$PATH:$HOME/esp/xtensa-esp32-elf/bin
(python2)$ export IDF_PATH=/Users/<ユーザ名>/esp/esp-idf
(python2)$ git clone --recursive https://github.com/espressif/esp-idf.git

마지막 export 2개는, 필요에 따라서 .bash_profile인가 무언가에 추기해 둡니다.

다음으로 hello world 샘플을 움직여 보겠습니다.
(python2)$ cd esp-idf/examples/get-started/hello_world
(python2)$ make menuconfig

그러면 이런 화면이 나옵니다.


화살표의 위아래에서 위의 메뉴가 움직이고 화살표의 좌우로 아래의 메뉴가 움직입니다.
↓↓↓에서 Serial flasher config를 선택하고 Enter를 누릅니다.

다시 Enter를 눌러 직렬 포트를 설정합니다.

나와 같이, 아키즈키의 ESP32-DevKitC ESP-WROOM-32 개발 보드 를 사신 분이라면, /dev/cu.SLAB_USBtoUART 로 괜찮다고 생각합니다.
Enter에서 빠져 나가 →에서를 선택하여 Enter로, 한 번 더 →를 선택하여 Enter를 눌러 콘솔 화면으로 돌아갑니다.
make && make flash

이것으로, 잘 작동할 것입니다만, 왠지 Arduino의 시리얼 모니터로 아무것도 보이지 않기 때문에, 일단 여기까지 스튜디오에 돌려줍니다. 현장에서는 이상입니다.

좋은 웹페이지 즐겨찾기