├── main ├── component.mk ├── main.c └── CMakeLists.txt ├── Makefile ├── debug ├── ftdi_ft2322.cfg └── esp-wroom-32.cfg ├── CMakeLists.txt ├── .gitignore ├── .vscode ├── settings.json ├── launch.json └── c_cpp_properties.json ├── readme.md └── misc └── ESP32 JTAG.svg /main/component.mk: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | PROJECT_NAME := main 2 | 3 | include $(IDF_PATH)/make/project.mk -------------------------------------------------------------------------------- /main/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void app_main(void) 4 | { 5 | printf("Hello world!\n"); 6 | } 7 | -------------------------------------------------------------------------------- /main/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(COMPONENT_SRCS "main.c") 2 | set(COMPONENT_ADD_INCLUDEDIRS ".") 3 | 4 | register_component() -------------------------------------------------------------------------------- /debug/ftdi_ft2322.cfg: -------------------------------------------------------------------------------- 1 | interface ftdi 2 | ftdi_vid_pid 0x0403 0x6010 3 | ftdi_layout_init 0x0038 0x003b 4 | 5 | transport select jtag 6 | 7 | adapter_khz 200 -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # The following lines of boilerplate have to be in your project's 2 | # CMakeLists in this exact order for cmake to work correctly 3 | cmake_minimum_required(VERSION 3.5) 4 | 5 | include($ENV{IDF_PATH}/tools/cmake/project.cmake) 6 | project(mair-template) -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | sdkconfig 3 | sdkconfig.old 4 | ipch/ 5 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 6 | 7 | # dependencies 8 | node_modules/ 9 | /.pnp 10 | .pnp.js 11 | 12 | # testing 13 | /coverage 14 | 15 | # production 16 | /build 17 | 18 | # misc 19 | .DS_Store 20 | .env.local 21 | .env.development.local 22 | .env.test.local 23 | .env.production.local 24 | 25 | npm-debug.log* 26 | yarn-debug.log* 27 | yarn-error.log* 28 | _9_internet/_9_8_Server_react/build -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "terminal.integrated.shell.windows": "cmd.exe", 3 | "terminal.integrated.shellArgs.windows": ["/k", "c:\\esp\\esp-idf\\export.bat"], 4 | "terminal.integrated.shell.linux": "/bin/bash", 5 | "terminal.integrated.shellArgs.linux": ["--init-file", "~/esp/esp-idf/export.sh", "-i"], 6 | "terminal.integrated.shell.osx": "/bin/bash", 7 | "terminal.integrated.shellArgs.osx": ["--init-file", "~/esp/esp-idf/export.sh", "-i"], 8 | "files.associations": { 9 | "*.md": "markdown", 10 | "*.mdx": "tdx", 11 | "stdio.h": "c" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": "ESP32 OpenOCD", 9 | "type": "cppdbg", 10 | "request": "launch", 11 | "miDebuggerPath": "${env:IDF_TOOLS_PATH}/tools/xtensa-esp32-elf/esp32-2019r1-8.2.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-gdb.exe", 12 | "cwd": "${workspaceFolder}/build", 13 | //change the name of the elf file as required 14 | "program": "${workspaceFolder}/build/mair-template.elf", 15 | "setupCommands": [ 16 | { 17 | "description": "Enable pretty-printing for gdb", 18 | "text": "-enable-pretty-printing", 19 | "ignoreFailures": true 20 | }, 21 | { 22 | // there's a bug in vs code that prevents us from using ${workspaceFolder} variable. 23 | // update the path as needed 24 | "text": "file 'C:/_esp32/esp32_starter_template/build/mair-template.elf'" 25 | }, 26 | { 27 | "text": "target remote 127.0.0.1:3333" 28 | }, 29 | { 30 | "text": "set remote hardware-watchpoint-limit 2" 31 | }, 32 | { 33 | "text": "monitor reset halt" 34 | }, 35 | { 36 | "text": "flushregs" 37 | } 38 | ], 39 | "externalConsole": false, 40 | 41 | "logging": { 42 | // "trace": true, 43 | // "traceResponse": true, 44 | //"engineLogging": true 45 | } 46 | } 47 | ] 48 | } 49 | -------------------------------------------------------------------------------- /debug/esp-wroom-32.cfg: -------------------------------------------------------------------------------- 1 | # Example OpenOCD configuration file for ESP-WROOM-32 module. 2 | # By default, the following configuration is used: 3 | # - dual core debugging 4 | # - support for listing FreeRTOS tasks is enabled 5 | # - OpenOCD is configured to set SPI flash voltage at 3.3V 6 | # by keeping MTDI bootstrapping pin low 7 | # 8 | # Use variables listed below to customize this. 9 | # Variables can be modified in this file or set on the command line. 10 | # 11 | # For example, OpenOCD can be started for single core ESP32 debugging on 12 | # ESP-WROVER-KIT with ESP-WROOM-32 module as follows: 13 | # 14 | # openocd -f interface/ftdi/esp32_devkitj_v1.cfg -c 'set ESP32_ONLYCPU 1' -f board/esp-wroom-32.cfg 15 | # 16 | # If a different JTAG interface is used, change the first -f option. 17 | # 18 | # If OpenOCD is built from source, pass an additional -s option to specify 19 | # the location of 'tcl' directory: 20 | # 21 | # src/openocd -s tcl 22 | # 23 | # Note: 24 | # For ESP32-WROVER module use 'esp32-wrover.cfg' configuration file 25 | # ESP-WROOM-32 and ESP32-WROVER have different flash voltage setting 26 | 27 | 28 | # The ESP32 only supports JTAG. 29 | transport select jtag 30 | 31 | # The speed of the JTAG interface, in KHz. If you get DSR/DIR errors (and they 32 | # do not relate to OpenOCD trying to read from a memory range without physical 33 | # memory being present there), you can try lowering this. 34 | # 35 | # On DevKit-J, this can go as high as 20MHz if CPU frequency is 80MHz, or 26MHz 36 | # if CPU frequency is 160MHz or 240MHz. 37 | adapter_khz 20000 38 | 39 | # If single core debugging is required, uncomment the following line 40 | # set ESP32_ONLYCPU 1 41 | 42 | # To disable RTOS support, uncomment the following line 43 | # set ESP32_RTOS none 44 | 45 | # Tell OpenOCD which SPI flash voltage is used by the board (3.3 or 1.8) 46 | # The TDI pin of ESP32 is also a bootstrap pin that selects the voltage the SPI flash 47 | # chip runs at. When a hard reset happens (e.g. because someone switches the board off 48 | # and on) the ESP32 will use the current TDI value as the bootstrap value because the 49 | # JTAG adapter overrides the pull-up or pull-down resistor that is supposed to do the 50 | # bootstrapping. These lines basically set the idle value of the TDI line to a 51 | # specified value, therefore reducing the chance of a bad bootup due to a bad flash 52 | # voltage greatly. 53 | # This option defaults to 3.3, if not set. To override the default, uncomment 54 | # the following line: 55 | # set ESP32_FLASH_VOLTAGE 1.8 56 | 57 | # Source the ESP32 configuration file 58 | source [find target/esp32.cfg] 59 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | 2 | # ESP32 Starter template 3 | 4 | ## About This template 5 | 6 | This template can be used as is but, its intended as a quick start for the students learning the ESP32-IDF through the Udemy course [Getting started with the ESP32 and the IDF](https://github.com/Mair/esp32-starter/blob/master/misc/commingsoon.md) 7 | ## prerequisites 8 | 9 | 1. setup your toolchain and ESP-IDF as described in the [official documentation](https://docs.espressif.com/projects/esp-idf/en/latest/get-started/#step-1-set-up-the-toolchain) 10 | 11 | 2. add an additional environment variable called `IDF_TOOLS` that points to the tools directory in the xtensia installation (C:\Program Files\Espressif\ESP-IDF Tools\tools) 12 | 13 | 3. In VSCODE add the c++ extension 14 | https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools 15 | 16 | 4. ensure tour ESP32 is plugged in and that a COM PORT is established (You may need a driver for your ESP32 dev board) 17 | 18 | ## vs code intellisense 19 | 20 | intellisense should just work so long as you have set up the IDF_PATH environment variable as described in the [official documentation](https://docs.espressif.com/projects/esp-idf/en/latest/get-started/#step-1-set-up-the-toolchain) and the IDF_TOOLS as described above. 21 | 22 | >NB. you may meed to do an initial build and restart vscode before it can resolve all variables. 23 | 24 | ## flashing the esp32 25 | 26 | 1. in vs code, open a new terminal by pressing ctrl + \` (or pressing F1 and typing `open new terminal`) 27 | 2. type the following command 28 | 29 | ### for setups with idf.py 30 | 31 | ```bash 32 | idf.py -p [your com port] flash monitor 33 | ``` 34 | 35 | ### or other versions - 36 | *to set your com port* 37 | ```bash 38 | make menuconfig 39 | ``` 40 | set your com port in the menu under serial 41 | then 42 | ``` 43 | make flash monitor 44 | ``` 45 | ## debuging 46 | 47 | You will need an FT2322 in order to use a jtag. you can get them for about $10.00 on ali express. 48 | 49 | wire up the FT2322 and the esp32 as follows 50 | 51 | ![FT2322 jtag debugging][FT2322-jtag] 52 | 53 | [FT2322-jtag]: /misc/pin%20mapping.svg "Logo Title Text 2" 54 | 55 | | FT2322 Pin Name | FT2322 pin number | ESP32 pin name| ESP32 pin number 56 | | --------------- |:-----------------:|:-------------:|:-------------:| 57 | | TCK | ADBUS 0 | 13 | MTCK 58 | | TDI | ADBUS 1 | 12 | MTDI 59 | | TDO | ADBUS 2 | 15 | MTDO 60 | | TMS | ADBUS 3 | 14 | MTMS 61 | | GND | | GND | 62 | 63 | start the debugger by using 64 | 65 | ``` 66 | openocd -f debug\ftdi_ft2322.cfg -f debug\esp-wroom-32.cfg 67 | ``` 68 | -------------------------------------------------------------------------------- /.vscode/c_cpp_properties.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "MESSAGE":" MAC AND LINUX USERS!!!- change path from c:/... to ~/esp/... or as approirate for your enviroment", 4 | "IDF_TOOLS": "c:/esp/tools/.espressif/tools", 5 | "IDF_PATH": "c:/esp/esp-idf" 6 | }, 7 | "configurations": [ 8 | { 9 | "name": "esp32", 10 | "browse": { 11 | "path": [ 12 | "${workspaceFolder}", 13 | "${IDF_PATH}", 14 | "${IDF_TOOLS}" 15 | ], 16 | "limitSymbolsToIncludedHeaders": true 17 | }, 18 | "includePath": [ 19 | "${workspaceFolder}", 20 | "${workspaceFolder}/build/config", 21 | "${workspaceFolder}/build/bootloader/config", 22 | "${IDF_TOOLS}/xtensa-esp32-elf/esp32-2019r1-8.2.0/xtensa-esp32-elf/lib/gcc/xtensa-esp32-elf/8.2.0/include", 23 | "${IDF_TOOLS}/xtensa-esp32-elf/esp32-2019r1-8.2.0/xtensa-esp32-elf/xtensa-esp32-elf/include", 24 | "${IDF_PATH}/components/newlib/include", 25 | "${IDF_PATH}/components/esp32/include", 26 | "${IDF_PATH}/components/soc/esp32/include", 27 | "${IDF_PATH}/components/heap/include", 28 | "${IDF_PATH}/components/soc/include", 29 | "${IDF_PATH}/components/driver/include", 30 | "${IDF_PATH}/components/freertos/include", 31 | "${IDF_PATH}/components/tcpip_adapter/include", 32 | "${IDF_PATH}/components/nvs_flash/include", 33 | "${IDF_PATH}/components/spi_flash/include", 34 | "${IDF_PATH}/components/json/cJSON", 35 | "${IDF_PATH}/components/nvs_flash/test_nvs_host", 36 | "${IDF_PATH}/components/app_update/include", 37 | "${IDF_PATH}/components/esp_common/include", 38 | "${IDF_PATH}/components/xtensa/include", 39 | "${IDF_PATH}/components/xtensa/esp32/include", 40 | "${IDF_PATH}/components/esp_rom/include", 41 | "${IDF_PATH}/components/spiffs/include", 42 | "${IDF_PATH}/components/vfs/include", 43 | "${IDF_PATH}/components/esp_event/include", 44 | "${IDF_PATH}/components/esp_wifi/include", 45 | "${IDF_PATH}/components/lwip/lwip/src/include", 46 | "${IDF_PATH}/components/lwip/port/esp32/include", 47 | "${IDF_PATH}/components/lwip/include/apps/sntp", 48 | "${IDF_PATH}/components/lwip/include/apps", 49 | "${IDF_PATH}/components/esp_http_server/include", 50 | "${IDF_PATH}/components/nghttp/nghttp2/third-party/http-parser", 51 | "${IDF_PATH}/components/log/include" 52 | ], 53 | "defines": [], 54 | "cStandard": "c11", 55 | "cppStandard": "c++17", 56 | "intelliSenseMode": "clang-x64" 57 | } 58 | ], 59 | "version": 4 60 | } -------------------------------------------------------------------------------- /misc/ESP32 JTAG.svg: -------------------------------------------------------------------------------- 1 | --------------------------------------------------------------------------------