2019-10-10 04:52:07 -04:00
|
|
|
|
***********************************************
|
2020-11-30 07:11:36 -05:00
|
|
|
|
从零开始设置 macOS 环境下的工具链
|
2019-10-10 04:52:07 -04:00
|
|
|
|
***********************************************
|
2018-08-15 22:31:04 -04:00
|
|
|
|
|
2019-10-10 04:52:07 -04:00
|
|
|
|
:link_to_translation:`en:[English]`
|
2018-10-22 06:26:44 -04:00
|
|
|
|
|
2019-06-24 21:26:53 -04:00
|
|
|
|
软件包管理器
|
2019-10-10 04:52:07 -04:00
|
|
|
|
===============
|
2019-06-24 21:26:53 -04:00
|
|
|
|
|
2020-11-30 04:58:27 -05:00
|
|
|
|
从零开始设置工具链,您需要安装 MacPorts_ 或 Homebrew_ 软件包管理器。或者,您也可以直接下载 :doc:`预编译的工具链 <macos-setup>`。
|
2019-06-24 21:26:53 -04:00
|
|
|
|
|
2020-11-30 04:58:27 -05:00
|
|
|
|
MacPorts 需要完整的 XCode 软件,而 Homebrew 只需要安装 XCode 命令行工具即可。
|
2019-06-24 21:26:53 -04:00
|
|
|
|
|
2020-11-30 04:58:27 -05:00
|
|
|
|
.. _Homebrew: https://brew.sh/
|
2019-10-10 04:52:07 -04:00
|
|
|
|
.. _MacPorts: https://www.macports.org/install.php
|
2019-06-24 21:26:53 -04:00
|
|
|
|
|
2019-10-10 04:52:07 -04:00
|
|
|
|
请参考 :ref:`工具链自定义设置 <get-started-customized-setup>` 章节,查看可能需要从头开始设置工具链的情况。
|
2019-06-24 21:26:53 -04:00
|
|
|
|
|
2019-10-10 04:52:07 -04:00
|
|
|
|
安装准备
|
|
|
|
|
=====================
|
2018-08-15 22:31:04 -04:00
|
|
|
|
|
|
|
|
|
- 安装 pip::
|
|
|
|
|
|
2019-10-10 04:52:07 -04:00
|
|
|
|
sudo easy_install pip
|
2018-08-15 22:31:04 -04:00
|
|
|
|
|
2019-06-24 21:26:53 -04:00
|
|
|
|
- 安装 pyserial::
|
2018-08-15 22:31:04 -04:00
|
|
|
|
|
2019-10-10 04:52:07 -04:00
|
|
|
|
pip install --user pyserial
|
2018-08-15 22:31:04 -04:00
|
|
|
|
|
2019-06-24 21:26:53 -04:00
|
|
|
|
- 安装 CMake 和 Ninja 编译工具:
|
2018-08-15 22:31:04 -04:00
|
|
|
|
|
2020-11-30 04:58:27 -05:00
|
|
|
|
- 若有 Homebrew,您可以运行::
|
2018-08-15 22:31:04 -04:00
|
|
|
|
|
2020-04-06 10:41:44 -04:00
|
|
|
|
brew install cmake ninja dfu-util
|
2019-06-24 21:26:53 -04:00
|
|
|
|
|
2019-10-10 04:52:07 -04:00
|
|
|
|
- 若有 MacPorts,您可以运行::
|
2019-06-24 21:26:53 -04:00
|
|
|
|
|
2020-04-06 10:41:44 -04:00
|
|
|
|
sudo port install cmake ninja dfu-util
|
2019-06-24 21:26:53 -04:00
|
|
|
|
|
|
|
|
|
从源代码编译工具链
|
2019-10-10 04:52:07 -04:00
|
|
|
|
=================================
|
2019-06-24 21:26:53 -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
|
|
|
|
- 对于 MacPorts::
|
2018-08-15 22:31:04 -04:00
|
|
|
|
|
2019-10-10 04:52:07 -04:00
|
|
|
|
sudo port install gsed gawk binutils gperf grep gettext wget libtool autoconf automake make
|
2018-08-15 22:31:04 -04:00
|
|
|
|
|
2020-11-30 04:58:27 -05:00
|
|
|
|
- 对于 Homebrew::
|
2018-08-15 22:31:04 -04:00
|
|
|
|
|
2019-10-10 04:52:07 -04:00
|
|
|
|
brew install gnu-sed gawk binutils gperftools gettext wget help2man libtool autoconf automake make
|
2018-08-15 22:31:04 -04:00
|
|
|
|
|
2019-06-24 21:26:53 -04:00
|
|
|
|
创建一个文件系统镜像(区分大小写)::
|
2018-08-15 22:31:04 -04:00
|
|
|
|
|
2020-11-30 04:58:27 -05:00
|
|
|
|
hdiutil create ~/esp/crosstool.dmg -volname "ctng" -size 10g -fs "Case-sensitive HFS+"
|
2018-08-15 22:31:04 -04:00
|
|
|
|
|
|
|
|
|
挂载::
|
|
|
|
|
|
2019-10-10 04:52:07 -04:00
|
|
|
|
hdiutil mount ~/esp/crosstool.dmg
|
2018-08-15 22:31:04 -04:00
|
|
|
|
|
2019-10-10 04:52:07 -04:00
|
|
|
|
创建指向您工作目录的符号链接::
|
2018-08-15 22:31:04 -04:00
|
|
|
|
|
2020-11-30 04:58:27 -05:00
|
|
|
|
mkdir -p ~/esp
|
|
|
|
|
ln -s /Volumes/ctng ~/esp/ctng-volume
|
2018-10-22 06:26:44 -04:00
|
|
|
|
|
2020-11-30 04:58:27 -05:00
|
|
|
|
前往新创建的目录::
|
2018-10-22 06:26:44 -04:00
|
|
|
|
|
2019-10-10 04:52:07 -04:00
|
|
|
|
cd ~/esp/ctng-volume
|
2018-08-15 22:31:04 -04:00
|
|
|
|
|
2020-11-30 04:58:27 -05:00
|
|
|
|
下载并编译 ``crosstool-NG``:
|
2018-08-15 22:31:04 -04:00
|
|
|
|
|
2019-11-12 22:46:16 -05:00
|
|
|
|
.. include-build-file:: inc/scratch-build-code.inc
|
2018-08-15 22:31:04 -04:00
|
|
|
|
|
2019-10-10 04:52:07 -04:00
|
|
|
|
编译工具链::
|
2018-08-15 22:31:04 -04:00
|
|
|
|
|
2021-01-26 21:12:58 -05:00
|
|
|
|
./ct-ng {IDF_TARGET_TOOLCHAIN_PREFIX}
|
2019-10-10 04:52:07 -04:00
|
|
|
|
./ct-ng build
|
2021-01-26 21:12:58 -05:00
|
|
|
|
chmod -R u+w builds/{IDF_TARGET_TOOLCHAIN_PREFIX}
|
2018-08-15 22:31:04 -04:00
|
|
|
|
|
2021-01-26 21:12:58 -05:00
|
|
|
|
编译得到的工具链会被保存到 ``~/esp/ctng-volume/crosstool-NG/builds/{IDF_TARGET_TOOLCHAIN_PREFIX}``。使用工具链前,请将 ``~/esp/ctng-volume/crosstool-NG/builds/{IDF_TARGET_TOOLCHAIN_PREFIX}/bin`` 添加至 ``PATH`` 环境变量。
|
2018-08-15 22:31:04 -04:00
|
|
|
|
|
|
|
|
|
|
2019-06-24 21:26:53 -04:00
|
|
|
|
后续步骤
|
2019-10-10 04:52:07 -04:00
|
|
|
|
==========
|
|
|
|
|
|
2020-11-30 04:58:27 -05:00
|
|
|
|
请前往 :ref:`get-started-get-esp-idf` 章节继续设置开发环境。
|
2018-08-15 22:31:04 -04:00
|
|
|
|
|