diff --git a/Kconfig b/Kconfig index ac8a1db950..f6ebbc5731 100644 --- a/Kconfig +++ b/Kconfig @@ -4,6 +4,9 @@ # mainmenu "Espressif IoT Development Framework Configuration" +config IDF_CMAKE + bool + option env="IDF_CMAKE" menu "SDK tool configuration" config TOOLPREFIX @@ -15,6 +18,7 @@ config TOOLPREFIX config PYTHON string "Python 2 interpreter" + depends on !IDF_CMAKE default "python" help The executable name/path that is used to run python. On some systems Python 2.x diff --git a/components/app_update/CMakeLists.txt b/components/app_update/CMakeLists.txt index 44663f68ea..e1401c6859 100644 --- a/components/app_update/CMakeLists.txt +++ b/components/app_update/CMakeLists.txt @@ -1,7 +1,7 @@ set(COMPONENT_SRCDIRS ".") set(COMPONENT_ADD_INCLUDEDIRS "include") -set(COMPONENT_REQUIRES "") -set(COMPONENT_PRIV_REQUIRES bootloader_support spi_flash) +set(COMPONENT_REQUIRES spi_flash) +set(COMPONENT_PRIV_REQUIRES bootloader_support) register_component() diff --git a/components/esp32/CMakeLists.txt b/components/esp32/CMakeLists.txt index 2c4fc74298..42e14ba197 100644 --- a/components/esp32/CMakeLists.txt +++ b/components/esp32/CMakeLists.txt @@ -20,10 +20,12 @@ else() set(COMPONENT_SRCDIRS ". hwcrypto") set(COMPONENT_ADD_INCLUDEDIRS "include") - set(COMPONENT_REQUIRES driver) # required because esp_sleep.h uses gpio_num_t & touch_pad_t + set(COMPONENT_REQUIRES driver tcpip_adapter) + # driver is a public requirement because esp_sleep.h uses gpio_num_t & touch_pad_t + # tcpip_adapter is a public requirement because esp_event.h uses tcpip_adapter types set(COMPONENT_PRIV_REQUIRES app_trace bootloader_support ethernet log mbedtls nvs_flash - pthread spi_flash tcpip_adapter vfs wpa_supplicant xtensa-debug-module) + pthread spi_flash vfs wpa_supplicant xtensa-debug-module) register_component() @@ -65,8 +67,8 @@ else() set(LD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/ld) add_custom_command( OUTPUT esp32_out.ld - COMMAND "${CMAKE_C_COMPILER}" -C -P -x c -E -o esp32_out.ld -I ${CMAKE_BINARY_DIR} ${LD_DIR}/esp32.ld - MAIN_DEPENDENCY ${LD_DIR}/esp32.ld + COMMAND "${CMAKE_C_COMPILER}" -C -P -x c -E -o esp32_out.ld -I ${CONFIG_DIR} ${LD_DIR}/esp32.ld + MAIN_DEPENDENCY ${LD_DIR}/esp32.ld ${SDKCONFIG_H} COMMENT "Generating linker script..." VERBATIM) add_custom_target(esp32_linker_script DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/esp32_out.ld) diff --git a/components/esp32/lib b/components/esp32/lib index 8cd9fd455e..92a091649f 160000 --- a/components/esp32/lib +++ b/components/esp32/lib @@ -1 +1 @@ -Subproject commit 8cd9fd455e98a5c818f2796b4b83107884b7874c +Subproject commit 92a091649f7c8476580177e2a769b15d9c4c191f diff --git a/components/esptool_py/CMakeLists.txt b/components/esptool_py/CMakeLists.txt index 0d62557c81..690763934e 100644 --- a/components/esptool_py/CMakeLists.txt +++ b/components/esptool_py/CMakeLists.txt @@ -1,7 +1,7 @@ register_config_only_component() # Generate pre-canned flasher args files suitable for passing to esptool.py -foreach(part project app bootloader) +foreach(part project app bootloader partition_table) configure_file( "${CMAKE_CURRENT_LIST_DIR}/flash_${part}_args.in" "${CMAKE_BINARY_DIR}/flash_${part}_args" diff --git a/components/esptool_py/Kconfig.projbuild b/components/esptool_py/Kconfig.projbuild index c87d8adcf1..799b576a08 100644 --- a/components/esptool_py/Kconfig.projbuild +++ b/components/esptool_py/Kconfig.projbuild @@ -1,9 +1,10 @@ menu "Serial flasher config" config ESPTOOLPY_PORT - string "Default serial port" - default "/dev/ttyUSB0" - help + string "Default serial port" + depends on !IDF_CMAKE + default "/dev/ttyUSB0" + help The serial port that's connected to the ESP chip. This can be overridden by setting the ESPPORT environment variable. @@ -11,6 +12,7 @@ config ESPTOOLPY_PORT choice ESPTOOLPY_BAUD prompt "Default baud rate" + depends on !IDF_CMAKE default ESPTOOLPY_BAUD_115200B help Default baud rate to use while communicating with the ESP chip. Can be overridden by @@ -19,113 +21,115 @@ choice ESPTOOLPY_BAUD This value is ignored when using the CMake-based build system or idf.py. config ESPTOOLPY_BAUD_115200B - bool "115200 baud" + bool "115200 baud" config ESPTOOLPY_BAUD_230400B - bool "230400 baud" + bool "230400 baud" config ESPTOOLPY_BAUD_921600B - bool "921600 baud" + bool "921600 baud" config ESPTOOLPY_BAUD_2MB - bool "2Mbaud" + bool "2Mbaud" config ESPTOOLPY_BAUD_OTHER bool "Other baud rate" endchoice config ESPTOOLPY_BAUD_OTHER_VAL - int "Other baud rate value" if ESPTOOLPY_BAUD_OTHER - default 115200 + int "Other baud rate value" if ESPTOOLPY_BAUD_OTHER + default 115200 config ESPTOOLPY_BAUD - int - default 115200 if ESPTOOLPY_BAUD_115200B - default 230400 if ESPTOOLPY_BAUD_230400B - default 921600 if ESPTOOLPY_BAUD_921600B - default 2000000 if ESPTOOLPY_BAUD_2MB - default ESPTOOLPY_BAUD_OTHER_VAL if ESPTOOLPY_BAUD_OTHER + int + depends on !IDF_CMAKE + default 115200 if ESPTOOLPY_BAUD_115200B + default 230400 if ESPTOOLPY_BAUD_230400B + default 921600 if ESPTOOLPY_BAUD_921600B + default 2000000 if ESPTOOLPY_BAUD_2MB + default ESPTOOLPY_BAUD_OTHER_VAL if ESPTOOLPY_BAUD_OTHER config ESPTOOLPY_COMPRESSED - bool "Use compressed upload" - default "y" - help - The flasher tool can send data compressed using zlib, letting the ROM on the ESP chip - decompress it on the fly before flashing it. For most payloads, this should result in a - speed increase. + bool "Use compressed upload" + depends on !IDF_CMAKE + default "y" + help + The flasher tool can send data compressed using zlib, letting the ROM on the ESP chip + decompress it on the fly before flashing it. For most payloads, this should result in a + speed increase. choice FLASHMODE - prompt "Flash SPI mode" - default FLASHMODE_DIO - help - Mode the flash chip is flashed in, as well as the default mode for the - binary to run in. + prompt "Flash SPI mode" + default FLASHMODE_DIO + help + Mode the flash chip is flashed in, as well as the default mode for the + binary to run in. config FLASHMODE_QIO - bool "QIO" + bool "QIO" config FLASHMODE_QOUT - bool "QOUT" + bool "QOUT" config FLASHMODE_DIO - bool "DIO" + bool "DIO" config FLASHMODE_DOUT - bool "DOUT" + bool "DOUT" endchoice # Note: we use esptool.py to flash bootloader in # dio mode for QIO/QOUT, bootloader then upgrades # itself to quad mode during initialisation config ESPTOOLPY_FLASHMODE - string - default "dio" if FLASHMODE_QIO - default "dio" if FLASHMODE_QOUT - default "dio" if FLASHMODE_DIO - default "dout" if FLASHMODE_DOUT + string + default "dio" if FLASHMODE_QIO + default "dio" if FLASHMODE_QOUT + default "dio" if FLASHMODE_DIO + default "dout" if FLASHMODE_DOUT choice ESPTOOLPY_FLASHFREQ - prompt "Flash SPI speed" - default ESPTOOLPY_FLASHFREQ_40M - help - The SPI flash frequency to be used. + prompt "Flash SPI speed" + default ESPTOOLPY_FLASHFREQ_40M + help + The SPI flash frequency to be used. config ESPTOOLPY_FLASHFREQ_80M - bool "80 MHz" + bool "80 MHz" config ESPTOOLPY_FLASHFREQ_40M - bool "40 MHz" + bool "40 MHz" config ESPTOOLPY_FLASHFREQ_26M - bool "26 MHz" + bool "26 MHz" config ESPTOOLPY_FLASHFREQ_20M - bool "20 MHz" + bool "20 MHz" endchoice config ESPTOOLPY_FLASHFREQ - string - default "80m" if ESPTOOLPY_FLASHFREQ_80M - default "40m" if ESPTOOLPY_FLASHFREQ_40M - default "26m" if ESPTOOLPY_FLASHFREQ_26M - default "20m" if ESPTOOLPY_FLASHFREQ_20M + string + default "80m" if ESPTOOLPY_FLASHFREQ_80M + default "40m" if ESPTOOLPY_FLASHFREQ_40M + default "26m" if ESPTOOLPY_FLASHFREQ_26M + default "20m" if ESPTOOLPY_FLASHFREQ_20M choice ESPTOOLPY_FLASHSIZE - prompt "Flash size" - default ESPTOOLPY_FLASHSIZE_2MB - help - SPI flash size, in megabytes + prompt "Flash size" + default ESPTOOLPY_FLASHSIZE_2MB + help + SPI flash size, in megabytes config ESPTOOLPY_FLASHSIZE_1MB - bool "1 MB" + bool "1 MB" config ESPTOOLPY_FLASHSIZE_2MB - bool "2 MB" + bool "2 MB" config ESPTOOLPY_FLASHSIZE_4MB - bool "4 MB" + bool "4 MB" config ESPTOOLPY_FLASHSIZE_8MB - bool "8 MB" + bool "8 MB" config ESPTOOLPY_FLASHSIZE_16MB - bool "16 MB" + bool "16 MB" endchoice config ESPTOOLPY_FLASHSIZE - string - default "1MB" if ESPTOOLPY_FLASHSIZE_1MB - default "2MB" if ESPTOOLPY_FLASHSIZE_2MB - default "4MB" if ESPTOOLPY_FLASHSIZE_4MB - default "8MB" if ESPTOOLPY_FLASHSIZE_8MB - default "16MB" if ESPTOOLPY_FLASHSIZE_16MB + string + default "1MB" if ESPTOOLPY_FLASHSIZE_1MB + default "2MB" if ESPTOOLPY_FLASHSIZE_2MB + default "4MB" if ESPTOOLPY_FLASHSIZE_4MB + default "8MB" if ESPTOOLPY_FLASHSIZE_8MB + default "16MB" if ESPTOOLPY_FLASHSIZE_16MB config ESPTOOLPY_FLASHSIZE_DETECT bool "Detect flash size when flashing bootloader" diff --git a/components/esptool_py/flash_app_args.in b/components/esptool_py/flash_app_args.in index 7cc24a6381..1e2fa31c23 100644 --- a/components/esptool_py/flash_app_args.in +++ b/components/esptool_py/flash_app_args.in @@ -1,4 +1 @@ ---flash_mode ${ESPFLASHMODE} ---flash_size ${ESPFLASHSIZE} ---flash_freq ${ESPFLASHFREQ} ${CONFIG_APP_OFFSET} ${PROJECT_NAME}.bin diff --git a/components/esptool_py/flash_partition_table_args.in b/components/esptool_py/flash_partition_table_args.in index f5bbe084c2..0983e11c4b 100644 --- a/components/esptool_py/flash_partition_table_args.in +++ b/components/esptool_py/flash_partition_table_args.in @@ -1,4 +1 @@ ---flash_mode ${ESPFLASHMODE} ---flash_size ${ESPFLASHSIZE} ---flash_freq ${ESPFLASHFREQ} 0x8000 partition_table/partition-table.bin diff --git a/components/esptool_py/flasher_args.json.in b/components/esptool_py/flasher_args.json.in index 0266316ea4..1d68a2bb99 100644 --- a/components/esptool_py/flasher_args.json.in +++ b/components/esptool_py/flasher_args.json.in @@ -4,8 +4,14 @@ "--flash_freq", "${ESPFLASHFREQ}" ], "flash_files" : { "0x1000" : "bootloader/bootloader.bin", - "0x8000" : "partition_table/partition-table.bin", + "${PARTITION_TABLE_OFFSET}" : "partition_table/partition-table.bin", "${CONFIG_APP_OFFSET}" : "${PROJECT_NAME}.bin", "${PHY_PARTITION_OFFSET}" : "${PHY_PARTITION_BIN_FILE}" - } + }, + "bootloader" : { "offset" : "0x1000", + "file" : "bootloader/bootloader.bin" }, + "app" : { "offset" : "${CONFIG_APP_OFFSET}", + "file" : "${PROJECT_NAME}.bin" }, + "partition_table" : { "offset" : "${PARTITION_TABLE_OFFSET}", + "file" : "partition_table/partition-table.bin" } } diff --git a/components/lwip/CMakeLists.txt b/components/lwip/CMakeLists.txt index d44424735a..2d362f288c 100644 --- a/components/lwip/CMakeLists.txt +++ b/components/lwip/CMakeLists.txt @@ -16,7 +16,7 @@ set(COMPONENT_SRCDIRS ${LWIP_PPP_DIRS} netif port/freertos port/netif port/debug port) -set(COMPONENT_REQUIRES "") +set(COMPONENT_REQUIRES vfs) set(COMPONENT_PRIV_REQUIRES ethernet tcpip_adapter) register_component() diff --git a/components/partition_table/CMakeLists.txt b/components/partition_table/CMakeLists.txt index 72ef78ff10..eae14ceb2f 100644 --- a/components/partition_table/CMakeLists.txt +++ b/components/partition_table/CMakeLists.txt @@ -1,5 +1,3 @@ -set(partition_table_offset 0x8000) - register_config_only_component() # Set partition_csv to the configured partition source file @@ -56,5 +54,5 @@ add_custom_target(partition_table ALL DEPENDS "${final_partition_bin}") # the list of esptool write arguments for flashing set_property(GLOBAL APPEND_STRING PROPERTY ESPTOOL_WRITE_FLASH_ARGS - "${partition_table_offset} ${final_partition_bin} ") + "${PARTITION_TABLE_OFFSET} ${final_partition_bin} ") diff --git a/components/partition_table/project_include.cmake b/components/partition_table/project_include.cmake new file mode 100644 index 0000000000..1658df30e8 --- /dev/null +++ b/components/partition_table/project_include.cmake @@ -0,0 +1 @@ +set(PARTITION_TABLE_OFFSET 0x8000) diff --git a/docs/en/api-guides/build-system.rst b/docs/en/api-guides/build-system.rst index 2135ca0a2a..f32cc9eb31 100644 --- a/docs/en/api-guides/build-system.rst +++ b/docs/en/api-guides/build-system.rst @@ -130,6 +130,23 @@ You can also use an IDE with CMake integration. The IDE will want to know the pa When adding custom non-build steps like "flash" to the IDE, it is recommended to execute ``idf.py`` for these "special" commands. +.. setting-python-interpreter: + +Setting the Python Interpreter +------------------------------ + +Currently, ESP-IDF only works with Python 2.7. If you have a system where the default ``python`` interpreter is Python 3.x, this can lead to problems. + +If using ``idf.py``, running ``idf.py`` as ``python2 $IDF_PATH/tools/idf.py ...`` will work around this issue (``idf.py`` will tell other Python processes to use the same Python interpreter). You can set up a shell alias or another script to simplify the command. + +If using CMake directly, running ``cmake -D PYTHON=python2 ...`` will cause CMake to override the default Python interpreter. + +If using an IDE with CMake, setting the ``PYTHON`` value as a CMake cache override in the IDE UI will override the default Python interpreter. + +To manage the Python version more generally via the command line, check out the tools pyenv_ or virtualenv_. These let you change the default python version. + +.. _example-project-structure: + Example Project =============== @@ -190,6 +207,8 @@ Minimal project:: project(myProject) +.. _project-mandatory-parts: + Mandatory Parts --------------- @@ -758,12 +777,23 @@ For project components (not part of ESP-IDF), there are a few options: The best option will depend on your particular project and its users. +Build System Metadata +===================== + +For integration into IDEs and other build systems, when CMake runs the build process generates a number of metadata files in the ``build/`` directory. To regenerate these files, run ``cmake`` or ``idf.py reconfigure`` (or any other ``idf.py`` build command). + +- ``compile_commands.json`` is a standard format JSON file which describes every source file which is compiled in the project. A CMake feature generates this file, and many IDEs know how to parse it. +- ``project_description.json`` contains some general information about the ESP-IDF project, configured paths, etc. +- ``flasher_args.json`` contains esptool.py arguments to flash the project's binary files. There are also ``flash_*_args`` files which can be used directly with esptool.py. See `Flash arguments`_. +- ``CMakeCache.txt`` is the CMake cache file which contains other information about the CMake process, toolchain, etc. +- ``config/sdkconfig.json`` is a JSON-formatted version of the project configuration values. + .. _gnu-make-to-cmake: Migrating from ESP-IDF GNU Make System ====================================== -Some aspects of the CMake-based ESP-IDF build system are very similar to the older GNU Make-based system. For example, to adapt a ``component.mk`` file to ``CMakeLists.txt`` variables like ``COMPONENT_SRCS`` and ``COMPONENT_SRCDIRS`` can stay the same and the syntax only needs changing to CMake syntax. +Some aspects of the CMake-based ESP-IDF build system are very similar to the older GNU Make-based system. For example, to adapt a ``component.mk`` file to ``CMakeLists.txt`` variables like ``COMPONENT_ADD_INCLUDEDIRS`` and ``COMPONENT_SRCDIRS`` can stay the same and the syntax only needs changing to CMake syntax. Automatic Conversion Tool ------------------------- @@ -782,6 +812,14 @@ It does so by running ``make`` to expand the ESP-IDF build system variables whic The conversion tool is not capable of dealing with complex Makefile logic or unusual targets. These will need to be converted by hand. +'main' is no longer a component +------------------------------- + +In the GNU Make build system ``main`` is a component with a ``component.mk`` file like other components. + +Due to CMake requirements for building executables, ``main`` source files are now linked directly into the final binary. The source files in ``main`` must be listed in the ``MAIN_SRCS`` variable (see :ref:`project mandatory variables ` for more details). At least one source file has to be listed here (although it doesn't need to contain anything in particular). + +In general, it's better not to have too many source files in ``MAIN_SRCS``. If you find that you are adding many source files here, see if you reorganize and group some into project components (see the :ref:`example project structure `, above). No Longer Available in CMake ---------------------------- @@ -793,10 +831,10 @@ Some features are significantly different or removed in the CMake-based system. - ``CC``, ``LD``, ``AR``, ``OBJCOPY``: Full paths to each tool from the gcc xtensa cross-toolchain. Use ``CMAKE_C_COMPILER``, ``CMAKE_C_LINK_EXECUTABLE``, ``CMAKE_OBJCOPY``, etc instead. `Full list here `_. - ``HOSTCC``, ``HOSTLD``, ``HOSTAR``: Full names of each tool from the host native toolchain. These are no longer provided, external projects should detect any required host toolchain manually. - ``COMPONENT_ADD_LDFLAGS``: Used to override linker flags. Use the CMake `target_link_libraries`_ command instead. -- ``COMPONENT_ADD_LINKER_DEPS``: List of files that linking should depend on. `target_link_libraries`_ will usually infer these dependencies automatically for files like linker scripts. -- ``COMPONENT_SUBMODULES``: No longer used by ESP-IDF components, the build system will automatically enumerate all submodules in the repo. +- ``COMPONENT_ADD_LINKER_DEPS``: List of files that linking should depend on. `target_link_libraries`_ will usually infer these dependencies automatically. For linker scripts, use the provided custom CMake function ``target_linker_scripts``. +- ``COMPONENT_SUBMODULES``: No longer used, the build system will automatically enumerate all submodules in the ESP-IDF repo. - ``COMPONENT_EXTRA_INCLUDES``: Used to be an alternative to ``COMPONENT_PRIV_INCLUDEDIRS`` for absolute paths. Use ``COMPONENT_PRIV_INCLUDEDIRS`` for all cases now (can be relative or absolute). -- ``COMPONENT_OBJS``: Used to be specified as a list of object files. Now specified as an optional list of source files via ``COMPONENT_SRCS``. +- ``COMPONENT_OBJS``: Previously, component sources could be specified as a list of object files. Now they can be specified as an list of source files via ``COMPONENT_SRCS``. - ``COMPONENT_EXTRA_CLEAN``: Set property ``ADDITIONAL_MAKE_CLEAN_FILES`` instead but note :ref:`CMake has some restrictions around this functionality `. - ``COMPONENT_OWNBUILDTARGET`` & ``COMPONENT_OWNCLEANTARGET``: Use CMake `ExternalProject`_ instead. See :ref:`component-build-full-override` for full details. - ``COMPONENT_CONFIG_ONLY``: Call ``register_config_only_component()`` instead. See `Configuration-Only Components`_. @@ -816,17 +854,6 @@ No Longer Necessary It is no longer necessary to set ``COMPONENT_SRCDIRS`` if setting ``COMPONENT_SRCS`` (in fact, in the CMake-based system ``COMPONENT_SRCDIRS`` is ignored if ``COMPONENT_SRCS`` is set). -Build System Metadata -===================== - -For integration into IDEs and other build systems, when cmake runs the build process generates a number of metadata files in the ``build/`` directory. To regenerate these files, run ``cmake`` or ``idf.py reconfigure`` (or any other ``idf.py`` build command). - -- ``compile_commands.json`` is a standard format JSON file which describes every source file which is compiled in the project. A CMake feature generates this file, and many IDEs know how to parse it. -- ``project_description.json`` contains some general information about the ESP-IDF project, configured paths, etc. -- ``flasher_args.json`` contains esptool.py arguments to flash the project's binary files. There are also ``flash_*_args`` files which can be used directly with esptool.py. See `Flash arguments`_. -- ``CMakeCache.txt`` is the CMake cache file which contains other information about the CMake process, toolchain, etc. -- ``sdkconfig.json`` is a JSON-formatted version of the project configuration values. - .. _esp-idf-template: https://github.com/espressif/esp-idf-template .. _cmake: https://cmake.org .. _ninja: https://ninja-build.org @@ -848,3 +875,6 @@ For integration into IDEs and other build systems, when cmake runs the build pro .. _target_link_libraries: https://cmake.org/cmake/help/v3.5/command/target_link_libraries.html#command:target_link_libraries .. _cmake_toolchain_file: https://cmake.org/cmake/help/v3.5/variable/CMAKE_TOOLCHAIN_FILE.html .. _quirc: https://github.com/dlbeer/quirc +.. _pyenv: https://github.com/pyenv/pyenv#README +.. _virtualenv: https://virtualenv.pypa.io/en/stable/ + diff --git a/docs/en/get-started/add-idf_path-to-profile.rst b/docs/en/get-started/add-idf_path-to-profile.rst index f775f901f9..5ba2fad5bc 100644 --- a/docs/en/get-started/add-idf_path-to-profile.rst +++ b/docs/en/get-started/add-idf_path-to-profile.rst @@ -39,16 +39,20 @@ If you got here from section :ref:`get-started-setup-path`, while installing s/w Linux and MacOS --------------- -Set up ``IDF_PATH`` and add ``idf.py`` to the PATH by adding the following two lines to ``~/.profile`` file:: +Set up ``IDF_PATH`` and add ``idf.py`` to the PATH by adding the following two lines to your ``~/.profile`` file:: export IDF_PATH=~/esp/esp-idf export PATH="$PATH:$IDF_PATH/tools" +.. note:: + + ``~/.profile`` means a file named ``.profile`` in your user's home directory (which is abbreviated ``~`` in the shell). + Log off and log in back to make this change effective. .. note:: - If you have ``/bin/bash`` set as login shell, and both ``.bash_profile`` and ``.profile`` exist, then update ``.bash_profile`` instead. + Not all shells use ``.profile``. If you have ``/bin/bash`` and ``.bash_profile`` exists then update this file instead. For ``zsh``, update ``.zprofile``. Other shells may use other profile files (consult the shell's documentation). Run the following command to check if ``IDF_PATH`` is set:: diff --git a/docs/en/get-started/establish-serial-connection.rst b/docs/en/get-started/establish-serial-connection.rst index 363de1ccee..ec8e4b1c58 100644 --- a/docs/en/get-started/establish-serial-connection.rst +++ b/docs/en/get-started/establish-serial-connection.rst @@ -54,6 +54,8 @@ MacOS :: ls /dev/cu.* +.. note: MacOS users: if you don't see the serial port then check you have the USB/serial drivers installed as shown in the Getting Started guide for your particular development board. For MacOS High Sierra (10.13), you may also have to explicitly allow the drivers to load. Open System Preferences -> Security & Privacy -> General and check if there is a message shown here about "System Software from developer ..." where the developer name is Silicon Labs or FTDI. + .. _linux-dialout-group: Adding user to ``dialout`` on Linux @@ -69,7 +71,7 @@ Make sure you re-login to enable read and write permissions for the serial port. Verify serial connection ------------------------ -Now verify that the serial connection is operational. You can do this using a serial terminal program. In this example we will use `PuTTY SSH Client `_ that is avilable for both Windows and Linux. You can use other serial program and set communication parameters like below. +Now verify that the serial connection is operational. You can do this using a serial terminal program. Windows and Linux users can use the `PuTTY SSH Client `_ for this. Alternatively, any other serial program can be used with the communication parameters shown below. Run terminal, set identified serial port, baud rate = 115200, data bits = 8, stop bits = 1, and parity = N. Below are example screen shots of setting the port and such transmission parameters (in short described as 115200-8-1-N) on Windows and Linux. Remember to select exactly the same serial port you have identified in steps above. diff --git a/docs/en/get-started/index.rst b/docs/en/get-started/index.rst index 39148baadb..c99fc669fd 100644 --- a/docs/en/get-started/index.rst +++ b/docs/en/get-started/index.rst @@ -2,7 +2,7 @@ Get Started *********** -This document is intended to help users set up the software environment for developement of applications using hardware based on the Espressif ESP32. Through a simple example we would like to illustrate how to use ESP-IDF (Espressif IoT Development Framework), including the menu based configuration, compiling the ESP-IDF and firmware download to ESP32 boards. +This document is intended to help users set up the software environment for development of applications using hardware based on the Espressif ESP32. Through a simple example we would like to illustrate how to use ESP-IDF (Espressif IoT Development Framework), including the menu based configuration, compiling the ESP-IDF and firmware download to ESP32 boards. .. note:: The CMake-based build system is currently in preview release. Documentation may have missing gaps, and you may enocunter bugs (please report these). To view documentation for the older GNU Make based build system, switch versions to the 'latest' master branch or a stable release. @@ -22,7 +22,8 @@ What You Need To develop applications for ESP32 you need: * **PC** loaded with either Windows, Linux or Mac operating system -* **Toolchain** to build the **Application** for ESP32 +* **Toolchain** to compile code for ESP32 +* **Build tools** CMake and Ninja to build a full **Application** for ESP32 * **ESP-IDF** that essentially contains API for ESP32 and scripts to operate the **Toolchain** * A text editor to write programs (**Projects**) in C, e.g. `Eclipse `_ * The **ESP32** board itself and a **USB cable** to connect it to the **PC** @@ -34,28 +35,23 @@ To develop applications for ESP32 you need: Development of applications for ESP32 -Preparation of development environment consists of three steps: +Development Environment Steps: 1. Setup of **Toolchain** -2. Getting of **ESP-IDF** from GitHub -3. Installation and configuration of **Eclipse** +2. Getting **ESP-IDF** from GitHub -You may skip the last step, if you prefer to use different editor. - -Having environment set up, you are ready to start the most interesting part - the application development. This process may be summarized in four steps: +Once the development environment is set up, we will follow these steps to create an ESP-IDF application: 1. Configuration of a **Project** and writing the code 2. Compilation of the **Project** and linking it to build an **Application** -3. Flashing (uploading) of the **Application** to **ESP32** -4. Monitoring / debugging of the **Application** - -See instructions below that will walk you through these steps. +3. Flashing (uploading) the compiled **Application** to **ESP32** over a USB/serial connection +4. Monitoring / debugging of the **Application** output via USB/serial -Guides -====== +Development Board Guides +======================== -If you have one of ESP32 development boards listed below, click on provided links to get you up and running. +If you have one of ESP32 development boards listed below, click on the link for hardware setup: .. toctree:: :maxdepth: 1 @@ -125,7 +121,7 @@ ESP-IDF will be downloaded into ``~/esp/esp-idf``. .. highlight:: batch -For Windows Command Prompt users, the equivalent commands are:: +For **Windows Command Prompt** users, the equivalent commands are:: mkdir %userprofile%\esp cd %userprofile%\esp @@ -176,7 +172,7 @@ Copy :example:`get-started/hello_world` to ``~/esp`` directory:: .. highlight:: batch -For Windows Command Prompt users, the equivalent commands are:: +For **Windows Command Prompt** users, the equivalent commands are:: cd %userprofile%\esp xcopy /e /i %IDF_PATH%\examples\get-started\hello_world hello_world @@ -187,7 +183,7 @@ It is also possible to build examples in-place, without copying them first. .. important:: - The esp-idf build system does not support spaces in paths to esp-idf or to projects. + The esp-idf build system does not support spaces in the path to either esp-idf or to projects. .. _get-started-connect: @@ -197,7 +193,6 @@ Connect You are almost there. To be able to proceed further, connect ESP32 board to PC, check under what serial port the board is visible and verify if serial communication works. If you are not sure how to do it, check instructions in section :doc:`establish-serial-connection`. Note the port number, as it will be required in the next step. - .. _get-started-configure: Configure @@ -212,9 +207,9 @@ Being in terminal window, go to directory of ``hello_world`` application by typi .. highlight:: batch -For Windows Command Prompt users:: +For **Windows Command Prompt** users:: - cd %userprofile%\esp + cd %userprofile%\esp\hello_world idf.py menuconfig .. note:: If you get an error about ``idf.py`` not being found, check the ``tools`` directory is part of your Path as described above in :ref:`get-started-setup-path`. If there is no ``idf.py`` in the ``tools`` directory, check you have the correct branch for the CMake preview as shown under :ref:`get-started-get-esp-idf`. @@ -235,7 +230,7 @@ If previous steps have been done correctly, the following menu will be displayed Here are couple of tips on navigation and use of ``menuconfig``: * Use up & down arrow keys to navigate the menu. -* Use Enter key to go into a submenu, Escape key to go out or to exit. +* Use Enter key to go into a submenu, Escape key to go up a level or exit. * Type ``?`` to see a help screen. Enter key exits the help screen. * Use Space key, or ``Y`` and ``N`` keys to enable (Yes) and disable (No) configuration items with checkboxes "``[*]``" * Pressing ``?`` while highlighting a configuration item displays help about that item. @@ -247,18 +242,52 @@ Here are couple of tips on navigation and use of ``menuconfig``: .. _get-started-build-flash: -Build and Flash -=============== +Build The Project and Flash +=========================== .. highlight:: bash -Now you can build and flash the application. Run:: +Now you can build the project. Run:: + + idf.py build + +This command will compile the application and all the ESP-IDF components, generate bootloader, partition table, and application binaries. + +.. highlight: none + +:: + $ idf.py build + Running cmake in directory /path/to/hello_world/build + Executing "cmake -G Ninja --warn-uninitialized /path/to/hello_world"... + Warn about uninitialized values. + -- Found Git: /usr/bin/git (found version "2.17.0") + -- Building empty aws_iot component due to configuration + -- Component names: ... + -- Component paths: ... + + ... (more lines of build system output) + + [527/527] Generating hello-world.bin + esptool.py v2.3.1 + + Project build complete. To flash, run this command: + ../../../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 + or run 'idf.py flash' + +If there are no errors, the build will finish by generating the firmware binary .bin file. + +Flash To A Device +================= + +Now you can flash the application to the ESP32 board. Run:: idf.py -p PORT flash Replace PORT with the name of your ESP32 board's serial port. On Windows, serial ports have names like ``COM1``. On MacOS, they start with ``/dev/cu.``. On Linux, they start with ``/dev/tty``. (See :doc:`establish-serial-connection` for full details.) -This will compile the application and all the ESP-IDF components, generate bootloader, partition table, and application binaries, and flash these binaries to your ESP32 board. +This step will flash the binaries that you just built to your ESP32 board. + +.. note:: Running ``idf.py build`` before ``idf.py flash`` is not actually necessary, the flash step will automatically build the project if required before flashing. .. highlight:: none @@ -295,7 +324,7 @@ This will compile the application and all the ESP-IDF components, generate bootl If there are no issues, at the end of build process, you should see messages describing progress of flashing the project binary image onto the ESP32. Finally, the module will be reset and "hello_world" application will be running there. -If you'd like to use the Eclipse IDE instead of running ``idf.py``, check out the :doc:`Eclipse guide `. +.. (Not currently supported) If you'd like to use the Eclipse IDE instead of running ``idf.py``, check out the :doc:`Eclipse guide `. .. _get-started-build-monitor: @@ -303,9 +332,9 @@ If you'd like to use the Eclipse IDE instead of running ``idf.py``, check out th Monitor ======= -To see if "hello_world" application is indeed running, type ``idf.py monitor``. This command is launching :doc:`IDF Monitor ` application:: +To see if "hello_world" application is indeed running, type ``idf.py -p PORT monitor``. This command is launching :doc:`IDF Monitor ` application:: - $ idf.py monitor + $ idf.py -p /dev/ttyUSB0 monitor Running idf_monitor in directory [...]/esp/hello_world/build Executing "python [...]/esp-idf/tools/idf_monitor.py -b 115200 [...]/esp/hello_world/build/hello-world.elf"... --- idf_monitor on /dev/ttyUSB0 115200 --- @@ -335,7 +364,7 @@ To exit the monitor use shortcut ``Ctrl+]``. e���)(Xn@�y.!��(�PW+)��Hn9a؅/9�!�t5��P�~�k��e�ea�5�jA ~zY��Y(1�,1�� e���)(Xn@�y.!Dr�zY(�jpi�|�+z5Ymvp - or monitor fails shortly after upload, your board is likely using 26MHz crystal, while the ESP-IDF assumes default of 40MHz. Exit the monitor, go back to the :ref:`menuconfig `, change :ref:`CONFIG_ESP32_XTAL_FREQ_SEL` to 26MHz, then :ref:`build and flash ` the application again. This is found under ``idf.py menuconfig`` under Component config --> ESP32-specific --> Main XTAL frequency. + or monitor fails shortly after upload, your board is likely using 26MHz crystal. Most development board designs use 40MHz and the ESP-IDF uses this default value. Exit the monitor, go back to the :ref:`menuconfig `, change :ref:`CONFIG_ESP32_XTAL_FREQ_SEL` to 26MHz, then :ref:`build and flash ` the application again. This is found under ``idf.py menuconfig`` under Component config --> ESP32-specific --> Main XTAL frequency. .. note:: @@ -367,9 +396,9 @@ Another solution is to update only what has changed. This method is useful if yo .. highlight:: batch -For Windows Command Prompt users:: +For **Windows Command Prompt** users:: - cd %userprofile%\esp + cd %userprofile%\esp\esp-idf git pull git submodule update --init --recursive @@ -377,7 +406,7 @@ The ``git pull`` command is fetching and merging changes from ESP-IDF repository .. highlight:: bash -If you would like to use specific release of ESP-IDF, e.g. `v2.1`, run:: +To use a specific release of ESP-IDF, e.g. `v2.1`, run:: cd ~/esp git clone https://github.com/espressif/esp-idf.git esp-idf-v2.1 @@ -387,7 +416,7 @@ If you would like to use specific release of ESP-IDF, e.g. `v2.1`, run:: .. highlight:: batch -For Windows Command Prompt users:: +For **Windows Command Prompt** users:: cd %userprofile%\esp git clone https://github.com/espressif/esp-idf.git esp-idf-v2.1 diff --git a/docs/en/get-started/macos-setup.rst b/docs/en/get-started/macos-setup.rst index a699c3bef6..fc9ffc9b3d 100644 --- a/docs/en/get-started/macos-setup.rst +++ b/docs/en/get-started/macos-setup.rst @@ -8,6 +8,8 @@ Standard Setup of Toolchain for Mac OS Install Prerequisites ===================== +ESP-IDF will use the version of Python installed by default on Mac OS. + - install pip:: sudo easy_install pip @@ -30,6 +32,13 @@ Install Prerequisites - It is strongly recommended to also install ccache_ for faster builds. If you have HomeBrew_, this can be done via ``brew install ccache`` or ``sudo port install ccache`` on MacPorts_. +.. note:: + If an error like this is shown during any step:: + + xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun + + Then you will need to install the XCode command line tools to continue. You can install these by running ``xcode-select --install``. + Toolchain Setup =============== diff --git a/docs/en/get-started/windows-setup-scratch.rst b/docs/en/get-started/windows-setup-scratch.rst index 9088976130..f7ee770816 100644 --- a/docs/en/get-started/windows-setup-scratch.rst +++ b/docs/en/get-started/windows-setup-scratch.rst @@ -45,10 +45,10 @@ Once Python is installed, open a Windows Command Prompt from the Start menu and pip install pyserial -MConf -^^^^^ +MConf for IDF +^^^^^^^^^^^^^ -Download the ESP-IDF customized version of the configuration tool mconf from the `mconf releases page `_. +Download the configuration tool mconf-idf from the `kconfig-frontends releases page `_. This is the ``mconf`` configuration tool with some minor customizations for ESP-IDF. This tool will also need to be unzipped to a directory which is then `added to your Path `_. diff --git a/docs/en/get-started/windows-setup.rst b/docs/en/get-started/windows-setup.rst index c9e1b70115..9b12e9d90e 100644 --- a/docs/en/get-started/windows-setup.rst +++ b/docs/en/get-started/windows-setup.rst @@ -23,9 +23,9 @@ ESP-IDF Tools Installer The easiest way to install ESP-IDF's prerequisites is to download the ESP-IDF Tools installer from this URL: -https://dl.espressif.com/dl/esp-idf-tools-setup-1.0.exe +https://dl.espressif.com/dl/esp-idf-tools-setup-1.1.exe -The installer will automatically install the ESP32 Xtensa gcc toolchain, Ninja_ build tool, and a customized configuration tool called mconf. The installer can also download and run installers for CMake_ and Python_ 2.7 if these are not already installed on the computer. +The installer will automatically install the ESP32 Xtensa gcc toolchain, Ninja_ build tool, and a configuration tool called mconf-idf_. The installer can also download and run installers for CMake_ and Python_ 2.7 if these are not already installed on the computer. By default, the installer updates the Windows ``Path`` environment variable so all of these tools can be run from anywhere. If you disable this option, you will need to configure the environment where you are using ESP-IDF (terminal or chosen IDE) with the correct paths. @@ -68,5 +68,5 @@ For advanced users who want to customize the install process: .. _ninja: https://ninja-build.org/ .. _Python: https://www.python.org/downloads/windows/ .. _Git for Windows: https://gitforwindows.org/ -.. _mconf: https://github.com/espressif/kconfig-frontends/releases/ +.. _mconf-idf: https://github.com/espressif/kconfig-frontends/releases/ .. _Github Desktop: https://desktop.github.com/ diff --git a/make/project_config.mk b/make/project_config.mk index 8f0006c795..50cf139e62 100644 --- a/make/project_config.mk +++ b/make/project_config.mk @@ -15,11 +15,11 @@ SDKCONFIG ?= $(PROJECT_PATH)/sdkconfig # overrides (usually used for esp-idf examples) SDKCONFIG_DEFAULTS ?= $(PROJECT_PATH)/sdkconfig.defaults -# Workaround to run make parallel (-j). mconf and conf cannot be made simultaneously -$(KCONFIG_TOOL_DIR)/mconf: $(KCONFIG_TOOL_DIR)/conf +# Workaround to run make parallel (-j). mconf-idf and conf-idf cannot be made simultaneously +$(KCONFIG_TOOL_DIR)/mconf-idf: $(KCONFIG_TOOL_DIR)/conf-idf # reset MAKEFLAGS as the menuconfig makefile uses implicit compile rules -$(KCONFIG_TOOL_DIR)/mconf $(KCONFIG_TOOL_DIR)/conf: $(wildcard $(KCONFIG_TOOL_DIR)/*.c) +$(KCONFIG_TOOL_DIR)/mconf-idf $(KCONFIG_TOOL_DIR)/conf-idf: $(wildcard $(KCONFIG_TOOL_DIR)/*.c) MAKEFLAGS="" CC=$(HOSTCC) LD=$(HOSTLD) \ $(MAKE) -C $(KCONFIG_TOOL_DIR) @@ -36,13 +36,14 @@ $(SDKCONFIG): defconfig endif endif -# macro for the commands to run kconfig tools conf or mconf. +# macro for the commands to run kconfig tools conf-idf or mconf-idf. # $1 is the name (& args) of the conf tool to run define RunConf mkdir -p $(BUILD_DIR_BASE)/include/config cd $(BUILD_DIR_BASE); KCONFIG_AUTOHEADER=$(abspath $(BUILD_DIR_BASE)/include/sdkconfig.h) \ COMPONENT_KCONFIGS="$(COMPONENT_KCONFIGS)" KCONFIG_CONFIG=$(SDKCONFIG) \ COMPONENT_KCONFIGS_PROJBUILD="$(COMPONENT_KCONFIGS_PROJBUILD)" \ + IDF_CMAKE=n \ $(KCONFIG_TOOL_DIR)/$1 $(IDF_PATH)/Kconfig endef @@ -58,7 +59,7 @@ ifndef MAKE_RESTARTS # depend on any prerequisite that may cause a make restart as part of # the prerequisite's own recipe. -menuconfig: $(KCONFIG_TOOL_DIR)/mconf +menuconfig: $(KCONFIG_TOOL_DIR)/mconf-idf $(summary) MENUCONFIG ifdef BATCH_BUILD @echo "Can't run interactive configuration inside non-interactive build process." @@ -67,25 +68,25 @@ ifdef BATCH_BUILD @echo "See esp-idf documentation for more details." @exit 1 else - $(call RunConf,mconf) + $(call RunConf,mconf-idf) endif # defconfig creates a default config, based on SDKCONFIG_DEFAULTS if present -defconfig: $(KCONFIG_TOOL_DIR)/conf +defconfig: $(KCONFIG_TOOL_DIR)/conf-idf $(summary) DEFCONFIG ifneq ("$(wildcard $(SDKCONFIG_DEFAULTS))","") cat $(SDKCONFIG_DEFAULTS) >> $(SDKCONFIG) # append defaults to sdkconfig, will override existing values endif - $(call RunConf,conf --olddefconfig) + $(call RunConf,conf-idf --olddefconfig) # if neither defconfig or menuconfig are requested, use the GENCONFIG rule to # ensure generated config files are up to date -$(SDKCONFIG_MAKEFILE) $(BUILD_DIR_BASE)/include/sdkconfig.h: $(KCONFIG_TOOL_DIR)/conf $(SDKCONFIG) $(COMPONENT_KCONFIGS) $(COMPONENT_KCONFIGS_PROJBUILD) | $(call prereq_if_explicit,defconfig) $(call prereq_if_explicit,menuconfig) +$(SDKCONFIG_MAKEFILE) $(BUILD_DIR_BASE)/include/sdkconfig.h: $(KCONFIG_TOOL_DIR)/conf-idf $(SDKCONFIG) $(COMPONENT_KCONFIGS) $(COMPONENT_KCONFIGS_PROJBUILD) | $(call prereq_if_explicit,defconfig) $(call prereq_if_explicit,menuconfig) $(summary) GENCONFIG ifdef BATCH_BUILD # can't prompt for new config values like on terminal - $(call RunConf,conf --olddefconfig) + $(call RunConf,conf-idf --olddefconfig) endif - $(call RunConf,conf --silentoldconfig) + $(call RunConf,conf-idf --silentoldconfig) touch $(SDKCONFIG_MAKEFILE) $(BUILD_DIR_BASE)/include/sdkconfig.h # ensure newer than sdkconfig else # "$(MAKE_RESTARTS)" != "" diff --git a/tools/cmake/idf_functions.cmake b/tools/cmake/idf_functions.cmake index 3415f9da29..bd0aea6e55 100644 --- a/tools/cmake/idf_functions.cmake +++ b/tools/cmake/idf_functions.cmake @@ -98,8 +98,6 @@ function(idf_set_global_compiler_options) # go into the final binary so have no impact on size) add_compile_options(-ggdb) - add_compile_options("-I${CMAKE_BINARY_DIR}") # for sdkconfig.h - # Enable ccache if it's on the path if(NOT CCACHE_DISABLE) find_program(CCACHE_FOUND ccache) diff --git a/tools/cmake/kconfig.cmake b/tools/cmake/kconfig.cmake index eeb8ce1139..478b73e348 100644 --- a/tools/cmake/kconfig.cmake +++ b/tools/cmake/kconfig.cmake @@ -1,27 +1,41 @@ include(ExternalProject) macro(kconfig_set_variables) + set(CONFIG_DIR ${CMAKE_BINARY_DIR}/config) set_default(SDKCONFIG ${PROJECT_PATH}/sdkconfig) - set(SDKCONFIG_HEADER ${CMAKE_BINARY_DIR}/sdkconfig.h) - set(SDKCONFIG_CMAKE ${CMAKE_BINARY_DIR}/sdkconfig.cmake) - set(SDKCONFIG_JSON ${CMAKE_BINARY_DIR}/sdkconfig.json) + set(SDKCONFIG_HEADER ${CONFIG_DIR}/sdkconfig.h) + set(SDKCONFIG_CMAKE ${CONFIG_DIR}/sdkconfig.cmake) + set(SDKCONFIG_JSON ${CONFIG_DIR}/sdkconfig.json) set(ROOT_KCONFIG ${IDF_PATH}/Kconfig) set_default(SDKCONFIG_DEFAULTS "${SDKCONFIG}.defaults") + + # ensure all source files can include sdkconfig.h + include_directories("${CONFIG_DIR}") endmacro() if(CMAKE_HOST_WIN32) - # Prefer a prebuilt mconf on Windows + # Prefer a prebuilt mconf-idf on Windows find_program(WINPTY winpty) - find_program(MCONF mconf) + find_program(MCONF mconf-idf) + + # Fall back to the old binary which was called 'mconf' not 'mconf-idf' + if(NOT MCONF) + find_program(MCONF mconf) + if(MCONF) + message(WARNING "Falling back to mconf binary '${MCONF}' not mconf-idf. " + "This is probably because an old version of IDF mconf is installed and this is fine. " + "However if there are config problems please check the Getting Started guide for your platform.") + endif() + endif() if(NOT MCONF) find_program(NATIVE_GCC gcc) if(NOT NATIVE_GCC) message(FATAL_ERROR - "Windows requires a prebuilt ESP-IDF-specific mconf for your platform " - "on the PATH, or an MSYS2 version of gcc on the PATH to build mconf. " + "Windows requires a prebuilt mconf-idf for your platform " + "on the PATH, or an MSYS2 version of gcc on the PATH to build mconf-idf. " "Consult the setup docs for ESP-IDF on Windows.") endif() elseif(WINPTY) @@ -32,23 +46,32 @@ endif() if(NOT MCONF) # Use the existing Makefile to build mconf (out of tree) when needed # - set(MCONF kconfig_bin/mconf) + set(MCONF kconfig_bin/mconf-idf) - externalproject_add(mconf + externalproject_add(mconf-idf SOURCE_DIR ${IDF_PATH}/tools/kconfig CONFIGURE_COMMAND "" BINARY_DIR "kconfig_bin" - BUILD_COMMAND make -f ${IDF_PATH}/tools/kconfig/Makefile mconf + BUILD_COMMAND make -f ${IDF_PATH}/tools/kconfig/Makefile mconf-idf BUILD_BYPRODUCTS ${MCONF} INSTALL_COMMAND "" EXCLUDE_FROM_ALL 1 ) - set(menuconfig_depends DEPENDS mconf) + + file(GLOB mconf_srcfiles ${IDF_PATH}/tools/kconfig/*.c) + externalproject_add_stepdependencies(mconf-idf build + ${mconf_srcfiles} + ${IDF_PATH}/tools/kconfig/Makefile + ${CMAKE_CURRENT_LIST_FILE}) + unset(mconf_srcfiles) + + set(menuconfig_depends DEPENDS mconf-idf) + endif() # Find all Kconfig files for all components function(kconfig_process_config) - file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/include/config") + file(MAKE_DIRECTORY "${CONFIG_DIR}") set(kconfigs) set(kconfigs_projbuild) @@ -83,9 +106,10 @@ function(kconfig_process_config) ${defaults_arg} --create-config-if-missing --env "COMPONENT_KCONFIGS=${kconfigs}" - --env "COMPONENT_KCONFIGS_PROJBUILD=${kconfigs_projbuild}") + --env "COMPONENT_KCONFIGS_PROJBUILD=${kconfigs_projbuild}" + --env "IDF_CMAKE=y") - # Generate the menuconfig target (uses C-based mconf tool, either prebuilt or via mconf target above) + # Generate the menuconfig target (uses C-based mconf-idf tool, either prebuilt or via mconf-idf target above) add_custom_target(menuconfig ${menuconfig_depends} # create any missing config file, with defaults if necessary @@ -93,6 +117,7 @@ function(kconfig_process_config) COMMAND ${CMAKE_COMMAND} -E env "COMPONENT_KCONFIGS=${kconfigs}" "COMPONENT_KCONFIGS_PROJBUILD=${kconfigs_projbuild}" + "IDF_CMAKE=y" "KCONFIG_CONFIG=${SDKCONFIG}" ${MCONF} ${ROOT_KCONFIG} VERBATIM diff --git a/tools/cmake/utilities.cmake b/tools/cmake/utilities.cmake index 791e3fbfa5..e1c682c898 100644 --- a/tools/cmake/utilities.cmake +++ b/tools/cmake/utilities.cmake @@ -9,7 +9,7 @@ # function(set_default variable default_value) if(NOT ${variable}) - if($ENV{${variable}}) + if(DEFINED ENV{${variable}} AND NOT "$ENV{${variable}}" STREQUAL "") set(${variable} $ENV{${variable}} PARENT_SCOPE) else() set(${variable} ${default_value} PARENT_SCOPE) @@ -132,7 +132,7 @@ endmacro() # Append a single line to the file specified # The line ending is determined by the host OS function(file_append_line file line) - if(ENV{MSYSTEM} OR CMAKE_HOST_WIN32) + if(DEFINED ENV{MSYSTEM} OR CMAKE_HOST_WIN32) set(line_ending "\r\n") else() # unix set(line_ending "\n") diff --git a/tools/idf.py b/tools/idf.py index d5fbf279a3..8b2c058fb4 100755 --- a/tools/idf.py +++ b/tools/idf.py @@ -309,6 +309,54 @@ def fullclean(action, args): else: os.remove(f) +def print_closing_message(args): + # print a closing message of some kind + # + + if "flash" in str(args.actions): + print("Done") + return + + # Otherwise, if we built any binaries print a message about + # how to flash them + def print_flashing_message(title, key): + print("\n%s build complete. To flash, run this command:" % title) + + with open(os.path.join(args.build_dir, "flasher_args.json")) as f: + flasher_args = json.load(f) + + def flasher_path(f): + return os.path.relpath(os.path.join(args.build_dir, f)) + + if key != "project": + cmd = "" + if key == "bootloader": + cmd = " ".join(flasher_args["write_flash_args"]) + " " + + cmd += flasher_args[key]["offset"] + " " + cmd += flasher_path(flasher_args[key]["file"]) + else: + cmd = " ".join(flasher_args["write_flash_args"]) + " " + for o,f in flasher_args["flash_files"].items(): + cmd += o + " " + flasher_path(f) + " " + + print("%s -p %s -b %s write_flash %s" % ( + os.path.relpath("%s/components/esptool_py/esptool/esptool.py" % os.environ["IDF_PATH"]), + args.port or "(PORT)", + args.baud, + cmd.strip())) + print("or run 'idf.py %s'" % (key + "-flash" if key != "project" else "flash",)) + + if "all" in args.actions or "build" in args.actions: + print_flashing_message("Project", "project") + else: + if "app" in args.actions: + print_flashing_message("App", "app") + if "partition_table" in args.actions: + print_flashing_message("Partition Table", "partition_table") + if "bootloader" in args.actions: + print_flashing_message("Bootloader", "bootloader") + ACTIONS = { # action name : ( function (or alias), dependencies, order-only dependencies ) "all" : ( build_target, [], [ "reconfigure", "menuconfig", "clean", "fullclean" ] ), @@ -343,8 +391,10 @@ def get_commandline_options(): result.append(a) return result - def main(): + if sys.version_info[0] != 2 or sys.version_info[1] != 7: + raise FatalError("ESP-IDF currently only supports Python 2.7, and this is Python %d.%d.%d. Search for 'Setting the Python Interpreter' in the ESP-IDF docs for some tips to handle this." % sys.version_info[:3]) + parser = argparse.ArgumentParser(description='ESP-IDF build management tool') parser.add_argument('-p', '--port', help="Serial port", default=os.environ.get('ESPPORT', None)) @@ -391,10 +441,12 @@ def main(): completed_actions.add(action) - while len(args.actions) > 0: - execute_action(args.actions[0], args.actions[1:]) - args.actions.pop(0) + actions = list(args.actions) + while len(actions) > 0: + execute_action(actions[0], actions[1:]) + actions.pop(0) + print_closing_message(args) if __name__ == "__main__": try: diff --git a/tools/idf_monitor.py b/tools/idf_monitor.py index 29347efc94..278626657f 100755 --- a/tools/idf_monitor.py +++ b/tools/idf_monitor.py @@ -3,8 +3,8 @@ # esp-idf serial output monitor tool. Does some helpful things: # - Looks up hex addresses in ELF file with addr2line # - Reset ESP32 via serial RTS line (Ctrl-T Ctrl-R) -# - Run "make/idf.py flash" (Ctrl-T Ctrl-F) -# - Run "make/idf.py app-flash" (Ctrl-T Ctrl-A) +# - Run "make (or idf.py) flash" (Ctrl-T Ctrl-F) +# - Run "make (or idf.py) app-flash" (Ctrl-T Ctrl-A) # - If gdbstub output is detected, gdb is automatically loaded # # Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD diff --git a/tools/kconfig/.gitignore b/tools/kconfig/.gitignore index 1950c8cb1b..641b9e576d 100644 --- a/tools/kconfig/.gitignore +++ b/tools/kconfig/.gitignore @@ -16,7 +16,9 @@ gconf.glade.h # configuration programs # conf +conf-idf mconf +mconf-idf nconf qconf gconf diff --git a/tools/kconfig/Makefile b/tools/kconfig/Makefile index c8a56abdd1..c8f8ba0141 100644 --- a/tools/kconfig/Makefile +++ b/tools/kconfig/Makefile @@ -43,7 +43,7 @@ endif endif # MING32 endif # MSYSTEM -default: mconf conf +default: mconf-idf conf-idf xconfig: qconf $< $(silent) $(Kconfig) @@ -51,41 +51,41 @@ xconfig: qconf gconfig: gconf $< $(silent) $(Kconfig) -menuconfig: mconf +menuconfig: mconf-idf $< $(silent) $(Kconfig) -config: conf +config: conf-idf $< $(silent) --oldaskconfig $(Kconfig) nconfig: nconf $< $(silent) $(Kconfig) -silentoldconfig: conf +silentoldconfig: conf-idf mkdir -p include/config include/generated $< $(silent) --$@ $(Kconfig) -localyesconfig localmodconfig: streamline_config.pl conf +localyesconfig localmodconfig: streamline_config.pl conf-idf mkdir -p include/config include/generated perl $< --$@ . $(Kconfig) > .tmp.config if [ -f .config ]; then \ cmp -s .tmp.config .config || \ (mv -f .config .config.old.1; \ mv -f .tmp.config .config; \ - conf $(silent) --silentoldconfig $(Kconfig); \ + conf-idf $(silent) --silentoldconfig $(Kconfig); \ mv -f .config.old.1 .config.old) \ else \ mv -f .tmp.config .config; \ - conf $(silent) --silentoldconfig $(Kconfig); \ + conf-idf $(silent) --silentoldconfig $(Kconfig); \ fi rm -f .tmp.config -# These targets map 1:1 to the commandline options of 'conf' +# These targets map 1:1 to the commandline options of 'conf-idf' simple-targets := oldconfig allnoconfig allyesconfig allmodconfig \ alldefconfig randconfig listnewconfig olddefconfig PHONY += $(simple-targets) -$(simple-targets): conf +$(simple-targets): conf-idf $< $(silent) --$@ $(Kconfig) PHONY += oldnoconfig savedefconfig defconfig @@ -95,10 +95,10 @@ PHONY += oldnoconfig savedefconfig defconfig # counter-intuitive name. oldnoconfig: olddefconfig -savedefconfig: conf +savedefconfig: conf-idf $< $(silent) --$@=defconfig $(Kconfig) -defconfig: conf +defconfig: conf-idf ifeq ($(KBUILD_DEFCONFIG),) $< $(silent) --defconfig $(Kconfig) else @@ -111,12 +111,12 @@ else endif endif -%_defconfig: conf +%_defconfig: conf-idf $< $(silent) --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig) configfiles=$(wildcard $(srctree)/kernel/configs/$@ $(srctree)/arch/$(SRCARCH)/configs/$@) -%.config: conf +%.config: conf-idf $(if $(call configfiles),, $(error No configuration exists for this target on this architecture)) $(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh -m .config $(configfiles) +yes "" | $(MAKE) -f $(srctree)/Makefile oldconfig @@ -178,10 +178,10 @@ lxdialog/%.o: $(SRCDIR)/lxdialog/%.c # =========================================================================== # Shared Makefile for the various kconfig executables: -# conf: Used for defconfig, oldconfig and related targets +# conf-idf: Used for defconfig, oldconfig and related targets # nconf: Used for the nconfig target. # Utilizes ncurses -# mconf: Used for the menuconfig target +# mconf-idf: Used for the menuconfig target # Utilizes the lxdialog package # qconf: Used for the xconfig target # Based on Qt which needs to be installed to compile it @@ -200,14 +200,15 @@ qconf-cxxobjs := qconf.o qconf-objs := zconf.tab.o gconf-objs := gconf.o zconf.tab.o -hostprogs-y := conf nconf mconf kxgettext qconf gconf +hostprogs-y := conf-idf nconf mconf-idf kxgettext qconf gconf all-objs := $(conf-objs) $(mconf-objs) $(lxdialog) all-deps := $(all-objs:.o=.d) clean-files := qconf.moc .tmp_qtcheck .tmp_gtkcheck clean-files += zconf.tab.c zconf.lex.c zconf.hash.c gconf.glade.h -clean-files += $(all-objs) $(all-deps) conf mconf +clean-files += $(all-objs) $(all-deps) conf-idf mconf-idf conf mconf +# (note: cleans both mconf & conf (old names) and conf-idf & mconf-idf (new names)) # Check that we have the required ncurses stuff installed for lxdialog (menuconfig) PHONY += dochecklxdialog @@ -324,10 +325,10 @@ gconf.glade.h: gconf.glade gconf.glade -mconf: lxdialog $(mconf-objs) +mconf-idf: lxdialog $(mconf-objs) $(CC) -o $@ $(mconf-objs) $(LOADLIBES_mconf) -conf: $(conf-objs) +conf-idf: $(conf-objs) $(CC) -o $@ $(conf-objs) $(LOADLIBES_conf) zconf.tab.c: zconf.lex.c diff --git a/tools/kconfig/mconf.c b/tools/kconfig/mconf.c index 315ce2c7cb..75fe116357 100644 --- a/tools/kconfig/mconf.c +++ b/tools/kconfig/mconf.c @@ -980,11 +980,17 @@ static int handle_exit(void) } /* fall through */ case -1: - if (!silent) + if (!silent) { + const char *is_cmake = getenv("IDF_CMAKE"); + const char *build_msg; + if (is_cmake && is_cmake[0] == 'y') + build_msg = _("Ready to use CMake (or 'idf.py build') to build the project."); + else + build_msg = _("Execute 'make' to start the build or try 'make help'."); printf(_("\n\n" - "*** End of the configuration.\n" - "*** Execute 'make' to start the build or try 'make help'." - "\n\n")); + "*** End of the configuration.\n" + "*** %s\n\n"), build_msg); + } res = 0; break; default: diff --git a/tools/kconfig_new/kconfiglib.py b/tools/kconfig_new/kconfiglib.py index 527c5a55a2..a8522a5c89 100644 --- a/tools/kconfig_new/kconfiglib.py +++ b/tools/kconfig_new/kconfiglib.py @@ -924,7 +924,7 @@ class Kconfig(object): def write_node(node): item = node.item - if isinstance(item, Symbol): + if isinstance(item, Symbol) and item.env_var is None: config_string = item.config_string if config_string: write(config_string) diff --git a/tools/windows/tool_setup/build_installer.sh b/tools/windows/tool_setup/build_installer.sh index 8733629b61..8dc21f1de2 100755 --- a/tools/windows/tool_setup/build_installer.sh +++ b/tools/windows/tool_setup/build_installer.sh @@ -13,14 +13,14 @@ set -e cd `dirname $0` pushd dl wget --continue "https://dl.espressif.com/dl/xtensa-esp32-elf-win32-1.22.0-80-g6c4433a-5.2.0.zip" -wget --continue "https://github.com/espressif/kconfig-frontends/releases/download/v4.6.0.0-idf-20180319/mconf-v4.6.0.0-idf-20180319-win32.zip" +wget --continue "https://github.com/espressif/kconfig-frontends/releases/download/v4.6.0.0-idf-20180525/mconf-v4.6.0.0-idf-20180525-win32.zip" wget --continue "https://github.com/ninja-build/ninja/releases/download/v1.8.2/ninja-win.zip" popd rm -rf input/* pushd input unzip ../dl/xtensa-esp32-elf-win32-1.22.0-80-g6c4433a-5.2.0.zip -unzip ../dl/mconf-v4.6.0.0-idf-20180319-win32.zip +unzip ../dl/mconf-v4.6.0.0-idf-20180525-win32.zip unzip ../dl/ninja-win.zip popd diff --git a/tools/windows/tool_setup/idf_tool_setup.iss b/tools/windows/tool_setup/idf_tool_setup.iss index 8c888e8f02..551c5abcbd 100644 --- a/tools/windows/tool_setup/idf_tool_setup.iss +++ b/tools/windows/tool_setup/idf_tool_setup.iss @@ -2,8 +2,8 @@ [Setup] AppName=ESP-IDF Tools -AppVersion=1.0 -OutputBaseFilename=esp-idf-tools-setup-1.0 +AppVersion=1.1 +OutputBaseFilename=esp-idf-tools-setup-1.1 DefaultDirName={pf}\Espressif\ESP-IDF Tools DefaultGroupName=ESP-IDF Tools @@ -22,7 +22,7 @@ Name: "custom"; Description: "Custom installation"; Flags: iscustom [Components] Name: toolchain; Description: ESP32 Xtensa GCC Cross-Toolchain; Types: full custom; -Name: mconf; Description: ESP-IDF console menuconfig tool; Types: full custom; +Name: mconf_idf; Description: ESP-IDF console menuconfig tool; Types: full custom; Name: ninja; Description: Install Ninja build v1.8.2; Types: full custom [Tasks] @@ -42,7 +42,7 @@ Name: python64; Description: Download and Run Python 2.7.14 Installer and instal [Files] Components: toolchain; Source: "input\xtensa-esp32-elf\*"; DestDir: "{app}\toolchain\"; Flags: recursesubdirs; -Components: mconf; Source: "input\mconf-v4.6.0.0-idf-20180319-win32\*"; DestDir: "{app}\mconf\"; +Components: mconf_idf; Source: "input\mconf-v4.6.0.0-idf-20180525-win32\*"; DestDir: "{app}\mconf-idf\"; Components: ninja; Source: "input\ninja.exe"; DestDir: "{app}"; [Run] @@ -61,13 +61,13 @@ Root: HKCU; Subkey: "Environment"; \ ValueType: expandsz; ValueName: "Path"; ValueData: "{app};{olddata}"; Check: not IsInPath('{app}'); \ Components: ninja; Tasks: addpath\user -; mconf path +; mconf-idf path Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; \ - ValueType: expandsz; ValueName: "Path"; ValueData: "{app}\mconf;{olddata}"; Check: not IsInPath('{app}\mconf'); \ - Components: mconf; Tasks: addpath\allusers + ValueType: expandsz; ValueName: "Path"; ValueData: "{app}\mconf-idf;{olddata}"; Check: not IsInPath('{app}\mconf-idf'); \ + Components: mconf_idf; Tasks: addpath\allusers Root: HKCU; Subkey: "Environment"; \ - ValueType: expandsz; ValueName: "Path"; ValueData: "{app}\mconf;{olddata}"; Check: not IsInPath('{app}\mconf'); \ - Components: mconf; Tasks: addpath\user + ValueType: expandsz; ValueName: "Path"; ValueData: "{app}\mconf-idf;{olddata}"; Check: not IsInPath('{app}\mconf-idf'); \ + Components: mconf_idf; Tasks: addpath\user ; toolchain path Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; \