1.. zephyr:board:: ttgo_lora32
2
3Overview
4********
5
6The Lilygo TTGO LoRa32 is a development board for LoRa applications based on the ESP32-PICO-D4.
7
8It's available in two versions supporting two different frequency ranges and features the following integrated components:
9
10- ESP32-PICO-D4 chip (240MHz dual core, 600 DMIPS, 520KB SRAM, Wi-Fi)
11- SSD1306, 128x64 px, 0.96" screen
12- SX1278 (433MHz) or SX1276 (868/915/923MHz) LoRa radio frontend
13- JST GH 2-pin battery connector
14- TF card slot
15
16Some of the ESP32 I/O pins are accessible on the board's pin headers.
17
18Functional Description
19**********************
20
21The following table below describes the key components, interfaces, and controls
22of the Lilygo TTGO LoRa32 board.
23
24.. _SX127x: https://www.semtech.com/products/wireless-rf/lora-connect/sx1276#documentation
25.. _ESP32-PICO-D4: https://www.espressif.com/sites/default/files/documentation/esp32-pico-d4_datasheet_en.pdf
26.. _SSD1306: https://cdn-shop.adafruit.com/datasheets/SSD1306.pdf
27
28+------------------+-------------------------------------------------------------------------+
29| Key Component    | Description                                                             |
30+==================+=========================================================================+
31| ESP32-PICO-D4    | This `ESP32-PICO-D4`_ module provides complete Wi-Fi and Bluetooth      |
32|                  | functionalities and integrates a 4-MB SPI flash.                        |
33+------------------+-------------------------------------------------------------------------+
34| Diagnostic LED   | One user LED connected to the GPIO pin.                                 |
35+------------------+-------------------------------------------------------------------------+
36| USB Port         | USB interface. Power supply for the board as well as the                |
37|                  | serial communication interface between a computer and the board.        |
38|                  | Micro-USB type connector.                                               |
39+------------------+-------------------------------------------------------------------------+
40| Power Switch     | Sliding power switch.                                                   |
41+------------------+-------------------------------------------------------------------------+
42| OLED display     | Built-in OLED display \(`SSD1306`_, 0.96", 128x64 px\) controlled       |
43|                  | by I2C interface                                                        |
44+------------------+-------------------------------------------------------------------------+
45| SX1276/SX1278    | LoRa radio frontend chip, connected via SPI.                            |
46|                  | Use SX1276 for 433MHz and SX1276 for 868/915/923MHz.                    |
47+------------------+-------------------------------------------------------------------------+
48| TF card slot     | TF card slot wired to the SDHC interface of the MCU.                    |
49+------------------+-------------------------------------------------------------------------+
50
51
52Start Application Development
53*****************************
54
55Before powering up your Lilygo TTGO LoRa32, please make sure that the board is in good
56condition with no obvious signs of damage.
57
58System requirements
59*******************
60
61Prerequisites
62=============
63
64Espressif HAL requires WiFi and Bluetooth binary blobs in order work. Run the command
65below to retrieve those files.
66
67.. code-block:: console
68
69   west blobs fetch hal_espressif
70
71.. note::
72
73   It is recommended running the command above after :file:`west update`.
74
75Building & Flashing
76*******************
77
78Simple boot
79===========
80
81The board could be loaded using the single binary image, without 2nd stage bootloader.
82It is the default option when building the application without additional configuration.
83
84.. note::
85
86   Simple boot does not provide any security features nor OTA updates.
87
88MCUboot bootloader
89==================
90
91User may choose to use MCUboot bootloader instead. In that case the bootloader
92must be built (and flashed) at least once.
93
94There are two options to be used when building an application:
95
961. Sysbuild
972. Manual build
98
99.. note::
100
101   User can select the MCUboot bootloader by adding the following line
102   to the board default configuration file.
103
104   .. code-block:: cfg
105
106      CONFIG_BOOTLOADER_MCUBOOT=y
107
108Sysbuild
109========
110
111The sysbuild makes possible to build and flash all necessary images needed to
112bootstrap the board with the ESP32-PICO-D4 SoC.
113
114To build the sample application using sysbuild use the command:
115
116.. zephyr-app-commands::
117   :tool: west
118   :zephyr-app: samples/hello_world
119   :board: ttgo_lora32/esp32/procpu
120   :goals: build
121   :west-args: --sysbuild
122   :compact:
123
124By default, the ESP32-PICO-D4 sysbuild creates bootloader (MCUboot) and application
125images. But it can be configured to create other kind of images.
126
127Build directory structure created by sysbuild is different from traditional
128Zephyr build. Output is structured by the domain subdirectories:
129
130.. code-block::
131
132  build/
133  ├── hello_world
134  │   └── zephyr
135  │       ├── zephyr.elf
136  │       └── zephyr.bin
137  ├── mcuboot
138  │    └── zephyr
139  │       ├── zephyr.elf
140  │       └── zephyr.bin
141  └── domains.yaml
142
143.. note::
144
145   With ``--sysbuild`` option the bootloader will be re-build and re-flash
146   every time the pristine build is used.
147
148For more information about the system build please read the :ref:`sysbuild` documentation.
149
150Manual build
151============
152
153During the development cycle, it is intended to build & flash as quickly possible.
154For that reason, images can be built one at a time using traditional build.
155
156The instructions following are relevant for both manual build and sysbuild.
157The only difference is the structure of the build directory.
158
159.. note::
160
161   Remember that bootloader (MCUboot) needs to be flash at least once.
162
163Build and flash applications as usual (see :ref:`build_an_application` and
164:ref:`application_run` for more details).
165
166.. zephyr-app-commands::
167   :zephyr-app: samples/hello_world
168   :board: ttgo_lora32/esp32/procpu
169   :goals: build
170
171The usual ``flash`` target will work with the ``ttgo_lora32`` board target.
172Here is an example for the :zephyr:code-sample:`hello_world`
173application.
174
175.. zephyr-app-commands::
176   :zephyr-app: samples/hello_world
177   :board: ttgo_lora32/esp32/procpu
178   :goals: flash
179
180The default baud rate for the Lilygo TTGO LoRa32 is set to 1500000bps. If experiencing issues when flashing,
181try using different values by using ``--esp-baud-rate <BAUD>`` option during
182``west flash`` (e.g. ``west flash --esp-baud-rate 115200``).
183
184You can also open the serial monitor using the following command:
185
186.. code-block:: shell
187
188   west espressif monitor
189
190After the board has automatically reset and booted, you should see the following
191message in the monitor:
192
193.. code-block:: console
194
195   ***** Booting Zephyr OS vx.x.x-xxx-gxxxxxxxxxxxx *****
196   Hello World! ttgo_lora32
197
198Code samples
199============
200
201The following sample applications will work out of the box with this board:
202
203* :zephyr:code-sample:`lora-send`
204* :zephyr:code-sample:`lora-receive`
205* :zephyr:code-sample:`fs`
206* :zephyr:code-sample:`character-frame-buffer`
207
208Debugging
209*********
210
211Lilygo TTGO LoRa32 debugging is not supported due to pinout limitations.
212
213Related Documents
214*****************
215- `Lilygo TTGO LoRa32 schematic <https://github.com/Xinyuan-LilyGO/LilyGo-LoRa-Series/blob/master/schematic/T3_V1.6.1.pdf>`_ (PDF)
216- `Lilygo TTGO LoRa32 documentation <https://www.lilygo.cc/products/lora3>`_
217- `Lilygo github repo <https://github.com/Xinyuan-LilyGo>`_
218- `ESP32-PICO-D4 Datasheet <https://www.espressif.com/sites/default/files/documentation/esp32-pico-d4_datasheet_en.pdf>`_ (PDF)
219- `ESP32 Datasheet <https://www.espressif.com/sites/default/files/documentation/esp32_datasheet_en.pdf>`_ (PDF)
220- `ESP32 Hardware Reference <https://docs.espressif.com/projects/esp-idf/en/latest/esp32/hw-reference/index.html>`_
221