ESP32

Note that $ means host terminal, and # means Ubuntu terminal on Docker.

  1. Install Docker on host machine.
  2. Insert USB cable from ESP32 board into host machine.
  3. Determine serial port name on host machine:

     $ ls /dev/tty*
     /dev/ttyUSB0
    
  4. $ docker run -it --device=/dev/ttyUSB0 ubuntu bash

  5. # cd ~
  6. # apt update
  7. # apt-get install nano
  8. # apt install screen
  9. Verify serial connection from Docker to ESP32 board:

     # screen /dev/ttyUSB0 115200
    
  10. Exit screen with Ctrl-A + k + y.

  11. Browse to Standard Setup of Toolchain for Linux.
  12. # apt-get install gcc git wget make libncurses-dev flex bison gperf python python-pip python-setuptools python-serial python-cryptography python-future python-pyparsing python-pyelftools
  13. # mkdir ~/esp
  14. Download ESP32 toolchain for 64-bit Linux (e.g. xtensa-esp32-elf-gcc8_2_0-esp32-2019r1-linux-amd64.tar.gz) to host machine.
  15. $ docker cp xtensa-esp32-elf-gcc8_2_0-esp32-2019r1-linux-amd64.tar.gz 2c42dd04b822:/root/esp
  16. # cd ~/esp
  17. # tar -xzf xtensa-esp32-elf-gcc8_2_0-esp32-2019r1-linux-amd64.tar.gz
  18. # export PATH=$HOME/esp/xtensa-esp32-elf/bin:$PATH
  19. # git clone --recursive https://github.com/espressif/esp-idf.git
  20. # export IDF_PATH=$HOME/esp/esp-idf
  21. # pip2 install -r $IDF_PATH/requirements.txt

Hello World Example

  1. # cd ~/esp/esp-idf/examples/get-started/hello_world
  2. # make menuconfig to customize. Defaults, however, should work.
  3. # make
  4. # make flash
  5. # make monitor
  6. Press Ctl + ] to exit the monitor.
  7. # make clean

Console Example

  1. # cd ~/esp/esp-idf/examples/system/console
  2. # make
  3. # make flash
  4. # make monitor
  5. Test the console:

     esp32> help
     help
       Print the list of registered commands
     free
       Get the total size of heap memory available
     restart
       Restart the program
     ...
    
  6. Press Ctl + ] to exit the monitor.

