Skip to content

Commit 0a2e4d1

Browse files
lfeltennashif
authored andcommitted
boards: lilygo: ttgo_lora32: initial support
adds initial support for Lilygo TTGO LoRa32 board dts: vendor-prefixes: add vendor lilygo Co-authored-by: Benjamin Cabé <[email protected]> Signed-off-by: Lothar Felten <[email protected]>
1 parent c4df21e commit 0a2e4d1

15 files changed

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

0 commit comments

Comments
 (0)