1. Homebrew
1.1 Homebrew介绍:
Homebrew是一款Mac OS平台下的软件包管理工具,拥有安装、卸载、更新、查看、搜索等很多实用的功能。简单的一条指令,就可以实现包管理,而不用你关心各种依赖和文件路径的情况,十分方便快捷。
1.2 安装Homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
1.3 安装依赖包
brew install binutils coreutils automake autoconf wget gawk libtool help2man gperf gnu-sed grep
2. 下载ESP8266 编译工具
sudo mkdir -p /opt/espressif
sudo chmod 777 /opt/espressif
cd /opt/espressif
wget https://github.com/esp8266/Arduino/releases/download/2.3.0/osx-xtensa-lx106-elf-gb404fb9-2.tar.gz
tar zxvf osx-xtensa-lx106-elf-gb404fb9-2.tar.gz
下载ESP8266标准Libc及对应的头文件:
cd /opt/espressif/xtensa-lx106-elf/xtensa-lx106-elf
wget -O lib/libc.a https://github.com/esp8266/esp8266-wiki/raw/master/libs/libc.a
wget -O lib/libhal.a https://github.com/esp8266/esp8266-wiki/raw/master/libs/libhal.a
wget -O include.tgz https://github.com/esp8266/esp8266-wiki/raw/master/include.tgz
tar zxvf include.tgz
3. 设置bash的PATH
默认使用bash,编辑
sudo vi ~/.bash_profile
在文件中添加如下内容:
export PATH=/opt/espressif/xtensa-lx106-elf/bin:$PATH
5. 环境测试
xtensa-lx106-elf-gcc -v
如显示以下内容,则说明安装成功
Using built-in specs.
COLLECT_GCC=xtensa-lx106-elf-gcc
COLLECT_LTO_WRAPPER=/opt/espressif/xtensa-lx106-elf/bin/../libexec/gcc/xtensa-lx106-elf/4.8.2/lto-wrapper
Target: xtensa-lx106-elf
Configured with: /Users/igrokhotkov/e/ESPTools/crosstool-NG/.build/src/gcc-4.8.2/configure --build=x86_64-build_apple-darwin14.1.0 --host=x86_64-build_apple-darwin14.1.0 --target=xtensa-lx106-elf --prefix=/Users/igrokhotkov/e/ESPTools/crosstool-NG/builds/xtensa-lx106-elf --with-local-prefix=/Users/igrokhotkov/e/ESPTools/crosstool-NG/builds/xtensa-lx106-elf/xtensa-lx106-elf/sysroot --disable-libmudflap --with-sysroot=/Users/igrokhotkov/e/ESPTools/crosstool-NG/builds/xtensa-lx106-elf/xtensa-lx106-elf/sysroot --with-newlib --enable-threads=no --disable-shared --with-pkgversion='crosstool-NG 1.20.0' --disable-__cxa_atexit --with-gmp=/Users/igrokhotkov/e/ESPTools/crosstool-NG/.build/xtensa-lx106-elf/buildtools --with-mpfr=/Users/igrokhotkov/e/ESPTools/crosstool-NG/.build/xtensa-lx106-elf/buildtools --with-mpc=/Users/igrokhotkov/e/ESPTools/crosstool-NG/.build/xtensa-lx106-elf/buildtools --with-isl=/Users/igrokhotkov/e/ESPTools/crosstool-NG/.build/xtensa-lx106-elf/buildtools --with-cloog=/Users/igrokhotkov/e/ESPTools/crosstool-NG/.build/xtensa-lx106-elf/buildtools --with-libelf=/Users/igrokhotkov/e/ESPTools/crosstool-NG/.build/xtensa-lx106-elf/buildtools --enable-lto --enable-target-optspace --disable-libgomp --disable-libmudflap --disable-nls --disable-multilib --enable-languages=c,c++
Thread model: single
gcc version 4.8.2 (crosstool-NG 1.20.0)