ubuntu安装ESP8266开发环境
2017-06-11 本文已影响113人
freelamb
环境
ubuntu16.04 LTS版本 64位操作系统
步骤1 安装需要的编译工具
# apt-get install git autoconf build-essential gperf bison flex texinfo libtool libncurses5-dev wget gawk libc6-dev-amd64 python-serial libexpat-dev
步骤2 创建必要的文件目录
# mkdir /opt/Espressif
# chown $username /opt/Espressif/
步骤3 编译交叉编译工具
$ cd /opt/Espressif
$ git clone -b lx106 git://github.com/jcmvbkbc/crosstool-NG.git
$ cd crosstool-NG
$ ./bootstrap && ./configure --prefix=`pwd` && make && make install
$ ./ct-ng xtensa-lx106-elf
$ ./ct-ng build
说明:pwd为要编译安装的路径,可以选者为当前,即:/opt/Espressif/crosstool-NG
步骤4 添加交叉工具的可执行文件到环境变量
PATH=$pwd/builds/xtensa-lx106-elf/bin:$PATH
步骤5 依据乐鑫官方的SDK进行后续开发
https://github.com/espressif/ESP8266_RTOS_SDK
备注
在执行如下编译构建命令
$ ./ct-ng build
时会出现如下的错误
[INFO ] Performing some trivial sanity checks
[INFO ] Build started 20170611.213027
[INFO ] Building environment variables
[INFO ] =================================================================
[INFO ] Retrieving needed toolchain components' tarballs
[INFO ] Retrieving needed toolchain components' tarballs: done in 0.05s (at 00:01)
[INFO ] =================================================================
[INFO ] Extracting and patching toolchain components
[ERROR] The 'binutils-2.24' sources were partially extracted.
[ERROR] Please remove first:
[ERROR] - the source dir for 'binutils-2.24', in '/opt/Espressif/crosstool-NG/.build/src'
[ERROR] - the file '/opt/Espressif/crosstool-NG/.build/src/.binutils-2.24.extracting'
[ERROR] I'll stop now to avoid any carnage...
[ERROR]
[ERROR] >>
[ERROR] >> Build failed in step 'Extracting and patching toolchain components'
[ERROR] >> called in step '(top-level)'
[ERROR] >>
[ERROR] >> Error happened in: CT_Abort[scripts/functions@331]
[ERROR] >> called from: CT_Extract[scripts/functions@932]
[ERROR] >> called from: do_binutils_extract[scripts/build/binutils/binutils.sh@31]
[ERROR] >> called from: main[scripts/crosstool-NG.sh@607]
[ERROR] >>
[ERROR] >> For more info on this error, look at the file: 'build.log'
[ERROR] >> There is a list of known issues, some with workarounds, in:
[ERROR] >> 'share/doc/crosstool-ng/ct-ng.1.20.0/B - Known issues.txt'
[ERROR]
[ERROR] (elapsed: 0:01.13)
[00:01] / ct-ng:148: recipe for target 'build' failed
这个是由于binutils-2.24解压失败导致的,在编译构建过程中会向网络拉去binutils-2.24压缩包,拉取失败导致后面的解压也是失败。
解决方法:
- 去binutils下载对应版本的binutils压缩包。
- 删除$pwd/.build/tarballs/binutils-2.24.tar.xz文件,并将刚刚下载的binutils-2.24.tar.gz复制过去
- 删除$pwd/.build/src的整个文件夹
- 重新执行./ct-ng build进行编译构建
- 出现下面的构建后,即为编译构建完成
[INFO ] Performing some trivial sanity checks
[INFO ] Build started 20170611.213150
[INFO ] Building environment variables
[INFO ] =================================================================
[INFO ] Retrieving needed toolchain components' tarballs
[INFO ] Retrieving needed toolchain components' tarballs: done in 0.05s (at 00:02)
[INFO ] =================================================================
[INFO ] Extracting and patching toolchain components
[INFO ] Extracting and patching toolchain components: done in 34.62s (at 00:36)
[INFO ] =================================================================
[INFO ] Installing GMP for host
[INFO ] Installing GMP for host: done in 36.25s (at 01:13)
[INFO ] =================================================================
[INFO ] Installing MPFR for host
[INFO ] Installing MPFR for host: done in 18.04s (at 01:31)
[INFO ] =================================================================
[INFO ] Installing ISL for host
[INFO ] Installing ISL for host: done in 30.69s (at 02:01)
[INFO ] =================================================================
[INFO ] Installing CLooG for host
[INFO ] Installing CLooG for host: done in 7.12s (at 02:08)
[INFO ] =================================================================
[INFO ] Installing MPC for host
[INFO ] Installing MPC for host: done in 7.00s (at 02:15)
[INFO ] =================================================================
[INFO ] Installing binutils for host
[INFO ] Installing binutils for host: done in 58.79s (at 03:14)
[INFO ] =================================================================
[INFO ] Installing final compiler
[INFO ] Installing final compiler: done in 201.61s (at 06:36)
[INFO ] =================================================================
[INFO ] Installing cross-gdb
[INFO ] Installing cross-gdb: done in 93.62s (at 08:10)
[INFO ] =================================================================
[INFO ] Cleaning-up the toolchain's directory
[INFO ] Stripping all toolchain executables
[INFO ] Cleaning-up the toolchain's directory: done in 0.67s (at 08:10)
[INFO ] Build completed at 20170611.213959
[INFO ] (elapsed: 8:09.61)
[INFO ] Finishing installation (may take a few seconds)...
参考
https://github.com/esp8266/esp8266-wiki/wiki/Toolchain
https://github.com/esp8266/esp8266-wiki/wiki/Building
http://www.crifan.com/crosstool_ng_cygwin_the_binutils_2_20_1a_sources_were_partially_extracted_please_remove_first/
https://www.htlinux.com/install-esp8266-sdk-toolchain-on-linux-ubuntu-14-10-desktop/