Prepare to Run Ayla Example

  1. Revert to version needed by Ayla software:

     # cd ~/esp/esp-idf
     # git branch                 # master
     # git checkout v3.2          # Deletes $IDF_PATH/requirements.txt.
     # git branch                 # (HEAD detached at v3.2) master
     # git submodule update       # Updates about five submodules.
     # git show                   # Shoes id, author, date.</pre>
    
  2. Re-make the Hello World Example. Search page to see warnings and errors below.

     # make
     make[1]: Entering directory '/root/esp/esp-idf/tools/kconfig'
     cc -c  -DCURSES_LOC="<ncurses.h>" -DLOCALE -MMD  /root/esp/esp-idf/tools/kconfig/mconf.c -o mconf.o
     flex -L -Pzconf -ozconf.lex.c /root/esp/esp-idf/tools/kconfig/zconf.l
     bison -t -l -p zconf -o zconf.tab.c /root/esp/esp-idf/tools/kconfig/zconf.y
     sed -E "s/\\x0D$//" /root/esp/esp-idf/tools/kconfig/zconf.gperf | gperf -t --output-file zconf.hash.c -a -C -E -g -k '1,3,$' -p -t
     cc -I /root/esp/esp-idf/tools/kconfig -c  -DCURSES_LOC="<ncurses.h>" -DLOCALE -MMD  zconf.tab.c -o zconf.tab.o
     /root/esp/esp-idf/tools/kconfig/lxdialog/check-lxdialog.sh -check cc  -DCURSES_LOC="<ncurses.h>" -DLOCALE -MMD -lncurses
     cc -c  -DCURSES_LOC="<ncurses.h>" -DLOCALE -MMD  /root/esp/esp-idf/tools/kconfig/lxdialog/checklist.c -o lxdialog/checklist.o
     cc -c  -DCURSES_LOC="<ncurses.h>" -DLOCALE -MMD  /root/esp/esp-idf/tools/kconfig/lxdialog/util.c -o lxdialog/util.o
     cc -c  -DCURSES_LOC="<ncurses.h>" -DLOCALE -MMD  /root/esp/esp-idf/tools/kconfig/lxdialog/inputbox.c -o lxdialog/inputbox.o
     cc -c  -DCURSES_LOC="<ncurses.h>" -DLOCALE -MMD  /root/esp/esp-idf/tools/kconfig/lxdialog/textbox.c -o lxdialog/textbox.o
     cc -c  -DCURSES_LOC="<ncurses.h>" -DLOCALE -MMD  /root/esp/esp-idf/tools/kconfig/lxdialog/yesno.c -o lxdialog/yesno.o
     cc -c  -DCURSES_LOC="<ncurses.h>" -DLOCALE -MMD  /root/esp/esp-idf/tools/kconfig/lxdialog/menubox.c -o lxdialog/menubox.o
     cc -o mconf-idf mconf.o zconf.tab.o lxdialog/checklist.o lxdialog/util.o lxdialog/inputbox.o lxdialog/textbox.o lxdialog/yesno.o lxdialog/menubox.o -lncurses
     cc -c  -DCURSES_LOC="<ncurses.h>" -DLOCALE -MMD  /root/esp/esp-idf/tools/kconfig/conf.c -o conf.o
     cc -o conf-idf conf.o  zconf.tab.o -lncurses
     make[1]: Leaving directory '/root/esp/esp-idf/tools/kconfig'
     GENCONFIG
     *
     * Restart config...
     *
     *
     * Amazon Web Services IoT Platform
     *
     Amazon Web Services IoT Platform (AWS_IOT_SDK) [N/y/?] (NEW) 
     *
     * Ethernet
     *
     Number of DMA RX buffers (DMA_RX_BUF_NUM) [10] (NEW) 
     Number of DMA TX buffers (DMA_TX_BUF_NUM) [10] (NEW) 
     Enable received buffers be copied to Layer3 from Layer2 (EMAC_L2_TO_L3_RX_BUF_MODE) [Y/n/?] (NEW) 
     Period (ms) of checking Ethernet linkup status (EMAC_CHECK_LINK_PERIOD_MS) [2000] (NEW) 
     EMAC_TASK_PRIORITY (EMAC_TASK_PRIORITY) [20] (NEW) 
     Stack Size of EMAC Task (EMAC_TASK_STACK_SIZE) [3072] (NEW) 
     *
     * TCP
     *
     Maximum active TCP Connections (LWIP_MAX_ACTIVE_TCP) [16] 16
     Maximum listening TCP Connections (LWIP_MAX_LISTENING_TCP) [16] 16
     Maximum number of retransmissions of data segments (TCP_MAXRTX) [12] 12
     Maximum number of retransmissions of SYN segments (TCP_SYNMAXRTX) [6] 6
     Maximum Segment Size (MSS) (TCP_MSS) [1436] (NEW) 
     Maximum segment lifetime (MSL) (TCP_MSL) [60000] 60000
     Default send buffer size (TCP_SND_BUF_DEFAULT) [5744] 5744
     Default receive window size (TCP_WND_DEFAULT) [5744] 5744
     Default TCP receive mail box size (TCP_RECVMBOX_SIZE) [6] 6
     Queue incoming out-of-order segments (TCP_QUEUE_OOSEQ) [Y/n/?] y
     Keep TCP connections when IP changed (ESP_TCP_KEEP_CONNECTION_WHEN_IP_CHANGES) [N/y/?] n
     Pre-allocate transmit PBUF size
     > 1. MSS (TCP_OVERSIZE_MSS)
       2. 25% MSS (TCP_OVERSIZE_QUARTER_MSS)
       3. Disabled (TCP_OVERSIZE_DISABLE)
     choice[1-3?]: 1
     *
     * mbedTLS
     *
     Memory allocation strategy
     > 1. Internal memory (MBEDTLS_INTERNAL_MEM_ALLOC)
       2. Default alloc mode (MBEDTLS_DEFAULT_MEM_ALLOC)
       3. Custom alloc mode (MBEDTLS_CUSTOM_MEM_ALLOC)
     choice[1-3?]: 1
     TLS maximum message content length (MBEDTLS_SSL_MAX_CONTENT_LEN) [16384] 16384
     Asymmetric in/out fragment length (MBEDTLS_ASYMMETRIC_CONTENT_LEN) [N/y/?] n
     Enable mbedTLS debugging (MBEDTLS_DEBUG) [N/y/?] n
     Enable hardware AES acceleration (MBEDTLS_HARDWARE_AES) [Y/n/?] y
     Enable hardware MPI (bignum) acceleration (MBEDTLS_HARDWARE_MPI) [N/y/?] n
     Enable hardware SHA acceleration (MBEDTLS_HARDWARE_SHA) [N/y/?] n
     Enable mbedtls time (MBEDTLS_HAVE_TIME) [Y/n/?] y
       Enable mbedtls certificate expiry check (MBEDTLS_HAVE_TIME_DATE) [N/y/?] n
     TLS Protocol Role
     > 1. Server & Client (MBEDTLS_TLS_SERVER_AND_CLIENT)
       2. Server (MBEDTLS_TLS_SERVER_ONLY)
       3. Client (MBEDTLS_TLS_CLIENT_ONLY)
       4. None (MBEDTLS_TLS_DISABLED)
     choice[1-4?]: 1
     Support TLS renegotiation (MBEDTLS_SSL_RENEGOTIATION) [Y/n/?] y
     Legacy SSL 3.0 support (MBEDTLS_SSL_PROTO_SSL3) [N/y/?] n
     Support TLS 1.0 protocol (MBEDTLS_SSL_PROTO_TLS1) [Y/n] y
     Support TLS 1.1 protocol (MBEDTLS_SSL_PROTO_TLS1_1) [Y/n] y
     Support TLS 1.2 protocol (MBEDTLS_SSL_PROTO_TLS1_2) [Y/n] y
     Support DTLS protocol (all versions) (MBEDTLS_SSL_PROTO_DTLS) [N/y/?] n
     Support ALPN (Application Layer Protocol Negotiation) (MBEDTLS_SSL_ALPN) [Y/n/?] y
     TLS: Support RFC 5077 SSL session tickets (MBEDTLS_SSL_SESSION_TICKETS) [Y/n/?] (NEW) 
     Enable RIPEMD-160 hash algorithm (MBEDTLS_RIPEMD160_C) [N/y/?] n
     #
     # configuration written to /root/esp/esp-idf/examples/get-started/hello_world/sdkconfig
     #
     WARNING: Toolchain version is not supported: esp32-2019r1
     Expected to see version: crosstool-ng-1.22.0-80-g6c4433a
     Please check ESP-IDF setup instructions and update the toolchain, or proceed at your own risk.
     WARNING: Compiler version is not supported: 8.2.0
     Expected to see version(s): 5.2.0
     Please check ESP-IDF setup instructions and update the toolchain, or proceed at your own risk.
     CC build/bootloader/bootloader_support/src/bootloader_flash.o
     CC build/bootloader/bootloader_support/src/flash_qio_mode.o
     CC build/bootloader/bootloader_support/src/efuse.o
     CC build/bootloader/bootloader_support/src/bootloader_init.o
     CC build/bootloader/bootloader_support/src/bootloader_common.o
     CC build/bootloader/bootloader_support/src/secure_boot.o
     CC build/bootloader/bootloader_support/src/bootloader_clock.o
     CC build/bootloader/bootloader_support/src/bootloader_random.o
     CC build/bootloader/bootloader_support/src/secure_boot_signatures.o
     CC build/bootloader/bootloader_support/src/flash_partitions.o
     CC build/bootloader/bootloader_support/src/esp_image_format.o
     CC build/bootloader/bootloader_support/src/bootloader_sha.o
     CC build/bootloader/bootloader_support/src/flash_encrypt.o
     CC build/bootloader/bootloader_support/src/bootloader_utility.o
     AR build/bootloader/bootloader_support/libbootloader_support.a
     CC build/bootloader/log/log.o
     AR build/bootloader/log/liblog.a
     CC build/bootloader/spi_flash/spi_flash_rom_patch.o
     AR build/bootloader/spi_flash/libspi_flash.a
     CC build/bootloader/micro-ecc/micro-ecc/uECC.o
     AR build/bootloader/micro-ecc/libmicro-ecc.a
     CC build/bootloader/soc/esp32/rtc_pm.o
     CC build/bootloader/soc/esp32/rtc_periph.o
     CC build/bootloader/soc/esp32/cpu_util.o
     CC build/bootloader/soc/esp32/sdmmc_periph.o
     CC build/bootloader/soc/esp32/rtc_wdt.o
     CC build/bootloader/soc/esp32/soc_memory_layout.o
     CC build/bootloader/soc/esp32/sdio_slave_periph.o
     CC build/bootloader/soc/esp32/rtc_time.o
     CC build/bootloader/soc/esp32/spi_periph.o
     CC build/bootloader/soc/esp32/rtc_init.o
     CC build/bootloader/soc/esp32/rtc_clk_init.o
     CC build/bootloader/soc/esp32/gpio_periph.o
     CC build/bootloader/soc/esp32/rtc_sleep.o
     CC build/bootloader/soc/esp32/rtc_clk.o
     CC build/bootloader/soc/src//memory_layout_utils.o
     AR build/bootloader/soc/libsoc.a
     CC build/bootloader/main/bootloader_start.o
     AR build/bootloader/main/libmain.a
     LD build/bootloader/bootloader.elf
     esptool.py v2.6
     Python requirements from /root/esp/esp-idf/requirements.txt are satisfied.
     Building partitions from /root/esp/esp-idf/components/partition_table/partitions_singleapp.csv...
     CC build/app_trace/app_trace_util.o
     CC build/app_trace/host_file_io.o
     CC build/app_trace/app_trace.o
     CC build/app_trace/gcov/gcov_rtio.o
     AR build/app_trace/libapp_trace.a
     CC build/app_update/esp_ota_ops.o
     AR build/app_update/libapp_update.a
     CXX build/asio/asio/asio/src/asio.o
     In file included from /root/esp/xtensa-esp32-elf/xtensa-esp32-elf/include/c++/8.2.0/cstdlib:75,
                      from /root/esp/xtensa-esp32-elf/xtensa-esp32-elf/include/c++/8.2.0/ext/string_conversions.h:41,
                      from /root/esp/xtensa-esp32-elf/xtensa-esp32-elf/include/c++/8.2.0/bits/basic_string.h:6391,
                      from /root/esp/xtensa-esp32-elf/xtensa-esp32-elf/include/c++/8.2.0/string:52,
                      from /root/esp/esp-idf/components/asio/asio/asio/include/asio/impl/error.ipp:19,
                      from /root/esp/esp-idf/components/asio/asio/asio/include/asio/impl/src.hpp:22,
                      from /root/esp/esp-idf/components/asio/asio/asio/src/asio.cpp:11:
     /root/esp/xtensa-esp32-elf/xtensa-esp32-elf/sys-include/stdlib.h:155:44: error: expected initializer before '__result_use_check'
      void *reallocarray(void *, size_t, size_t) __result_use_check __alloc_size(2)
                                                 ^~~~~~~~~~~~~~~~~~
     /root/esp/xtensa-esp32-elf/xtensa-esp32-elf/sys-include/stdlib.h:340:52: error: expected initializer before '__alloc_align'
      void * aligned_alloc(size_t, size_t) __malloc_like __alloc_align(1)
                                                         ^~~~~~~~~~~~~
     /root/esp/esp-idf/make/component_wrapper.mk:285: recipe for target 'asio/asio/src/asio.o' failed
     make[1]: *** [asio/asio/src/asio.o] Error 1
     /root/esp/esp-idf/make/project.mk:530: recipe for target 'component-asio-build' failed
     make: *** [component-asio-build] Error 2