index.rst 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752
  1. ***********
  2. Get Started
  3. ***********
  4. {IDF_TARGET_CORE_NUM:default="2", esp32="2", esp32s2="1", esp32c3="1"}
  5. {IDF_TARGET_FEATURES:default="WiFi/BT/BLE, silicon revision 1, 2MB external flash", esp32="WiFi/BT/BLE, silicon revision 1, 2MB external flash", esp32s2="WiFi, silicon revision 0, 2MB external flash", esp32c3="WiFi/BLE, silicon revision 0, 2MB external flash"}
  6. {IDF_TARGET_HEAP_SIZE:default="298968", esp32="298968", esp32s2="253900", esp32c3="337332"}
  7. :link_to_translation:`zh_CN:[中文]`
  8. .. Please keep README.md in sync with these instructions.
  9. This document is intended to help you set up the software development environment for the hardware based on the {IDF_TARGET_NAME} chip by Espressif.
  10. After that, a simple example will show you how to use ESP-IDF (Espressif IoT Development Framework) for menu configuration, then for building and flashing firmware onto an {IDF_TARGET_NAME} board.
  11. .. include-build-file:: inc/version-note.inc
  12. Introduction
  13. ============
  14. {IDF_TARGET_NAME} is a system on a chip that integrates the following features:
  15. .. only:: esp32
  16. * Wi-Fi (2.4 GHz band)
  17. * Bluetooth
  18. * Dual high performance Xtensa® 32-bit LX6 CPU cores
  19. * Ultra Low Power co-processor
  20. * Multiple peripherals
  21. .. only:: esp32s2
  22. * Wi-Fi (2.4 GHz band)
  23. * High performance single core Xtensa® 32-bit LX7 CPU
  24. * Ultra Low Power co-processor running either RISC-V or FSM core
  25. * Multiple peripherals
  26. * Built-in security hardware
  27. * USB OTG interface
  28. .. only:: esp32c3
  29. * Wi-Fi (2.4 GHz band)
  30. * Bluetooth Low Energy
  31. * High performance 32-bit RISC-V single-core processor
  32. * Multiple peripherals
  33. * Built-in security hardware
  34. Powered by 40 nm technology, {IDF_TARGET_NAME} provides a robust, highly integrated platform, which helps meet the continuous demands for efficient power usage, compact design, security, high performance, and reliability.
  35. Espressif provides basic hardware and software resources to help application developers realize their ideas using the {IDF_TARGET_NAME} series hardware. The software development framework by Espressif is intended for development of Internet-of-Things (IoT) applications with Wi-Fi, Bluetooth, power management and several other system features.
  36. What You Need
  37. =============
  38. Hardware:
  39. * An **{IDF_TARGET_NAME}** board
  40. * **USB cable** - USB A / micro USB B
  41. * **Computer** running Windows, Linux, or macOS
  42. Software:
  43. You have a choice to either download and install the following software manually
  44. * **Toolchain** to compile code for {IDF_TARGET_NAME}
  45. * **Build tools** - CMake and Ninja to build a full **Application** for {IDF_TARGET_NAME}
  46. * **ESP-IDF** that essentially contains API (software libraries and source code) for {IDF_TARGET_NAME} and scripts to operate the **Toolchain**
  47. **or** get through the onboarding process using the following official plugins for integrated development environments (IDE) described in separate documents
  48. * `Eclipse Plugin <https://github.com/espressif/idf-eclipse-plugin>`_ (`installation link <https://github.com/espressif/idf-eclipse-plugin#installing-idf-plugin-using-update-site-url>`_)
  49. * `VS Code Extension <https://github.com/espressif/vscode-esp-idf-extension>`_ (`onboarding <https://github.com/espressif/vscode-esp-idf-extension/blob/master/docs/ONBOARDING.md>`_)
  50. .. figure:: ../../_static/what-you-need.png
  51. :align: center
  52. :alt: Development of applications for {IDF_TARGET_NAME}
  53. :figclass: align-center
  54. Development of applications for {IDF_TARGET_NAME}
  55. Development Board Overviews
  56. ===========================
  57. If you have one of {IDF_TARGET_NAME} development boards listed below, you can click on the link to learn more about its hardware.
  58. .. only:: esp32
  59. .. toctree::
  60. :maxdepth: 1
  61. ESP32-DevKitC <../hw-reference/esp32/get-started-devkitc>
  62. ESP-WROVER-KIT <../hw-reference/esp32/get-started-wrover-kit>
  63. ESP32-PICO-KIT <../hw-reference/esp32/get-started-pico-kit>
  64. ESP32-Ethernet-Kit <../hw-reference/esp32/get-started-ethernet-kit>
  65. ESP32-DevKit-S(-R) <../hw-reference/esp32/user-guide-devkits-r-v1.1>
  66. ESP32-PICO-KIT-1 <../hw-reference/esp32/get-started-pico-kit-1>
  67. ESP32-PICO-DevKitM-2 <../hw-reference/esp32/get-started-pico-devkitm-2>
  68. ESP32-DevKitM-1 <../hw-reference/esp32/user-guide-devkitm-1>
  69. .. only:: esp32s2
  70. .. toctree::
  71. :maxdepth: 1
  72. ESP32-S2-Saola-1 <../hw-reference/esp32s2/user-guide-saola-1-v1.2>
  73. ESP32-S2-DevKitM-1(U) <../hw-reference/esp32s2/user-guide-devkitm-1-v1>
  74. ESP32-S2-Kaluga-Kit <../hw-reference/esp32s2/user-guide-esp32-s2-kaluga-1-kit>
  75. .. only:: esp32c3
  76. .. toctree::
  77. :maxdepth: 1
  78. ESP32-C3-DevKitM-1 <../hw-reference/esp32c3/user-guide-devkitm-1>
  79. ESP32-C3-DevKitC-02 <../hw-reference/esp32c3/user-guide-devkitc-02>
  80. .. _get-started-step-by-step:
  81. Installation Step by Step
  82. =========================
  83. This is a detailed roadmap to walk you through the installation process.
  84. Setting up Development Environment
  85. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  86. * :ref:`get-started-get-prerequisites` for :doc:`Windows <windows-setup>`, :doc:`Linux <linux-setup>`, or :doc:`macOS <macos-setup>`
  87. * :ref:`get-started-get-esp-idf`
  88. * :ref:`get-started-set-up-tools`
  89. * :ref:`get-started-set-up-env`
  90. Creating Your First Project
  91. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  92. * :ref:`get-started-start-project`
  93. * :ref:`get-started-connect`
  94. * :ref:`get-started-configure`
  95. * :ref:`get-started-build`
  96. * :ref:`get-started-flash`
  97. * :ref:`get-started-build-monitor`
  98. .. _get-started-get-prerequisites:
  99. Step 1. Install prerequisites
  100. =============================
  101. Some tools need to be installed on the computer before proceeding to the next steps. Follow the links below for the instructions for your OS:
  102. .. toctree::
  103. :hidden:
  104. Windows <windows-setup>
  105. Linux <linux-setup>
  106. macOS <macos-setup>
  107. +-------------------+-------------------+-------------------+
  108. | |windows-logo| | |linux-logo| | |macos-logo| |
  109. +-------------------+-------------------+-------------------+
  110. | `Windows`_ | `Linux`_ | `Mac OS`_ |
  111. +-------------------+-------------------+-------------------+
  112. .. |windows-logo| image:: ../../_static/windows-logo.png
  113. :target: ../get-started/windows-setup.html
  114. .. |linux-logo| image:: ../../_static/linux-logo.png
  115. :target: ../get-started/linux-setup.html
  116. .. |macos-logo| image:: ../../_static/macos-logo.png
  117. :target: ../get-started/macos-setup.html
  118. .. _Windows: ../get-started/windows-setup.html
  119. .. _Linux: ../get-started/linux-setup.html
  120. .. _Mac OS: ../get-started/macos-setup.html
  121. .. note::
  122. This guide uses the directory ``~/esp`` on Linux and macOS or ``%userprofile%\esp`` on Windows as an installation folder for ESP-IDF. You can use any directory, but you will need to adjust paths for the commands respectively. Keep in mind that ESP-IDF does not support spaces in paths.
  123. .. _get-started-get-esp-idf:
  124. Step 2. Get ESP-IDF
  125. ===================
  126. To build applications for the {IDF_TARGET_NAME}, you need the software libraries provided by Espressif in `ESP-IDF repository <https://github.com/espressif/esp-idf>`_.
  127. To get ESP-IDF, navigate to your installation directory and clone the repository with ``git clone``, following instructions below specific to your operating system.
  128. Linux and macOS
  129. ~~~~~~~~~~~~~~~
  130. Open Terminal, and run the following commands:
  131. .. include-build-file:: inc/git-clone-bash.inc
  132. ESP-IDF will be downloaded into ``~/esp/esp-idf``.
  133. Consult :doc:`/versions` for information about which ESP-IDF version to use in a given situation.
  134. Windows
  135. ~~~~~~~
  136. In addition to installing the tools, :ref:`get-started-windows-tools-installer` for Windows introduced in Step 1 can also download a copy of ESP-IDF.
  137. Consult :doc:`/versions` for information about which ESP-IDF version to use in a given situation.
  138. If you wish to download ESP-IDF without the help of ESP-IDF Tools Installer, refer to these :ref:`instructions <get-esp-idf-windows-command-line>`.
  139. .. _get-started-set-up-tools:
  140. Step 3. Set up the tools
  141. ========================
  142. Aside from the ESP-IDF, you also need to install the tools used by ESP-IDF, such as the compiler, debugger, Python packages, etc.
  143. Windows
  144. ~~~~~~~
  145. :ref:`get-started-windows-tools-installer` for Windows introduced in Step 1 installs all the required tools.
  146. If you want to install the tools without the help of ESP-IDF Tools Installer, open the Command Prompt and follow these steps:
  147. .. code-block:: batch
  148. cd %userprofile%\esp\esp-idf
  149. install.bat
  150. or with Windows PowerShell
  151. .. code-block:: powershell
  152. cd ~/esp/esp-idf
  153. ./install.ps1
  154. Linux and macOS
  155. ~~~~~~~~~~~~~~~
  156. .. code-block:: bash
  157. cd ~/esp/esp-idf
  158. ./install.sh
  159. Alternative File Downloads
  160. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  161. The tools installer downloads a number of files attached to GitHub Releases. If accessing GitHub is slow then it is possible to set an environment variable to prefer Espressif's download server for GitHub asset downloads.
  162. .. note:: This setting only controls individual tools downloaded from GitHub releases, it doesn't change the URLs used to access any Git repositories.
  163. Windows
  164. -------
  165. To prefer the Espressif download server when running the ESP-IDF Tools Installer or installing tools from the command line, open the System control panel, then click on Advanced Settings. Add a new Environment Variable (of type either User or System) with the name ``IDF_GITHUB_ASSETS`` and value ``dl.espressif.com/github_assets``. Click OK once done.
  166. If the command line window or ESP-IDF Tools Installer window was already open before you added the new environment variable, you will need to close and reopen it.
  167. While this environment variable is still set, the ESP-IDF Tools Installer and the command line installer will prefer the Espressif download server.
  168. .. Once the ESP-IDF Tools Installer binary is updated to include the checkbox, the above can be rewritten to refer to it
  169. Linux and macOS
  170. ---------------
  171. To prefer the Espressif download server when installing tools, use the following sequence of commands when running ``install.sh``:
  172. .. code-block:: bash
  173. cd ~/esp/esp-idf
  174. export IDF_GITHUB_ASSETS="dl.espressif.com/github_assets"
  175. ./install.sh
  176. Customizing the tools installation path
  177. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  178. The scripts introduced in this step install compilation tools required by ESP-IDF inside the user home directory: ``$HOME/.espressif`` on Linux and macOS, ``%USERPROFILE%\.espressif`` on Windows. If you wish to install the tools into a different directory, set the environment variable ``IDF_TOOLS_PATH`` before running the installation scripts. Make sure that your user account has sufficient permissions to read and write this path.
  179. If changing the ``IDF_TOOLS_PATH``, make sure it is set to the same value every time the Install script (``install.bat``, ``install.ps1`` or ``install.sh``) and an Export script (``export.bat``, ``export.ps1`` or ``export.sh``) are executed.
  180. .. _get-started-set-up-env:
  181. Step 4. Set up the environment variables
  182. ========================================
  183. The installed tools are not yet added to the PATH environment variable. To make the tools usable from the command line, some environment variables must be set. ESP-IDF provides another script which does that.
  184. Windows
  185. ~~~~~~~
  186. :ref:`get-started-windows-tools-installer` for Windows creates an "ESP-IDF Command Prompt" shortcut in the Start Menu. This shortcut opens the Command Prompt and sets up all the required environment variables. You can open this shortcut and proceed to the next step.
  187. Alternatively, if you want to use ESP-IDF in an existing Command Prompt window, you can run:
  188. .. code-block:: batch
  189. %userprofile%\esp\esp-idf\export.bat
  190. or with Windows PowerShell
  191. .. code-block:: powershell
  192. .$HOME/esp/esp-idf/export.ps1
  193. .. _get-started-export:
  194. Linux and macOS
  195. ~~~~~~~~~~~~~~~
  196. In the terminal where you are going to use ESP-IDF, run:
  197. .. code-block:: bash
  198. . $HOME/esp/esp-idf/export.sh
  199. or for fish (supported only since fish version 3.0.0):
  200. .. code-block:: bash
  201. . $HOME/esp/esp-idf/export.fish
  202. Note the space between the leading dot and the path!
  203. If you plan to use esp-idf frequently, you can create an alias for executing ``export.sh``:
  204. 1. Copy and paste the following command to your shell's profile (``.profile``, ``.bashrc``, ``.zprofile``, etc.)
  205. .. code-block:: bash
  206. alias get_idf='. $HOME/esp/esp-idf/export.sh'
  207. 2. Refresh the configuration by restarting the terminal session or by running ``source [path to profile]``, for example, ``source ~/.bashrc``.
  208. Now you can run ``get_idf`` to set up or refresh the esp-idf environment in any terminal session.
  209. Technically, you can add ``export.sh`` to your shell's profile directly; however, it is not recommended. Doing so activates IDF virtual environment in every terminal session (including those where IDF is not needed), defeating the purpose of the virtual environment and likely affecting other software.
  210. .. _get-started-start-project:
  211. Step 5. Start a Project
  212. =======================
  213. Now you are ready to prepare your application for {IDF_TARGET_NAME}. You can start with :example:`get-started/hello_world` project from :idf:`examples` directory in IDF.
  214. Copy the project :example:`get-started/hello_world` to ``~/esp`` directory:
  215. Linux and macOS
  216. ~~~~~~~~~~~~~~~
  217. .. code-block:: bash
  218. cd ~/esp
  219. cp -r $IDF_PATH/examples/get-started/hello_world .
  220. Windows
  221. ~~~~~~~
  222. .. code-block:: batch
  223. cd %userprofile%\esp
  224. xcopy /e /i %IDF_PATH%\examples\get-started\hello_world hello_world
  225. There is a range of example projects in the :idf:`examples` directory in ESP-IDF. You can copy any project in the same way as presented above and run it.
  226. It is also possible to build examples in-place, without copying them first.
  227. .. important::
  228. The ESP-IDF build system does not support spaces in the paths to either ESP-IDF or to projects.
  229. .. _get-started-connect:
  230. Step 6. Connect Your Device
  231. ===========================
  232. Now connect your {IDF_TARGET_NAME} board to the computer and check under what serial port the board is visible.
  233. Serial ports have the following patterns in their names:
  234. - **Windows**: names like ``COM1``
  235. - **Linux**: starting with ``/dev/tty``
  236. - **macOS**: starting with ``/dev/cu.``
  237. If you are not sure how to check the serial port name, please refer to :doc:`establish-serial-connection` for full details.
  238. .. note::
  239. Keep the port name handy as you will need it in the next steps.
  240. .. _get-started-configure:
  241. Step 7. Configure
  242. =================
  243. Navigate to your ``hello_world`` directory from :ref:`get-started-start-project`, set {IDF_TARGET_NAME} chip as the target and run the project configuration utility ``menuconfig``.
  244. Linux and macOS
  245. ~~~~~~~~~~~~~~~
  246. .. code-block:: bash
  247. cd ~/esp/hello_world
  248. idf.py set-target {IDF_TARGET_PATH_NAME}
  249. idf.py menuconfig
  250. Windows
  251. ~~~~~~~
  252. .. code-block:: batch
  253. cd %userprofile%\esp\hello_world
  254. idf.py set-target {IDF_TARGET_PATH_NAME}
  255. idf.py menuconfig
  256. Setting the target with ``idf.py set-target {IDF_TARGET_PATH_NAME}`` should be done once, after opening a new project. If the project contains some existing builds and configuration, they will be cleared and initialized. The target may be saved in environment variable to skip this step at all. See :ref:`selecting-idf-target` for additional information.
  257. If the previous steps have been done correctly, the following menu appears:
  258. .. figure:: ../../_static/project-configuration.png
  259. :align: center
  260. :alt: Project configuration - Home window
  261. :figclass: align-center
  262. Project configuration - Home window
  263. You are using this menu to set up project specific variables, e.g. Wi-Fi network name and password, the processor speed, etc. Setting up the project with menuconfig may be skipped for "hello_word". This example will run with default configuration.
  264. .. only:: esp32
  265. .. attention::
  266. If you use ESP32-DevKitC board with the **ESP32-SOLO-1** module, enable single core mode (:ref:`CONFIG_FREERTOS_UNICORE`) in menuconfig before flashing examples.
  267. .. note::
  268. The colors of the menu could be different in your terminal. You can change the appearance with the option
  269. ``--style``. Please run ``idf.py menuconfig --help`` for further information.
  270. .. _get-started-build:
  271. Step 8. Build the Project
  272. =========================
  273. Build the project by running:
  274. .. code-block:: batch
  275. idf.py build
  276. This command will compile the application and all ESP-IDF components, then it will generate the bootloader, partition table, and application binaries.
  277. .. code-block:: none
  278. $ idf.py build
  279. Running cmake in directory /path/to/hello_world/build
  280. Executing "cmake -G Ninja --warn-uninitialized /path/to/hello_world"...
  281. Warn about uninitialized values.
  282. -- Found Git: /usr/bin/git (found version "2.17.0")
  283. -- Building empty aws_iot component due to configuration
  284. -- Component names: ...
  285. -- Component paths: ...
  286. ... (more lines of build system output)
  287. [527/527] Generating hello-world.bin
  288. esptool.py v2.3.1
  289. Project build complete. To flash, run this command:
  290. ../../../components/esptool_py/esptool/esptool.py -p (PORT) -b 921600 write_flash --flash_mode dio --flash_size detect --flash_freq 40m 0x10000 build/hello-world.bin build 0x1000 build/bootloader/bootloader.bin 0x8000 build/partition_table/partition-table.bin
  291. or run 'idf.py -p PORT flash'
  292. If there are no errors, the build will finish by generating the firmware binary .bin files.
  293. .. _get-started-flash:
  294. Step 9. Flash onto the Device
  295. =============================
  296. Flash the binaries that you just built (bootloader.bin, partition-table.bin and hello-world.bin) onto your {IDF_TARGET_NAME} board by running:
  297. .. code-block:: bash
  298. idf.py -p PORT [-b BAUD] flash
  299. Replace PORT with your {IDF_TARGET_NAME} board's serial port name from :ref:`get-started-connect`.
  300. You can also change the flasher baud rate by replacing BAUD with the baud rate you need. The default baud rate is ``460800``.
  301. For more information on idf.py arguments, see :ref:`idf.py`.
  302. .. note::
  303. The option ``flash`` automatically builds and flashes the project, so running ``idf.py build`` is not necessary.
  304. Encountered Issues While Flashing?
  305. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  306. {IDF_TARGET_STRAP_GPIO:default="GPIO0", esp32="GPIO0", esp32s2="GPIO0", esp32c3="GPIO9"}
  307. If you run the given command and see errors such as "Failed to connect", there might be several reasons for this. One of the reasons might be issues encountered by ``esptool.py``, the utility that is called by the build system to reset the chip, interact with the ROM bootloader, and flash firmware. One simple solution to try is manual reset described below, and if it does not help you can find more details about possible issues in `Troubleshooting <https://github.com/espressif/esptool#bootloader-wont-respond>`_.
  308. ``esptool.py`` resets {IDF_TARGET_NAME} automatically by asserting DTR and RTS control lines of the USB to serial converter chip, i.e., FTDI or CP210x (for more information, see :doc:`establish-serial-connection`). The DTR and RTS control lines are in turn connected to ``{IDF_TARGET_STRAP_GPIO}`` and ``CHIP_PU`` (EN) pins of {IDF_TARGET_NAME}, thus changes in the voltage levels of DTR and RTS will boot {IDF_TARGET_NAME} into Firmware Download mode. As an example, check the `schematic <https://dl.espressif.com/dl/schematics/esp32_devkitc_v4-sch-20180607a.pdf>`_ for the ESP32 DevKitC development board.
  309. In general, you should have no problems with the official esp-idf development boards. However, ``esptool.py`` is not able to reset your hardware automatically in the following cases:
  310. - Your hardware does not have the DTR and RTS lines connected to ``{IDF_TARGET_STRAP_GPIO}`` and ``CHIP_PU``
  311. - The DTR and RTS lines are configured differently
  312. - There are no such serial control lines at all
  313. Depending on the kind of hardware you have, it may also be possible to manually put your {IDF_TARGET_NAME} board into Firmware Download mode (reset).
  314. - For development boards produced by Espressif, this information can be found in the respective getting started guides or user guides. For example, to manually reset an esp-idf development board, hold down the **Boot** button (``{IDF_TARGET_STRAP_GPIO}``) and press the **EN** button (``CHIP_PU``).
  315. - For other types of hardware, try pulling ``{IDF_TARGET_STRAP_GPIO}`` down.
  316. Normal Operation
  317. ~~~~~~~~~~~~~~~~
  318. When flashing, you will see the output log similar to the following:
  319. .. only:: esp32
  320. .. code-block:: none
  321. ...
  322. esptool.py --chip esp32 -p /dev/ttyUSB0 -b 460800 --before=default_reset --after=hard_reset write_flash --flash_mode dio --flash_freq 40m --flash_size 2MB 0x8000 partition_table/partition-table.bin 0x1000 bootloader/bootloader.bin 0x10000 hello-world.bin
  323. esptool.py v3.0-dev
  324. Serial port /dev/ttyUSB0
  325. Connecting........_
  326. Chip is ESP32D0WDQ6 (revision 0)
  327. Features: WiFi, BT, Dual Core, Coding Scheme None
  328. Crystal is 40MHz
  329. MAC: 24:0a:c4:05:b9:14
  330. Uploading stub...
  331. Running stub...
  332. Stub running...
  333. Changing baud rate to 460800
  334. Changed.
  335. Configuring flash size...
  336. Compressed 3072 bytes to 103...
  337. Writing at 0x00008000... (100 %)
  338. Wrote 3072 bytes (103 compressed) at 0x00008000 in 0.0 seconds (effective 5962.8 kbit/s)...
  339. Hash of data verified.
  340. Compressed 26096 bytes to 15408...
  341. Writing at 0x00001000... (100 %)
  342. Wrote 26096 bytes (15408 compressed) at 0x00001000 in 0.4 seconds (effective 546.7 kbit/s)...
  343. Hash of data verified.
  344. Compressed 147104 bytes to 77364...
  345. Writing at 0x00010000... (20 %)
  346. Writing at 0x00014000... (40 %)
  347. Writing at 0x00018000... (60 %)
  348. Writing at 0x0001c000... (80 %)
  349. Writing at 0x00020000... (100 %)
  350. Wrote 147104 bytes (77364 compressed) at 0x00010000 in 1.9 seconds (effective 615.5 kbit/s)...
  351. Hash of data verified.
  352. Leaving...
  353. Hard resetting via RTS pin...
  354. Done
  355. .. only:: esp32s2
  356. .. code-block:: none
  357. ...
  358. esptool.py --chip esp32s2 -p /dev/ttyUSB0 -b 460800 --before=default_reset --after=hard_reset write_flash --flash_mode dio --flash_freq 40m --flash_size 2MB 0x8000 partition_table/partition-table.bin 0x1000 bootloader/bootloader.bin 0x10000 hello-world.bin
  359. esptool.py v3.0-dev
  360. Serial port /dev/ttyUSB0
  361. Connecting....
  362. Chip is ESP32-S2
  363. Features: WiFi
  364. Crystal is 40MHz
  365. MAC: 18:fe:34:72:50:e3
  366. Uploading stub...
  367. Running stub...
  368. Stub running...
  369. Changing baud rate to 460800
  370. Changed.
  371. Configuring flash size...
  372. Compressed 3072 bytes to 103...
  373. Writing at 0x00008000... (100 %)
  374. Wrote 3072 bytes (103 compressed) at 0x00008000 in 0.0 seconds (effective 3851.6 kbit/s)...
  375. Hash of data verified.
  376. Compressed 22592 bytes to 13483...
  377. Writing at 0x00001000... (100 %)
  378. Wrote 22592 bytes (13483 compressed) at 0x00001000 in 0.3 seconds (effective 595.1 kbit/s)...
  379. Hash of data verified.
  380. Compressed 140048 bytes to 70298...
  381. Writing at 0x00010000... (20 %)
  382. Writing at 0x00014000... (40 %)
  383. Writing at 0x00018000... (60 %)
  384. Writing at 0x0001c000... (80 %)
  385. Writing at 0x00020000... (100 %)
  386. Wrote 140048 bytes (70298 compressed) at 0x00010000 in 1.7 seconds (effective 662.5 kbit/s)...
  387. Hash of data verified.
  388. Leaving...
  389. Hard resetting via RTS pin...
  390. Done
  391. .. only:: esp32c3
  392. .. code-block:: none
  393. ...
  394. esptool.py --chip esp32c3 -p /dev/ttyUSB0 -b 460800 --before=default_reset --after=hard_reset write_flash --flash_mode dio --flash_freq 80m --flash_size 2MB 0x8000 partition_table/partition-table.bin 0x0 bootloader/bootloader.bin 0x10000 hello-world.bin
  395. esptool.py v3.0
  396. Serial port /dev/ttyUSB0
  397. Connecting....
  398. Chip is ESP32-C3
  399. Features: Wi-Fi
  400. Crystal is 40MHz
  401. MAC: 7c:df:a1:40:02:a4
  402. Uploading stub...
  403. Running stub...
  404. Stub running...
  405. Changing baud rate to 460800
  406. Changed.
  407. Configuring flash size...
  408. Compressed 3072 bytes to 103...
  409. Writing at 0x00008000... (100 %)
  410. Wrote 3072 bytes (103 compressed) at 0x00008000 in 0.0 seconds (effective 4238.1 kbit/s)...
  411. Hash of data verified.
  412. Compressed 18960 bytes to 11311...
  413. Writing at 0x00000000... (100 %)
  414. Wrote 18960 bytes (11311 compressed) at 0x00000000 in 0.3 seconds (effective 584.9 kbit/s)...
  415. Hash of data verified.
  416. Compressed 145520 bytes to 71984...
  417. Writing at 0x00010000... (20 %)
  418. Writing at 0x00014000... (40 %)
  419. Writing at 0x00018000... (60 %)
  420. Writing at 0x0001c000... (80 %)
  421. Writing at 0x00020000... (100 %)
  422. Wrote 145520 bytes (71984 compressed) at 0x00010000 in 2.3 seconds (effective 504.4 kbit/s)...
  423. Hash of data verified.
  424. Leaving...
  425. Hard resetting via RTS pin...
  426. Done
  427. If there are no issues by the end of the flash process, the board will reboot and start up the “hello_world” application.
  428. If you'd like to use the Eclipse or VS Code IDE instead of running ``idf.py``, check out the :doc:`Eclipse guide <eclipse-setup>`, :doc:`VS Code guide <vscode-setup>`.
  429. .. _get-started-build-monitor:
  430. Step 10. Monitor
  431. ================
  432. To check if "hello_world" is indeed running, type ``idf.py -p PORT monitor`` (Do not forget to replace PORT with your serial port name).
  433. This command launches the :doc:`IDF Monitor <../api-guides/tools/idf-monitor>` application::
  434. $ idf.py -p /dev/ttyUSB0 monitor
  435. Running idf_monitor in directory [...]/esp/hello_world/build
  436. Executing "python [...]/esp-idf/tools/idf_monitor.py -b 115200 [...]/esp/hello_world/build/hello-world.elf"...
  437. --- idf_monitor on /dev/ttyUSB0 115200 ---
  438. --- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
  439. ets Jun 8 2016 00:22:57
  440. rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
  441. ets Jun 8 2016 00:22:57
  442. ...
  443. After startup and diagnostic logs scroll up, you should see "Hello world!" printed out by the application.
  444. .. code-block:: none
  445. ...
  446. Hello world!
  447. Restarting in 10 seconds...
  448. This is {IDF_TARGET_PATH_NAME} chip with {IDF_TARGET_CORE_NUM} CPU core(s), {IDF_TARGET_FEATURES}
  449. Minimum free heap size: {IDF_TARGET_HEAP_SIZE} bytes
  450. Restarting in 9 seconds...
  451. Restarting in 8 seconds...
  452. Restarting in 7 seconds...
  453. To exit IDF monitor use the shortcut ``Ctrl+]``.
  454. .. only:: esp32
  455. If IDF monitor fails shortly after the upload, or, if instead of the messages above, you see random garbage similar to what is given below, your board is likely using a 26 MHz crystal. Most development board designs use 40 MHz, so ESP-IDF uses this frequency as a default value.
  456. .. figure:: ../../_static/get-started-garbled-output.png
  457. :align: center
  458. :alt: Garbled output
  459. :figclass: align-center
  460. If you have such a problem, do the following:
  461. 1. Exit the monitor.
  462. 2. Go back to :ref:`menuconfig <get-started-configure>`.
  463. 3. Go to Component config --> ESP32-specific --> Main XTAL frequency, then change :ref:`CONFIG_ESP32_XTAL_FREQ_SEL` to 26 MHz.
  464. 4. After that, :ref:`build and flash <get-started-flash>` the application again.
  465. .. note::
  466. You can combine building, flashing and monitoring into one step by running::
  467. idf.py -p PORT flash monitor
  468. See also:
  469. - :doc:`IDF Monitor <../api-guides/tools/idf-monitor>` for handy shortcuts and more details on using IDF monitor.
  470. - :ref:`idf.py` for a full reference of ``idf.py`` commands and options.
  471. **That's all that you need to get started with {IDF_TARGET_NAME}!**
  472. Now you are ready to try some other :idf:`examples`, or go straight to developing your own applications.
  473. .. important::
  474. Some of examples do not support {IDF_TARGET_NAME} because required hardware is not included in {IDF_TARGET_NAME} so it cannot be supported.
  475. If building an example, please check the README file for the ``Supported Targets`` table. If this is present including {IDF_TARGET_NAME} target, or the table does not exist at all, the example will work on {IDF_TARGET_NAME}.
  476. Updating ESP-IDF
  477. ================
  478. You should update ESP-IDF from time to time, as newer versions fix bugs and provide new features. The simplest way to do the update is to delete the existing ``esp-idf`` folder and clone it again, as if performing the initial installation described in :ref:`get-started-get-esp-idf`.
  479. Another solution is to update only what has changed. :ref:`The update procedure depends on the version of ESP-IDF you are using <updating>`.
  480. After updating ESP-IDF, execute the Install script again, in case the new ESP-IDF version requires different versions of tools. See instructions at :ref:`get-started-set-up-tools`.
  481. Once the new tools are installed, update the environment using the Export script. See instructions at :ref:`get-started-set-up-env`.
  482. Related Documents
  483. =================
  484. .. toctree::
  485. :maxdepth: 1
  486. establish-serial-connection
  487. eclipse-setup
  488. vscode-setup
  489. ../api-guides/tools/idf-monitor
  490. toolchain-setup-scratch
  491. :esp32: ../get-started-legacy/index
  492. .. _Stable version: https://docs.espressif.com/projects/esp-idf/en/stable/
  493. .. _Releases page: https://github.com/espressif/esp-idf/releases