1.. zephyr:board:: heltec_wireless_stick_lite_v3
2
3Overview
4********
5
6HelTec Wireless Stick Lite (V3) is a development board with Wi-Fi, Bluetooth and LoRa support. It is designed and produced by HelTec Automation(TM). [1]_
7
8Hardware
9********
10
11The main hardware features are:
12
13- ESP32-S3FN8 low-power MCU-based SoC (dual-core Xtensa® 32-bit LX7 microprocessor, five stage pipeline rack Structure, main frequency up to 240 MHz).
14- Semtech SX1262 LoRa node chip
15- Type-C USB interface with a complete voltage regulator, ESD protection, short circuit protection, RF shielding, and other protection measures (note: you need an USB-A to USB-C cable if you want to power-up the board from USB).
16- Onboard SH1.25-2 battery interface, integrated lithium battery management system (charge and discharge management, overcharge protection, battery power detection, USB / battery power automatic switching).
17- Integrated WiFi and Bluetooth interfaces with 2.4GHz metal spring antenna and reserved IPEX (U.FL) interface for LoRa use.
18- Integrated CP2102 USB to serial port chip, convenient for program downloading, debugging information printing.
19- Good RF circuit design and low-power design.
20
21Supported Features
22==================
23- LoRa via SPI
24- UART0 (USB Serial via CP2102)
25- UART1
26- I2C
27- CAN (optional, need to enable)
28- PWM LED
29- User Switch / Button
30
31Connections and IOs
32===================
33
34.. figure:: heltec_wireless_stick_lite_v3_pinout.webp
35   :width: 600px
36   :align: center
37   :alt: HelTec Wireless Stick Lite (V3) Pinout
38
39   Pinout (Credit: Chengdu HelTec Automation Technology Co., Ltd.)
40
41.. table:: HelTec Wireless Stick Lite (V3) Pinout
42   :widths: auto
43
44   +--------+---------+-----------------------------+
45   | Header | Function| Description                 |
46   +========+=========+=============================+
47   | J2.1   | Ve      |                             |
48   +--------+---------+-----------------------------+
49   | J2.2   | GND     |                             |
50   +--------+---------+-----------------------------+
51   | J2.3   |         |                             |
52   +--------+---------+-----------------------------+
53   | J2.4   | U0RXD   | Zephyr Console+Shell        |
54   +--------+---------+-----------------------------+
55   | J2.5   | U0TXD   | Zephyr Console+Shell        |
56   +--------+---------+-----------------------------+
57   | J2.6   |         |                             |
58   +--------+---------+-----------------------------+
59   | J2.7   |         |                             |
60   +--------+---------+-----------------------------+
61   | J2.8   | GPIO35  | PWM LED Control             |
62   +--------+---------+-----------------------------+
63   | J2.9   | GPIO36  | Vext Control                |
64   +--------+---------+-----------------------------+
65   | J2.10  | GPIO37  | ADC Control                 |
66   +--------+---------+-----------------------------+
67   | J2.11  |         |                             |
68   +--------+---------+-----------------------------+
69   | J2.12  | GPIO39  |                             |
70   +--------+---------+-----------------------------+
71   | J2.13  | GPIO40  |                             |
72   +--------+---------+-----------------------------+
73   | J2.14  | GPIO41  |                             |
74   +--------+---------+-----------------------------+
75   | J2.15  | GPIO42  |                             |
76   +--------+---------+-----------------------------+
77   | J2.16  | GPIO45  |                             |
78   +--------+---------+-----------------------------+
79   | J2.17  | GPIO46  |                             |
80   +--------+---------+-----------------------------+
81   | J2.18  | ADC1_CH0| Battery Voltage Measurement |
82   +--------+---------+-----------------------------+
83   | J2.19  |         |                             |
84   +--------+---------+-----------------------------+
85   | J2.20  |         |                             |
86   +--------+---------+-----------------------------+
87   | J3.1   | 5V      |                             |
88   +--------+---------+-----------------------------+
89   | J3.2   | 3V3     |                             |
90   +--------+---------+-----------------------------+
91   | J3.3   | GND     |                             |
92   +--------+---------+-----------------------------+
93   | J3.4   | GPIO47  |                             |
94   +--------+---------+-----------------------------+
95   | J3.5   | GPIO48  |                             |
96   +--------+---------+-----------------------------+
97   | J3.6   | GPIO0   | User Switch                 |
98   +--------+---------+-----------------------------+
99   | J3.7   |         |                             |
100   +--------+---------+-----------------------------+
101   | J3.8   |         |                             |
102   +--------+---------+-----------------------------+
103   | J3.9   | U1RXD   | UART 1                      |
104   +--------+---------+-----------------------------+
105   | J3.10  | GPIO21  |                             |
106   +--------+---------+-----------------------------+
107   | J3.11  |         |                             |
108   +--------+---------+-----------------------------+
109   | J3.12  | U1TXD   | UART 1                      |
110   +--------+---------+-----------------------------+
111   | J3.13  |         |                             |
112   +--------+---------+-----------------------------+
113   | J3.14  | NC      | Reset Switch                |
114   +--------+---------+-----------------------------+
115   | J3.15  |         |                             |
116   +--------+---------+-----------------------------+
117   | J3.16  |         |                             |
118   +--------+---------+-----------------------------+
119   | J3.17  |         |                             |
120   +--------+---------+-----------------------------+
121   | J3.18  |         |                             |
122   +--------+---------+-----------------------------+
123   | J3.19  | TWAI_TX | CAN (optional)              |
124   +--------+---------+-----------------------------+
125   | J3.20  | TWAI_RX | CAN (optional)              |
126   +--------+---------+-----------------------------+
127
128
129System requirements
130*******************
131
132Prerequisites
133=============
134
135Espressif HAL requires WiFi and Bluetooth binary blobs in order work. Run the command
136below to retrieve those files.
137
138.. code-block:: console
139
140   west blobs fetch hal_espressif
141
142.. note::
143
144   It is recommended running the command above after :file:`west update`.
145
146Programming and Debugging
147*************************
148
149Simple boot
150===========
151
152The board could be loaded using the single binary image, without 2nd stage bootloader.
153It is the default option when building the application without additional configuration.
154
155.. note::
156
157   Simple boot does not provide any security features nor OTA updates.
158
159MCUboot bootloader
160==================
161
162User may choose to use MCUboot bootloader instead. In that case the bootloader
163must be built (and flashed) at least once.
164
165There are two options to be used when building an application:
166
1671. Sysbuild
1682. Manual build
169
170.. note::
171
172   User can select the MCUboot bootloader by adding the following line
173   to the board default configuration file.
174
175   .. code:: cfg
176
177      CONFIG_BOOTLOADER_MCUBOOT=y
178
179Sysbuild
180========
181
182The sysbuild makes possible to build and flash all necessary images needed to
183bootstrap the board with the EPS32-S3 SoC.
184
185To build the sample application using sysbuild use the command:
186
187.. zephyr-app-commands::
188   :tool: west
189   :zephyr-app: samples/hello_world
190   :board: heltec_wireless_stick_lite_v3
191   :goals: build
192   :west-args: --sysbuild
193   :compact:
194
195By default, the ESP32S3 sysbuild creates bootloader (MCUboot) and application
196images. But it can be configured to create other kind of images.
197
198Build directory structure created by sysbuild is different from traditional
199Zephyr build. Output is structured by the domain subdirectories:
200
201.. code-block::
202
203  build/
204  ├── hello_world
205  │   └── zephyr
206  │       ├── zephyr.elf
207  │       └── zephyr.bin
208  ├── mcuboot
209  │    └── zephyr
210  │       ├── zephyr.elf
211  │       └── zephyr.bin
212  └── domains.yaml
213
214.. note::
215
216   With ``--sysbuild`` option the bootloader will be re-build and re-flash
217   every time the pristine build is used.
218
219For more information about the system build please read the :ref:`sysbuild` documentation.
220
221Manual build
222============
223
224During the development cycle, it is intended to build & flash as quickly possible.
225For that reason, images can be built one at a time using traditional build.
226
227The instructions following are relevant for both manual build and sysbuild.
228The only difference is the structure of the build directory.
229
230.. note::
231
232   Remember that bootloader (MCUboot) needs to be flash at least once.
233
234Build and flash applications as usual (see :ref:`build_an_application` and
235:ref:`application_run` for more details).
236
237.. zephyr-app-commands::
238   :zephyr-app: samples/hello_world
239   :board: heltec_wireless_stick_lite_v3/esp32s3/procpu
240   :goals: build
241
242The usual ``flash`` target will work with the ``heltec_wireless_stick_lite_v3`` board
243configuration. Here is an example for the :zephyr:code-sample:`hello_world`
244application.
245
246.. zephyr-app-commands::
247   :zephyr-app: samples/hello_world
248   :board: heltec_wireless_stick_lite_v3/esp32s3/procpu
249   :goals: flash
250
251Open the serial monitor using the following command:
252
253.. code-block:: shell
254
255   west espressif monitor
256
257After the board has automatically reset and booted, you should see the following
258message in the monitor:
259
260.. code-block:: console
261
262   ***** Booting Zephyr OS vx.x.x-xxx-gxxxxxxxxxxxx *****
263   Hello World! heltec_wireless_stick_lite_v3
264
265Debugging
266=========
267
268As with much custom hardware, the ESP32S3 modules require patches to
269OpenOCD that are not upstreamed yet. Espressif maintains their own fork of
270the project. The custom OpenOCD can be obtained at `OpenOCD ESP32`_.
271
272The Zephyr SDK uses a bundled version of OpenOCD by default. You can overwrite that behavior by adding the
273``-DOPENOCD=<path/to/bin/openocd> -DOPENOCD_DEFAULT_PATH=<path/to/openocd/share/openocd/scripts>``
274parameter when building.
275
276Here is an example for building the :zephyr:code-sample:`hello_world` application.
277
278.. zephyr-app-commands::
279   :zephyr-app: samples/hello_world
280   :board: heltec_wireless_stick_lite_v3/esp32s3/procpu
281   :goals: build flash
282   :gen-args: -DOPENOCD=<path/to/bin/openocd> -DOPENOCD_DEFAULT_PATH=<path/to/openocd/share/openocd/scripts>
283
284You can debug an application in the usual way. Here is an example for the :zephyr:code-sample:`hello_world` application.
285
286.. zephyr-app-commands::
287   :zephyr-app: samples/hello_world
288   :board: heltec_wireless_stick_lite_v3/esp32s3/procpu
289   :goals: debug
290
291References
292**********
293
294- `Heltec Wireless Stick Lite (v3) Pinout Diagram <https://resource.heltec.cn/download/Wireless_Stick_Lite_V3/HTIT-WSL_V3.png>`_
295- `Heltec Wireless Stick Lite (v3) Schematic Diagrams <https://resource.heltec.cn/download/Wireless_Stick_Lite_V3/HTIT-WSL_V3_Schematic_Diagram.pdf>`_
296- `ESP-IDF Programming Guide <https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/api-reference/index.html>`_
297- `esptool documentation <https://github.com/espressif/esptool/blob/master/README.md>`_
298- `OpenOCD ESP32 <https://github.com/espressif/openocd-esp32/releases>`_
299
300.. [1] https://heltec.org/project/wireless-stick-lite-v2/
301