index.rst 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681
  1. ***********
  2. Get Started
  3. ***********
  4. :link_to_translation:`zh_CN:[中文]`
  5. .. Please keep README.md in sync with these instructions.
  6. 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. 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.
  7. .. include-build-file:: inc/version-note.inc
  8. Introduction
  9. ============
  10. {IDF_TARGET_NAME} is a system on a chip that integrates the following features:
  11. .. only:: esp32
  12. * Wi-Fi (2.4 GHz band)
  13. * Bluetooth
  14. * Dual high performance cores
  15. * Ultra Low Power co-processor
  16. * Multiple peripherals
  17. .. only:: esp32s2
  18. * Wi-Fi (2.4 GHz band)
  19. * High performance single-core
  20. * Ultra Low Power co-processor running either RISC-V or FSM core
  21. * Multiple peripherals
  22. * Built-in security hardware
  23. * USB OTG interface
  24. 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.
  25. 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.
  26. What You Need
  27. =============
  28. Hardware:
  29. * An **{IDF_TARGET_NAME}** board
  30. * **USB cable** - USB A / micro USB B
  31. * **Computer** running Windows, Linux, or macOS
  32. Software:
  33. You have a choice to either download and install the following software manually
  34. * **Toolchain** to compile code for {IDF_TARGET_NAME}
  35. * **Build tools** - CMake and Ninja to build a full **Application** for {IDF_TARGET_NAME}
  36. * **ESP-IDF** that essentially contains API (software libraries and source code) for {IDF_TARGET_NAME} and scripts to operate the **Toolchain**
  37. **or** get through the onboarding process using the following official plugins for integrated development environments (IDE) described in separate documents
  38. * `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>`_)
  39. * `VS Code Extension <https://github.com/espressif/vscode-esp-idf-extension>`_ (`setup <https://github.com/espressif/vscode-esp-idf-extension/blob/master/docs/tutorial/install.md>`_)
  40. .. figure:: ../../_static/what-you-need.png
  41. :align: center
  42. :alt: Development of applications for {IDF_TARGET_NAME}
  43. :figclass: align-center
  44. Development of applications for {IDF_TARGET_NAME}
  45. Development Board Overviews
  46. ===========================
  47. If you have one of {IDF_TARGET_NAME} development boards listed below, you can click on the link to learn more about its hardware.
  48. .. only:: esp32
  49. .. toctree::
  50. :maxdepth: 1
  51. ESP32-DevKitC <../hw-reference/esp32/get-started-devkitc>
  52. ESP-WROVER-KIT <../hw-reference/esp32/get-started-wrover-kit>
  53. ESP32-PICO-KIT <../hw-reference/esp32/get-started-pico-kit>
  54. ESP32-Ethernet-Kit <../hw-reference/esp32/get-started-ethernet-kit>
  55. ESP32-DevKit-S(-R) <../hw-reference/esp32/user-guide-devkits-r-v1.1>
  56. .. only:: esp32s2
  57. .. toctree::
  58. :maxdepth: 1
  59. ESP32-S2-Saola-1 <../hw-reference/esp32s2/user-guide-saola-1-v1.2>
  60. ESP32-S2-DevKitM-1(U) <../hw-reference/esp32s2/user-guide-devkitm-1-v1>
  61. ESP32-S2-DevKitC-1 <../hw-reference/esp32s2/user-guide-s2-devkitc-1>
  62. ESP32-S2-Kaluga-Kit <../hw-reference/esp32s2/user-guide-esp32-s2-kaluga-1-kit>
  63. .. _get-started-step-by-step:
  64. Installation Step by Step
  65. =========================
  66. This is a detailed roadmap to walk you through the installation process.
  67. Setting up Development Environment
  68. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  69. * :ref:`get-started-get-prerequisites` for :doc:`Windows <windows-setup>`, :doc:`Linux <linux-setup>`, or :doc:`macOS <macos-setup>`
  70. * :ref:`get-started-get-esp-idf`
  71. * :ref:`get-started-set-up-tools`
  72. * :ref:`get-started-set-up-env`
  73. Creating Your First Project
  74. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  75. * :ref:`get-started-start-project`
  76. * :ref:`get-started-connect`
  77. * :ref:`get-started-configure`
  78. * :ref:`get-started-build`
  79. * :ref:`get-started-flash`
  80. * :ref:`get-started-build-monitor`
  81. .. _get-started-get-prerequisites:
  82. Step 1. Install prerequisites
  83. =============================
  84. 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:
  85. .. toctree::
  86. :hidden:
  87. Windows <windows-setup>
  88. Linux <linux-setup>
  89. macOS <macos-setup>
  90. +-------------------+-------------------+-------------------+
  91. | |windows-logo| | |linux-logo| | |macos-logo| |
  92. +-------------------+-------------------+-------------------+
  93. | `Windows`_ | `Linux`_ | `mac OS`_ |
  94. +-------------------+-------------------+-------------------+
  95. .. |windows-logo| image:: ../../_static/windows-logo.png
  96. :target: ../get-started/windows-setup.html
  97. .. |linux-logo| image:: ../../_static/linux-logo.png
  98. :target: ../get-started/linux-setup.html
  99. .. |macos-logo| image:: ../../_static/macos-logo.png
  100. :target: ../get-started/macos-setup.html
  101. .. _Windows: ../get-started/windows-setup.html
  102. .. _Linux: ../get-started/linux-setup.html
  103. .. _mac OS: ../get-started/macos-setup.html
  104. .. _get-started-get-esp-idf:
  105. Step 2. Get ESP-IDF
  106. ===================
  107. 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>`_.
  108. To get ESP-IDF, navigate to your installation directory and clone the repository with ``git clone``, following instructions below specific to your operating system.
  109. .. note::
  110. 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.
  111. Linux and macOS
  112. ~~~~~~~~~~~~~~~
  113. Open Terminal, and run the following commands:
  114. .. include-build-file:: inc/git-clone-bash.inc
  115. ESP-IDF will be downloaded into ``~/esp/esp-idf``.
  116. Consult :doc:`/versions` for information about which ESP-IDF version to use in a given situation.
  117. Windows
  118. ~~~~~~~
  119. 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.
  120. Consult :doc:`/versions` for information about which ESP-IDF version to use in a given situation.
  121. 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>`.
  122. .. _get-started-set-up-tools:
  123. Step 3. Set up the tools
  124. ========================
  125. Aside from the ESP-IDF, you also need to install the tools used by ESP-IDF, such as the compiler, debugger, Python packages, etc.
  126. Windows
  127. ~~~~~~~
  128. :ref:`get-started-windows-tools-installer` for Windows introduced in Step 1 installs all the required tools.
  129. If you want to install the tools without the help of ESP-IDF Tools Installer, open the Command Prompt and follow these steps:
  130. .. code-block:: batch
  131. cd %userprofile%\esp\esp-idf
  132. install.bat {IDF_TARGET_PATH_NAME}
  133. or with Windows PowerShell
  134. .. code-block:: powershell
  135. cd ~/esp/esp-idf
  136. ./install.ps1 {IDF_TARGET_PATH_NAME}
  137. Linux and macOS
  138. ~~~~~~~~~~~~~~~
  139. .. code-block:: bash
  140. cd ~/esp/esp-idf
  141. ./install.sh {IDF_TARGET_PATH_NAME}
  142. or with Fish shell
  143. .. code-block:: fish
  144. cd ~/esp/esp-idf
  145. ./install.fish {IDF_TARGET_PATH_NAME}
  146. .. note::
  147. To install tools for multiple targets you can specify those targets at once. For example: ``./install.sh esp32,esp32s2``.
  148. To install tools for all supported targets, run the script without specifying targets ``./install.sh`` or use ``./install.sh all``.
  149. Alternative File Downloads
  150. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  151. 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.
  152. .. note:: This setting only controls individual tools downloaded from GitHub releases, it doesn't change the URLs used to access any Git repositories.
  153. Windows
  154. -------
  155. 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.
  156. 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.
  157. While this environment variable is still set, the ESP-IDF Tools Installer and the command line installer will prefer the Espressif download server.
  158. .. Once the ESP-IDF Tools Installer binary is updated to include the checkbox, the above can be rewritten to refer to it
  159. Linux and macOS
  160. ---------------
  161. To prefer the Espressif download server when installing tools, use the following sequence of commands when running ``install.sh``:
  162. .. code-block:: bash
  163. cd ~/esp/esp-idf
  164. export IDF_GITHUB_ASSETS="dl.espressif.com/github_assets"
  165. ./install.sh
  166. Customizing the tools installation path
  167. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  168. 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.
  169. 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.
  170. .. _get-started-set-up-env:
  171. Step 4. Set up the environment variables
  172. ========================================
  173. 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.
  174. Windows
  175. ~~~~~~~
  176. :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.
  177. Alternatively, if you want to use ESP-IDF in an existing Command Prompt window, you can run:
  178. .. code-block:: batch
  179. %userprofile%\esp\esp-idf\export.bat
  180. or with Windows PowerShell
  181. .. code-block:: powershell
  182. .$HOME/esp/esp-idf/export.ps1
  183. Linux and macOS
  184. ~~~~~~~~~~~~~~~
  185. In the terminal where you are going to use ESP-IDF, run:
  186. .. code-block:: bash
  187. . $HOME/esp/esp-idf/export.sh
  188. Note the space between the leading dot and the path!
  189. If you plan to use esp-idf frequently, you can create an alias for executing ``export.sh``:
  190. 1. Copy and paste the following command to your shell's profile (``.profile``, ``.bashrc``, ``.zprofile``, etc.)
  191. .. code-block:: bash
  192. alias get_idf='. $HOME/esp/esp-idf/export.sh'
  193. 2. Refresh the configuration by restarting the terminal session or by running ``source [path to profile]``, for example, ``source ~/.bashrc``.
  194. Now you can run ``get_idf`` to set up or refresh the esp-idf environment in any terminal session.
  195. 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.
  196. .. _get-started-start-project:
  197. Step 5. Start a Project
  198. =======================
  199. 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.
  200. Copy the project :example:`get-started/hello_world` to ``~/esp`` directory:
  201. Linux and macOS
  202. ~~~~~~~~~~~~~~~
  203. .. code-block:: bash
  204. cd ~/esp
  205. cp -r $IDF_PATH/examples/get-started/hello_world .
  206. Windows
  207. ~~~~~~~
  208. .. code-block:: batch
  209. cd %userprofile%\esp
  210. xcopy /e /i %IDF_PATH%\examples\get-started\hello_world hello_world
  211. 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. It is also possible to build examples in-place, without copying them first.
  212. .. important::
  213. The ESP-IDF build system does not support spaces in the paths to either ESP-IDF or to projects.
  214. .. _get-started-connect:
  215. Step 6. Connect Your Device
  216. ===========================
  217. Now connect your {IDF_TARGET_NAME} board to the computer and check under what serial port the board is visible.
  218. Serial ports have the following patterns in their names:
  219. - **Windows**: names like ``COM1``
  220. - **Linux**: starting with ``/dev/tty``
  221. - **macOS**: starting with ``/dev/cu.``
  222. If you are not sure how to check the serial port name, please refer to :doc:`establish-serial-connection` for full details.
  223. .. note::
  224. Keep the port name handy as you will need it in the next steps.
  225. .. _get-started-configure:
  226. Step 7. Configure
  227. =================
  228. 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``.
  229. Linux and macOS
  230. ~~~~~~~~~~~~~~~
  231. .. code-block:: bash
  232. cd ~/esp/hello_world
  233. idf.py set-target {IDF_TARGET_PATH_NAME}
  234. idf.py menuconfig
  235. Windows
  236. ~~~~~~~
  237. .. code-block:: batch
  238. cd %userprofile%\esp\hello_world
  239. idf.py set-target {IDF_TARGET_PATH_NAME}
  240. idf.py menuconfig
  241. 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.
  242. If the previous steps have been done correctly, the following menu appears:
  243. .. figure:: ../../_static/project-configuration.png
  244. :align: center
  245. :alt: Project configuration - Home window
  246. :figclass: align-center
  247. Project configuration - Home window
  248. 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.
  249. .. only:: esp32
  250. .. attention::
  251. 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.
  252. .. note::
  253. The colors of the menu could be different in your terminal. You can change the appearance with the option ``--style``. Please run ``idf.py menuconfig --help`` for further information.
  254. .. _get-started-build:
  255. Step 8. Build the Project
  256. =========================
  257. Build the project by running:
  258. .. code-block:: batch
  259. idf.py build
  260. This command will compile the application and all ESP-IDF components, then it will generate the bootloader, partition table, and application binaries.
  261. .. code-block:: none
  262. $ idf.py build
  263. Running cmake in directory /path/to/hello_world/build
  264. Executing "cmake -G Ninja --warn-uninitialized /path/to/hello_world"...
  265. Warn about uninitialized values.
  266. -- Found Git: /usr/bin/git (found version "2.17.0")
  267. -- Building empty aws_iot component due to configuration
  268. -- Component names: ...
  269. -- Component paths: ...
  270. ... (more lines of build system output)
  271. [527/527] Generating hello-world.bin
  272. esptool.py v2.3.1
  273. Project build complete. To flash, run this command:
  274. ../../../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
  275. or run 'idf.py -p PORT flash'
  276. If there are no errors, the build will finish by generating the firmware binary .bin files.
  277. .. _get-started-flash:
  278. Step 9. Flash onto the Device
  279. =============================
  280. Flash the binaries that you just built (bootloader.bin, partition-table.bin and hello-world.bin) onto your {IDF_TARGET_NAME} board by running:
  281. .. code-block:: bash
  282. idf.py -p PORT [-b BAUD] flash
  283. Replace PORT with your {IDF_TARGET_NAME} board's serial port name from :ref:`get-started-connect`.
  284. You can also change the flasher baud rate by replacing BAUD with the baud rate you need. The default baud rate is ``460800``.
  285. For more information on idf.py arguments, see :ref:`idf.py`.
  286. .. note::
  287. The option ``flash`` automatically builds and flashes the project, so running ``idf.py build`` is not necessary.
  288. Encountered Issues While Flashing?
  289. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  290. 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>`_.
  291. ``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 ``GPIO0`` 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.
  292. 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:
  293. - Your hardware does not have the DTR and RTS lines connected to ``GPIO0`` and ``CIHP_PU``
  294. - The DTR and RTS lines are configured differently
  295. - There are no such serial control lines at all
  296. 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).
  297. - 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 (``GPIO0``) and press the **EN** button (``CHIP_PU``).
  298. - For other types of hardware, try pulling ``GPIO0`` down.
  299. Normal Operation
  300. ~~~~~~~~~~~~~~~~
  301. When flashing, you will see the output log similar to the following:
  302. .. only:: esp32
  303. .. code-block:: none
  304. ...
  305. 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
  306. esptool.py v3.0-dev
  307. Serial port /dev/ttyUSB0
  308. Connecting........_
  309. Chip is ESP32D0WDQ6 (revision 0)
  310. Features: WiFi, BT, Dual Core, Coding Scheme None
  311. Crystal is 40MHz
  312. MAC: 24:0a:c4:05:b9:14
  313. Uploading stub...
  314. Running stub...
  315. Stub running...
  316. Changing baud rate to 460800
  317. Changed.
  318. Configuring flash size...
  319. Compressed 3072 bytes to 103...
  320. Writing at 0x00008000... (100 %)
  321. Wrote 3072 bytes (103 compressed) at 0x00008000 in 0.0 seconds (effective 5962.8 kbit/s)...
  322. Hash of data verified.
  323. Compressed 26096 bytes to 15408...
  324. Writing at 0x00001000... (100 %)
  325. Wrote 26096 bytes (15408 compressed) at 0x00001000 in 0.4 seconds (effective 546.7 kbit/s)...
  326. Hash of data verified.
  327. Compressed 147104 bytes to 77364...
  328. Writing at 0x00010000... (20 %)
  329. Writing at 0x00014000... (40 %)
  330. Writing at 0x00018000... (60 %)
  331. Writing at 0x0001c000... (80 %)
  332. Writing at 0x00020000... (100 %)
  333. Wrote 147104 bytes (77364 compressed) at 0x00010000 in 1.9 seconds (effective 615.5 kbit/s)...
  334. Hash of data verified.
  335. Leaving...
  336. Hard resetting via RTS pin...
  337. Done
  338. .. only:: esp32s2
  339. .. code-block:: none
  340. ...
  341. 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
  342. esptool.py v3.0-dev
  343. Serial port /dev/ttyUSB0
  344. Connecting....
  345. Chip is ESP32-S2
  346. Features: WiFi
  347. Crystal is 40MHz
  348. MAC: 18:fe:34:72:50:e3
  349. Uploading stub...
  350. Running stub...
  351. Stub running...
  352. Changing baud rate to 460800
  353. Changed.
  354. Configuring flash size...
  355. Compressed 3072 bytes to 103...
  356. Writing at 0x00008000... (100 %)
  357. Wrote 3072 bytes (103 compressed) at 0x00008000 in 0.0 seconds (effective 3851.6 kbit/s)...
  358. Hash of data verified.
  359. Compressed 22592 bytes to 13483...
  360. Writing at 0x00001000... (100 %)
  361. Wrote 22592 bytes (13483 compressed) at 0x00001000 in 0.3 seconds (effective 595.1 kbit/s)...
  362. Hash of data verified.
  363. Compressed 140048 bytes to 70298...
  364. Writing at 0x00010000... (20 %)
  365. Writing at 0x00014000... (40 %)
  366. Writing at 0x00018000... (60 %)
  367. Writing at 0x0001c000... (80 %)
  368. Writing at 0x00020000... (100 %)
  369. Wrote 140048 bytes (70298 compressed) at 0x00010000 in 1.7 seconds (effective 662.5 kbit/s)...
  370. Hash of data verified.
  371. Leaving...
  372. Hard resetting via RTS pin...
  373. Done
  374. If there are no issues by the end of the flash process, the board will reboot and start up the “hello_world” application.
  375. 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>`.
  376. .. _get-started-build-monitor:
  377. Step 10. Monitor
  378. ================
  379. 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).
  380. This command launches the :doc:`IDF Monitor <../api-guides/tools/idf-monitor>` application::
  381. $ idf.py -p /dev/ttyUSB0 monitor
  382. Running idf_monitor in directory [...]/esp/hello_world/build
  383. Executing "python [...]/esp-idf/tools/idf_monitor.py -b 115200 [...]/esp/hello_world/build/hello-world.elf"...
  384. --- idf_monitor on /dev/ttyUSB0 115200 ---
  385. --- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
  386. ets Jun 8 2016 00:22:57
  387. rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
  388. ets Jun 8 2016 00:22:57
  389. ...
  390. After startup and diagnostic logs scroll up, you should see "Hello world!" printed out by the application.
  391. .. code-block:: none
  392. ...
  393. Hello world!
  394. Restarting in 10 seconds...
  395. This is esp32 chip with 2 CPU cores, WiFi/BT/BLE, silicon revision 1, 2MB external flash
  396. Restarting in 9 seconds...
  397. Restarting in 8 seconds...
  398. Restarting in 7 seconds...
  399. To exit IDF monitor use the shortcut ``Ctrl+]``.
  400. .. only:: esp32
  401. 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.
  402. .. figure:: ../../_static/get-started-garbled-output.png
  403. :align: center
  404. :alt: Garbled output
  405. :figclass: align-center
  406. If you have such a problem, do the following:
  407. 1. Exit the monitor.
  408. 2. Go back to :ref:`menuconfig <get-started-configure>`.
  409. 3. Go to Component config --> ESP32-specific --> Main XTAL frequency, then change :ref:`CONFIG_ESP32_XTAL_FREQ_SEL` to 26 MHz.
  410. 4. After that, :ref:`build and flash <get-started-flash>` the application again.
  411. .. note::
  412. You can combine building, flashing and monitoring into one step by running::
  413. idf.py -p PORT flash monitor
  414. See also:
  415. - :doc:`IDF Monitor <../api-guides/tools/idf-monitor>` for handy shortcuts and more details on using IDF monitor.
  416. - :ref:`idf.py` for a full reference of ``idf.py`` commands and options.
  417. **That's all that you need to get started with {IDF_TARGET_NAME}!**
  418. Now you are ready to try some other :idf:`examples`, or go straight to developing your own applications.
  419. .. important::
  420. Some of examples do not support {IDF_TARGET_NAME} because required hardware is not included in {IDF_TARGET_NAME} so it cannot be supported.
  421. 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}.
  422. Updating ESP-IDF
  423. ================
  424. 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`.
  425. Another solution is to update only what has changed. :ref:`The update procedure depends on the version of ESP-IDF you are using <updating>`.
  426. 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`.
  427. Once the new tools are installed, update the environment using the Export script. See instructions at :ref:`get-started-set-up-env`.
  428. Related Documents
  429. =================
  430. .. toctree::
  431. :maxdepth: 1
  432. establish-serial-connection
  433. eclipse-setup
  434. vscode-setup
  435. ../api-guides/tools/idf-monitor
  436. toolchain-setup-scratch
  437. :esp32: ../get-started-legacy/index
  438. .. _Stable version: https://docs.espressif.com/projects/esp-idf/en/stable/
  439. .. _Releases page: https://github.com/espressif/esp-idf/releases