Lightning LN882x
Introduction
Lightning LN882x is a family of Wi-Fi and BLE microcontrollers designed for indoor short-range IoT.
Features:
- 32-bit Cortex M4F CPU (160 MHz)
- 296 KiB SRAM
- built-in 512 KiB to 2 MiB flash with XiP
- 802.11b/g/n Wi-Fi
- Bluetooth 5.1 (LN882H only)
Resources:
- LN882H : MCU Combo Wi-Fi/BLE IoT
- LN882H Datasheet : LN882H Datasheet
- LN882H DOC : Official LN882H Document Collection
- LN882H SDK : Official LN882H SDK
- LN882X SDK : Official LN882X SDK
- LN8825A/B : Wi-Fi SOC
- LN8825A/B SDK : Official LN8825A/B SDK
- Flashing tool (GUI) : Flashing tool with GUI (chinese)
- Flashing tool (CMD) : Command-line Flashing tool
Finding your board
You need to know which board your device uses. Head to Supported Boards to find it. A good number of popular boards have their dedicated support and documentation pages in LibreTiny. Otherwise, you have to use one of the Generic boards that matches the CPU model of your device.
Flashing
Read this!
This is probably the most important part of the docs - flashing firmware to the chip.
This is why you're here. Please read this section carefully, and only then start flashing firmware.
LN882x has two UART ports - The UART0 port is used for flashing and text output.
You need to find which pins correspond to UART0 TX and RX. If your board is supported, you'll find the pinout on its documentation page. Otherwise (and for generic boards), you'll have to find the pinout online.
Wiring
Connect UART0 of the LN882H to the USB-TTL adapter:
PC | LN882H |
---|---|
RX | TX0 (GPIOA2 / P2) |
TX | RX0 (GPIOA3 / P3) |
GND | GND |
Important
Using a good, stable 3.3V power supply is crucial. Most flashing issues are caused by either voltage drops during intensive flash operations, or bad/loose wires. The UART adapter's 3.3V power regulator is usually not enough.
Instead, a regulated bench power supply, or a linear 1117-type regulator is recommended.
Note
"CEN" pin is the RESET pin - connecting it to GND will keep the chip in "reset" state. Disconnecting it will allow the chip to start back up.
If you're having issues with using CEN pin (or if it's not accessible on your device) you can toggle the 3.3V power instead. Removing power will keep it in "reset", and applying it back will start it again.
The download mode is entered when the chip communicates with the flasher program. Hence, the first step is running the flasher program (described below). While the program is trying to establish communication, the chip has to be rebooted. In order to do that, you need to bridge BOOT1 pin to GND with a wire before powering the chip.
After linking with the chip, the flasher program will begin writing (or reading) the firmware automatically. If that doesn't happen, try resetting the chip again until it works.
If you're getting a No response received
(or similar) error, this means that:
- the power supply is too weak (read above)
- you're resetting the chip too quickly, i.e. you resetted it after the program started communicating with it
Flashing
The recommended tool to flash (or dump firmware) is ltchiptool
.
Read Using ltchiptool to learn the flashing procedure
Tip
Because the UART uploading code is programmed in the ROM of the chip, it can't be software-bricked, even if you damage the bootloader.
Firmware output files
These files are present in the build directory after successful compilation:
File | Description |
---|---|
firmware.uf2 | UF2 package for UART and OTA upload |
image_firmware.0x000000.bin | Full flash binary image - flashable at 0x0 |
image_boot.0x000000.bin | Boot partition binary image - flashable at 0x0 |
image_part_tab.0x006000.bin | Partition table binary image - flashable at 0x6000 |
image_app.0x007000.bin | Application partition binary image - flashable at 0x7000 |
image_ota.0x133000.bin | OTA partition binary image - flashable at 0x133000 |
Other tools/guides
-
Official command-line flashing tool
Usage Examples:
LN882H_CMD_Tool.exe COM1 download flash 921600 0x0 image_firmware.0x000000.bin
LN882H_CMD_Tool.exe COM1 download flash 921600 0x7000 image_app.0x007000.bin