2019-06-24 21:26:53 -04:00
|
|
|
|
******************************************
|
2018-08-15 22:31:04 -04:00
|
|
|
|
从零开始设置 Linux 环境下的工具链
|
2019-06-24 21:26:53 -04:00
|
|
|
|
******************************************
|
|
|
|
|
|
2019-01-27 13:01:34 -05:00
|
|
|
|
:link_to_translation:`en:[English]`
|
2018-08-15 22:31:04 -04:00
|
|
|
|
|
2019-10-10 04:52:07 -04:00
|
|
|
|
除了从乐鑫官网直接下载已编译好的二进制工具链外,您还可以按照本文介绍,从头开始设置自己的工具链。如需快速使用已编译好的二进制工具链,可回到 :doc:`linux-setup` 章节。
|
2018-12-12 12:38:23 -05:00
|
|
|
|
|
2019-06-24 21:26:53 -04:00
|
|
|
|
安装准备
|
|
|
|
|
=====================
|
2018-08-15 22:31:04 -04:00
|
|
|
|
|
2019-06-24 21:26:53 -04:00
|
|
|
|
编译 ESP-IDF 需要以下软件包:
|
2018-08-15 22:31:04 -04:00
|
|
|
|
|
2019-06-24 21:26:53 -04:00
|
|
|
|
- CentOS 7::
|
2018-08-15 22:31:04 -04:00
|
|
|
|
|
2020-11-30 07:11:36 -05:00
|
|
|
|
sudo yum -y update && sudo yum install git wget ncurses-devel flex bison gperf python3 python3-pip cmake ninja-build ccache
|
|
|
|
|
|
|
|
|
|
目前仍然支持 CentOS 7,但为了更好的用户体验,建议使用 CentOS 8。
|
2018-08-15 22:31:04 -04:00
|
|
|
|
|
|
|
|
|
- Ubuntu 和 Debian::
|
|
|
|
|
|
2020-11-30 07:11:36 -05:00
|
|
|
|
sudo apt-get install git wget libncurses-dev flex bison gperf python3 python3-pip python3-setuptools python3-serial python3-cryptography python3-future python3-pyparsing python3-pyelftools cmake ninja-build ccache libffi-dev libssl-dev dfu-util
|
2018-08-15 22:31:04 -04:00
|
|
|
|
|
|
|
|
|
- Arch::
|
|
|
|
|
|
2020-11-30 07:11:36 -05:00
|
|
|
|
sudo pacman -Sy --needed gcc git make ncurses flex bison gperf python-pyserial python-cryptography python-future python-pyparsing python-pyelftools cmake ninja ccache dfu-util
|
|
|
|
|
|
|
|
|
|
.. 注解::
|
2018-08-15 22:31:04 -04:00
|
|
|
|
|
2020-11-30 07:11:36 -05:00
|
|
|
|
使用 ESP-IDF 需要 CMake 3.5 或以上版本。较早的 Linux 发行版可能需要升级自身的软件源仓库,或开启 backports 套件库,或安装 "cmake3" 软件包(不是安装 "cmake")。
|
2018-08-15 22:31:04 -04:00
|
|
|
|
|
|
|
|
|
从源代码编译工具链
|
2019-06-24 21:26:53 -04:00
|
|
|
|
=================================
|
2018-08-15 22:31:04 -04:00
|
|
|
|
|
2019-10-10 04:52:07 -04:00
|
|
|
|
安装依赖项:
|
2018-08-15 22:31:04 -04:00
|
|
|
|
|
2019-10-10 04:52:07 -04:00
|
|
|
|
- CentOS 7::
|
2018-08-15 22:31:04 -04:00
|
|
|
|
|
2020-11-30 07:11:36 -05:00
|
|
|
|
sudo yum install gawk gperf grep gettext ncurses-devel python3 python3-devel automake bison flex texinfo help2man libtool make
|
2018-08-15 22:31:04 -04:00
|
|
|
|
|
2019-10-10 04:52:07 -04:00
|
|
|
|
- Ubuntu pre-16.04::
|
2018-08-15 22:31:04 -04:00
|
|
|
|
|
2019-10-10 04:52:07 -04:00
|
|
|
|
sudo apt-get install gawk gperf grep gettext libncurses-dev python python-dev automake bison flex texinfo help2man libtool make
|
2018-08-15 22:31:04 -04:00
|
|
|
|
|
2019-10-10 04:52:07 -04:00
|
|
|
|
- Ubuntu 16.04 或以上 ::
|
2018-08-15 22:31:04 -04:00
|
|
|
|
|
2019-10-10 04:52:07 -04:00
|
|
|
|
sudo apt-get install gawk gperf grep gettext python python-dev automake bison flex texinfo help2man libtool libtool-bin make
|
2018-08-15 22:31:04 -04:00
|
|
|
|
|
2019-10-10 04:52:07 -04:00
|
|
|
|
- Debian 9::
|
2018-08-15 22:31:04 -04:00
|
|
|
|
|
2019-10-10 04:52:07 -04:00
|
|
|
|
sudo apt-get install gawk gperf grep gettext libncurses-dev python python-dev automake bison flex texinfo help2man libtool libtool-bin make
|
2018-08-15 22:31:04 -04:00
|
|
|
|
|
2019-10-10 04:52:07 -04:00
|
|
|
|
- Arch::
|
2018-08-15 22:31:04 -04:00
|
|
|
|
|
2020-11-30 07:11:36 -05:00
|
|
|
|
sudo pacman -Sy --needed python-pip
|
2018-08-15 22:31:04 -04:00
|
|
|
|
|
2019-06-24 21:26:53 -04:00
|
|
|
|
创建工作目录,并进入该目录::
|
2018-10-22 06:26:44 -04:00
|
|
|
|
|
2019-10-10 04:52:07 -04:00
|
|
|
|
mkdir -p ~/esp
|
|
|
|
|
cd ~/esp
|
2018-10-22 06:26:44 -04:00
|
|
|
|
|
2019-06-24 21:26:53 -04:00
|
|
|
|
下载并编译 ``crosstool-NG`` :
|
2018-08-15 22:31:04 -04:00
|
|
|
|
|
2018-08-29 09:30:03 -04:00
|
|
|
|
.. include:: /_build/inc/scratch-build-code.inc
|
2018-08-15 22:31:04 -04:00
|
|
|
|
|
|
|
|
|
编译工具链::
|
|
|
|
|
|
|
|
|
|
./ct-ng xtensa-esp32-elf
|
|
|
|
|
./ct-ng build
|
|
|
|
|
chmod -R u+w builds/xtensa-esp32-elf
|
|
|
|
|
|
2019-10-10 04:52:07 -04:00
|
|
|
|
编译得到的工具链会被保存到 ``~/esp/crosstool-NG/builds/xtensa-esp32-elf``。请按照 :ref:`标准设置指南 <setup-linux-toolchain-add-it-to-path-legacy>` 的介绍,将工具链添加到 ``PATH``。
|
2019-06-24 21:26:53 -04:00
|
|
|
|
|
2018-08-15 22:31:04 -04:00
|
|
|
|
|
2020-11-30 07:11:36 -05:00
|
|
|
|
|
|
|
|
|
停用 Python 2
|
|
|
|
|
====================
|
|
|
|
|
|
|
|
|
|
Python 2 已经 `结束生命周期 <https://www.python.org/doc/sunset-python-2/>`_,ESP-IDF 很快将不再支持 Python 2。请安装 Python 3.6 或以上版本。可参考上面列出的目前主流 Linux 发行版的安装说明。
|
|
|
|
|
|
|
|
|
|
|
2019-06-24 21:26:53 -04:00
|
|
|
|
后续步骤
|
|
|
|
|
==========
|
2018-08-15 22:31:04 -04:00
|
|
|
|
|
2020-11-30 07:11:36 -05:00
|
|
|
|
请前往 :ref:`get-started-get-esp-idf` 章节继续设置开发环境。
|