1.. zephyr:board:: olimex_esp32_evb
2
3Overview
4********
5
6The Olimex ESP32-EVB is an OSHW certified, open-source IoT board based on the
7Espressif ESP32-WROOM-32E/UE module. It has a wired 100Mbit/s Ethernet Interface,
8Bluetooth LE, WiFi, infrared remote control, and CAN connectivity. Two relays
9allows switching power appliances on and off.
10
11The board can operate from a single LiPo backup battery as it has an internal
12LiPo battery charger. There is no step-up converter, so relays, CAN, and USB
13power does not work when running off battery.
14
15Hardware
16********
17
18- ESP32-WROOM-32E/UE module with 4MB flash.
19- On-board programmer, CH340T USB-to-UART
20- WiFi, Bluetooth LE connectivity.
21- 100Mbit/s Ethernet interface, Microchip LAN8710A PHY.
22- MicroSD card slot.
23- 2 x 10A/250VAC (15A/120VAC 15A/24VDC) relays with connectors and status LEDs.
24- CAN interface, Microchip MCP2562-E high-speed CAN transceiver.
25- IR receiver and transmitter, up to 5 meters distance.
26- BL4054B LiPo battery charger with status LEDs for stand-alone operation during
27  power outages.
28- Power jack for external 5VDC power supply.
29- Univeral EXTension (UEXT) connector for connecting UEXT modules.
30- User push button.
31- 40 pin GPIO connector with all ESP32 pins.
32
33For more information about the ESP32-EVB and the ESP32-WROOM-32E/UE module, see
34these reference documents:
35
36- `ESP32-EVB Website`_
37- `ESP32-EVB Schematic`_
38- `ESP32-EVB GitHub Repository`_
39- `ESP32-WROOM32-E/UE Datasheet`_
40
41Supported Features
42******************
43
44The olimex_esp32_evb board configuration supports the following hardware
45features:
46
47+-----------+------------+-------------------------------------+
48| Interface | Controller | Driver/Component                    |
49+===========+============+=====================================+
50| EFUSE     | on-chip    | hwinfo, device ID                   |
51+-----------+------------+-------------------------------------+
52| FLASH     | module     | External flash                      |
53+-----------+------------+-------------------------------------+
54| GPIO      | on-chip    | gpio                                |
55+-----------+------------+-------------------------------------+
56| I2C       | on-chip    | I2C                                 |
57+-----------+------------+-------------------------------------+
58| INTERRUPT | on-chip    | interrupt controller                |
59+-----------+------------+-------------------------------------+
60| IO_MUX    | on-chip    | pinctrl                             |
61+-----------+------------+-------------------------------------+
62| SPI       | on-chip    | spi                                 |
63+-----------+------------+-------------------------------------+
64| TIMG      | on-chip    | counter                             |
65+-----------+------------+-------------------------------------+
66| TRNG      | on-chip    | entropy                             |
67+-----------+------------+-------------------------------------+
68| TWAI      | on-chip    | CAN controller                      |
69+-----------+------------+-------------------------------------+
70| UART      | on-chip    | uart                                |
71+-----------+------------+-------------------------------------+
72| WDT       | on-chip    | watchdog                            |
73+-----------+------------+-------------------------------------+
74| WiFi      | on-chip    | WiFi                                |
75+-----------+------------+-------------------------------------+
76
77The default configuration can be found in
78:zephyr_file:`boards/olimex/olimex_esp32_evb/olimex_esp32_evb_appcpu_defconfig`
79and
80:zephyr_file:`boards/olimex/olimex_esp32_evb/olimex_esp32_evb_procpu_defconfig`
81
82
83Other hardware features are not currently supported by the port.
84
85System requirements
86*******************
87
88Prerequisites
89=============
90
91Espressif HAL requires WiFi and Bluetooth binary blobs in order work. Run the command
92below to retrieve those files.
93
94.. code-block:: console
95
96   west blobs fetch hal_espressif
97
98.. note::
99
100   It is recommended running the command above after :file:`west update`.
101
102Building & Flashing
103*******************
104
105Simple boot
106===========
107
108The board could be loaded using the single binary image, without 2nd stage bootloader.
109It is the default option when building the application without additional configuration.
110
111.. note::
112
113   Simple boot does not provide any security features nor OTA updates.
114
115MCUboot bootloader
116==================
117
118User may choose to use MCUboot bootloader instead. In that case the bootloader
119must be built (and flashed) at least once.
120
121There are two options to be used when building an application:
122
1231. Sysbuild
1242. Manual build
125
126.. note::
127
128   User can select the MCUboot bootloader by adding the following line
129   to the board default configuration file.
130
131   .. code:: cfg
132
133      CONFIG_BOOTLOADER_MCUBOOT=y
134
135Sysbuild
136========
137
138The sysbuild makes possible to build and flash all necessary images needed to
139bootstrap the board with the ESP32 SoC.
140
141To build the sample application using sysbuild use the command:
142
143.. zephyr-app-commands::
144   :tool: west
145   :zephyr-app: samples/hello_world
146   :board: olimex_esp32_evb
147   :goals: build
148   :west-args: --sysbuild
149   :compact:
150
151By default, the ESP32 sysbuild creates bootloader (MCUboot) and application
152images. But it can be configured to create other kind of images.
153
154Build directory structure created by sysbuild is different from traditional
155Zephyr build. Output is structured by the domain subdirectories:
156
157.. code-block::
158
159  build/
160  ├── hello_world
161  │   └── zephyr
162  │       ├── zephyr.elf
163  │       └── zephyr.bin
164  ├── mcuboot
165  │    └── zephyr
166  │       ├── zephyr.elf
167  │       └── zephyr.bin
168  └── domains.yaml
169
170.. note::
171
172   With ``--sysbuild`` option the bootloader will be re-build and re-flash
173   every time the pristine build is used.
174
175For more information about the system build please read the :ref:`sysbuild` documentation.
176
177Manual build
178============
179
180During the development cycle, it is intended to build & flash as quickly possible.
181For that reason, images can be built one at a time using traditional build.
182
183The instructions following are relevant for both manual build and sysbuild.
184The only difference is the structure of the build directory.
185
186.. note::
187
188   Remember that bootloader (MCUboot) needs to be flash at least once.
189
190Build and flash applications as usual (see :ref:`build_an_application` and
191:ref:`application_run` for more details).
192
193.. zephyr-app-commands::
194   :zephyr-app: samples/hello_world
195   :board: olimex_esp32_evb/esp32/procpu
196   :goals: build
197
198The usual ``flash`` target will work with the ``olimex_esp32_evb`` board
199configuration. Here is an example for the :zephyr:code-sample:`hello_world`
200application.
201
202.. zephyr-app-commands::
203   :zephyr-app: samples/hello_world
204   :board: olimex_esp32_evb/esp32/procpu
205   :goals: flash
206
207Open the serial monitor using the following command:
208
209.. code-block:: shell
210
211   west espressif monitor
212
213After the board has automatically reset and booted, you should see the following
214message in the monitor:
215
216.. code-block:: console
217
218   ***** Booting Zephyr OS vx.x.x-xxx-gxxxxxxxxxxxx *****
219   Hello World! olimex_esp32_evb
220
221Debugging
222*********
223
224As with much custom hardware, the ESP32 modules require patches to
225OpenOCD that are not upstreamed yet. Espressif maintains their own fork of
226the project. The custom OpenOCD can be obtained at `OpenOCD ESP32`_.
227
228The Zephyr SDK uses a bundled version of OpenOCD by default. You can overwrite that behavior by adding the
229``-DOPENOCD=<path/to/bin/openocd> -DOPENOCD_DEFAULT_PATH=<path/to/openocd/share/openocd/scripts>``
230parameter when building.
231
232Here is an example for building the :zephyr:code-sample:`hello_world` application.
233
234.. zephyr-app-commands::
235   :zephyr-app: samples/hello_world
236   :board: olimex_esp32_evb/esp32/procpu
237   :goals: build flash
238   :gen-args: -DOPENOCD=<path/to/bin/openocd> -DOPENOCD_DEFAULT_PATH=<path/to/openocd/share/openocd/scripts>
239
240You can debug an application in the usual way. Here is an example for the :zephyr:code-sample:`hello_world` application.
241
242.. zephyr-app-commands::
243   :zephyr-app: samples/hello_world
244   :board: olimex_esp32_evb/esp32/procpu
245   :goals: debug
246
247References
248**********
249
250.. target-notes::
251
252.. _ESP32-EVB Website:
253   https://www.olimex.com/Products/IoT/ESP32/ESP32-EVB/open-source-hardware
254
255.. _ESP32-EVB Schematic:
256   https://github.com/OLIMEX/ESP32-EVB/raw/master/HARDWARE/REV-I/ESP32-EVB_Rev_I.pdf
257
258.. _ESP32-EVB GitHub Repository:
259   https://github.com/OLIMEX/ESP32-EVB
260
261.. _ESP32-WROOM32-E/UE Datasheet:
262   https://www.espressif.com/sites/default/files/documentation/esp32-wroom-32e_esp32-wroom-32ue_datasheet_en.pdf
263
264.. _OpenOCD ESP32:
265   https://github.com/espressif/openocd-esp32/releases
266